ó &œ‡Uc@sÒdZddlZddlZddlmZmZmZmZmZddlZej dZ ddddd d d d gZ d ej fd„ƒYZ d ej fd„ƒYZ d ejfd„ƒYZe ZdS(s,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. iÿÿÿÿN(t OptParseErrort OptionErrortOptionValueErrortBadOptionErrortOptionConflictErrors glib._glibRRRRtOptionConflictErrorOptiont OptionGroupt OptionParsert make_optiontOptioncBs_eZdZejjd ZejjdddgZdejZ d„Z d„Z d„Z RS( s¼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. Attributes: optional_arg This does not need a arguement, but it can be supplied. hidden The help list does not show this option 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. tfilenamethiddentin_maint optional_args--cOstjj|||Ž|js.tdƒ‚nt|jƒt|jƒkr[tdƒ‚n|js}td|jdƒ‚ndS(Ns!%s at least one long option name.s;%s at least more long option names than short option names.s%s needs a help message.i(toptparseR t__init__t _long_optst ValueErrortlent _short_optsthelp(tselftargstkwargs((s9/usr/lib/python2.7/vendor-packages/gtk-2.0/glib/option.pyRXs   cCsi|j|kr%|jj|jƒntjj||ƒt|jƒt|jƒkretdƒ‚ndS(NsCgoption.Option needs more long option names than short option names( t REMAININGRtappendRR t_set_opt_stringRRR(Rtopts((s9/usr/lib/python2.7/vendor-packages/gtk-2.0/glib/option.pyRes ccs!d}|jr$|jtjO_n|jrB|jtjO_n|jƒrj|jrw|tjO}qwn |tj O}|j dkr–|tj O}nxEt |j |jƒD].\}}|d|d||j|jfVq¬Wx<|j t|jƒD]$}|dd||j|jfVqõWdS(NiR iit(R tflagst_glibtOPTION_FLAG_HIDDENR tOPTION_FLAG_IN_MAINt takes_valueR tOPTION_FLAG_OPTIONAL_ARGtOPTION_FLAG_NO_ARGttypetOPTION_FLAG_FILENAMEtzipRRRtmetavarR(RRt long_namet short_name((s9/usr/lib/python2.7/vendor-packages/gtk-2.0/glib/option.pyt_to_goptionentriesms     "&(sfilename( t__name__t __module__t__doc__RR tTYPEStATTRSRtOPTION_REMAININGRRRR*(((s9/usr/lib/python2.7/vendor-packages/gtk-2.0/glib/option.pyR 4s     cBsJeZdZddddd„Zd„Zd„Zdd„Zd„ZRS(s×A group of command line options. Arguements: name: The groups name, used to create the --help-{name} option description: Shown as title of the groups help view help_description: Shown as help to the --help-{name} option option_list: The options used in this group, must be option.Option() defaults: A dicitionary of default values 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. tcCsƒtjj|td|ƒ||_d|_||_|rF||_nd|_ ||_ |rx|D]}|j |ƒqeWndS(Nterror( RtOptionContainerRR tnametNonetparserthelp_descriptiontdefaultstvaluesttranslation_domaint add_option(RR4t descriptionR7t option_listR8R:toption((s9/usr/lib/python2.7/vendor-packages/gtk-2.0/glib/option.pyR›s       cCsg|_|jƒdS(N(R=t_create_option_mappings(R((s9/usr/lib/python2.7/vendor-packages/gtk-2.0/glib/option.pyt_create_option_list­s cs‡‡fd†}tjˆjˆjˆj|ƒ}ˆjrO|jˆjƒng}x$ˆjD]}|j|j ƒƒq_W|j |ƒ|S(Ncs³|jdƒrˆj|}n ˆj|}y|j||ˆjˆƒWnctk r®tjƒd}tj t |ƒƒ}tj |_ tj |_t |ƒ|_|‚nXdS(Ns--i(t startswitht _long_optt _short_opttprocessR9Rtsystexc_infoRtGErrortstrt OPTION_ERRORtdomaintOPTION_ERROR_BAD_VALUEtcodetmessage(t option_namet option_valuetgrouptoptR2tgerror(R6R(s9/usr/lib/python2.7/vendor-packages/gtk-2.0/glib/option.pytcallback²s    ( RRR4R<R7R:tset_translation_domainR=textendR*t add_entries(RR6RSRPtentriesR>((R6Rs9/usr/lib/python2.7/vendor-packages/gtk-2.0/glib/option.pyt_to_goptiongroup±s  cCs|jƒ|j|ƒS(s€ Returns the corresponding GOptionGroup object. Can be used as parameter for gnome_program_init(), gtk_init(). (tset_values_to_defaultsRX(RR6((s9/usr/lib/python2.7/vendor-packages/gtk-2.0/glib/option.pytget_option_groupÎs cCs|x`|jD]U}|jj|jƒ}t|tƒr |jƒ}|j||ƒ|j|jtdefaulttopt_str((s9/usr/lib/python2.7/vendor-packages/gtk-2.0/glib/option.pyRYÖs N( R+R,R-R5RR@RXRZRY(((s9/usr/lib/python2.7/vendor-packages/gtk-2.0/glib/option.pyR…s    cBsSeZdZd„Zd„Zd„Zd„Zd„Zd„Zddd„Z RS( sqCommand line parser with GOption support. 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. Attribues: help_enabled: The --help, --help-all and --help-{group} options are enabled (default). ignore_unknown_options: Do not throw a exception when a option is not knwon, the option will be in the result list. 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. cOscd|krt|d((RR9s9/usr/lib/python2.7/vendor-packages/gtk-2.0/glib/option.pyt_to_goptioncontexts&     cOsït|dtƒr6tjj|t|||ŽƒdSt|ƒdkrÕ| rÕt|dtƒr¤|djs||d_n|dj|k r¤tdƒ‚q¤nt|dt jƒrÕ|j j |dƒdSntjj|||ŽdS(Niis"invalid OptionGroup (wrong parser)( R]R^RRtadd_option_groupRRR6RRRpR(RRR((s9/usr/lib/python2.7/vendor-packages/gtk-2.0/glib/option.pyRz&s  cCsG|j}x6|jD]+}t|tjƒr|j|jƒqqW|S(N(R=RpR]RRRU(RtoptionsRP((s9/usr/lib/python2.7/vendor-packages/gtk-2.0/glib/option.pyt_get_all_options6s  cCs5|j|ƒ}|jtjdg|ƒd|(dS(Nii(RytparseREtargv(RtlargstrargsR9Rt((s9/usr/lib/python2.7/vendor-packages/gtk-2.0/glib/option.pyt _process_args=sc CsA|p g}y"tjj|||ƒ\}}Wn«tjk rÛtjƒd}|jtjkri‚n|j tj krt |j ƒ‚qÜ|j tj kr±t|j ƒ‚qÜ|j tjkrÕt|j ƒ‚qÜ‚nXxD|jD]9}x0|jjjƒD]\}}|j||ƒqÿWqæW|dt|ƒ !}||fS(Nii(RRt parse_argsRRGRERFRJRIRLRKRRMtOPTION_ERROR_UNKNOWN_OPTIONRtOPTION_ERROR_FAILEDRRpR9t__dict__titemst ensure_valueR( RRR9told_argsR{R2RPtkeytvalue((s9/usr/lib/python2.7/vendor-packages/gtk-2.0/glib/option.pyR‚Es(  N( R+R,R-RRlRyRzR|RR5R‚(((s9/usr/lib/python2.7/vendor-packages/gtk-2.0/glib/option.pyRßs    (R-RERRRRRRtglibtmodulesRt__all__R RRR(((s9/usr/lib/python2.7/vendor-packages/gtk-2.0/glib/option.pyts"  (   QZ