Fix update.py
This commit is contained in:
parent
ea1a247bc0
commit
482be408af
16
update.py
16
update.py
|
|
@ -86,21 +86,25 @@ def main():
|
||||||
print('Already up to date.')
|
print('Already up to date.')
|
||||||
return
|
return
|
||||||
|
|
||||||
|
tag = now.strftime('%Y.%m.%d')
|
||||||
temp_note_fd, temp_note_name = mkstemp()
|
temp_note_fd, temp_note_name = mkstemp()
|
||||||
with open(temp_note_fd, 'w', encoding='utf-8') as f:
|
with open(temp_note_fd, 'w', encoding='utf-8') as f:
|
||||||
f.write(now.strftime('%Y.%m.%d') + '\n\n```diff' + diff + '\n```')
|
f.write(tag + '\n\n```diff' + diff + '\n```')
|
||||||
temp_zip_fd, temp_zip_name = mkstemp()
|
temp_zip_fd, temp_zip_name = mkstemp(suffix='.zip')
|
||||||
with open(temp_zip_fd, 'w', encoding='utf-8') as f:
|
f = open(temp_zip_fd, 'wb')
|
||||||
pack_data(f)
|
pack_data(f)
|
||||||
|
f.close()
|
||||||
|
|
||||||
subprocess.run(['hub', 'release', 'create', '-F', temp_note_name,
|
subprocess.run(['hub', 'release', 'create', '-F', temp_note_name,
|
||||||
'-a', temp_zip_name + '#JSON数据打包',
|
'-a', f'{temp_zip_name}#holiday-cn-{tag}.zip',
|
||||||
now.strftime('%Y.%m.%d')], check=True)
|
tag], check=True)
|
||||||
os.unlink(temp_note_fd)
|
os.unlink(temp_note_fd)
|
||||||
os.unlink(temp_note_name)
|
os.unlink(temp_note_name)
|
||||||
|
|
||||||
|
|
||||||
def pack_data(file):
|
def pack_data(file):
|
||||||
|
"""Pack data json in zip file. """
|
||||||
|
|
||||||
zip_file = ZipFile(file, 'w')
|
zip_file = ZipFile(file, 'w')
|
||||||
for i in os.listdir(__dirname__):
|
for i in os.listdir(__dirname__):
|
||||||
if not re.match(r'\d+\.json', i):
|
if not re.match(r'\d+\.json', i):
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user