Module Import alias Import alias Import alias FunctionDef arguments args NameParam defaults body Expr Str TryExcept body Assign NameStore Call AttributeLoad NameLoad attr NameLoad handlers ExceptHandler type NameLoad body Raise Call AttributeLoad NameLoad attr BinOpMod Str NameLoad orelse Return NameLoad decorator_list ClassDef bases AttributeLoad AttributeLoad NameLoad attr attr body Expr Str Assign NameStore TupleLoad Str Str FunctionDef arguments args NameParam NameParam NameParam defaults AttributeLoad NameLoad attr Str body Assign AttributeStore NameLoad attr NameLoad Assign AttributeStore NameLoad attr NameLoad decorator_list FunctionDef arguments args NameParam NameParam defaults body Expr Str If BoolOpOr CompareLt AttributeLoad NameLoad attr Num CompareLt AttributeLoad NameLoad attr Num body Assign NameStore Call AttributeLoad NameLoad attr orelse Assign NameStore BinOpDiv AttributeLoad NameLoad attr AttributeLoad NameLoad attr Assign NameStore Call AttributeLoad Call AttributeLoad NameLoad attr NameLoad attr keyword AttributeLoad NameLoad attr Return Call AttributeLoad NameLoad attr AttributeLoad NameLoad attr decorator_list decorator_list
N/A N/A bitmath N/A argparse N/A progressbar.widgets BitmathType N/A N/A bmstring N/A N/A N/A An 'argument type' for integrations with the argparse module.

For more information, see
https://docs.python.org/2/library/argparse.html#type Of particular
interest to us is this bit:

   ``type=`` can take any callable that takes a single string
   argument and returns the converted value

I.e., ``type`` can be a function (such as this function) or a class
which implements the ``__call__`` method.

Example usage of the bitmath.BitmathType argparser type:

   >>> import bitmath
   >>> import argparse
   >>> parser = argparse.ArgumentParser()
   >>> parser.add_argument("--file-size", type=bitmath.BitmathType)
   >>> parser.parse_args("--file-size 1337MiB".split())
   Namespace(file_size=MiB(1337.0))

Invalid usage includes any input that the bitmath.parse_string
function already rejects. Additionally, **UNQUOTED** arguments with
spaces in them are rejected (shlex.split used in the following
examples to conserve single quotes in the parse_args call):

   >>> parser = argparse.ArgumentParser()
   >>> parser.add_argument("--file-size", type=bitmath.BitmathType)
   >>> import shlex

   >>> # The following is ACCEPTABLE USAGE:
   ...
   >>> parser.parse_args(shlex.split("--file-size '1337 MiB'"))
   Namespace(file_size=MiB(1337.0))

   >>> # The following is INCORRECT USAGE because the string "1337 MiB" is not quoted!
   ...
   >>> parser.parse_args(shlex.split("--file-size 1337 MiB"))
   error: argument --file-size: 1337 can not be parsed into a valid bitmath object
 N/A N/A N/A argvalue N/A N/A bitmath parse_string bmstring N/A N/A N/A ValueError N/A N/A N/A N/A argparse ArgumentTypeError N/A '%s' can not be parsed into a valid bitmath object bmstring N/A N/A argvalue N/A BitmathFileTransferSpeed N/A N/A N/A progressbar widgets Widget N/A N/A Widget for showing the transfer speed (useful for file transfers). N/A __slots__ N/A system format __init__ N/A N/A self system format N/A N/A bitmath NIST {value:.2f} {unit}/s N/A N/A N/A self system system N/A N/A self format format N/A update N/A N/A self pbar N/A N/A N/A Updates the widget with the current NIST/SI speed.

Basically, this calculates the average rate of update and figures out
how to make a "pretty" prefix unit N/A N/A N/A N/A pbar seconds_elapsed 2e-06 N/A N/A pbar currval 2e-06 N/A N/A scaled N/A N/A bitmath Byte N/A N/A speed N/A N/A pbar currval N/A pbar seconds_elapsed N/A scaled N/A N/A N/A N/A bitmath Byte speed best_prefix system N/A self system N/A N/A N/A scaled format N/A self format N/A N/A