Salome HOME
Cleanup
[modules/hydrosolver.git] / src / salome_hydro / study.py
index bc5f4d39b92c1bdee149f010225b525c30e0470b..f045f9b77d0a6d93d4b37bc5a0806cfc50280939 100644 (file)
@@ -171,7 +171,7 @@ class HydroStudyEditor:
                                             comment = str(filePath),
                                             typeId = TELEMAC2D_CASE_TYPE_ID)
 
-    def generate_study_script(self, filePath)
+    def generate_study_script(self, filePath):
         """
         Generating a python script from the eficas info
         """
@@ -181,27 +181,38 @@ class HydroStudyEditor:
             jdc = jdcfile.read()
         params = jdc_to_dict(jdc, ["TELEMAC2D", "_F"])
 
+        # Generation script string
         python_script = generate_study_script(params)
-        print python_script
 
-    def generate_study_yacs(self, filePath)
+        # Computing name of the file (same as filePath)
+        file_dir, filename = os.path.split(filePath)
+        root, sfx = os.path.splitext(filename)
+        python_file = os.path.join(file_dir,root+".py")
+
+        # Writting to file
+        with open(python_file,'w') as pfile:
+            pfile.write(python_script)
+
+    def generate_study_yacs(self, filePath):
         """
         Generating a yacs file from the eficas info
         """
         # Create "Python script" item
-        from TelApy.api.generate_study import generate_yacs_study
+        from TelApy.api.generate_study import generate_study_yacs
         with open(filePath) as jdcfile:
             jdc = jdcfile.read()
         params = jdc_to_dict(jdc, ["TELEMAC2D", "_F"])
 
-        yacs_scheme = generate_yacs_study(params)
-        file_dir = os.path.basename(filePath)
-        root, sfx = filePath.splitext()
-        yacs_file = os.path.join(file_dir,root+".xml")
+        # Generation YACS scheme
+        yacs_scheme = generate_study_yacs(params)
 
-        print yacs_file
-        print yacs_scheme
+        # Computing name of the file (same as filePath)
+        file_dir, filename = os.path.split(filePath)
+        root, sfx = os.path.splitext(filename)
+        yacs_file = os.path.join(file_dir,root+".xml")
 
+        # Writting to file
+        yacs_scheme.saveSchema(yacs_file)
 
     def find_or_create_coupling1d2d_case(self, filePath):
         self.find_or_create_hydro_component()