Your IP : 3.144.95.167


Current Path : /usr/lib64/python3.6/site-packages/gi/__pycache__/
Upload File :
Current File : //usr/lib64/python3.6/site-packages/gi/__pycache__/_option.cpython-36.pyc

3

��<_�3�	@s�dZddlZddlZddlmZmZmZmZmZddlm	Z	ej
dkrTeZdd�Z
neZeZ
dd	lmZdd
lmZe	d�Zejej��Zdd
dddddddg	ZGdd�dej�ZGdd�dej�ZGdd�dej�ZeZdS)a,GOption command line parser

Extends optparse to use the GOptionGroup, GOptionEntry and GOptionContext
objects. So it is possible to use the gtk, gnome_program and gstreamer command
line groups and contexts.

Use this interface instead of the raw wrappers of GOptionContext and
GOptionGroup in glib.
�N)�
OptParseError�OptionError�OptionValueError�BadOptionError�OptionConflictError�)�get_introspection_module�cCs|j�S)N)�encode)�s�r�/usr/lib64/python3.6/_option.py�<lambda>&sr)�_gi)�GError�GLibrrrrr�Option�OptionGroup�OptionParser�make_optionc@sPeZdZdZejjdZejjdddgZdej	Z
dd�Zd	d
�Zdd�Z
d
S)ra�Represents a command line option

    To use the extended possibilities of the GOption API Option
    (and make_option) are extended with new types and attributes.

    Types:
        filename   The supplied arguments are read as filename, GOption
                   parses this type in with the GLib filename encoding.

    :ivar optional_arg:
        This does not need a arguement, but it can be supplied.
    :ivar hidden:
        The help list does not show this option
    :ivar in_main:
        This option apears in the main group, this should only
        be used for backwards compatibility.

    Use Option.REMAINING as option name to get all positional arguments.

    .. NOTE::
        Every argument to an option is passed as utf-8 coded string, the only
        exception are options which use the 'filename' type, its arguments
        are passed as strings in the GLib filename encoding.

    For further help, see optparse.Option.
    �filename�hidden�in_main�optional_argz--cOsXtjj|f|�|�|js"td��t|j�t|j�kr>td��|jsTtd|jd��dS)Nz!%s at least one long option name.z;%s at least more long option names than short option names.z%s needs a help message.r)�optparser�__init__�
_long_opts�
ValueError�len�_short_opts�help)�self�args�kwargsrrr
reszOption.__init__cCsF|j|kr|jj|j�tjj||�t|j�t|j�krBtd��dS)NzCgoption.Option needs more long option names than short option names)	�	REMAININGr�appendrr�_set_opt_stringrrr)r!Zoptsrrr
r&qs

zOption._set_opt_stringccs�d}|jr|tjjO}|jr(|tjjO}|j�rD|jrP|tjjO}n|tjj	O}|j
dkrf|tjjO}x>t|j
|j�D],\}}|dd�t|d�||j|jfVqvWx<|j
t|j�d�D]$}|dd�td�||j|jfVq�WdS)Nrr�r�)rrZOptionFlagsZHIDDENrZIN_MAINZtakes_valuerZOPTIONAL_ARGZNO_ARG�typeZFILENAME�ziprr�_bytesr �metavarr)r!�flagsZ	long_nameZ
short_namerrr
�_to_goptionentriesys
(zOption._to_goptionentriesN)r)�__name__�
__module__�__qualname__�__doc__rrZTYPESZATTRSrZOPTION_REMAININGr$rr&r.rrrr
r>s
c@s<eZdZdZddd�Zdd�Zdd	�Zdd
d�Zdd
�ZdS)ra�A group of command line options.

    :param str name:
        The groups name, used to create the --help-{name} option
    :param str description:
        Shown as title of the groups help view
    :param str help_description:
        Shown as help to the --help-{name} option
    :param list option_list:
        The options used in this group, must be option.Option()
    :param dict defaults:
        A dicitionary of default values
    :param translation_domain:
           Sets the translation domain for gettext().

    .. NOTE::
        This OptionGroup does not exactly map the optparse.OptionGroup
        interface. There is no parser object to supply, but it is possible
        to set default values and option_lists. Also the default values and
        values are not shared with the OptionParser.

    To pass a OptionGroup into a function which expects a GOptionGroup (e.g.
    gnome_program_init() ). OptionGroup.get_option_group() can be used.

    For further help, see optparse.OptionGroup.
    �NcCsZtjj|td|�||_d|_||_|r.||_d|_||_	|rVx|D]}|j
|�qDWdS)N�error)rZOptionContainerrr�name�parser�help_description�defaults�values�translation_domainZ
add_option)r!r5�descriptionr7�option_listr8r:�optionrrr
r�s
zOptionGroup.__init__cCsg|_|j�dS)N)r<Z_create_option_mappings)r!rrr
�_create_option_list�szOptionGroup._create_option_listcsf��fdd�}tj�j�j�j|�}�jr6|j�j�g}x�jD]}|j|j	��qBW|j
|�|S)Ncs�|jd�r�j|}n
�j|}y|j||�j��WnJtk
r�tj�d}tt	|��}t
|_tj
j|_t	|�|_|�YnXdS)Nz--r)�
startswith�	_long_opt�
_short_opt�processr9r�sys�exc_infor�str�OPTION_CONTEXT_ERROR_QUARK�domainrr�	BAD_VALUE�code�message)�option_name�option_value�group�optr4Zgerror)r6r!rr
�callback�s



z.OptionGroup._to_goptiongroup.<locals>.callback)rrr5r;r7r:Zset_translation_domainr<�extendr.�add_entries)r!r6rOrMZentriesr=r)r6r!r
�_to_goptiongroup�s

zOptionGroup._to_goptiongroupcCs|j�|j|�S)z� Returns the corresponding GOptionGroup object.

        Can be used as parameter for gnome_program_init(), gtk_init().
        )�set_values_to_defaultsrR)r!r6rrr
�get_option_group�szOptionGroup.get_option_groupcCsVxB|jD]8}|jj|j�}t|t�r|j�}|j||�|j|j<qWtj	|j�|_
dS)N)r<r8�get�dest�
isinstance�_basestringZget_opt_stringZcheck_valuerZValuesr9)r!r=�defaultZopt_strrrr
rS�s
z"OptionGroup.set_values_to_defaults)r3NNN)N)	r/r0r1r2rr>rRrTrSrrrr
r�s

c@sJeZdZdZdd�Zdd�Zdd�Zdd	�Zd
d�Zdd
�Z	ddd�Z
dS)raHCommand line parser with GOption support.

    :param bool help_enabled:
        The --help, --help-all and --help-{group} options are enabled (default).
    :param bool ignore_unknown_options:
        Do not throw a exception when a option is not knwon, the option
        will be in the result list.

    .. NOTE::
        The OptionParser interface is not the exactly the same as the
        optparse.OptionParser interface. Especially the usage parameter
        is only used to show the metavar of the arguements.

    OptionParser.add_option_group() does not only accept OptionGroup instances
    but also glib.OptionGroup, which is returned by gtk_get_option_group().

    Only glib.option.OptionGroup and glib.option.Option instances should
    be passed as groups and options.

    For further help, see optparse.OptionParser.
    cOsLd|krt|d<|jdd�|_|jdd�|_tjj|f|�ddi|��dS)NZoption_class�help_enabledT�ignore_unknown_optionsFZadd_help_option)r�poprZr[rrr)r!r"r#rrr
r
s
zOptionParser.__init__cCs8|dkrd|_n$|jd�r.|td�d�|_n||_dS)Nr3z%prog)�usager?r)r!r]rrr
�	set_usages

zOptionParser.set_usagec
s��jr�jd�j}n�j}tj|�}|j�j�|j�j�x4�jD]*}t	|tj
�r^|}n
|j��}|j|�qHW��fdd�}tj
ddd|�}g}x�j
D]}	|j|	j��q�W|j|�|j|�|S)Nz - cs4|jd�r�j|}n
�j|}|j||���dS)Nz--)r?r@rArB)rKrLrMrN)r!r9rr
rO+s

z1OptionParser._to_goptioncontext.<locals>.callback)r;r]rZ
OptionContextZset_help_enabledrZZset_ignore_unknown_optionsr[�
option_groupsrWrrTZ	add_groupr<rPr.rQZset_main_group)
r!r9Zparameter_string�contextZoption_groupZg_grouprOZ
main_groupZmain_entriesr=r)r!r9r
�_to_goptioncontexts&



zOptionParser._to_goptioncontextcOs�t|dt�r,tjj|t|f|�|��dSt|�dkr�|r�t|dt�rv|djs`||d_|dj|k	rvtd��t|dt	j�r�|j
j|d�dStjj|f|�|�dS)Nrrz"invalid OptionGroup (wrong parser))rWrXrr�add_option_grouprrr6rrr_r%)r!r"r#rrr
rb;s

zOptionParser.add_option_groupcCs:|jdd�}x&|jD]}t|tj�r|j|j�qW|S)N)r<r_rWrrrP)r!�optionsrMrrr
�_get_all_optionsKs
zOptionParser._get_all_optionscCs4|j|�}|jtjdg|�dd�|dd�<dS)Nrr)ra�parserC�argv)r!ZlargsZrargsr9r`rrr
�
_process_argsRs
zOptionParser._process_argsNc	
Cs�|pg}ytjj|||�\}}Wn|tk
r�tj�d}|jtkrH�|jt	j
jkrbt|j
��n6|jt	j
jkr|t|j
��n|jt	j
jkr�t|j
��n�YnXx4|jD]*}x$|jjj�D]\}}|j||�q�Wq�W|dt|��}||fS)Nrr')rr�
parse_argsrrCrDrGrFrIrrrHrrJZUNKNOWN_OPTIONrZFAILEDrr_r9�__dict__�itemsZensure_valuer)	r!r"r9Zold_argsrcr4rM�key�valuerrr
rhZs(
zOptionParser.parse_args)NN)r/r0r1r2rr^rarbrdrgrhrrrr
r�s	 )r	r)r2rCrrrrrr�moduler�version_inforErXr+Z
basestringZgirZ	gi._errorrrZquark_to_stringZoption_error_quarkrF�__all__rrrrrrrr
�<module>s6

Ta

?>