OwlCyberSecurity - MANAGER
Edit File: fancy_getopt.cpython-34.pyc
� i fxE������������������@���sK��d��Z��d�d�l�Z�d�d�l�Z�d�d�l�Z�d�d�l�Z�d�d�l�Td�Z�e�j�d�e���Z�e�j�d�e�e�f���Z �e �j�d�d���Z�Gd �d ����d ���Z �d�d����Z�d �d����e�j�D��Z�d�d����Z�d�d����Z�Gd�d����d���Z�e�d�k�rGd�Z�xK�d�d�d�d�f�D]7�Z�e�d�e���e�d�j�e�e�e�������e����q Wn��d�S)a6��distutils.fancy_getopt Wrapper around the standard getopt module that provides the following additional features: * short and long options are tied together * options have help strings, so fancy_getopt could potentially create a complete usage summary * options set attributes of a passed-in object �����N)�*z[a-zA-Z](?:[a-zA-Z0-9-]*)z^%s$z^(%s)=!(%s)$�-�_c���������������@���s����e��Z�d��Z�d�Z�d�d�d���Z�d�d����Z�d�d����Z�d�d�d �d ���Z�d�d����Z�d �d����Z �d�d����Z �d�d����Z�d�d����Z�d�d����Z �d�d�d�d���Z�d�d����Z�d�d�d���Z�d�d�d�d���Z�d�S)�FancyGetopta���Wrapper around the standard 'getopt()' module that provides some handy extra functionality: * short and long options are tied together * options have help strings, and help text can be assembled from them * options set attributes of a passed-in object * boolean options can have "negative aliases" -- eg. if --quiet is the "negative alias" of --verbose, then "--quiet" on the command line sets 'verbose' to false Nc�������������C���st���|�|��_��i��|��_�|��j��r(�|��j����n��i��|��_�i��|��_�g��|��_�g��|��_�i��|��_�i��|��_�i��|��_ �g��|��_ �d��S)N)�option_table�option_index�_build_index�alias�negative_alias� short_opts� long_opts� short2long� attr_name� takes_arg�option_order)�selfr�����r����;/opt/alt/python34/lib64/python3.4/distutils/fancy_getopt.py�__init__)���s���� zFancyGetopt.__init__c�������������C���s6���|��j��j����x"�|��j�D]�}�|�|��j��|�d�<q�Wd��S)Nr���)r����clearr���)r����optionr���r���r���r���Q���s���� zFancyGetopt._build_indexc�������������C���s���|�|��_��|��j����d��S)N)r���r���)r���r���r���r���r����set_option_tableV���s���� zFancyGetopt.set_option_tablec�������������C���sR���|�|��j��k�r"�t�d�|�����n,�|�|�|�f�}�|��j�j�|���|�|��j��|�<d��S)Nz'option conflict: already an option '%s')r����DistutilsGetoptErrorr����append)r����long_optionZshort_optionZhelp_stringr���r���r���r���� add_optionZ���s����zFancyGetopt.add_optionc�������������C���s ���|�|��j��k�S)zcReturn true if the option table for this parser has an option with long name 'long_option'.)r���)r���r���r���r���r���� has_optionc���s����zFancyGetopt.has_optionc�������������C���s ���|�j��t���S)z�Translate long option name 'long_option' to the form it has as an attribute of some object: ie., translate hyphens to underscores.)� translate� longopt_xlate)r���r���r���r���r���� get_attr_nameh���s����zFancyGetopt.get_attr_namec�������������C���s����t��|�t���s�t���xp�|�j����D]b�\�}�}�|�|��j�k�rY�t�d�|�|�|�f�����n��|�|��j�k�r"�t�d�|�|�|�f�����q"�q"�Wd��S)Nz(invalid %s '%s': option '%s' not definedz0invalid %s '%s': aliased option '%s' not defined)� isinstance�dict�AssertionError�itemsr���r���)r����aliasesZwhatr ����optr���r���r����_check_alias_dictn���s����zFancyGetopt._check_alias_dictc�������������C���s���|��j��|�d���|�|��_�d�S)z'Set the aliases for this option parser.r ���N)r&���r ���)r���r ���r���r���r����set_aliasesx���s����zFancyGetopt.set_aliasesc�������������C���s���|��j��|�d���|�|��_�d�S)z�Set the negative aliases for this option parser. 'negative_alias' should be a dictionary mapping option names to option names, both the key and value must already be defined in the option table.znegative aliasN)r&���r ���)r���r ���r���r���r����set_negative_aliases}���s����z FancyGetopt.set_negative_aliasesc�������������C���s���g��|��_��g��|��_�|��j�j����i��|��_�xa|��j�D]V}�t�|���d�k�rb�|�\�}�}�}�d�}�n:�t�|���d�k�r��|�\�}�}�}�}�n�t�d�|�f�����t�|�t ���s��t�|���d�k��r��t �d�|�����n��|�d�k�p��t�|�t ���o��t�|���d�k�st �d �|�����n��|�|��j�|�<|��j��j�|���|�d�d �k�rq|�rQ|�d�}�n��|�d�d���}�d�|��j�|�<na�|��j �j�|���}�|�d�k �r�|��j�|�r�t �d�|�|�f�����n��|�|��j��d�<n��d�|��j�|�<|��j�j�|���}�|�d�k �r&|��j�|�|��j�|�k�r&t �d �|�|�f�����q&n��t�j�|���sHt �d�|�����n��|��j�|���|��j�|�<|�r2�|��j�j�|���|�|��j�|�d�<q2�q2�Wd�S)z�Populate the various data structures that keep tabs on the option table. Called by 'getopt()' before it can do anything worthwhile. ����r�������zinvalid option tuple: %r����z9invalid long option '%s': must be a string of length >= 2N����z:invalid short option '%s': must a single character or None�=�:z>invalid negative alias '%s': aliased option '%s' takes a valuezginvalid alias '%s': inconsistent with aliased option '%s' (one of them takes a value, the other doesn'tzEinvalid long option name '%s' (must be letters, numbers, hyphens only���r/���r/���)r���r���r ���r����repeatr����len� ValueErrorr ����strr���r���r���r ����getr ���� longopt_re�matchr���r���)r���r����long�short�helpr0���Zalias_tor���r���r����_grok_option_table����s^���� " ! � zFancyGetopt._grok_option_tablec�������������C���s>��|�d�k�r"�t��j�d�d���}�n��|�d�k�r@�t����}�d�}�n�d�}�|��j����d�j�|��j���}�y"�t�j�|�|�|��j���\�}�}�Wn4�t�j�k �r��}�z�t �|�����WYd�d�}�~�Xn�Xxh|�D]`\�}�}�t �|���d�k�r|�d�d�k�r|��j�|�d�}�n>�t �|���d�k�r,|�d�d���d �k�s2t���|�d�d���}�|��j �j�|���} �| �rc| �}�n��|��j�|�s�|�d �k�s�t�d�����|��j�j�|���} �| �r�| �}�d�}�q�d�}�n��|��j�|�} �|�r�|��j�j�| ���d�k �r�t�|�| �d���d�}�n��t�|�| �|���|��j�j�|�|�f���q��W|�r6|�|�f�S|�Sd�S)a��Parse command-line options in args. Store as attributes on object. If 'args' is None or not supplied, uses 'sys.argv[1:]'. If 'object' is None or not supplied, creates a new OptionDummy object, stores option values there, and returns a tuple (args, object). If 'object' is supplied, it is modified in place and 'getopt()' just returns 'args'; in both cases, the returned 'args' is a modified copy of the passed-in 'args' list, which is left untouched. Nr,���TF� r+���r���r���z--��zboolean option can't have value)�sys�argv�OptionDummyr:����joinr����getoptr����errorZDistutilsArgErrorr1���r ���r"���r ���r4���r���r ���r���r0����getattr�setattrr���r���)r����args�objectZcreated_objectr���Zopts�msgr%����valr ����attrr���r���r���rA�������sF���� "". zFancyGetopt.getoptc�������������C���s)���|��j��d�k�r�t�d�����n�|��j��Sd�S)z�Returns the list of (option, value) tuples processed by the previous run of 'getopt()'. Raises RuntimeError if 'getopt()' hasn't been called yet. Nz!'getopt()' hasn't been called yet)r����RuntimeError)r���r���r���r����get_option_order��s����zFancyGetopt.get_option_orderc�������������C���s���d�}�x|�|��j��D]q�}�|�d�}�|�d�}�t�|���}�|�d�d�k�rS�|�d�}�n��|�d�k �rl�|�d�}�n��|�|�k�r�|�}�q�q�W|�d�d�d�}�d�}�|�|�} �d�|�} �|�r��|�g�}�n �d �g�}�x|��j��D]}�|�d�d ���\�}�}�}�t�|�| ���} �|�d�d�k�r'|�d�d���}�n��|�d�k�rt| �rZ|�j�d�|�|�| �d�f���q�|�j�d�|�|�f���nH�d �|�|�f�}�| �r�|�j�d�|�|�| �d�f���n�|�j�d�|���x)�| �d�d���D]�}�|�j�| �|���q�Wq��W|�S)z�Generate help text (a list of strings, one per suggested line of output) from the option table for this FancyGetopt object. r���r,���r-���N����r+����N���r;���zOption summary:r)���z --%-*s %sz --%-*s z%s (-%s)z --%-*sr/���r/���r/���)r���r1���� wrap_textr���)r����headerZmax_optr���r7���r8����lZ opt_widthZ line_widthZ text_widthZ big_indent�linesr9����textZ opt_namesr���r���r���� generate_help��sF���� ! zFancyGetopt.generate_helpc�������������C���sG���|�d��k�r�t��j�}�n��x(�|��j�|���D]�}�|�j�|�d���q(�Wd��S)N� )r=����stdoutrS����write)r���rO����file�liner���r���r���� print_helph��s����zFancyGetopt.print_help)�__name__� __module__�__qualname__�__doc__r���r���r���r���r���r���r&���r'���r(���r:���rA���rK���rS���rY���r���r���r���r���r������s��� ( M= Or���c�������������C���s)���t��|����}�|�j�|���|�j�|�|���S)N)r���r(���rA���)�optionsZnegative_optrF���rE����parserr���r���r����fancy_getopto��s���� r`���c�������������C���s���i��|��]�}�d��t��|�����q�S)r;���)�ord)�.0Z_wscharr���r���r���� <dictcomp>u��s��� �rc���c�������������C���s���|��d�k�r�g��St��|����|�k�r)�|��g�S|��j����}��|��j�t���}��t�j�d�|����}�d�d����|�D��}�g��}�x|�r}g��}�d�}�xt�|�r��t��|�d���}�|�|�|�k�r��|�j�|�d���|�d�=|�|�}�q��|�r��|�d �d�d�k�r��|�d �=n��Pq��W|�rd|�d�k�rC|�j�|�d�d�|�����|�d�|�d���|�d�<n��|�d�d�d�k�rd|�d�=qdn��|�j�d�j�|�����qr�W|�S)z�wrap_text(text : string, width : int) -> [string] Split 'text' into multiple lines of no more than 'width' characters each, and return the list of strings that results. Nz( +|-+)c�������������S���s���g��|��]�}�|�r�|���q�Sr���r���)rb���Zchr���r���r���� <listcomp>���s��� �zwrap_text.<locals>.<listcomp>r���r,���r;���r<���r/���r/���)r1���� expandtabsr����WS_TRANS�re�splitr���r@���)rR����widthZchunksrQ���Zcur_lineZcur_lenrP���r���r���r���rN���w��s:���� rN���c�������������C���s ���|��j��t���S)zXConvert a long option name to a valid Python identifier by changing "-" to "_". )r���r���)r%���r���r���r����translate_longopt���s����rj���c���������������@���s%���e��Z�d��Z�d�Z�g��d�d���Z�d�S)r?���z_Dummy class just used as a place to hold command-line option values as instance attributes.c�������������C���s%���x�|�D]�}�t��|��|�d���q�Wd�S)zkCreate a new OptionDummy instance. The attributes listed in 'options' will be initialized to None.N)rD���)r���r^���r%���r���r���r���r������s���� zOptionDummy.__init__N)rZ���r[���r\���r]���r���r���r���r���r���r?������s���r?����__main__z�Tra-la-la, supercalifragilisticexpialidocious. How *do* you spell that odd word, anyways? (Someone ask Mary -- she'll know [or she'll say, "How should I know?"].)� ������������(���z width: %drT���)r]���r=����stringrg���rA���Zdistutils.errorsZlongopt_pat�compiler5���Zneg_alias_rer3���� maketransr���r���r`���Z whitespacerf���rN���rj���r?���rZ���rR����w�printr@���r���r���r���r����<module> ���s(���$ ��S6