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:
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