cleaned up defunct bits of pyc implementation

This commit is contained in:
dtookey 2020-10-02 12:38:10 -04:00
parent 0e53eedfba
commit 9038d244f2

View File

@ -8,7 +8,6 @@ from commands.command_base import AbstractCommand
def load_commands() -> dict: def load_commands() -> dict:
clear_compiled()
commands = compile_and_load() commands = compile_and_load()
return commands return commands
@ -30,27 +29,19 @@ def compile_and_load_file(path: str) -> (str, AbstractCommand):
def compile_and_load() -> dict: def compile_and_load() -> dict:
dic = {} dic = {}
compiled_path = get_implementations_dir() implementations = get_implementations_dir()
for dirName, subdirList, fileList in os.walk(compiled_path): for dirName, subdirList, fileList in os.walk(implementations):
for file in fileList: for file in fileList:
name = os.path.join(dirName, file) name = os.path.join(dirName, file)
print("compiling %s" % name) print("compiling %s" % name)
name, command = compile_and_load_file(name) name, command = compile_and_load_file(name)
if command is not None:
dic[name] = command dic[name] = command
break break
return dic return dic
def clear_compiled(): def get_base_dir() -> str:
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():
cwd = os.getcwd() cwd = os.getcwd()
split = os.path.split(cwd) split = os.path.split(cwd)
current = split[len(split) - 1] current = split[len(split) - 1]
@ -63,22 +54,15 @@ def get_base_dir():
raise raise
def script_to_pyc(path: str): def get_implementations_dir() -> 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():
return check_dir(os.path.join(get_base_dir(), "implemented")) 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")) 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): if not os.path.exists(path):
os.mkdir(path, 0x777) os.mkdir(path, 0x777)
return path return path