This commit is contained in:
Hsiao-Wei Wang 2022-01-31 14:59:54 -08:00
parent e1fa8726d0
commit 09b982ede3

View File

@ -44,9 +44,11 @@ def load_text(params: List[str], file_path: str='', func: str='', lang: str='')
# Auto-detect file-path based on call stack # Auto-detect file-path based on call stack
file_path = inspect.stack()[1].filename file_path = inspect.stack()[1].filename
if file_path[-4:] == '.pyc': if file_path[-4:] == '.pyc':
file_path = file_path[:-4] + '.json' # replace .pyc with .json file_path = file_path[:-4] + '.json' # replace .pyc with .json
elif file_path[-3:] == '.py': elif file_path[-3:] == '.py':
file_path = file_path[:-3] + '.json' # replace .py with .json file_path = file_path[:-3] + '.json' # replace .py with .json
else:
raise KeyError("Wrong file_path %s", file_path)
if func == '': if func == '':
# Auto-detect function based on call stack # Auto-detect function based on call stack