HEX
Server: Apache
System: Linux scp1.abinfocom.com 5.4.0-216-generic #236-Ubuntu SMP Fri Apr 11 19:53:21 UTC 2025 x86_64
User: confeduphaar (1010)
PHP: 8.1.33
Disabled: exec,passthru,shell_exec,system
Upload Files
File: //lib/python3/dist-packages/gi/__pycache__/_option.cpython-38.pyc
U

��	^�3�	@s�dZddlZddlZddlmZmZmZmZmZddlm	Z	ddl
mZddlm
Z
ddlmZe	d	�Ze�e���Zd
ddd
dddddg	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)�string_types)�_gi)�GError�GLibrrrrr�Option�OptionGroup�OptionParser�make_optionc@sPeZdZdZejjdZejjdddgZdej	Z
dd�Zd	d
�Zdd�Z
d
S)r
a�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_arg�--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�kwargs�r!�,/usr/lib/python3/dist-packages/gi/_option.pyr_s�zOption.__init__cCsF|j|kr|j�|j�tj�||�t|j�t|j�krBtd��dS)NzCgoption.Option needs more long option names than short option names)	�	REMAININGr�appendrr
�_set_opt_stringrrr)rZoptsr!r!r"r%ks

zOption._set_opt_stringccs�d}|jr|tjjO}|jr(|tjjO}|��rD|jrP|tjjO}n|tjj	O}|j
dkrf|tjjO}t|j
|j�D]@\}}|d}t|t�s�|�d�}|dd�|||j|jfVqt|j
t|j�d�D] }|dd�d||j|jfVq�dS)Nrrrzutf-8��)rrZOptionFlagsZHIDDENrZIN_MAINZtakes_valuerZOPTIONAL_ARGZNO_ARG�typeZFILENAME�ziprr�
isinstance�bytes�encoder�metavarr)r�flagsZ	long_nameZ
short_nameZshort_bytesr!r!r"�_to_goptionentriesss$


zOption._to_goptionentriesN)�__name__�
__module__�__qualname__�__doc__rr
ZTYPESZATTRSrZOPTION_REMAININGr#rr%r/r!r!r!r"r
8s�
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.
    �NcCsVtj�|td|�||_d|_||_|r.||_d|_||_	|rR|D]}|�
|�qBdS)N�error)rZOptionContainerrr
�name�parser�help_description�defaults�values�translation_domainZ
add_option)rr6�descriptionr8�option_listr9r;�optionr!r!r"r�szOptionGroup.__init__cCsg|_|��dS�N)r=Z_create_option_mappings)rr!r!r"�_create_option_list�szOptionGroup._create_option_listcsb��fdd�}t��j�j�j|�}�jr6|��j�g}�jD]}|�|�	��q@|�
|�|S)Ncs�|�d�r�j|}n
�j|}z|�||�j��WnJtk
r�t��d}tt	|��}t
|_tj
j|_t	|�|_|�YnXdS)Nrr)�
startswith�	_long_opt�
_short_opt�processr:r�sys�exc_infor�str�OPTION_CONTEXT_ERROR_QUARK�domainrr�	BAD_VALUE�code�message)�option_name�option_value�group�optr5Zgerror�r7rr!r"�callback�s



z.OptionGroup._to_goptiongroup.<locals>.callback)r
rr6r<r8r;Zset_translation_domainr=�extendr/�add_entries)rr7rRrO�entriesr>r!rQr"�_to_goptiongroup�s�

zOptionGroup._to_goptiongroupcCs|��|�|�S)z� Returns the corresponding GOptionGroup object.

        Can be used as parameter for gnome_program_init(), gtk_init().
        )�set_values_to_defaultsrV)rr7r!r!r"�get_option_group�szOptionGroup.get_option_groupcCsR|jD]8}|j�|j�}t|t�r|��}|�||�|j|j<qt�	|j�|_
dSr?)r=r9�get�destr*r	Zget_opt_stringZcheck_valuerZValuesr:)rr>�defaultZopt_strr!r!r"rW�s

�z"OptionGroup.set_values_to_defaults)r4NNN)N)	r0r1r2r3rr@rVrXrWr!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<|�dd�|_|�dd�|_tjj|f|�ddi|��dS)NZoption_class�help_enabledT�ignore_unknown_optionsFZadd_help_option)r
�popr\r]rrrrr!r!r"rs�
��zOptionParser.__init__cCs8|dkrd|_n$|�d�r.|td�d�|_n||_dS)Nr4z%prog)�usagerAr)rr_r!r!r"�	set_usages

zOptionParser.set_usagec
s��jr�jd�j}n�j}t�|�}|��j�|��j��jD]*}t	|tj
�r\|}n
|���}|�|�qF��fdd�}t�
ddd|�}g}�j
D]}	|�|	���q�|�|�|�|�|S)Nz - cs4|�d�r�j|}n
�j|}|�||���dS)Nr)rArBrCrD)rMrNrOrP�rr:r!r"rR(s

z1OptionParser._to_goptioncontext.<locals>.callback)r<r_r
Z
OptionContextZset_help_enabledr\Zset_ignore_unknown_optionsr]�
option_groupsr*rrXZ	add_groupr=rSr/rTZset_main_group)
rr:Zparameter_string�contextZoption_groupZg_grouprRZ
main_groupZmain_entriesr>r!rar"�_to_goptioncontexts&





zOptionParser._to_goptioncontextcOs�t|dt�r,tj�|t|f|�|��dSt|�dkr�|s�t|dt�rt|djs^||d_|dj|k	rttd��t|dt	j�r�|j
�|d�dStjj|f|�|�dS)Nrrz"invalid OptionGroup (wrong parser))r*r	rr�add_option_grouprrr7rr
rbr$rr!r!r"re8s�

zOptionParser.add_option_groupcCs6|jdd�}|jD]}t|tj�r|�|j�q|Sr?)r=rbr*rrrS)r�optionsrOr!r!r"�_get_all_optionsHs

zOptionParser._get_all_optionscCs4|�|�}|�tjdg|�dd�|dd�<dS)Nrr)rd�parserE�argv)rZlargsZrargsr:rcr!r!r"�
_process_argsOs
zOptionParser._process_argsNcCs�ztj�|||�\}}Wn|tk
r�t��d}|jtkr@�|jt	j
jkrZt|j
��n6|jt	j
jkrtt|j
��n|jt	j
jkr�t|j
��n�YnX|jD]&}|jj��D]\}}|�||�q�q�||fS)Nr)rr�
parse_argsrrErFrIrHrKrrrJrrLZUNKNOWN_OPTIONrZFAILEDrrbr:�__dict__�itemsZensure_value)rrr:rfr5rO�key�valuer!r!r"rkWs*�

zOptionParser.parse_args)NN)r0r1r2r3rr`rdrergrjrkr!r!r!r"r�s	 )r3rErrrrrr�modulerZ_compatr	Zgir
Z	gi._errorrrZquark_to_stringZoption_error_quarkrH�__all__r
rrrr!r!r!r"�<module>s.
�
Wa