Skip to main content

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

Project description

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

package version from PyPI build status from GitHub test coverage from Codecov grade from Codacy 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.11 or later.

Python libraries as specified in requirements.txt.

Building and running tests additionally requires packages listed in requirements_test.txt.

Tested on Linux, macOS and Windows.

Installation

For simplest installation use pip:

pip3 install argunparse

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

argunparse-0.2.0.tar.gz (10.8 kB view details)

Uploaded Source

Built Distribution

argunparse-0.2.0-py3-none-any.whl (9.4 kB view details)

Uploaded Python 3

File details

Details for the file argunparse-0.2.0.tar.gz.

File metadata

  • Download URL: argunparse-0.2.0.tar.gz
  • Upload date:
  • Size: 10.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for argunparse-0.2.0.tar.gz
Algorithm Hash digest
SHA256 0a575ca43f98a72ade6c0a59ad843cfd19df7aacbe062d4d35a99c023036d1d1
MD5 bb1e8ff8088991eb176025585e3b6365
BLAKE2b-256 663cb64928efa2282589e7977c46a46192b709f710646ea8def55073702ee570

See more details on using hashes here.

File details

Details for the file argunparse-0.2.0-py3-none-any.whl.

File metadata

  • Download URL: argunparse-0.2.0-py3-none-any.whl
  • Upload date:
  • Size: 9.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for argunparse-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 031dd2fff527a9ef96d299b4dc6c9dcadd2cc42e2aff01d2cb2c6c7e69a87aa0
MD5 bd23f5f9c4a4f5f189e3adcb5fc41a21
BLAKE2b-256 cf0a77c3e62ad282e769eb2941e04d94019bb65c4e51a2397b984610b3616735

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page