We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
--pdb
Prototype:
diff --git a/git_history/cli.py b/git_history/cli.py index f3a4c40..83f988e 100644 --- a/git_history/cli.py +++ b/git_history/cli.py @@ -117,6 +117,11 @@ def cli(): is_flag=True, help="Debug mode", ) +@click.option( + "_pdb", "--pdb", + is_flag=True, + help="Open Python debugger if an error occurs", +) @click.option( "--silent", is_flag=True, @@ -142,6 +147,7 @@ def file( ignore_duplicate_ids, wal, debug, + _pdb, silent, ): "Analyze the history of a specific file and write it to SQLite" @@ -178,7 +184,7 @@ def file( if not convert: convert = "json.loads(content)" - convert_function = compile_convert(convert, imports) + convert_function = compile_convert(convert, imports, _pdb) resolved_filepath = str(Path(filepath).resolve()) resolved_repo = str(Path(repo).resolve()) @@ -457,7 +463,7 @@ def build_csv_convert_string(dialect): ).strip() -def compile_convert(convert, imports): +def compile_convert(convert, imports, pdb=False): # Clean up the provided code # If single line and no 'return', add the return if "\n" not in convert and not convert.strip().startswith("return "): @@ -472,7 +478,16 @@ def compile_convert(convert, imports): for import_ in imports: globals[import_.split(".")[0]] = __import__(import_) exec(code_o, globals, locals) - return locals["fn"] + fn = locals["fn"] + if pdb: + def wrapper(content): + try: + yield from fn(content) + except Exception as e: + print(e) + import pdb; pdb.post_mortem() + return wrapper + return fn def remove_ignore_columns(items, ignore):
The text was updated successfully, but these errors were encountered:
No branches or pull requests
Prototype:
The text was updated successfully, but these errors were encountered: