Changeset View
Changeset View
Standalone View
Standalone View
scap/tasks.py
Show First 20 Lines • Show All 717 Lines • ▼ Show 20 Lines | def refresh_cdb_json_file(file_path): | ||||
json_data = json.dumps(out, indent=0, separators=(',', ':')) | json_data = json.dumps(out, indent=0, separators=(',', ':')) | ||||
# Make python json.dumps match php's json_encode | # Make python json.dumps match php's json_encode | ||||
# Remove first newline | # Remove first newline | ||||
json_data = json_data.replace('\n', '', 1) | json_data = json_data.replace('\n', '', 1) | ||||
# Escape slashes | # Escape slashes | ||||
json_data = json_data.replace('/', '\/') | json_data = json_data.replace('/', r'\/') | ||||
# Remove final newline | # Remove final newline | ||||
json_data = ''.join(json_data.rsplit('\n', 1)) | json_data = ''.join(json_data.rsplit('\n', 1)) | ||||
tmp_json.write(json_data) | tmp_json.write(json_data) | ||||
tmp_json.close() | tmp_json.close() | ||||
os.chmod(tmp_json.name, 0o644) | os.chmod(tmp_json.name, 0o644) | ||||
shutil.move(tmp_json.name, upstream_json) | shutil.move(tmp_json.name, upstream_json) | ||||
▲ Show 20 Lines • Show All 198 Lines • Show Last 20 Lines |
Content licensed under Creative Commons Attribution-ShareAlike 3.0 (CC-BY-SA) unless otherwise noted; code licensed under GNU General Public License (GPL) or other open source licenses. By using this site, you agree to the Terms of Use, Privacy Policy, and Code of Conduct. · Wikimedia Foundation · Privacy Policy · Code of Conduct · Terms of Use · Disclaimer · CC-BY-SA · GPL