mirror of
https://github.com/OrcaSlicer/OrcaSlicer.git
synced 2026-05-14 00:52:04 +00:00
preserve a single trailing newline when reformatting JSON files
This commit is contained in:
@@ -132,6 +132,7 @@ def update_profile_library(vendor="",profile_type="filament"):
|
|||||||
library[profile_section] = sorted_profiles
|
library[profile_section] = sorted_profiles
|
||||||
f.seek(0)
|
f.seek(0)
|
||||||
json.dump(library, f, indent="\t", ensure_ascii=False)
|
json.dump(library, f, indent="\t", ensure_ascii=False)
|
||||||
|
f.write('\n')
|
||||||
f.truncate()
|
f.truncate()
|
||||||
|
|
||||||
print(f"Profile library for {vendor} updated successfully!")
|
print(f"Profile library for {vendor} updated successfully!")
|
||||||
@@ -230,6 +231,7 @@ def clean_up_profile(vendor="", profile_type="", force=False):
|
|||||||
f.seek(0)
|
f.seek(0)
|
||||||
ordered_profile = create_ordered_profile(_profile, ['type', 'name', 'renamed_from', 'inherits', 'from', 'setting_id', 'filament_id', 'instantiation'])
|
ordered_profile = create_ordered_profile(_profile, ['type', 'name', 'renamed_from', 'inherits', 'from', 'setting_id', 'filament_id', 'instantiation'])
|
||||||
json.dump(ordered_profile, f, indent="\t", ensure_ascii=False)
|
json.dump(ordered_profile, f, indent="\t", ensure_ascii=False)
|
||||||
|
f.write('\n')
|
||||||
f.truncate()
|
f.truncate()
|
||||||
print(f"Updated profile: {full_path}")
|
print(f"Updated profile: {full_path}")
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
@@ -274,6 +276,7 @@ def rename_filament_system(vendor="OrcaFilamentLibrary"):
|
|||||||
if modified:
|
if modified:
|
||||||
with open(full_path, 'w', encoding='utf-8') as f:
|
with open(full_path, 'w', encoding='utf-8') as f:
|
||||||
json.dump(data, f, indent="\t", ensure_ascii=False)
|
json.dump(data, f, indent="\t", ensure_ascii=False)
|
||||||
|
f.write('\n')
|
||||||
print(f"Updated {full_path}")
|
print(f"Updated {full_path}")
|
||||||
|
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
|
|||||||
Reference in New Issue
Block a user