예제 #1
0
    def read_file(file_path):
        Logger.d("Reading file: {0}".format(file_path))

        with open(file_path, "r") as f:
            content = f.read()
            f.close()

        return content
예제 #2
0
    def run_all_generators(options, model):
        package = pyginny.generators

        prefix = package.__name__ + "."

        for importer, modname, ispkg in pkgutil.iter_modules(package.__path__, prefix):
            Logger.d("Found submodule {0} (is a package: {1})".format(modname, ispkg))
            module = __import__(modname + ".generator", fromlist=["dummy"])
            Logger.d("Imported {0}".format(module))

            obj = module.Generator(options=options, model=model)
            obj.run()
예제 #3
0
    def write_to_file(dir_path, filename, content):
        Logger.d("Creating file {0} in directory {1} with {2} bytes...".format(
            filename, dir_path, len(content)))

        full_file_path = os.path.join(dir_path, filename)
        FileUtil.remove_file(full_file_path)
        FileUtil.create_dir(dir_path)

        with open(full_file_path, "w") as f:
            f.write(content)
            f.close()

        Logger.d("Created file {0} in directory {1}".format(
            filename, dir_path))
예제 #4
0
    def get_all_generators_options():
        package = pyginny.generators

        prefix = package.__name__ + "."

        result = ""

        for importer, modname, ispkg in pkgutil.iter_modules(package.__path__, prefix):
            Logger.d("Found submodule {0} (is a package: {1})".format(modname, ispkg))
            module = __import__(modname + ".generator", fromlist=["dummy"])
            Logger.d("Imported {0}".format(module))

            obj = module.Generator(options=[], model=None)
            result = result + obj.get_usage_options()

        return result
예제 #5
0
    def remove_file(filename):
        Logger.d("Remove file: {0}".format(filename))

        if os.path.isfile(filename):
            os.remove(filename)
예제 #6
0
    def remove_dir(dir_path):
        Logger.d("Remove dir: {0}".format(dir_path))

        if os.path.isdir(dir_path):
            shutil.rmtree(dir_path)
예제 #7
0
    def create_dir(dir_path):
        Logger.d("Create a new dir: {0}".format(dir_path))

        if not os.path.isdir(dir_path):
            os.makedirs(dir_path)
예제 #8
0
 def test_debug_with_debug_turned_off(self):
     Constants.DEBUG = False
     Logger.d("test_debug_with_debug_turned_off")
     self.assertTrue(True)
예제 #9
0
 def test_debug_with_debug_turned_on(self):
     Constants.DEBUG = True
     Logger.d("test_debug_with_debug_turned_on")
     self.assertTrue(True)