ó
mÜJ]c           @` s   d  Z  d d l m Z m Z m Z m Z d d l Z e j e ƒ Z	 d d l
 m Z m Z d d l m Z d	 Z d e e ƒ f d „  ƒ  YZ d S(
   uX    Provides a base class for defining subcommands of the Bokeh command
line application.

i    (   t   absolute_importt   divisiont   print_functiont   unicode_literalsN(   t   ABCMetat   abstractmethod(   t   with_metaclassu
   Subcommandt
   Subcommandc           B` s&   e  Z d  Z d „  Z e d „  ƒ Z RS(   u   Abstract base class for subcommands

    Subclasses should implement an ``invoke(self, args)`` method that accepts
    a set of argparse processed arguments as input.

    Subclasses should also define the following class attributes:

    * ``name`` a name for this subcommand

    * ``help`` a help string for argparse to use for this subcommand

    * ``args`` the parameters to pass to ``parser.add_argument``

    The format of the ``args`` should be a sequence of tuples of the form:

    .. code-block:: python

        ('argname', dict(
            metavar='ARGNAME',
            nargs='+',
        ))

    Example:

        A simple subcommand "foo" might look like this:

        .. code-block:: python

            class Foo(Subcommand):

                name = "foo"
                help = "performs the Foo action"
                args = (
                    ('--yell', dict(
                        action='store_true',
                        help="Make it loud",
                    )),
                )

                def invoke(self, args):
                    if args.yell:
                        print("FOO!")
                    else:
                        print("foo")

        Then executing ``bokeh foo --yell`` would print ``FOO!`` at the console.

    c         C` sl   | |  _  t |  d d ƒ } xJ | D]B } | d } t | t ƒ sM | f } n  |  j  j | | d Ž  q" Wd S(   ut   Initialize the subcommand with its parser

        Args:
            parser (Parser) : an Argparse ``Parser`` instance to configure
                with the args for this subcommand.

        This method will automatically add all the arguments described in
        ``self.args``. Subclasses can perform any additional customizations
        on ``self.parser``.

        u   argsi    i   N(    (   t   parsert   getattrt
   isinstancet   tuplet   add_argument(   t   selfR   t   argst   argt   flags(    (    s7   lib/python2.7/site-packages/bokeh/command/subcommand.pyt   __init__b   s    	
c         C` s   t  d ƒ ‚ d S(   u   Takes over main program flow to perform the subcommand.

        *This method must be implemented by subclasses.*

        Args:
            args (seq) : command line arguments for the subcommand to parse

        Raises:
            NotImplementedError

        u   implement invoke()N(   t   NotImplementedError(   R   R   (    (    s7   lib/python2.7/site-packages/bokeh/command/subcommand.pyt   invokev   s    (   t   __name__t
   __module__t   __doc__R   R   R   (    (    (    s7   lib/python2.7/site-packages/bokeh/command/subcommand.pyR   0   s   0	(   u
   Subcommand(   R   t
   __future__R    R   R   R   t   loggingt	   getLoggerR   t   logt   abcR   R   t   bokeh.util.futureR   t   __all__R   (    (    (    s7   lib/python2.7/site-packages/bokeh/command/subcommand.pyt   <module>
   s   "