File tree Expand file tree Collapse file tree 2 files changed +9
-10
lines changed
Expand file tree Collapse file tree 2 files changed +9
-10
lines changed Original file line number Diff line number Diff line change @@ -837,18 +837,17 @@ def classlist_script(name, classlist):
837837 + "\n )"
838838 )
839839
840- def save (self , filepath : Union [str , Path ], filename : str = "project" ):
840+ def save (self , filepath : Union [str , Path ] = "./ project.json " ):
841841 """Save a project to a JSON file.
842842
843843 Parameters
844844 ----------
845845 filepath : str or Path
846- The path in which the project will be written.
847- filename : str
848- The name of the generated project file.
846+ The path to where the project file will be written.
849847
850848 """
851- filepath = Path (filepath )
849+ filepath = Path (filepath ).with_suffix (".json" )
850+
852851 json_dict = {}
853852 for field in self .model_fields :
854853 attr = getattr (self , field )
@@ -881,9 +880,8 @@ def make_custom_file_dict(item):
881880 json_dict [field ] = [item .model_dump () for item in attr ]
882881 else :
883882 json_dict [field ] = attr
884-
885- file = Path (filepath , f"{ filename .removesuffix ('.json' )} .json" )
886- file .write_text (json .dumps (json_dict ))
883+
884+ filepath .write_text (json .dumps (json_dict ))
887885
888886 @classmethod
889887 def load (cls , path : Union [str , Path ]) -> "Project" :
Original file line number Diff line number Diff line change @@ -1559,10 +1559,11 @@ def test_save_load(project, request):
15591559
15601560 with tempfile .TemporaryDirectory () as tmp :
15611561 # ignore relative path warnings
1562+ path = Path (tmp , "project.json" )
15621563 with warnings .catch_warnings ():
15631564 warnings .simplefilter ("ignore" )
1564- original_project .save (tmp )
1565- converted_project = RATapi .Project .load (Path ( tmp , "project.json" ) )
1565+ original_project .save (path )
1566+ converted_project = RATapi .Project .load (path )
15661567
15671568 # resolve custom files in case the original project had unresolvable relative paths
15681569 for file in original_project .custom_files :
You can’t perform that action at this time.
0 commit comments