1
1
import shutil
2
+ from pathlib import Path
2
3
3
4
from .Config import Config
4
5
from ..error import Result
@@ -52,8 +53,13 @@ def _get_file_url(self, module_id, file):
52
53
return url
53
54
54
55
def _get_changelog_common (self , module_id , changelog ):
55
- if not isinstance (changelog , str ) or changelog == "" :
56
+ is_file = False
57
+
58
+ if isinstance (changelog , str ) and changelog == "" :
56
59
return None
60
+ elif isinstance (changelog , Path ):
61
+ changelog = changelog .name
62
+ is_file = True
57
63
58
64
if changelog .startswith ("http" ):
59
65
changelog_file = self ._modules_folder .joinpath (module_id , f"{ module_id } .md" )
@@ -62,13 +68,18 @@ def _get_changelog_common(self, module_id, changelog):
62
68
msg = Log .get_msg (result .error )
63
69
self ._log .e (f"_get_changelog_common: [{ module_id } ] -> { msg } " )
64
70
changelog_file = None
65
- else :
71
+
72
+ elif is_file :
66
73
changelog_file = self ._local_folder .joinpath (changelog )
67
74
if not changelog_file .exists ():
68
75
msg = f"{ changelog } is not in { self ._local_folder } "
69
76
self ._log .d (f"_get_changelog_common: [{ module_id } ] -> { msg } " )
70
77
changelog_file = None
71
78
79
+ else :
80
+ self ._log .w (f"_get_changelog_common: [{ module_id } ] -> unsupported type [{ changelog } ]" )
81
+ changelog_file = None
82
+
72
83
if changelog_file is not None :
73
84
if not self ._check_changelog (module_id , changelog_file ):
74
85
changelog_file .unlink ()
@@ -210,7 +221,7 @@ def from_zip(self, track):
210
221
self ._log .i (f"from_zip: [{ track .id } ] -> { msg } " )
211
222
return None , 0.0
212
223
213
- changelog = self ._get_changelog_common (track .id , track .changelog )
224
+ changelog = self ._get_changelog_common (track .id , Path ( track .changelog ) )
214
225
online_module = self ._from_zip_common (track .id , zip_file , changelog , delete_tmp = False )
215
226
return online_module , last_modified
216
227
0 commit comments