File: //usr/lib/python2.7/site-packages/leapp/utils/clicmd.pyc
�
�S4bc @ s d d l Z d d l Z d d l Z d d l m Z m Z m Z d d l Z d d l m Z m
Z
m Z d e f d � � YZ d e f d � � YZ
d e f d � � YZ d
e f d � � YZ d d d d
� Z d � Z d d d � Z d � Z d � Z d S( i����N( t ArgumentParsert _SubParsersActiont RawDescriptionHelpFormatter( t CommandDefinitionErrort
UsageErrort CommandErrort _LeappArgumentParserc B s e Z d � Z d � Z RS( c C s t t | � j d t j � d S( Nt file( t superR t
print_helpt syst stderr( t self( ( s6 /usr/lib/python2.7/site-packages/leapp/utils/clicmd.pyR
s c C s/ | j � t j j d | � t j d � d S( Ns
error: %s
i ( R R
R t writet exit( R t message( ( s6 /usr/lib/python2.7/site-packages/leapp/utils/clicmd.pyt error s
( t __name__t
__module__R R ( ( ( s6 /usr/lib/python2.7/site-packages/leapp/utils/clicmd.pyR s t _LeappHelpFormatterc B s e Z d Z d � Z RS( s9
Capitalizes section headings in the help output
c C s t t | � j | j � � S( N( R R t
start_sectiont
capitalize( R t heading( ( s6 /usr/lib/python2.7/site-packages/leapp/utils/clicmd.pyR s ( R R t __doc__R ( ( ( s6 /usr/lib/python2.7/site-packages/leapp/utils/clicmd.pyR s t _SubParserActionOverridec B s e Z d Z d d � Z RS( s�
This class implements a workaround for an issue fixed in 2.7.9.
See https://bugs.python.org/issue9351
TL;DR: Before, 2.7.9 argparse._SubParserAction did not propagate sub parser default values
to the global namespace when they were already defined .
This implementation is a workaround to override those values additionally.
The additional code will not be executed if python 2.7.9 or higher is found.
c
C s� t t | � j | | | | � t j d k r2 d S| d } | d } | j | } | j | d � \ } } x0 t | � j � D] \ } } t
| | | � q~ Wd S( Ni i i i i ( i i i ( R R t __call__R
t version_infot _name_parser_mapt parse_known_argst Nonet varst itemst setattr(
R t parsert namespacet valuest
option_stringt parser_namet arg_stringst
sub_namespacet keyt value( ( s6 /usr/lib/python2.7/site-packages/leapp/utils/clicmd.pyR ) s
N( R R R R R ( ( ( s6 /usr/lib/python2.7/site-packages/leapp/utils/clicmd.pyR s
t Commandc B s� e Z d Z d d d d � Z d � Z d � Z d � Z d d d � Z d � Z d � Z
d � Z d d e e e
d d d d d d
�
Z d d d d � Z RS(
sW
Command implements a convenient command-based argument parsing the framework.
t c C sR | | _ | | _ | p | | _ i | _ g | _ | | _ d | _ d | _ d S( si
:param name: Name of the sub command
:type name: str
:param target: Function called when the command is invoked
:type target: Callable
:param help: Shows a help message
:type help: str
:param description: Extended description of the command (the default is `help`)
:type description: str
N( t namet helpt descriptiont
_sub_commandst _optionst targetR t parentR! ( R R, R1 R- R. ( ( s6 /usr/lib/python2.7/site-packages/leapp/utils/clicmd.pyt __init__9 s c C s t d t j j t j d � d t � } | j d d t � | j d d d d | �| j
d d � | j r� | j
d d
d d � } t | _ n | } | j | d
| �| j � \ } } | r� | j j � d } | j | j j | � n | j | � d S( s�
Entry point to the command execution. It is used for the main entry function of an application.
:param version: Version string to display for --version calls
:type version: str
:return: None
t progi t formatter_classt actiont parserss --versiont versiont funct titles Required argumentst metavart commandR! i����N( R t ost patht basenameR
t argvR t registerR t add_argumentt set_defaultsR R/ t add_subparserst Truet requiredt apply_parserR R4 t splitR! R R9 ( R R8 R! t st argst leftovert cmdname( ( s6 /usr/lib/python2.7/site-packages/leapp/utils/clicmd.pyt executeM s ( c C s- g | j D] } | d j d � r
| ^ q
S( sK
:return: Returns all options that are marked as 'inherit'
i t inherit( R0 t get( R t option( ( s6 /usr/lib/python2.7/site-packages/leapp/utils/clicmd.pyt get_inheritable_optionsl s c C s� y9 | j r | j j | � n | j r8 | j | � n Wn� t k
r� } | j j � | j j d d d d j d | j � � n; t k
r� } | j j d d d d j d | j � � n Xd S( sb
The actual call is dispatched through this method. It ensures that the parent is also called
to allow generic handling of some flags (especially inherited flags).
:param args: Arguments object that is a result of the `argparse` commandline parser
:type args: :py:class:`argparse.Namespace`
:return: None
t statusi R s
UsageError: {message}
s
Error: {message}
N(
R2 t calledR1 R R! R R t formatR R ( R RJ t e( ( s6 /usr/lib/python2.7/site-packages/leapp/utils/clicmd.pyRS r s
+c C sy | j | k r d S| r% | | _ n1 | j | j d | j d t d d | j �| _ | j j d | j j d | j � | j j
d d t � g } | j } x# | r� | | j � 7} | j } q� Wx1 | j
| D]"