mirror of
https://github.com/SoftFever/OrcaSlicer.git
synced 2025-07-16 03:07:55 -06:00
Update filament name checking script
(cherry picked from commit 7c4c1bf191de1fd6b86a07bf62c1ab634faa9f55)
This commit is contained in:
parent
eb38474bb2
commit
eb57036dab
1 changed files with 35 additions and 31 deletions
|
@ -139,9 +139,11 @@ def check_machine_default_materials(profiles_dir, vendor_name):
|
||||||
|
|
||||||
return error_count
|
return error_count
|
||||||
|
|
||||||
def check_name_consistency(profiles_dir, vendor_name):
|
def check_filament_name_consistency(profiles_dir, vendor_name):
|
||||||
"""
|
"""
|
||||||
Make sure profile names match in both vendor json and subpath files
|
Make sure filament profile names match in both vendor json and subpath files.
|
||||||
|
Filament profiles work only if the name in <vendor>.json matches the name in sub_path file,
|
||||||
|
or if it's one of the sub_path file's `renamed_from`.
|
||||||
"""
|
"""
|
||||||
error_count = 0
|
error_count = 0
|
||||||
vendor_dir = profiles_dir / vendor_name
|
vendor_dir = profiles_dir / vendor_name
|
||||||
|
@ -158,15 +160,10 @@ def check_name_consistency(profiles_dir, vendor_name):
|
||||||
print(f"Error loading vendor profile {vendor_file}: {e}")
|
print(f"Error loading vendor profile {vendor_file}: {e}")
|
||||||
return 1
|
return 1
|
||||||
|
|
||||||
for sect in [
|
if 'filament_list' not in data:
|
||||||
'machine_model_list',
|
return 0
|
||||||
'process_list',
|
|
||||||
'filament_list',
|
for child in data['filament_list']:
|
||||||
'machine_list',
|
|
||||||
]:
|
|
||||||
if sect not in data:
|
|
||||||
continue
|
|
||||||
for child in data[sect]:
|
|
||||||
name_in_vendor = child['name']
|
name_in_vendor = child['name']
|
||||||
sub_path = child['sub_path']
|
sub_path = child['sub_path']
|
||||||
sub_file = vendor_dir / sub_path
|
sub_file = vendor_dir / sub_path
|
||||||
|
@ -186,8 +183,15 @@ def check_name_consistency(profiles_dir, vendor_name):
|
||||||
|
|
||||||
name_in_sub = sub_data['name']
|
name_in_sub = sub_data['name']
|
||||||
|
|
||||||
if not name_in_vendor == name_in_sub:
|
if name_in_sub == name_in_vendor:
|
||||||
print(f"Profile name mismatch: '{name_in_vendor}' in {vendor_file.relative_to(profiles_dir)} but '{name_in_sub}' in {sub_file.relative_to(profiles_dir)}")
|
continue
|
||||||
|
|
||||||
|
if 'renamed_from' in sub_data:
|
||||||
|
renamed_from = [n.strip() for n in sub_data['renamed_from'].split(';')]
|
||||||
|
if name_in_vendor in renamed_from:
|
||||||
|
continue
|
||||||
|
|
||||||
|
print(f"Filament name mismatch: required '{name_in_vendor}' in {vendor_file.relative_to(profiles_dir)} but found '{name_in_sub}' in {sub_file.relative_to(profiles_dir)}, and none of its `renamed_from` matches the required name either")
|
||||||
error_count += 1
|
error_count += 1
|
||||||
|
|
||||||
return error_count
|
return error_count
|
||||||
|
@ -210,13 +214,13 @@ def main():
|
||||||
errors_found += check_filament_compatible_printers(profiles_dir / args.vendor / "filament")
|
errors_found += check_filament_compatible_printers(profiles_dir / args.vendor / "filament")
|
||||||
if args.check_materials:
|
if args.check_materials:
|
||||||
errors_found += check_machine_default_materials(profiles_dir, args.vendor)
|
errors_found += check_machine_default_materials(profiles_dir, args.vendor)
|
||||||
errors_found += check_name_consistency(profiles_dir, args.vendor)
|
errors_found += check_filament_name_consistency(profiles_dir, args.vendor)
|
||||||
checked_vendor_count += 1
|
checked_vendor_count += 1
|
||||||
else:
|
else:
|
||||||
for vendor_dir in profiles_dir.iterdir():
|
for vendor_dir in profiles_dir.iterdir():
|
||||||
if not vendor_dir.is_dir():
|
if not vendor_dir.is_dir():
|
||||||
continue
|
continue
|
||||||
errors_found += check_name_consistency(profiles_dir, vendor_dir.name)
|
errors_found += check_filament_name_consistency(profiles_dir, vendor_dir.name)
|
||||||
# skip "OrcaFilamentLibrary" folder
|
# skip "OrcaFilamentLibrary" folder
|
||||||
if vendor_dir.name == "OrcaFilamentLibrary":
|
if vendor_dir.name == "OrcaFilamentLibrary":
|
||||||
continue
|
continue
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue