From 9038d244f24b942fe65a44fa0203a6eb14ce0d26 Mon Sep 17 00:00:00 2001 From: dtookey Date: Fri, 2 Oct 2020 12:38:10 -0400 Subject: [PATCH] cleaned up defunct bits of pyc implementation --- commands/loader.py | 32 ++++++++------------------------ 1 file changed, 8 insertions(+), 24 deletions(-) diff --git a/commands/loader.py b/commands/loader.py index 38c3685..265c3d0 100644 --- a/commands/loader.py +++ b/commands/loader.py @@ -8,7 +8,6 @@ from commands.command_base import AbstractCommand def load_commands() -> dict: - clear_compiled() commands = compile_and_load() return commands @@ -30,27 +29,19 @@ def compile_and_load_file(path: str) -> (str, AbstractCommand): def compile_and_load() -> dict: dic = {} - compiled_path = get_implementations_dir() - for dirName, subdirList, fileList in os.walk(compiled_path): + implementations = get_implementations_dir() + for dirName, subdirList, fileList in os.walk(implementations): for file in fileList: name = os.path.join(dirName, file) print("compiling %s" % name) name, command = compile_and_load_file(name) - dic[name] = command + if command is not None: + dic[name] = command break return dic -def clear_compiled(): - compiled_path = get_compiled_dir() - for dirName, subdirList, fileList in os.walk(compiled_path): - for file in fileList: - name = os.path.join(dirName, file) - os.remove(name) - break - - -def get_base_dir(): +def get_base_dir() -> str: cwd = os.getcwd() split = os.path.split(cwd) current = split[len(split) - 1] @@ -63,22 +54,15 @@ def get_base_dir(): raise -def script_to_pyc(path: str): - split = os.path.split(path) - current = split[len(split) - 1] - full = os.path.join(get_compiled_dir(), current + 'c') - return full - - -def get_implementations_dir(): +def get_implementations_dir() -> str: return check_dir(os.path.join(get_base_dir(), "implemented")) -def get_compiled_dir(): +def get_compiled_dir() -> str: return check_dir(os.path.join(get_base_dir(), "compiled")) -def check_dir(path: str): +def check_dir(path: str) -> str: if not os.path.exists(path): os.mkdir(path, 0x777) return path