Example #1
0
    def load_extfolder(self):
        basepath = self.get_extfolderpath()
        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])
                    child = PyScript()
                    idx = p.add_child(newname, child, warning=warning)
                    child.set_path_pathmode(fpath, checklist=['extfolder'])
                    # child.import_script(fpath)
#                    script.onImportScriptFile(file = fpath)
        for x in warning:
            if len(x) != 0:
                print(x)
Example #2
0
 def set_path_pathmode(self, file,
                       modename='pathmode',
                       pathname='path',
                       extname='ext', checklist=None):
     return PyScript.set_path_pathmode(self, file,
                                       modename='pathmode',
                                       pathname='path',
                                       extname='ext', checklist=['extfolder'])