Saravanan666/pypi-org huggingface dataset:
Package: argparse-prompt
ArgparsePromptArgparsePrompt is a wrapper for the built-in Argparse, allowing missing command-line arguments to be filled in by the
user via interactive promptsInstallationArgparsePrompt can be installed using pip:pipinstallargparse_promptUsageBasic UsageThe only public interface of this module is thePromptParserclass, which is a subclass of Python'sArgumentParser. Use this class in exactly the same way that you would
use ArgumentParser, except that, if any argument does not have a specifieddefaultvalue, and a value is not provided
for it on the commandline, thePromptParserwill prompt for a value for this argument usinginput(), which is read
from stdin.Consider the code below (taken from one of the unit tests):fromargparse_promptimportPromptParserparser=PromptParser()parser.add_argument('--argument','-a',help='An argument you could provide',default='foo')print(parser.parse_args().argument)If you run this script with a value forargument, the parsing will run as normal:$ python test/default_parser.py --argument 12
12However if you don't specify a value forarg, the parser will prompt you for one$ python test/default_parser.py
argument: An argument you could provide
> (foo) car
carDefault ValuesSince this argument has a default value, you can also just hit enter and this value will be used automatically:python test/default_parser.py
argument: An argument you could provide
> (foo) 
fooType CheckingYou can also specify a type for the argument in the normal way:fromargparse_promptimportPromptParserparser=PromptParser()parser.add_argument('--argument','-a',help='An argument you could provide',type=int)print(parser.parse_args().argument)If you do, this type checking will be used for the value you enter at the prompt:$ python test/typed_parser.py  
argument: An argument you could provide
abc
Argument "argument" was given a value not of type <class 'int'>Secure ValuesFor arguments that need to be secure, such as passwords, secret keys etc, you can usesecure=Truewhen defining your
argument. This will cause whatever the user inputs for that field to be hidden from the terminal, in the same way thatgit, orsshhides the password input.For example:parser.add_argument('--password','-p',help='A very secret password',secure=True)Situationally Disabling the PromptIf you use thepromptargument toadd_argument, parsing will be disabled:parser.add_argument('--argument','-a',help='An argument you could provide',default='foo',prompt=False)Also, if you want to disable all prompting (for an automated script, for example), just set theARGPARSE_PROMPT_AUTOto
a truthy value:ARGPARSE_PROMPT_AUTO=1pythontest/default_parser.py
Package: argparse-pydantic
Argparse PydanticConfig for argparse with pydantic model.Simple wrapper for python argparse.Use pydantic model for you app config.It gives you typed config instead of default Namespace from argparse.Tested on python 3.7 - 3.11WIPInstallInstall from pypi:pip install argparse_pydanticOr install from github repo:pip install git+https://github.com/ayasyrev/argparse_pydantic.gitBase use.We use python argparse to parse arguments from command line.So, just create parser as usual:importargparseparser=argparse.ArgumentParser(prog="MyApp")Than create config for you app with Pydantic.frompydanticimportBaseModelclassAppCfg(BaseModel):echo:strNow add argument to parser from you config.fromargparse_pydanticimportadd_args_from_modelparser=add_args_from_model(parser,AppCfg)So we got parser with arguments from config.It exactly like parser made classic way:parser.add_argument("echo")Now we can use parser in you script usual way -parser.parse_args()$ python my_app.py -h
usage: MyApp [-h] echo

positional arguments:
  echo

options:
  -h, --help  show this help message and exitParse command line as usual.args=parser.parse_args(["argument from command line"])When we parse command line, we got Namespace object.Bat we can convert it to config object.fromargparse_pydanticimportcreate_model_objcfg=create_model_obj(AppCfg,args)Now we got  config with type checks / validation ont type hinting when use it at IDE.cfgoutputAppCfg(echo='argument from command line')cfg.echooutput'argument from command line'Optional if undefined.We can use undefined arguments as positional or optional (but required).classAppCfg2(BaseModel):arg_int:intarg_float:float=0.1parser=argparse.ArgumentParser(prog="MyApp")parser=add_args_from_model(parser,AppCfg2,undefined_positional=False)$ python my_app.py -h
usage: MyApp [-h] --arg_int ARG_INT [--arg_float ARG_FLOAT]

options:
  -h, --help            show this help message and exit
  --arg_int ARG_INT
  --arg_float ARG_FLOATAdd types and defaults values.And we can add type hints to help message from our config.parser=argparse.ArgumentParser(prog="MyApp")parser=add_args_from_model(parser,AppCfg2,undefined_positional=False,help_def_type=True,)$ python my_app.py -h
usage: MyApp [-h] --arg_int ARG_INT [--arg_float ARG_FLOAT]

options:
  -h, --help            show this help message and exit
  --arg_int ARG_INT     [int]
  --arg_float ARG_FLOAT
                        [float] default: 0.1ExamplesYou can see examples atexamplesfolder - Same examples as at python docs and tutorial for argparse.
Package: argparseqt
argparseqtAn easy way to make Qt GUIs using the argparse standard moduleInstallationVia pip:pipinstallargparseqtFrom source:gitclonehttps://github.com/domstoppable/argparseqt.gitcdargparseqt.git
pythonsetup.pyinstallDependenciesRequires:qtpyQt bindings for Python (eitherPySide2,PyQt5,PySide, orPyQt)UsageQuick startimportargparseimportargparseqt.guiparser=argparse.ArgumentParser(description='Main settings')parser.add_argument('--storeConst',action='store_const',const=999)textSettings=parser.add_argument_group('Strings',description='Text input')textSettings.add_argument('--freetext',type=str,default='Enter freetext here',help='Type anything you want here')textSettings.add_argument('--pickText',default='I choo-choo-choose you',choices=['Bee mine','I choo-choo-choose you'],help='Choose one of these')app=QtWidgets.QApplication()dialog=argparseqt.gui.ArgDialog(parser)dialog.exec_()ifdialog.result()==QtWidgets.QDialog.Accepted:values=dialog.getValues()print('Values:',values)else:print('User cancelled')Seeexample.pyfor more.
Package: arg-parser
Arg-Parser-PythonThis package helps to parse args from the command line or the terminal to a dictionary and calls registered functions when the individual command is given. This makes dealing with args much easier, more efficient and better ordered.Why to use it?When you want to get the args withsys.argvthey have to be in the correct position and if one is missing the script crashes. Executing a script working withsys.argvoften looks like this:py .\script.py get name.If you integrate this script the args are registered like this and much easier to read out.py .\script.py --get -n nameAs you can see this is variable and could also be called like this... -n name --get. Values can be accessed withargs["-argname"]Integration:Try to install this script withpip install arg_parserand thenfrom arg_parser import *at the top of your script.
If this doesn't work you can download it fromhttps://github.com/NightKylo/Python-Arg-Parser. After that put it into the same directory as your script. In your script addfrom arg_parser import *at the top.
Be aware that the better way is to install it via pip.Usage:To use the parser you have to initialize theParserclass viaParser(commands)wherecommandsis a register-object created like that:reg = Register(). You can register a command withreg + Command("--name", "description", ["-required_param"], ["-optional_param"])and a parameter withreg + Parameter("-name", "description"). If you want you can usereg.add(Parameter("-name", "description"))instead of+. If there are no required or optional params remove the lists or putNone.Now you need to specify how to handle a command. It works like this:@parser("--command_name") def handle_command_name(args: dict): do_whatever_you_want(). In the decorator above the function you have to pass the command eg--getand the parser will call the function when the command is supplied.argsis in this case a dictionary of the given args form the structure{ "-optname": "value", "-optname": "value" }. Be aware that this dictionary does not contain the given command, only the options.If you want to start the handle process manually you can add aTrueto the initialization of the parser and aparser.handle_commands()when you want to handle them. By default, the parser handles the commands when all handler-functions are given.Look at the example files athttps://github.com/NightKylo/Python-Arg-Parserfor more detailed information.How does it workIf you want to know, how this package works go tohttps://github.com/NightKylo/Python-Arg-Parser/tree/main/arg_parserand look at the parser.py file.
Package: argparse-range
argparse-rangeEasily check that an argument is within a range for argparseUse it like this:>>>fromargparseimportArgumentParser,ArgumentTypeError>>>fromargparse_rangeimportrange_action>>>parser=ArgumentParser()>>>_=parser.add_argument("rangedarg",action=range_action(0,10),help="An argument")>>>args=parser.parse_args(["0"])>>>args.rangedarg0>>>parser.parse_args(["20"])Traceback(mostrecentcalllast):....argparse.ArgumentTypeError:Invalidchoice:20(mustbeinrange0..=10)FeaturesHelptext is added transparentlyfoo.py --help

usage: foo.py [-h] rangedarg

positional arguments:
  rangedarg   An argument (must be in range 0..=10)

optional arguments:
  -h, --help  show this help message and exitInfers type by default>>>fromargparseimportArgumentParser>>>fromargparse_rangeimportrange_action>>>parser=ArgumentParser()>>>_=parser.add_argument("intarg",action=range_action(0,10))>>>_=parser.add_argument("floatarg",action=range_action(25.0,40.0))>>>_=parser.add_argument("explicit",action=range_action(25.0,40.0),type=int)>>>args=parser.parse_args(["5","30","30"])>>>assertisinstance(args.intarg,int)>>>assertisinstance(args.floatarg,float)>>>assertisinstance(args.explicit,int)Handles optional arguments and defaults just like normal parsing>>>fromargparseimportArgumentParser>>>fromargparse_rangeimportrange_action>>>parser=ArgumentParser()>>>_=parser.add_argument("--maybe",action=range_action(0,10),nargs="?")>>>parser.parse_args([])Namespace(maybe=None)>>>parser.parse_args(["--maybe"])Namespace(maybe=None)>>>parser.parse_args(["--maybe","5"])Namespace(maybe=5)>>>parser.parse_args(["--maybe","20"])Traceback(mostrecentcalllast):....argparse.ArgumentTypeError:Invalidchoice:20(mustbeinrange0..=10)Handles multiple arguments just like normal parsing>>>fromargparseimportArgumentParser>>>fromargparse_rangeimportrange_action>>>parser=ArgumentParser()>>>_=parser.add_argument("many",action=range_action(0,10),nargs="*")>>>parser.parse_args([])Namespace(many=[])>>>parser.parse_args(["5"])Namespace(many=[5])>>>parser.parse_args(["1","2","3","4"])Namespace(many=[1,2,3,4])
Package: argparse_subcommand
argparse_subcommandLibrary to extend Python argparse stdlib with easy handling of subcommandsExtendsargparse.ArgumentParserwith a facility for configuring subcommands by convention.
Each subcommand lives in its separate Python module.The name of the subcommand is the module name (without superpackage names)
with underscore replaced by dash.To be a subcommand module, a module must haveimport argparse_subcommand as ap_sub

meaning = "some help text for the subcommand"
def add_arguments(parser: ap_sub.ArgumentParser): ...  # configure the subcommand's sub-argparser
def execute(args: ap_sub.Namespace): ...  # run the subcommandThe module can alsooptionallyhave:aliases = ["subcmd-alias1", "subcmd-alias2"]  # optional.for making available the same subcommand under one or more
alternative names (e.g. an abbreviation).For use, create the parser as usual and then call the submodule scanner:parser = ap_sub.ArgumentParser(epilog=explanation)
parser.scan("mysubcmds.subcmd1", "mysubcmds.subcmd2")  # or provide module object instead of str
args = parser.parse_args()
parser.execute_subcommand(args)  # or supply nothing, then parse_args() will be called internallyBy convention, the subcommand modules (and only they) all go into a common package.
If you do that, you can scan them all at once:parser.scan("mysubcmds.*")argparse_subcommanduses only one sub-parser group, so that
subcommands cannot be nested, there is only one level of subcommands.
It will executeimportlib.import_module()on all modules mentioned in ascan()call as strings.Multiple calls toscan()are allowed, each can have one or more arguments.scan(..., strict=True)will exit when encountering a non-subcommand-module.scan(..., trace=True)produces output helpful for debugging your subcommands setup.That's all.Version history1.0, 2023-05:First release1.1, 2024-01:Error messages and trace messages go to stderr, not stdout.More informative messages when scanned modules are non-subcommand modules.
Small improvements to documentation.Added version history....
Package: argparse-subdec
This is a very simple Python package that allows one to createargparse’s
subcommands via function decorators.UsageCreate aSubDecobject:importargparse_subdec# Create the object to collect subcommands via decoratorssd=argparse_subdec.SubDec()Now, we can define our subcommands. We define a subcommand by decorating a
function with method calls tosd, like below:@sd.add_argument('--option',default='123')@sd.add_argument('--another')deffoo(args):print(f'foo subcommand: --option={args.option!r}and --another={args.another!r}')You can use any method name that you would use in a subparser. In our example
above, we usedadd_argument, probably most commonly used. When creating
the subparsers,sdwill replay those calls to the created subparser for
thefoosubcommand.In the example below we define a second subcommand, which will be namedfoo-bar:@sd.cmd(prefix_chars=':')@sd.add_argument('positional_arg',type=int)deffoo_bar(args):print(f'foo-bar subcommand:{args.positional_arg!r}')Note that we use a special decorator,sd.cmd, which makessdpass all
of its arguments down toadd_parser()when creating the subparser forfoo-bar.Once our subcommands are defined, we must callsd.create_parsers()in
order to effectively create the subparsers:parser=argparse.ArgumentParser()subparsers=parser.add_subparsers()sd.create_parsers(subparsers)The following is example of how we would call the subcommands:args=parser.parse_args(['foo','--another','hello'])args.fn(args)# The subcommand function is assigned to ``args.fn`` by default# Outputs: foo subcommand: --option='123' and --another='hello'For more details about the API, check out thesubdecmodule.InstallViapip:pipinstallargparse-subdec
Package: argparsethis
argparsethisA drop-in replacement to Python's built-in argparse, that provides the capability to argparseanyarbitrary string, not just command line arguments. Is sourced fromhttps://github.com/python/cpython/blob/3.8/Lib/argparse.py.Installationpip[3] install argparsethisUsageWhen creating your ArguementParser, just override the parameterinput_listas a list of strings to parse. We recommend usingshlexto split any raw strings into a list correctly. Ifinput_listis not overridden, it will use standard command line arguments like normal. Also adds theexit_on_errorparameter, if you want to raise anArgumentExceptionin the event of a parsing error or printing out the help, instead of just exiting (the default behavior).import shlex
import argparsethis as argparse

# Argument parsing which outputs a dictionary.
def parse_args(input_str):
    #Setup the argparser and all args
    input_list = shlex.split(input_str)

    parser = argparse.ArgumentParser(input_list = input_list, exit_on_error = False)
    parser.add_argument("-q", "--quiet", help="suppress extra output", action="store_true", default=False)

    return parser.parse_args()

argv1 = parse_args("test -h")
argv2 = parse_args("test -q")

if not argv2.quiet:
    print("LOUD NOISES")
else:
    print("Please be quiet")
Package: argparse-to-json
argparse-to-jsonConvert Python argparse parsers to json compatible withJSON Form.Usageimportargparsefromargparse_to_jsonimportconvert_parser_to_jsonparser=argparse.ArgumentParser()parser.add_argument('input')json_schema=convert_parser_to_json(parser)See theexamplefolder for aFlaskapp that renders forms for command line interfaces usingJSON Form. You can run the example as follows:pipinstallflaskFLASK_APP=app.py
flaskrunWhy?Because maybe I wanted to have a simple way to create GUIs for my Python CLI's.
Package: argparse-types
argparse_typesSpecial argparse typesHow to installpip install argparse-typesdescriptionAdditional types to use with argparsehow to useImport argparse_types pass the argparse_types."type" to the type keyword in argparse.add_argument.  Remember to pass not to call.example.pyimportargparseimportargparse_typesparser=argparse.ArgumentParser()parser.add_argument("-n",dest="number",type=argparse_types.pos_int)args=parser.parse_args()print(args.number)python3 example.py -n 3434python3 example.py -n -34example.py: error: argument -n: -34 is an invalid positive int valuetypespos_int- Positive int value not including 0neg_int- Negative int value not including 0zero_int- Zero int valuepos_float- Positive float value not including 0neg_float- Negative float value not including 0zero_float- Zero float valueint_float- Any int or float valuebool_none- True, False, None valueip4- ip address 0.0.0.0 to 255.255.255.255 not including port
Package: argparse-utilities
argparse-utilitiesActions and other utility functions for use with argparseQuickstartInstall from pip:pipinstallargparse-utilitiesUsageimportargparsefromargparse_utilitiesimportStoreMaxOneActionparser=argparse.ArgumentParser(prog='Foo',description='foo foo foo',)parser.add_argument('-f','--foo',action=StoreMaxOneAction,type=int,required=True,)x=parser.parse_args(['--foo','1'])# x will be argparse.Namespace(foo=1)parser.parse_args(['--foo','1','--foo','2'])# will throw ValueError('--foo supplied more than once')DevelopmentFor those developing or maintaining theargparse-utilitiespackage itself,
be sure to install it with the[dev]option to pull in packages
used when developing.pip install --editable .[dev]When developing, this package usespre-commit.  After the initial
clone of the repository, you will need to set up pre-commit with:# in the top level of the checked-out repository:
pre-commit installChangelog0.0.2 released 2023-11-09Initial Version
Package: argpext
Argpext provides methods to quickly expose any required callable
objects, such as function, or generator, to a
DOS/Linux command line hereby defining a task.Argpext provides method to organize multiple tasks conveniently into a tree structure.Each task of such tree can then be executed by passing the proper sequence
of command line arguments that is necessary to identify the task to
be executed; the remaining arguments, if any, specify the values of the arguments
argument passed to the task (if any).Help messages, which are mostly based on the docstrings, are
automatically produced when the –help (or -h) flag is passed.The return values of the functions and the values yielded by the
generators are treated differently.  Full-featured return value
objects are available at the point of execution in
Python. Customizable return value display option is available for
execution under Linux/DOS command prompt.A thorough documentation (with numerous examples) is provided at the link above.
Package: argpy
argpyA high-level shorthand argument parser for Python 3 or aboveOverviewThe objective of argpy is simply to strengthen one's propensity to utilize argparsing in Python scripts by making the definition of command line arguments slightly less tedious.InstallationRunpip3 install argpyArgumentsvarnametypedefaultoptionsOptionslistn / aExamplesImporting the Modulefrom argpy import argpyDefining and Retrieving OptionsOptions are passed into argpy in the form of a list of dictionaries. Here each item or element within the list represents one option. In the example below, option one is defined as name with a short form flag of -n and a long form flag of --name. The "dest" key defines how the passed in option will be accessed from within the program while the "help" key defines any additional help text that will be accessible by the user passing in the option via the command line. The second option demonstrates how to pass in a boolean argument, which defaults to False.# Define options
options = [
      {"flags": ("-n", "--name"), "dest": "name", "help": "The object's name"},
      {
          "flags": ("-a", "--activate"),
          "dest": "activate",
          "bool": True,
          "help": "Whether to activate the object",
      },
  ]The above options can be implemented and retrieved by continuing the script as follows:# Get arguments
arguments = argpy(options)

# Get name, activate
name = arguments.name
activate = arguments.activateIn case you're wondering what this would look like from that command line, see below.python3 my_script.py --name OptimusPrime --activateorpython3 my_script.py -n OptimusPrime -a
Package: argreq
Add requirements to function arguments using simple and elegant decoratorsInstallation:pipinstallargreqExamplesfromargreqimportargument,requirement@argument('a','>10',type=int)defint_grater_than_10(a):'''If a is smaller than 10, function raises 'NotValidArgumentError' '''print(f'a ({a}) is int and larger then 10!')@argument('a',('>10','<20'),type=int)defother_func(a):'''Check if a is grater than 10 AND smaller than 20'''print(f'a{a}is int and between 10 and 20')@argument('a','10<{}<20',type=int)defprettier_other_func(a):'''Same as above but in a single requirement'''print(f'a ({a}) is int and between 10 and 20 and prettier ;)')@argument('a','>0')@argument('b','>0')defdiv(a,b):'''Check if both a and b positive'''print(f'{a}/{b}={a/b}')@argument('d','"a" in{}',type=dict)defdict_func(d):'''Check if d has the key 'a' '''print(f'd ({d}) has "a" in it')@requirement('{a}>{b}>0')defa_grater_than_b_and_positives(a,b):'''Check if a is grater then b and both positives'''print(f'{a}>{b}')