mirror of
https://github.com/qiandao-today/templates.git
synced 2025-04-07 19:31:51 +00:00
Reduce json dumps content size
This commit is contained in:
parent
10f38d8ac0
commit
4ccbbce2af
5
.github/src/extract_issue_body.py
vendored
5
.github/src/extract_issue_body.py
vendored
|
@ -39,9 +39,8 @@ if len(issue_json) > 0 and 'name' in issue_json and 'author' in issue_json and '
|
|||
if update and issue_json['filename'] != hfile['har'][issue_json['name']]['filename'] and os.path.exists(hfile['har'][issue_json['name']]['filename']):
|
||||
os.remove(hfile['har'][issue_json['name']]['filename'])
|
||||
|
||||
content_jsonstring = json.dumps(har_content, indent=4, ensure_ascii=False)
|
||||
with open(issue_json['filename'], 'w', encoding='utf8') as f:
|
||||
f.write(content_jsonstring)
|
||||
f.write(json.dumps(har_content, indent=4, ensure_ascii=False))
|
||||
|
||||
har = {
|
||||
'name': issue_json['name'],
|
||||
|
@ -50,7 +49,7 @@ if len(issue_json) > 0 and 'name' in issue_json and 'author' in issue_json and '
|
|||
'update': update,
|
||||
'comments': issue_json.get('comments','').replace('\\r', '\r').replace('\\n', '\n').replace('\r','').replace('\n','<br>').strip(),
|
||||
'filename': issue_json['filename'],
|
||||
'content': base64.b64encode(content_jsonstring.encode('utf8')).decode('utf8'),
|
||||
'content': base64.b64encode(json.dumps(har_content, ensure_ascii=False).encode('utf8')).decode('utf8'),
|
||||
'date': hfile['har'][issue_json['name']]['date'] if update else time.strftime('%Y-%m-%d %H:%M:%S', time.localtime()),
|
||||
'version': hfile['har'][issue_json['name']]['version'] if update else time.strftime('%Y%m%d', time.localtime()),
|
||||
'commenturl': commenturl
|
||||
|
|
7
.github/workflows/update_content.yaml
vendored
7
.github/workflows/update_content.yaml
vendored
|
@ -2,7 +2,9 @@ name: Update Base64 Content
|
|||
on:
|
||||
workflow_dispatch: {}
|
||||
push:
|
||||
paths: [tpls_history.json]
|
||||
paths:
|
||||
- tpls_history.json
|
||||
- .github\workflows\update_content.yaml
|
||||
branches:
|
||||
- master
|
||||
- main
|
||||
|
@ -32,7 +34,8 @@ jobs:
|
|||
for name, har in list(hfile['har'].items()):
|
||||
with open(har['filename'], 'rb') as f:
|
||||
har_content = f.read()
|
||||
hfile['har'][name]['content'] = base64.b64encode(har_content).decode()
|
||||
json_content = json.loads(har_content)
|
||||
hfile['har'][name]['content'] = base64.b64encode(json.dumps(json_content, ensure_ascii=False).encode('utf8')).decode('utf8')
|
||||
json.dump(hfile, open('tpls_history.json', 'w', encoding='utf8'), indent=4, ensure_ascii=False)
|
||||
"""
|
||||
- name: Commit changes
|
||||
|
|
Loading…
Reference in New Issue
Block a user