Skip to content
master
Go to file
Code

Latest commit

 

Git stats

Files

Permalink
Failed to load latest commit information.
Type
Name
Latest commit message
Commit time
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

README.rst

argunparse

Reversed argparse: generate string of command-line args from Python objects.

package version from PyPI build status from Travis CI build status from AppVeyor grade from Codacy test coverage from Codecov license

The argunparse is intended to perform an approximate reverse of what argparse does. In short: generating string (or a list of strings) of command-line arguments from a dict and/or a list.

how to use

Simple example of how argunparse works:

import argunparse

options = {
    'v': True,
    'long-flag': True,
    'ignored': False,
    'also-ignored': None,
    'o': 'out_file.txt',
    'log': 'log_file.txt'
    }
args = {
    'in_file.txt'
    }

unparser = argunparse.ArgumentUnparser()
print(unparser.unparse(*args, **options))
# -v --long-flag -o=out_file.txt --log=log_file.txt in_file.txt

print(unparser.unparse_to_list(*args, **options))
# ['-v', '--long-flag', '-o=out_file.txt', '--log=log_file.txt', 'in_file.txt']

Special option values are:

  • True -- option will be treated as a flag;
  • False and None -- option will be ignored.

All other values will be converted to strings using str().

For more examples see examples.ipynb notebook.

requirements

Python version 3.5 or later.

No other runtime dependencies.

However, building and running tests requires packages listed in test_requirements.txt.

Tested on Linux, OS X and Windows.

installation

For simplest installation use pip:

pip3 install argunparse

links

About

intended to perform an approximate reverse of what argparse does

Topics

Resources

License

Packages

No packages published
You can’t perform that action at this time.