Esempio n. 1
0
    def load_script_folder(self, basepath, skip_underscore = False):
        from ifigure.mto.py_script import PyScript        
        warning = []
        for dirpath, dirname, filenames in os.walk(basepath):
            if '.' in os.path.basename(dirpath): continue
            dirname = [x for x in dirname if not '.'in x]
            relpath = os.path.relpath(dirpath, basepath)
            if relpath == '.': relpath =''
            p = self

            tmp = relpath.split(os.sep)
            if any(['.' in x for x in tmp]): continue
            for name in relpath.split(os.sep):
                if name == '': continue
                p = p.get_child(name = name)

            for name in dirname:
                obj = PyFolder()
                p.add_child(name, obj, warning = warning)
            for f in filenames:
                fpath = os.path.join(dirpath, f)                

                if fpath.endswith('.py'):
                    newname = str(os.path.basename(fpath).split('.')[0])
                    if skip_underscore and newname.startswith('_'): continue
                    child=PyScript()
                    idx  =p.add_child(newname, child, warning = warning)
                    child.import_script(fpath)
#                    script.onImportScriptFile(file = fpath)
        for x in warning:
            if len(x) != 0: print(x)
Esempio n. 2
0
 def load_default_script(self):
     base_mod='ifigure.add_on.solver.script'
     mod_path=cbook.GetModuleDir(base_mod)
     file=os.path.join(mod_path, 'run_stdsolver.py')
     sc = PyScript()
     self.add_child('solver_script', sc)
     sc.import_script(file)
     self.add_default_mergesol_script()
Esempio n. 3
0
 def load_default_script(self):
     base_mod = 'ifigure.add_on.solver.script'
     mod_path = cbook.GetModuleDir(base_mod)
     file = os.path.join(mod_path, 'run_stdsolver.py')
     sc = PyScript()
     self.add_child('solver_script', sc)
     sc.import_script(file)
     self.add_default_mergesol_script()
Esempio n. 4
0
 def add_default_cost_script(self):
     if self.has_child('cost'): return
     base_mod='ifigure.add_on.solver.script'
     mod_path=cbook.GetModuleDir(base_mod)
     file=os.path.join(mod_path, 'cost_optimizer.py')
     sc = PyScript()
     self.add_child('cost', sc)
     sc._name_readonly = True
     sc.import_script(file)
Esempio n. 5
0
 def add_default_mergesol_script(self):
     if self.has_child('merge_sol'): return
     base_mod='ifigure.add_on.solver.script'
     mod_path=cbook.GetModuleDir(base_mod)
     file=os.path.join(mod_path, 'merge_sol_parametric.py')
     sc = PyScript()
     self.add_child('merge_sol', sc)
     sc._name_readonly = True
     sc.import_script(file)
Esempio n. 6
0
 def add_default_cost_script(self):
     if self.has_child('cost'): return
     base_mod = 'ifigure.add_on.solver.script'
     mod_path = cbook.GetModuleDir(base_mod)
     file = os.path.join(mod_path, 'cost_optimizer.py')
     sc = PyScript()
     self.add_child('cost', sc)
     sc._name_readonly = True
     sc.import_script(file)
Esempio n. 7
0
 def add_default_mergesol_script(self):
     if self.has_child('merge_sol'): return
     base_mod = 'ifigure.add_on.solver.script'
     mod_path = cbook.GetModuleDir(base_mod)
     file = os.path.join(mod_path, 'merge_sol_parametric.py')
     sc = PyScript()
     self.add_child('merge_sol', sc)
     sc._name_readonly = True
     sc.import_script(file)
Esempio n. 8
0
 def load_default_script(self):
     base_mod='ifigure.add_on.solver.script'
     mod_path=cbook.GetModuleDir(base_mod)
     file=os.path.join(mod_path, 'run_parametric.py')
     sc = PyScript()
     self.add_child('solver_script', sc)
     sc._name_readonly = True
     sc.import_script(file)
     sc.setvar("task", 2)
     self.add_default_mergesol_script()
Esempio n. 9
0
 def load_default_script(self):
     base_mod = 'ifigure.add_on.solver.script'
     mod_path = cbook.GetModuleDir(base_mod)
     file = os.path.join(mod_path, 'run_parametric.py')
     sc = PyScript()
     self.add_child('solver_script', sc)
     sc._name_readonly = True
     sc.import_script(file)
     sc.setvar("task", 2)
     self.add_default_mergesol_script()