Skip to content

Commit

Permalink
Fix passing argument with dash character
Browse files Browse the repository at this point in the history
ArgumentParser transforms dash into underscore.
It is needed to replace underscore by dash when generating arguments for pipreqs
  • Loading branch information
NHanser authored Dec 20, 2021
1 parent d2b2c40 commit e1eb417
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions pipreqsnb/pipreqsnb.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,10 @@ def get_import_string_from_source(source):
def generate_pipreqs_str(args):
pipreqs_str = ''
for arg, val in args.__dict__.items():
if arg in pipreqs_options_store and val:
pipreqs_str += ' --{}'.format(arg)
elif arg in pipreqs_options_args and val is not None:
pipreqs_str += ' --{} {}'.format(arg, val)
if arg.replace('_','-') in pipreqs_options_store and val:
pipreqs_str += ' --{}'.format(arg.replace('_','-'))
elif arg.replace('_','-') in pipreqs_options_args and val is not None:
pipreqs_str += ' --{} {}'.format(arg.replace('_','-'), val)
pipreqs_str += ' {}'.format(args.path)
return pipreqs_str

Expand Down

0 comments on commit e1eb417

Please sign in to comment.