/snap/core18/2999/usr/lib/python3.6/__pycache__
NameSizeModeActions
abc.cpython-36.pyc75150644editdlrm
aifc.cpython-36.pyc259430644editdlrm
antigravity.cpython-36.pyc7790644editdlrm
argparse.cpython-36.pyc604560644editdlrm
ast.cpython-36.pyc117040644editdlrm
asynchat.cpython-36.pyc68150644editdlrm
asyncore.cpython-36.pyc158380644editdlrm
base64.cpython-36.pyc170590644editdlrm
bdb.cpython-36.pyc170330644editdlrm
binhex.cpython-36.pyc120860644editdlrm
bisect.cpython-36.pyc26760644editdlrm
bz2.cpython-36.pyc112820644editdlrm
calendar.cpython-36.pyc258820644editdlrm
cgi.cpython-36.pyc284160644editdlrm
cgitb.cpython-36.pyc100800644editdlrm
chunk.cpython-36.pyc49000644editdlrm
cmd.cpython-36.pyc125750644editdlrm
code.cpython-36.pyc98360644editdlrm
codecs.cpython-36.pyc339000644editdlrm
codeop.cpython-36.pyc62700644editdlrm
colorsys.cpython-36.pyc33110644editdlrm
compileall.cpython-36.pyc82780644editdlrm
configparser.cpython-36.pyc452440644editdlrm
contextlib.cpython-36.pyc111580644editdlrm
copy.cpython-36.pyc70790644editdlrm
copyreg.cpython-36.pyc42440644editdlrm
cProfile.cpython-36.pyc42940644editdlrm
crypt.cpython-36.pyc22420644editdlrm
csv.cpython-36.pyc118550644editdlrm
datetime.cpython-36.pyc545110644editdlrm
decimal.cpython-36.pyc3510644editdlrm
difflib.cpython-36.pyc596420644editdlrm
dis.cpython-36.pyc141810644editdlrm
doctest.cpython-36.pyc755890644editdlrm
dummy_threading.cpython-36.pyc11020644editdlrm
enum.cpython-36.pyc234530644editdlrm
filecmp.cpython-36.pyc83050644editdlrm
fileinput.cpython-36.pyc131520644editdlrm
fnmatch.cpython-36.pyc28740644editdlrm
formatter.cpython-36.pyc175790644editdlrm
fractions.cpython-36.pyc184260644editdlrm
ftplib.cpython-36.pyc283570644editdlrm
functools.cpython-36.pyc240620644editdlrm
genericpath.cpython-36.pyc37260644editdlrm
getopt.cpython-36.pyc62170644editdlrm
getpass.cpython-36.pyc41770644editdlrm
gettext.cpython-36.pyc143060644editdlrm
glob.cpython-36.pyc42590644editdlrm
gzip.cpython-36.pyc162260644editdlrm
hashlib.cpython-36.pyc66920644editdlrm
heapq.cpython-36.pyc142920644editdlrm
hmac.cpython-36.pyc48360644editdlrm
imaplib.cpython-36.pyc421380644editdlrm
imghdr.cpython-36.pyc41500644editdlrm
imp.cpython-36.pyc96960644editdlrm
inspect.cpython-36.pyc797390644editdlrm
io.cpython-36.pyc33870644editdlrm
ipaddress.cpython-36.pyc623860644editdlrm
keyword.cpython-36.pyc17650644editdlrm
linecache.cpython-36.pyc37780644editdlrm
locale.cpython-36.pyc340300644editdlrm
lzma.cpython-36.pyc119920644editdlrm
macpath.cpython-36.pyc56410644editdlrm
macurl2path.cpython-36.pyc18670644editdlrm
mailbox.cpython-36.pyc637520644editdlrm
mailcap.cpython-36.pyc72090644editdlrm
mimetypes.cpython-36.pyc155530644editdlrm
modulefinder.cpython-36.pyc153660644editdlrm
netrc.cpython-36.pyc38360644editdlrm
nntplib.cpython-36.pyc337800644editdlrm
ntpath.cpython-36.pyc131900644editdlrm
nturl2path.cpython-36.pyc14990644editdlrm
numbers.cpython-36.pyc121420644editdlrm
opcode.cpython-36.pyc54130644editdlrm
operator.cpython-36.pyc139130644editdlrm
optparse.cpython-36.pyc480540644editdlrm
os.cpython-36.pyc296280644editdlrm
pathlib.cpython-36.pyc420070644editdlrm
pdb.cpython-36.pyc460940644editdlrm
pickle.cpython-36.pyc426910644editdlrm
pickletools.cpython-36.pyc660200644editdlrm
pipes.cpython-36.pyc78080644editdlrm
pkgutil.cpython-36.pyc162610644editdlrm
platform.cpython-36.pyc291970644editdlrm
plistlib.cpython-36.pyc280550644editdlrm
poplib.cpython-36.pyc133290644editdlrm
posixpath.cpython-36.pyc104560644editdlrm
pprint.cpython-36.pyc158240644editdlrm
profile.cpython-36.pyc139010644editdlrm
pstats.cpython-36.pyc218570644editdlrm
pty.cpython-36.pyc38610644editdlrm
pyclbr.cpython-36.pyc83650644editdlrm
pydoc.cpython-36.pyc837750644editdlrm
py_compile.cpython-36.pyc65440644editdlrm
queue.cpython-36.pyc87550644editdlrm
quopri.cpython-36.pyc57730644editdlrm
random.cpython-36.pyc193300644editdlrm
re.cpython-36.pyc140580644editdlrm
reprlib.cpython-36.pyc54000644editdlrm
rlcompleter.cpython-36.pyc57800644editdlrm
runpy.cpython-36.pyc79820644editdlrm
sched.cpython-36.pyc65640644editdlrm
secrets.cpython-36.pyc21620644editdlrm
selectors.cpython-36.pyc176970644editdlrm
shelve.cpython-36.pyc94580644editdlrm
shlex.cpython-36.pyc69700644editdlrm
shutil.cpython-36.pyc307040644editdlrm
signal.cpython-36.pyc25150644editdlrm
site.cpython-36.pyc165600644editdlrm
sitecustomize.cpython-36.pyc2120644editdlrm
smtpd.cpython-36.pyc266830644editdlrm
smtplib.cpython-36.pyc353400644editdlrm
sndhdr.cpython-36.pyc69130644editdlrm
socket.cpython-36.pyc220130644editdlrm
socketserver.cpython-36.pyc242500644editdlrm
sre_compile.cpython-36.pyc102780644editdlrm
sre_constants.cpython-36.pyc59720644editdlrm
sre_parse.cpython-36.pyc203580644editdlrm
ssl.cpython-36.pyc369390644editdlrm
stat.cpython-36.pyc38510644editdlrm
statistics.cpython-36.pyc181740644editdlrm
string.cpython-36.pyc79640644editdlrm
stringprep.cpython-36.pyc100300644editdlrm
struct.cpython-36.pyc3120644editdlrm
subprocess.cpython-36.pyc354850644editdlrm
sunau.cpython-36.pyc169380644editdlrm
symbol.cpython-36.pyc25170644editdlrm
symtable.cpython-36.pyc104280644editdlrm
sysconfig.cpython-36.pyc159160644editdlrm
tabnanny.cpython-36.pyc69750644editdlrm
tarfile.cpython-36.pyc630850644editdlrm
telnetlib.cpython-36.pyc180970644editdlrm
tempfile.cpython-36.pyc253090644editdlrm
textwrap.cpython-36.pyc136840644editdlrm
this.cpython-36.pyc12650644editdlrm
threading.cpython-36.pyc372340644editdlrm
timeit.cpython-36.pyc116030644editdlrm
token.cpython-36.pyc33200644editdlrm
tokenize.cpython-36.pyc186470644editdlrm
trace.cpython-36.pyc194950644editdlrm
traceback.cpython-36.pyc196460644editdlrm
tracemalloc.cpython-36.pyc172290644editdlrm
tty.cpython-36.pyc10720644editdlrm
turtle.cpython-36.pyc1317510644editdlrm
types.cpython-36.pyc82010644editdlrm
typing.cpython-36.pyc733060644editdlrm
uu.cpython-36.pyc34980644editdlrm
uuid.cpython-36.pyc209180644editdlrm
warnings.cpython-36.pyc132580644editdlrm
wave.cpython-36.pyc178850644editdlrm
weakref.cpython-36.pyc191430644editdlrm
webbrowser.cpython-36.pyc157970644editdlrm
xdrlib.cpython-36.pyc83020644editdlrm
zipapp.cpython-36.pyc55340644editdlrm
zipfile.cpython-36.pyc497280644editdlrm
_bootlocale.cpython-36.pyc9800644editdlrm
_collections_abc.cpython-36.pyc287970644editdlrm
_compat_pickle.cpython-36.pyc65660644editdlrm
_compression.cpython-36.pyc41040644editdlrm
_dummy_thread.cpython-36.pyc48510644editdlrm
_markupbase.cpython-36.pyc79910644editdlrm
_osx_support.cpython-36.pyc96840644editdlrm
_pydecimal.cpython-36.pyc1634020644editdlrm
_pyio.cpython-36.pyc713860644editdlrm
_sitebuiltins.cpython-36.pyc34350644editdlrm
_strptime.cpython-36.pyc159630644editdlrm
_sysconfigdata_m_linux_x86_64-linux-gnu.cpython-36.pyc187790644editdlrm
_threading_local.cpython-36.pyc64250644editdlrm
_weakrefset.cpython-36.pyc78280644editdlrm
__future__.cpython-36.pyc41670644editdlrm
__phello__.foo.cpython-36.pyc1190644editdlrm
Edit: /snap/core18/2999/usr/lib/python3.6/__pycache__/argparse.cpython-36.pyc (60456B)
3 Nqia@sZdZdZdddddddd d d d d dddddgZddlZddlZddlZddl Z ddl Z ddl ZyddlmZmZWn$ek rddZddZYnXdZdZdZdZdZdZd ZGd!d"d"eZd#d$ZGd%ddeZGd&ddeZGd'd d eZGd(ddeZ Gd)d d eZ!d*d+Z"Gd,dde#Z$Gd-dde#Z%Gd.d d eZ&Gd/d0d0e&Z'Gd1d2d2e&Z(Gd3d4d4e(Z)Gd5d6d6e(Z*Gd7d8d8e&Z+Gd9d:d:e&Z,Gd;d<dd>e&Z.Gd?d@d@e&Z/GdAdBdBe&Z0GdCddeZ1GdDd d eZ2GdEdFdFeZ3GdGdHdHe3Z4GdIdJdJe4Z5GdKddee3Z6dS)La Command-line parsing library This module is an optparse-inspired command-line parsing library that: - handles both optional and positional arguments - produces highly informative usage messages - supports parsers that dispatch to sub-parsers The following is a simple usage example that sums integers from the command-line and writes the result to a file:: parser = argparse.ArgumentParser( description='sum the integers at the command line') parser.add_argument( 'integers', metavar='int', nargs='+', type=int, help='an integer to be summed') parser.add_argument( '--log', default=sys.stdout, type=argparse.FileType('w'), help='the file where the sum should be written') args = parser.parse_args() args.log.write('%s' % sum(args.integers)) args.log.close() The module contains the following public classes: - ArgumentParser -- The main entry point for command-line parsing. As the example above shows, the add_argument() method is used to populate the parser with actions for optional and positional arguments. Then the parse_args() method is invoked to convert the args at the command-line into an object with attributes. - ArgumentError -- The exception raised by ArgumentParser objects when there are errors with the parser's actions. Errors raised while parsing the command-line are caught by ArgumentParser and emitted as command-line messages. - FileType -- A factory for defining types of files to be created. As the example above shows, instances of FileType are typically passed as the type= argument of add_argument() calls. - Action -- The base class for parser actions. Typically actions are selected by passing strings like 'store_true' or 'append_const' to the action= argument of add_argument(). However, for greater customization of ArgumentParser actions, subclasses of Action may be defined and passed as the action= argument. - HelpFormatter, RawDescriptionHelpFormatter, RawTextHelpFormatter, ArgumentDefaultsHelpFormatter -- Formatter classes which may be passed as the formatter_class= argument to the ArgumentParser constructor. HelpFormatter is the default, RawDescriptionHelpFormatter and RawTextHelpFormatter tell the parser not to change the formatting for help text, and ArgumentDefaultsHelpFormatter adds information about argument defaults to the help. All other classes in this module are considered implementation details. (Also note that HelpFormatter and RawDescriptionHelpFormatter are only considered public as object names -- the API of the formatter objects is still considered an implementation detail.) z1.1ArgumentParser ArgumentErrorArgumentTypeErrorFileType HelpFormatterArgumentDefaultsHelpFormatterRawDescriptionHelpFormatterRawTextHelpFormatterMetavarTypeHelpFormatter NamespaceAction ONE_OR_MOREOPTIONALPARSER REMAINDERSUPPRESS ZERO_OR_MOREN)gettextngettextcCs|S)N)messagerr/usr/lib/python3.6/argparse.py_`srcCs|dkr |S|SdS)Nr)ZsingularZpluralnrrrrbsrz ==SUPPRESS==?*+zA...z...Z_unrecognized_argsc@s(eZdZdZddZddZddZdS) _AttributeHolderaAbstract base class that provides __repr__. The __repr__ method returns a string in the format:: ClassName(attr=name, attr=name, ...) The attributes are determined either by a class-level attribute, '_kwarg_names', or by inspecting the instance __dict__. cCst|j}g}i}x|jD]}|jt|qWx8|jD],\}}|jr`|jd||fq<|||<qsz6HelpFormatter._Section.format_help..z%*s%s:  ) rXrWrT _join_partsr/rVrYrrF)r'r&Z item_helpZcurrent_indentrYrrr format_helps    z"HelpFormatter._Section.format_help)N)r r0r1rSrarrrrrIs rIcCs|jjj||fdS)N)rKr/r")r'r[r\rrr _add_itemszHelpFormatter._add_itemcCs0|j|j||j|}|j|jg||_dS)N)rTrIrKrbra)r'rYZsectionrrr start_sectionszHelpFormatter.start_sectioncCs|jj|_|jdS)N)rKrXrV)r'rrr end_sections zHelpFormatter.end_sectioncCs$|tk r |dk r |j|j|gdS)N)rrb _format_text)r'textrrradd_textszHelpFormatter.add_textcCs&|tk r"||||f}|j|j|dS)N)rrb _format_usage)r'usageactionsgroupsprefixr\rrr add_usages zHelpFormatter.add_usagecCsz|jtk rv|j}||g}x |j|D]}|j||q&Wtdd|D}||j}t|j||_|j|j |gdS)NcSsg|] }t|qSr)len)rZsrrrr]sz.HelpFormatter.add_argument..) helpr_format_action_invocation_iter_indented_subactionsr"rDrFrHrb_format_action)r'actionZget_invocationZ invocations subactionZinvocation_lengthZ action_lengthrrr add_argument s   zHelpFormatter.add_argumentcCsx|D]}|j|qWdS)N)rv)r'rjrtrrr add_argumentss zHelpFormatter.add_argumentscCs.|jj}|r*|jjd|}|jdd}|S)Nz r_)rJrarPsubstrip)r'rprrrra"s  zHelpFormatter.format_helpcCsdjdd|DS)Nr^cSsg|]}|r|tk r|qSr)r)rZpartrrrr]*sz-HelpFormatter._join_parts..)r&)r'Z part_stringsrrrr`)s zHelpFormatter._join_partscs<|dkrtd}|dk r,|t|jd}n|dkrN| rNdt|jd}n|dkr0dt|jd}g}g}x(|D] }|jr|j|qv|j|qvW|j} | |||} djdd|| gD}|j|jt |t |kr0d} | ||} | ||} t j | | }t j | | }dj|| ks,t dj|| ks@t dfdd }t |t |d krdt |t |d }|r||g|||}|j |||n |r||g|||}n|g}nZdt |}||}|||}t |d krg}|j ||||j ||||g|}d j|}d ||fS)Nzusage: )rQz%(prog)s cSsg|] }|r|qSrr)rZrorrrr]Jsz/HelpFormatter._format_usage..z%\(.*?\)+(?=\s|$)|\[.*?\]+(?=\s|$)|\S+csg}g}|dk rt|d}n t|d}xb|D]Z}|dt|krp|rp|j|dj|g}t|d}|j||t|d7}q0W|r|j|dj||dk r|dt|d|d<|S)Nrr{r)rnr"r&)partsindentrllineslineZline_lenrz) text_widthrr get_lines^s"    z.HelpFormatter._format_usage..get_linesg?rr_z%s%s )N)rdictr@option_stringsr"_format_actions_usager&rErFrnrLfindallrUextend)r'rirjrkrlrQZ optionals positionalsrtformatZ action_usageZ part_regexpZ opt_usageZ pos_usageZ opt_partsZ pos_partsrr}r~r|r)rrrh.sZ            zHelpFormatter._format_usagec Cst}i}x|D]}y|j|jd}Wntk r>wYqX|t|j}||||jkrx|jD]}|j|qhW|js||kr||d7<nd||<d||<n*||kr||d7<nd||<d||<xt|d|D] } d || <qWqWg} x2t|D]$\} }|j t krj| j d|j | d krF|j | n"|j | dd kr.|j | dn|js|j|} |j|| } ||kr| ddkr| ddkr| dd} | j | nh|jd} |jdkrd | } n"|j|} |j|| }d | |f} |j r$||kr$d | } | j | q Wx(t|d dD]} || g| | | <qBWdjdd| D}d}d}tjd|d|}tjd|d|}tjd||fd|}tjdd|}|j}|S)Nrz [[]z (()r|z%sz%s %sz[%s]T)reverser{cSsg|]}|dk r|qS)Nr)rZitemrrrr]sz7HelpFormatter._format_actions_usage..z[\[(]z[\])]z(%s) z\1z (%s)z%s *%sr^z \(([^|]*)\)r)setindex_group_actionsr?rnaddrequiredrange enumeraterprr"getpopr#_get_default_metavar_for_positional _format_argsnargs!_get_default_metavar_for_optionalr-r&rLrxry)r'rjrk group_actionsZinsertsgroupstartendrtir|defaultrz option_string args_stringrfopencloserrrrsr                 z#HelpFormatter._format_actions_usagecCsFd|kr|t|jd}t|j|jd}d|j}|j|||dS)Nz%(prog))rQ r{z )rr@rDrErF _fill_text)r'rfrr}rrrres  zHelpFormatter._format_textc CsBt|jd|j}t|j|d}||jd}|j|}|jsV|jd|f}d|}n@t||kr~|jd||f}d|}d}n|jd|f}d|}|}|g}|jr|j |} |j | |} |j d|d| dfx@| ddD]} |j d|d| fqWn|j ds|j dx$|j |D]} |j |j| qW|j|S) Nr7rr^z%*s%s z %*s%-*s rrr_)rCrHrBrDrErFrqrprn _expand_help _split_linesr"endswithrrrsr`) r'rtZ help_positionZ help_widthZ action_widthZ action_headertupZ indent_firstr|Z help_textZ help_linesrrurrrrss6          zHelpFormatter._format_actioncCs|js&|j|}|j||d\}|Sg}|jdkrB|j|jn8|j|}|j||}x |jD]}|jd||fq`Wdj|SdS)Nrrz%s %sz, ) rr_metavar_formatterrrrrr"r&)r'rtrmetavarr|rrrrrrq%s     z'HelpFormatter._format_action_invocationcsP|jdk r|jn.|jdk r.z{%s},csttrSf|SdS)N) isinstancetuple)Z tuple_size)resultrrrFs z0HelpFormatter._metavar_formatter..format)rchoicesr&)r'rtdefault_metavarZ choice_strsrr)rrr=s   z HelpFormatter._metavar_formattercCs|j||}|jdkr$d|d}n|jtkr.r{) rrr rr rrrr&)r'rtrZ get_metavarrZformatsrrrrMs        zHelpFormatter._format_argscCstt||jd}x"t|D]}||tkr||=qWx,t|D] }t||dr@||j||<q@W|jddk rdjdd|dD}||d<|j ||S)N)rQr rz, cSsg|] }t|qSr)r)rZcrrrr]isz.HelpFormatter._expand_help..) rvarsr@listrhasattrr rr&_get_help_string)r'rtZparamsr*Z choices_strrrrr`s  zHelpFormatter._expand_helpc cs@y |j}Wntk rYnX|j|EdH|jdS)N)_get_subactionsAttributeErrorrTrV)r'rtZget_subactionsrrrrrms  z'HelpFormatter._iter_indented_subactionscCs|jjd|j}tj||S)Nr{)rOrxry _textwrapZwrap)r'rfrRrrrrwszHelpFormatter._split_linescCs$|jjd|j}tj||||dS)Nr{)Zinitial_indentZsubsequent_indent)rOrxryrZfill)r'rfrRr}rrrr{s zHelpFormatter._fill_textcCs|jS)N)rp)r'rtrrrrszHelpFormatter._get_help_stringcCs |jjS)N)destupper)r'rtrrrrsz/HelpFormatter._get_default_metavar_for_optionalcCs|jS)N)r)r'rtrrrrsz1HelpFormatter._get_default_metavar_for_positional)r7r8N)N) r r0r1r2rSrTrVobjectrIrbrcrdrgrmrvrwrar`rhrrersrqrrrrrrrrrrrrrrrs<  `a/  c@seZdZdZddZdS)rzHelp message formatter which retains any formatting in descriptions. Only the name of this class is considered a public API. All the methods provided by the class are considered an implementation detail. cs djfdd|jddDS)Nr^c3s|]}|VqdS)Nr)rZr)r}rr sz9RawDescriptionHelpFormatter._fill_text..T)keepends)r& splitlines)r'rfrRr}r)r}rrsz&RawDescriptionHelpFormatter._fill_textN)r r0r1r2rrrrrrsc@seZdZdZddZdS)rzHelp message formatter which retains formatting of all help text. Only the name of this class is considered a public API. All the methods provided by the class are considered an implementation detail. cCs|jS)N)r)r'rfrRrrrrsz!RawTextHelpFormatter._split_linesN)r r0r1r2rrrrrrsc@seZdZdZddZdS)rzHelp message formatter which adds default values to argument help. Only the name of this class is considered a public API. All the methods provided by the class are considered an implementation detail. cCs>|j}d|jkr:|jtk r:ttg}|js2|j|kr:|d7}|S)Nz %(default)z (default: %(default)s))rprrr rrr)r'rtrpZdefaulting_nargsrrrrs  z.ArgumentDefaultsHelpFormatter._get_help_stringN)r r0r1r2rrrrrrsc@s eZdZdZddZddZdS)r a Help message formatter which uses the argument 'type' as the default metavar value (instead of the argument 'dest') Only the name of this class is considered a public API. All the methods provided by the class are considered an implementation detail. cCs|jjS)N)rr )r'rtrrrrsz:MetavarTypeHelpFormatter._get_default_metavar_for_optionalcCs|jjS)N)rr )r'rtrrrrsz.r)r'namesr)r'rr$8szAction._get_kwargscCsttddS)Nz.__call__() not defined)NotImplementedErrorr)r'parserr5valuesrrrr__call__FszAction.__call__)NNNNNFNN)N)r r0r1r2rSr$rrrrrr s1 cs(eZdZdfdd ZdddZZS) _StoreActionNFc sT|dkrtd|dk r,|tkr,tdttt|j||||||||| | d dS)Nrznargs for store actions must be > 0; if you have nothing to store, actions such as store true or store const may be more appropriatez nargs must be %r to supply const) rrrrrrrrrpr)r?r superrrS) r'rrrrrrrrrpr) __class__rrrSLs   z_StoreAction.__init__cCst||j|dS)N)r4r)r'rr5rrrrrrisz_StoreAction.__call__)NNNNNFNN)N)r r0r1rSr __classcell__rr)rrrJsrcs(eZdZdfdd ZdddZZS) _StoreConstActionNFc s"tt|j||d||||ddS)Nr)rrrrrrrp)rrrS)r'rrrrrrpr)rrrrSos z_StoreConstAction.__init__cCst||j|jdS)N)r4rr)r'rr5rrrrrrsz_StoreConstAction.__call__)NFNN)N)r r0r1rSrrrr)rrrms  rcseZdZdfdd ZZS)_StoreTrueActionFNcs tt|j||d|||ddS)NT)rrrrrrp)rrrS)r'rrrrrp)rrrrSs z_StoreTrueAction.__init__)FFN)r r0r1rSrrr)rrrsrcseZdZdfdd ZZS)_StoreFalseActionTFNcs tt|j||d|||ddS)NF)rrrrrrp)rrrS)r'rrrrrp)rrrrSs z_StoreFalseAction.__init__)TFN)r r0r1rSrrr)rrrsrcs(eZdZdfdd ZdddZZS) _AppendActionNFc sT|dkrtd|dk r,|tkr,tdttt|j||||||||| | d dS)Nrznargs for append actions must be > 0; if arg strings are not supplying the value to append, the append const action may be more appropriatez nargs must be %r to supply const) rrrrrrrrrpr)r?r rrrS) r'rrrrrrrrrpr)rrrrSs   z_AppendAction.__init__cCs0tjt||jg}|j|t||j|dS)N)_copycopyr6rr"r4)r'rr5rrr/rrrrs z_AppendAction.__call__)NNNNNFNN)N)r r0r1rSrrrr)rrrsrcs(eZdZdfdd ZdddZZS) _AppendConstActionNFc s$tt|j||d|||||ddS)Nr)rrrrrrrpr)rrrS)r'rrrrrrpr)rrrrSs z_AppendConstAction.__init__cCs2tjt||jg}|j|jt||j|dS)N)rrr6rr"rr4)r'rr5rrr/rrrrs z_AppendConstAction.__call__)NFNN)N)r r0r1rSrrrr)rrrs  rcs(eZdZdfdd ZdddZZS) _CountActionNFcs tt|j||d|||ddS)Nr)rrrrrrp)rrrS)r'rrrrrp)rrrrSs z_CountAction.__init__cCs$t||jdd}t||j|dS)Nrr)r6rr4)r'rr5rrZ new_countrrrrsz_CountAction.__call__)NFN)N)r r0r1rSrrrr)rrrs rcs.eZdZeedffdd ZdddZZS) _HelpActionNcstt|j|||d|ddS)Nr)rrrrrp)rrrS)r'rrrrp)rrrrSs  z_HelpAction.__init__cCs|j|jdS)N) print_helpexit)r'rr5rrrrrrsz_HelpAction.__call__)N)r r0r1rrSrrrr)rrrsrcs0eZdZdeedffdd ZdddZZS)_VersionActionNz&show program's version number and exitcs$tt|j|||d|d||_dS)Nr)rrrrrp)rrrSversion)r'rrrrrp)rrrrSs z_VersionAction.__init__cCsD|j}|dkr|j}|j}|j||j|jtj|jdS)N)r_get_formatterrg_print_messagera_sysstdoutr)r'rr5rrrrWrrrrs z_VersionAction.__call__)N)r r0r1rrSrrrr)rrr s  rcsNeZdZGdddeZeddffdd ZddZdd Zd d d Z Z S) _SubParsersActioncseZdZfddZZS)z&_SubParsersAction._ChoicesPseudoActioncs@|}}|r|ddj|7}ttj|}|jg|||ddS)Nz (%s)z, )rrrpr)r&rr_ChoicesPseudoActionrS)r'r*aliasesrprrZsup)rrrrS+s   z/_SubParsersAction._ChoicesPseudoAction.__init__)r r0r1rSrrr)rrr)srNcs>||_||_tj|_g|_tt|j||t |j||ddS)N)rrrrrpr) _prog_prefix _parser_class _collections OrderedDict_name_parser_map_choices_actionsrrrSr)r'rrQ parser_classrrpr)rrrrS3s  z_SubParsersAction.__init__cKs|jddkr d|j|f|d<|jdf}d|krX|jd}|j|||}|jj||jf|}||j|<x|D]}||j|<qtW|S)NrQz%s %srrp)rrrrrr"rr)r'r*kwargsrrpZ choice_actionraliasrrr add_parserHs      z_SubParsersAction.add_parsercCs|jS)N)r)r'rrrr_sz!_SubParsersAction._get_subactionsc Cs|d}|dd}|jtk r,t||j|y|j|}Wn<tk rv|dj|jd}td|}t||YnX|j|d\} }x$t | j D]\} } t|| | qW|rt |j t gt |t j|dS)Nrrz, ) parser_namerz5unknown parser %(parser_name)r (choices: %(choices)s))rrr4rr>r&rrparse_known_argsrr/ setdefault_UNRECOGNIZED_ARGS_ATTRr3r) r'rr5rrrr(r\msgZ subnamespacekeyr+rrrrbs"    z_SubParsersAction.__call__)N) r r0r1r rrrSrrrrrr)rrr'src@s*eZdZdZd ddZddZd d ZdS) raFactory for creating file object types Instances of FileType are typically passed as type= arguments to the ArgumentParser add_argument() method. Keyword Arguments: - mode -- A string indicating how the file is to be opened. Accepts the same values as the builtin open() function. - bufsize -- The file's desired buffer size. Accepts the same values as the builtin open() function. - encoding -- The file's encoding. Accepts the same values as the builtin open() function. - errors -- A string indicating how encoding and decoding errors are to be handled. Accepts the same value as the builtin open() function. rrNcCs||_||_||_||_dS)N)_mode_bufsize _encoding_errors)r'modebufsizeencodingerrorsrrrrSszFileType.__init__cCs|dkr>d|jkrtjSd|jkr(tjStd|j}t|yt||j|j|j|j St k r}ztd}t |||fWYdd}~XnXdS)N-rwzargument "-" with mode %rzcan't open '%s': %s) rrstdinrrr?rrrrOSErrorr)r'stringrerrrrrs  zFileType.__call__cCsT|j|jf}d|jfd|jfg}djdd|Ddd|D}dt|j|fS)Nrrz, cSsg|]}|dkrt|qS)rr)r#)rZr)rrrr]sz%FileType.__repr__..cSs$g|]\}}|dk rd||fqS)Nz%s=%rr)rZkwr)rrrr]sz%s(%s))rrrrr&rr )r'r\rZargs_strrrrr,s  zFileType.__repr__r)rrNN)r r0r1r2rSrr,rrrrrs c@s(eZdZdZddZddZddZdS) r zSimple object for storing attributes. Implements equality by attribute names and values, and provides a simple string representation. cKs"x|D]}t||||qWdS)N)r4)r'rr*rrrrSs zNamespace.__init__cCst|tstSt|t|kS)N)rr NotImplementedr)r'otherrrr__eq__s zNamespace.__eq__cCs ||jkS)N)r.)r'rrrr __contains__szNamespace.__contains__N)r r0r1r2rSr r rrrrr scseZdZfddZddZd&ddZdd Zd d Zd d ZddZ ddZ ddZ ddZ ddZ ddZddZd'ddZddZd d!Zd"d#Zd$d%ZZS)(_ActionsContainercstt|j||_||_||_||_i|_|jddt |jddt |jddt |jddt |jddt |jddt |jddt|jddt|jdd t|jdd t|jdd t|jg|_i|_g|_g|_i|_tjd |_g|_dS) NrtZstoreZ store_const store_trueZ store_falser"Z append_constcountrprparsersz^-\d+$|^-\d*\.\d+$)rr rS descriptionargument_default prefix_charsconflict_handler _registriesregisterrrrrrrrrrr _get_handler_actions_option_string_actions_action_groups_mutually_exclusive_groups _defaultsrLrM_negative_number_matcher_has_negative_number_optionals)r'rrrr)rrrrSs2 z_ActionsContainer.__init__cCs|jj|i}|||<dS)N)rr)r' registry_namer+rregistryrrrrsz_ActionsContainer.registerNcCs|j|j||S)N)rr)r'rr+rrrr _registry_get sz_ActionsContainer._registry_getcKs6|jj|x$|jD]}|j|kr||j|_qWdS)N)rupdaterrr)r'rrtrrr set_defaultss   z_ActionsContainer.set_defaultscCs8x(|jD]}|j|kr|jdk r|jSqW|jj|dS)N)rrrrr)r'rrtrrr get_defaults  z_ActionsContainer.get_defaultc Os0|j}| s(t|dkrJ|dd|krJ|r|js>|jjdq>W|S)NT) _check_conflictrr" containerrrrmatchr)r'rtrrrrr)]s     z_ActionsContainer._add_actioncCs|jj|dS)N)rremove)r'rtrrr_remove_actionrsz _ActionsContainer._remove_actioncCsi}x8|jD].}|j|kr0td}t||j|||j<q Wi}xR|jD]H}|j|krt|j|j|j|jd||j<x|jD]}||j||<q|WqJWx4|jD]*}|j |j d}x|jD] }|||<qWqWx |j D]}|j ||j |qWdS)Nz.cannot merge actions - two groups are named %r)titlerr)r)rr5rr?r-rrrrr/rrrr))r'r1Ztitle_group_maprrZ group_maprt mutex_grouprrr_add_container_actionsus,         z(_ActionsContainer._add_container_actionscKs^d|krtd}t||jdttgkr2d|d<|jdtkrPd|krPd|d<t||gdS)Nrz1'required' is an invalid argument for positionalsrTr)rr)rr(rr rr)r'rrrrrrr$sz(_ActionsContainer._get_positional_kwargsc Osg}g}xv|D]n}|d|jkr@||jd}td}t|||j||d|jkrt|dkr|d|jkr|j|qW|jdd}|dkr|r|d}n|d}|j|j}|std}t|||jdd}t|||d S) Nr)optionrzNinvalid option string %(option)r: must start with a character %(prefix_chars)rrrz%dest= is required for options like %rrr)rr) rrr?r"rnrlstripreplacer) r'r\rrZlong_option_stringsrrrZdest_option_stringrrrr%s0          z&_ActionsContainer._get_optional_kwargscCs|jd|}|jd||S)Nrt)rr )r'rrrtrrrr&s z#_ActionsContainer._pop_action_classc CsDd|j}y t||Stk r>td}t||jYnXdS)Nz_handle_conflict_%sz%invalid conflict_resolution value: %r)rr3rrr?)r'Zhandler_func_namerrrrrs   z_ActionsContainer._get_handlercCsPg}x0|jD]&}||jkr |j|}|j||fq W|rL|j}|||dS)N)rrr"r)r'rtZconfl_optionalsrZconfl_optionalrrrrr0s   z!_ActionsContainer._check_conflictcCs6tddt|}djdd|D}t|||dS)Nzconflicting option string: %szconflicting option strings: %sz, cSsg|] \}}|qSrr)rZrrtrrrr]sz<_ActionsContainer._handle_conflict_error..)rrnr&r)r'rtconflicting_actionsrZconflict_stringrrr_handle_conflict_errors    z(_ActionsContainer._handle_conflict_errorcCsBx<|D]4\}}|jj||jj|d|js|jj|qWdS)N)rr3rrr1r4)r'rtr;rrrr_handle_conflict_resolves  z*_ActionsContainer._handle_conflict_resolve)N)N)r r0r1rSrr r"r#rvr-r/r)r4r7r$r%r&rr0r<r=rrr)rrr s$ 4   /($   r cs6eZdZdfdd ZfddZfddZZS) r,Nc s|j}|d|j|d|j|d|jtt|j}|fd|i|||_g|_|j |_ |j |_ |j |_ |j |_ |j |_ |j|_dS)Nrrrr)rrrrrr,rSr5rrrrrrr)r'r1r5rrr!Z super_init)rrrrSs    z_ArgumentGroup.__init__cs tt|j|}|jj||S)N)rr,r)rr")r'rt)rrrr)s z_ArgumentGroup._add_actioncs tt|j||jj|dS)N)rr,r4rr3)r'rt)rrrr4!sz_ArgumentGroup._remove_action)NN)r r0r1rSr)r4rrr)rrr,s r,cs.eZdZdfdd ZddZddZZS) r.Fcs tt|j|||_||_dS)N)rr.rSr _container)r'r1r)rrrrS(sz _MutuallyExclusiveGroup.__init__cCs2|jrtd}t||jj|}|jj||S)Nz-mutually exclusive arguments must be optional)rrr?r>r)rr")r'rtrrrrr)-s   z#_MutuallyExclusiveGroup._add_actioncCs|jj||jj|dS)N)r>r4rr3)r'rtrrrr45s z&_MutuallyExclusiveGroup._remove_action)F)r r0r1rSr)r4rrr)rrr.&sr.c seZdZdZddddgeddddddf fdd Zdd Zd d Zd d ZddZ ddZ d=ddZ d>ddZ ddZ ddZddZddZddZd d!Zd"d#Zd$d%Zd&d'Zd(d)Zd*d+Zd,d-Zd.d/Zd0d1Zd?d2d3Zd@d4d5ZdAd6d7ZdBd9d:Zd;d<ZZ S)CraObject for parsing command line strings into Python objects. Keyword Arguments: - prog -- The name of the program (default: sys.argv[0]) - usage -- A usage message (default: auto-generated from arguments) - description -- A description of what the program does - epilog -- Text following the argument descriptions - parents -- Parsers whose arguments should be copied into this one - formatter_class -- HelpFormatter class for printing help messages - prefix_chars -- Characters that prefix optional arguments - fromfile_prefix_chars -- Characters that prefix files containing additional arguments - argument_default -- The default value for all arguments - conflict_handler -- String indicating how to handle conflicts - add_help -- Add a -h/-help option - allow_abbrev -- Allow long options to be abbreviated unambiguously NrerrorTc  s&tt|j} | ||| | d|dkr6tjjtjd}||_||_ ||_ ||_ ||_ | |_ | |_|j}|td|_|td|_d|_dd}|jdd|d|krdn|d}|j r|j|d |d d d ttd d xD|D]<}|j|y |j}Wntk rYqX|jj|qWdS)N)rrrrrzpositional argumentszoptional argumentscSs|S)Nr)rrrridentityssz)ArgumentParser.__init__..identityrrhr7rpzshow this help message and exit)rtrrp)rrrSr<pathbasenamerargvrQriepilogformatter_classfromfile_prefix_charsadd_help allow_abbrevr-r _positionals _optionals _subparsersrrvrr7rrr!)r'rQrirrEparentsrFrrGrrrHrIZ superinitZ add_groupr@Zdefault_prefixrXZdefaults)rrrrSMsB     zArgumentParser.__init__cs"ddddddg}fdd|DS) NrQrirrFrrHcsg|]}|t|fqSr)r3)rZr*)r'rrr]sz.ArgumentParser._get_kwargs..r)r'rr)r'rr$szArgumentParser._get_kwargsc Ks|jdk r|jtd|jdt|d|ks8d|krht|jdd}t|jdd}|j|||_n|j|_|jddkr|j }|j }|j }|j |j ||d|jj|d<|j|d}|fd gi|}|jj||S) Nz(cannot have multiple subparser argumentsrr5rZ subcommandsrQr^rr)rLr?rrrrr-rJrr_get_positional_actionsrrmriraryr&r)) r'rr5rrWrrkZ parsers_classrtrrradd_subparserss$   zArgumentParser.add_subparserscCs$|jr|jj|n |jj||S)N)rrKr)rJ)r'rtrrrr)s zArgumentParser._add_actioncCsdd|jDS)NcSsg|]}|jr|qSr)r)rZrtrrrr]sz8ArgumentParser._get_optional_actions..)r)r'rrr_get_optional_actionssz$ArgumentParser._get_optional_actionscCsdd|jDS)NcSsg|]}|js|qSr)r)rZrtrrrr]sz:ArgumentParser._get_positional_actions..)r)r'rrrrNsz&ArgumentParser._get_positional_actionscCs4|j||\}}|r0td}|j|dj||S)Nzunrecognized arguments: %sr{)rrr?r&)r'r\r5rDrrrr parse_argss zArgumentParser.parse_argsc Cs |dkrtjdd}nt|}|dkr.t}x>|jD]4}|jtk r6t||js6|jtk r6t ||j|jq6Wx*|j D] }t||svt |||j |qvWy<|j ||\}}t|t r|j t|t t|t ||fStk rtjd}|jt|YnXdS)Nr)rrDrr rrrrrr4r_parse_known_argsrrr3delattrrexc_infor?r)r'r\r5rtrerrrrrrs,         zArgumentParser.parse_known_argscs" jdk r jix` jD]V}|j}xJt|jD]<\}}j|g}|j|d||j||ddq6Wq Wig}t} xnt| D]b\}} | dkr|jdxF| D]} |jdqWq j | } | dkrd} n | |<d} |j| qWdj |t t d fdd  fd d } j  fd d }gd rpt }nd}x| |krt fddD} |kr| }| kr| qvn| kr |}j|| |  qvW| }j|dg}x jD]|}|kr|jr>|jt|nT|jdk rt|jtrt|jr|jt|jkrt|j j||jqW|r jtddj |xb jD]X}|jrxH|jD]}|krPqWdd|jD}td} j|dj |qWfS)Nrz--rAOr^csj|j||}||jk rfj|x:j|gD]*}|kr8td}t|}t|||q8W|tk r||||dS)Nznot allowed with argument %s)r _get_valuesrrrrrr)rtZargument_stringsrZargument_valuesZconflict_actionrZ action_name)action_conflictsr5 seen_actionsseen_non_default_actionsr'rr take_action's    z5ArgumentParser._parse_known_args..take_actioncs|}|\}}}j}g}x>|dkr>j||dS|dk r||d}j}|dkr|d|kr|j|g|f|d} | |d}|ddpd} j} || kr| |}| }ntd} t|| |n@|dkr|d} |g}|j|||fPntd} t|| |q |d}|d}|||}||} || }|j|||fPq W|shtx |D]\}}}|||qnW| S)NrrVrzignored explicit argument %r)_match_argumentr"rrrrrU) start_index option_tuplertr explicit_argZmatch_argumentZ action_tuples arg_countr*charZnew_explicit_argZ optionals_maprstopr\rZselected_patterns)r(arg_strings_patternextrasoption_string_indicesr'r\rrconsume_optional<sP        z:ArgumentParser._parse_known_args..consume_optionalcsrj}|d}||}x8t|D]*\}}|||}||7}||q(Wt|ddd<|S)N)_match_arguments_partialziprn)r^Z match_partialZselected_patternZ arg_countsrtrar\)r(rdrr'r\rrconsume_positionalss  z=ArgumentParser._parse_known_args..consume_positionalsrcsg|]}|kr|qSrr)rZr)r^rrr]sz4ArgumentParser._parse_known_args..z(the following arguments are required: %sz, cSsg|]}|jtk rt|qSr)rprr)rZrtrrrr]sz#one of the arguments %s is requiredr{)Nr)rG_read_args_from_filesrrrrriterr"_parse_optionalr&rrNrDrCrrrrrrrrr3r4 _get_valuer?r)r'r(r5r6rrZ mutex_actionZ conflictsZarg_string_pattern_partsZarg_strings_iter arg_stringr_patternrgrjZmax_option_string_indexZnext_option_string_indexZpositionals_end_indexZstringsZ stop_indexZrequired_actionsrtrrrr) rYr(rdrer5rfrrZr[r'r^r\rrRs        J                 z ArgumentParser._parse_known_argscCsg}x|D]}| s"|d|jkr.|j|q ylt|ddR}g}x2|jjD]"}x|j|D]}|j|qdWqTW|j|}|j|WdQRXWq tk rt j d}|j t |Yq Xq W|S)Nrr) rGr"rreadrconvert_arg_line_to_argsrkrrrrTr?r)r'r(Znew_arg_stringsroZ args_filearg_liner)rUrrrrks     z$ArgumentParser._read_args_from_filescCs|gS)Nr)r'rsrrrrrsz'ArgumentParser.convert_arg_line_to_argscCst|j|}tj||}|dkrfdtdttdttdi}tdd|j|j}|j|j|}t ||t |j dS)Nzexpected one argumentzexpected at most one argumentzexpected at least one argumentzexpected %s argumentzexpected %s argumentsr) _get_nargs_patternrLr2rr r rrrrrnr)r'rtrd nargs_patternr2Z nargs_errorsrrrrrr] s    zArgumentParser._match_argumentcstg}xjtt|ddD]V}|d|}djfdd|D}tj||}|dk r|jdd|jDPqW|S)Nrrr^csg|]}j|qSr)rt)rZrt)r'rrr]&sz;ArgumentParser._match_arguments_partial..cSsg|] }t|qSr)rn)rZrrrrr]*sr)rrnr&rLr2rrk)r'rjrdrrZ actions_slicerpr2r)r'rrh s   z'ArgumentParser._match_arguments_partialc Cs|sdS|d|jkrdS||jkr8|j|}||dfSt|dkrHdSd|kr~|jdd\}}||jkr~|j|}|||fS|jr|j|}t|dkrdjdd|D}||d}td}|j||nt|dkr|\} | S|j j |r|j sdSd |krdSd|dfS) Nrr=z, cSsg|]\}}}|qSrr)rZrtrr`rrrr]Psz2ArgumentParser._parse_optional..)r8Zmatchesz4ambiguous option: %(option)s could match %(matches)sr{) rrrnsplitrI_get_option_tuplesr&rr?rr2r) r'rortrr`Z option_tuplesZoptionsr\rr_rrrrm0s>              zArgumentParser._parse_optionalc Cs0g}|j}|d|kr~|d|kr~d|kr<|jdd\}}n|}d}x|jD],}|j|rL|j|}|||f}|j|qLWn|d|ko|d|kr|}d}|dd}|dd} xr|jD]T}||kr|j|}||| f}|j|q|j|r|j|}|||f}|j|qWn|jtd||S)Nrrrvr7zunexpected option string: %s)rrwr startswithr"r?r) r'rrr*Z option_prefixr`rtrZshort_option_prefixZshort_explicit_argrrrrxks8             z!ArgumentParser._get_option_tuplescCs|j}|dkrd}nX|tkr"d}nJ|tkr0d}n<|tkr>d}n.|tkrLd}n |tkrZd}nddjd |}|jr|jdd }|jd d }|S) Nz(-*A-*)z(-*A?-*)z (-*[A-]*)z (-*A[A-]*)z([-AO]*)z (-*A[-AO]*)z(-*%s-*)z-*rVr^r) rr rr rrr&rr:)r'rtrrurrrrts$  z!ArgumentParser._get_nargs_patternc sxjttgkr2y|jdWntk r0YnX| rzjtkrzjrPj}nj}t |t rxj |}j |n| rjt krj rjdk rj}n|}j |nt|dkrjdtgkr|\}j |}j |njtkrfdd|D}nbjtkrDfdd|D}j |dn0fdd|D}x|D]}j |q^W|S)Nz--rcsg|]}j|qSr)rn)rZv)rtr'rrr]sz.ArgumentParser._get_values..csg|]}j|qSr)rn)rZrz)rtr'rrr]srcsg|]}j|qSr)rn)rZrz)rtr'rrr]s)rrrr3r?r rrrrrrn _check_valuerrn)r'rtr(r+rorzr)rtr'rrXs>       zArgumentParser._get_valuesc Cs|jd|j|j}t|s0td}t|||y ||}Wntk r~t|jdt|j}tt j d}t||YnLt t fk rt|jdt|j}||d}td}t|||YnX|S)Nrz%r is not callabler r)rr+z!invalid %(type)s value: %(value)r) r rr'rrrr3r#rrrTr(r?)r'rtror+rrr*r\rrrrns   zArgumentParser._get_valuecCsF|jdk rB||jkrB|djtt|jd}td}t|||dS)Nz, )r+rz3invalid choice: %(value)r (choose from %(choices)s))rr&mapr#rr)r'rtr+r\rrrrr{ s zArgumentParser._check_valuecCs$|j}|j|j|j|j|jS)N)rrmrirrra)r'rWrrr format_usage s zArgumentParser.format_usagecCsx|j}|j|j|j|j|j|jx:|jD]0}|j|j |j|j|j |j |j q0W|j|j |jS)N)rrmrirrrgrrrcr5rwrrdrEra)r'rWZ action_grouprrrra" s        zArgumentParser.format_helpcCs|j|jdS)N)rQ)rFrQ)r'rrrr9 szArgumentParser._get_formattercCs"|dkrtj}|j|j|dS)N)rrrr})r'filerrr print_usage? szArgumentParser.print_usagecCs"|dkrtj}|j|j|dS)N)rrrra)r'r~rrrrD szArgumentParser.print_helpcCs |r|dkrtj}|j|dS)N)rstderrwrite)r'rr~rrrrI szArgumentParser._print_messagercCs |r|j|tjtj|dS)N)rrrr)r'ZstatusrrrrrR szArgumentParser.exitcCs0|jtj|j|d}|jdtd|dS)zerror(message: string) Prints a usage message incorporating the message to stderr and exits. If you override this in a subclass, it should not return -- it should either exit or raise an exception. )rQrr7z%(prog)s: error: %(message)s N)rrrrQrr)r'rr\rrrr?W s  zArgumentParser.error)NN)NN)N)N)N)rN)!r r0r1r2rrSr$rOr)rPrNrQrrRrkrrr]rhrmrxrtrXrnr{r}rarrrrrr?rrr)rrr:sP4  #w;,,4    )7r2 __version____all__ collectionsrrrosr<rerLsysrZtextwraprrrr ImportErrorrr rr rrrrrr6rrrrr r Exceptionrrr rrrrrrrrrrrr r r,r.rrrrr>s n    [#%`65"