Example #1
0
    def __init__(self, **kwargs):
        """Follow normal initialization and add BACpypes arguments."""
        if _debug: ArgumentParser._debug("__init__")

        if not _argparse_success:
            raise ImportError("No module named argparse, install via pip or easy_install: https://pypi.python.org/pypi/argparse\n")

        _ArgumentParser.__init__(self, **kwargs)

        # add a way to get a list of the debugging hooks
        self.add_argument("--buggers",
            help="list the debugging logger names",
            action="store_true",
            )

        # add a way to attach debuggers
        self.add_argument('--debug', nargs='*',
            help="add console log handler to each debugging logger",
            )

        # add a way to turn on color debugging
        self.add_argument("--color",
            help="turn on color debugging",
            action="store_true",
            )
Example #2
0
    def __init__(self, *args, **kwargs):
        ArgumentParser.__init__(self, *args, **kwargs)

        group = self.add_argument_group("{} arguments".format(self.name))
        for cli, kwargs in self.arguments:
            group.add_argument(*cli, **kwargs)

        for name in self.common_groups:
            group = self.add_argument_group("{} arguments".format(name))
            arguments = COMMON_ARGUMENT_GROUPS[name]

            # Preset arguments are all mutually exclusive.
            if name == 'preset':
                group = group.add_mutually_exclusive_group()

            for cli, kwargs in arguments:
                group.add_argument(*cli, **kwargs)

        group = self.add_argument_group("task configuration arguments")
        self.task_configs = {
            c: all_task_configs[c]()
            for c in self.task_configs
        }
        for cfg in self.task_configs.values():
            cfg.add_arguments(group)
Example #3
0
 def __init__(self):
     ArgumentParser.__init__(
         self, prog="see", description="Mark episodes as SEEN", epilog="example: see lost.s01* lost.s02*"
     )
     self.add_argument(
         "filters", metavar="EPISODE", nargs="+", default=[""], help="episode name or filter, ex: lost.s01e0*"
     )
Example #4
0
 def __init__(self, args):
     ArgumentParser.__init__(self)
     self.add_argument('-i', '--ipc', dest='ipc', default=False)
     self.add_argument('-l', '--links', dest='links')
     self.add_argument('-c', '--cookie', dest='cookie')
     self.add_argument('-p', '--path', dest='path')
     self.arguments = self.parse_args(args)
Example #5
0
	def __init__(self, description=None):
		ArgumentParser.__init__(self, description=description)

		self.add_argument('-S', '--save',
                                  action='store_true',
                                  help='salva as configurações passadas pela linha de comando no arquivo de configuração')
		self.add_argument('-V', '--verbose',
                                  action='store_true',
                                  help='exibe informações mais detalhadas')

		#### BEGIN XGROUP
		xgroup = self.add_mutually_exclusive_group()
		xgroup.add_argument('-l', '--local',
                                    action='store_true',
                                    default=True,
                                    help='busca os arquivos de atividades em uma instalação local (default)')
		xgroup.add_argument('-r', '--remote',
                                    action='store_false',
                                    dest='local',
                                    help='busca os arquivos de atividades em um servidor remoto')
		#### END XGROUP

		self.add_argument('-s', '--server',
                                  default='localhost',
                                  help='define o endereço do servidor remoto como SERVER (útil quando empregado em conjunto com a opção -r)')

		self.add_argument('-b', '--browser',
                                  choices=('firefox', 'chromium-browser', 'google-chrome', 'opera', 'epiphany'),
                                  help='escolhe o navegador a ser utilizado')

		# Hacks argparse's non-localizable messages
		self._action_groups[1].title = 'opções genéricas'
		self._actions[0].help = 'exibe esta mensagem de ajuda e sai'
Example #6
0
 def __init__(self, args):
     ArgumentParser.__init__(self)
     self.add_argument("-i", "--ipc", dest="ipc", default=False)
     self.add_argument("-l", "--links", dest="links")
     self.add_argument("-c", "--cookie", dest="cookie")
     self.add_argument("-p", "--path", dest="path")
     self.arguments = self.parse_args(args)
Example #7
0
 def __init__(self, *args, **kwargs):
     '''
     Typical arguments
     \param description a text string saying what the program does. Optional.
     \param suite a function that returns a unittest test suite. Optional.
     '''
     self.tests = None
     if 'suite' in kwargs:
         self.tests = kwargs['suite']
         del kwargs['suite']
     ArgumentParser.__init__(self, *args, **kwargs)
     self.add_argument('-v',
                       '--verbose',
                       dest='verbose',
                       action='store_true',
                       default=False,
                       help='print debug messages')
     self.add_argument('-q',
                       '--quiet',
                       dest='quiet',
                       action='store_true',
                       default=False,
                       help='print only exceptions')
     self._functions = list()
     if self.tests:
         self.add_function('test', 'run unit tests in this module')
Example #8
0
 def __init__(self):
     ArgumentParser.__init__(self)
     self.add_argument(
         '-i',
         '--i_fna',
         metavar='INPUT_FNA_FOLDER',
         type=str,
         default=False,
         help='Folder containing the .fna genome sequence files')
     self.add_argument(
         '-c',
         '--clade',
         metavar='CLADE_NAME',
         type=str,
         default=False,
         help=
         'Name of the species pangenome database, for example: -c ecoli17')
     self.add_argument('-o',
                       '--output',
                       metavar='OUTPUT_FOLDER',
                       type=str,
                       default='database',
                       help='Result folder for all database files')
     self.add_argument('--verbose',
                       action='store_true',
                       help='Show progress information')
Example #9
0
    def __init__(self, version=None, usecert=True, *args, **kwargs):
        """ Construct a basic parser

        version  -- a version number if desired
        usercert -- if Truem add '--certfile' argument
        """

        ArgumentParser.__init__(self, *args, **kwargs)

        if usecert:
            self.add_argument('--certfile', type=str,
                              help="location of your CADC security certificate "
                              + "file (default=$HOME/.ssl/cadcproxy.pem, " + \
                              "otherwise uses $HOME/.netrc for name/password)",
                          default=os.path.join(os.getenv("HOME", "."),
                                                 ".ssl/cadcproxy.pem"))
        self.add_argument('--anonymous', action="store_true", default=False,
                          help='Force anonymous connection')
        self.add_argument('--host', help="Base hostname for services"
                          + "(default=www.canfar.phys.uvic.ca",
                          default='www.canfar.phys.uvic.ca')
        self.add_argument('--verbose', action="store_true", default=False,
                          help='verbose messages')
        self.add_argument('--debug', action="store_true", default=False,
                          help='debug messages')
        self.add_argument('--quiet', action="store_true", default=False,
                          help='run quietly')

        if version is not None:
            self.add_argument('--version', action='version',
                              version=version)
Example #10
0
    def __init__(self,
                 definition_document=None,
                 prog=None,
                 usage=None,
                 description=None,
                 epilog=None,
                 version=None,
                 parents=[],
                 formatter_class=DargeHelpFormatter,
                 prefix_chars='-',
                 fromfile_prefix_chars=None,
                 argument_default=None,
                 conflict_handler='error',
                 add_help=True,
                 parent_dargeparser=None):
        ArgumentParser.__init__(
            self,
            prog=prog,
            usage=usage,
            description=description,
            epilog=epilog,
            version=version,
            parents=parents,
            formatter_class=formatter_class,
            prefix_chars=prefix_chars,
            fromfile_prefix_chars=fromfile_prefix_chars,
            argument_default=argument_default,
            conflict_handler=conflict_handler,
            add_help=add_help)

        if definition_document is None:
            raise Exception("definition_document cannot be None")
        self.__definition_document__ = definition_document
        self.parent_dargeparser = parent_dargeparser
        self.current_parsing_child = None
    def __init__(self, description, epilog=''):
        ArgArgumentParser.__init__(self,
                                   description=description,
                                   epilog=epilog)

        self.add_argument(
            '--filename',
            help=
            'file to read openstack credentials from. If not set it take the environment variables'
        )
        self.add_argument('-v',
                          '--verbose',
                          action='count',
                          default=0,
                          help='increase output verbosity (use up to 3 times)'
                          '(not everywhere implemented)')
        self.add_argument(
            '--timeout',
            type=int,
            default=10,
            help=
            'amount of seconds until execution stops with unknown state (default 10 seconds)'
        )
        self.add_argument(
            '--insecure',
            default=False,
            action='store_true',
            help="Explicitly allow client to perform \"insecure\" "
            "SSL (https) requests. The server's certificate will "
            "not be verified against any certificate authorities. "
            "This option should be used with caution.")
        self.add_argument(
            '--cacert',
            help="Specify a CA bundle file to use in verifying a TLS"
            "(https) server certificate.")
Example #12
0
    def __init__(self):

        ArgumentParser.__init__(self)

        self.add_argument("--algo", help="Algo to use", default="ga")
        self.add_argument("--pop_size",
                          help="Population size",
                          type=int,
                          default=15)
        self.add_argument("--elite_pop",
                          help="Elite population size",
                          type=int,
                          default=3)
        self.add_argument("--nb_joints", help="Nb joints", type=int, default=4)
        self.add_argument("--joint_length",
                          help="Joint length",
                          type=float,
                          default=0.15)
        self.add_argument("--nb_obstacles",
                          help="Nb obstacles",
                          type=int,
                          default=0)
        self.add_argument("--max_steps",
                          help="Max steps",
                          type=int,
                          default=250)
        self.add_argument("--mode", help="Run mode", default="show")
        self.add_argument("--nb_eval",
                          help="Nb evaluations in eval mode",
                          type=int,
                          default=1000)
Example #13
0
    def __init__(self, **kwargs):
        # Do this early, so even option processing stuff is caught
        if '--bugreport' in sys.argv:
            self._debug_tb_callback()

        ArgParser.__init__(self, **kwargs)

        self.add_argument('-V', '--version', action=VersionAction, version=flexget.__version__,
                          help='Print FlexGet version and exit.')
        # This option is already handled above.
        self.add_argument('--bugreport', action='store_true', dest='debug_tb',
                          help='Use this option to create a detailed bug report, '
                               'note that the output might contain PRIVATE data, so edit that out')
        self.add_argument('--logfile', default='flexget.log',
                          help='Specify a custom logfile name/location. '
                               'Default is flexget.log in the config directory.')
        self.add_argument('--debug', action='store_true', dest='debug',
                          help=SUPPRESS)
        self.add_argument('--debug-trace', action='store_true', dest='debug_trace',
                          help=SUPPRESS)
        self.add_argument('--loglevel', default='verbose',
                          choices=['none', 'critical', 'error', 'warning', 'info', 'verbose', 'debug', 'trace'],
                          help=SUPPRESS)
        self.add_argument('--debug-sql', action='store_true', default=False,
                          help=SUPPRESS)
        self.add_argument('-c', dest='config', default='config.yml',
                          help='Specify configuration file. Default is config.yml')
        self.add_argument('--experimental', action='store_true', default=False,
                          help=SUPPRESS)
        self.add_argument('--del-db', action='store_true', dest='del_db', default=False,
                          help=SUPPRESS)
        self.add_argument('--profile', action='store_true', default=False, help=SUPPRESS)
Example #14
0
    def __init__(self, **kwargs):
        """
        :param nested_namespace_name: When used as a subparser, options from this parser will be stored nested under
            this attribute name in the root parser's namespace
        """
        # Do this early, so even option processing stuff is caught
        if '--bugreport' in unicode_argv():
            self._debug_tb_callback()

        self.subparsers = None
        self.raise_errors = None
        add_help = kwargs.pop('add_help', True)
        kwargs['add_help'] = False
        ArgParser.__init__(self, **kwargs)
        if add_help:
            self.add_argument(
                '--help',
                '-h',
                action=HelpAction,
                dest=SUPPRESS,
                default=SUPPRESS,
                nargs=0,
                help='Show this help message and exit',
            )
        # Overwrite _SubparserAction with our custom one
        self.register('action', 'parsers', NestedSubparserAction)

        self.post_defaults = {}
        if kwargs.get('parents'):
            for parent in kwargs['parents']:
                if hasattr(parent, 'post_defaults'):
                    self.set_post_defaults(**parent.post_defaults)
Example #15
0
    def __init__(self,
                 prog_version,
                 prog_version_date,
                 prog_description,
                 copyright_year,
                 copyright_authors,
                 use_config_parser_name=""):

        self.__version = "%(prog)s v" + prog_version + " from " + \
            prog_version_date

        # format copyright authors:
        # indent from second author
        copyright_authors = copyright_authors.splitlines()
        for i in range(len(copyright_authors)):
            copyright_authors[i] = "            " + copyright_authors[i]
        copyright_authors = "\n".join(map(unicode, copyright_authors))

        epilog = ":copyright: (c) " + copyright_year + " by \n" + \
        copyright_authors + \
        "\n:license: GPL v2 or any later version\n" + \
        ":bugreports: https://github.com/novoid/Memacs\n" + \
        ":version: " + prog_version + " from " + prog_version_date + "\n"

        self.__use_config_parser_name = use_config_parser_name

        ArgumentParser.__init__(self,
                                description=prog_description,
                                add_help=True,
                                epilog=epilog,
                                formatter_class=RawDescriptionHelpFormatter)
        self.__add_arguments()
    def __init__(self, description, epilog=""):
        ArgArgumentParser.__init__(self, description=description, epilog=epilog)

        self.add_argument(
            "--filename", help="file to read openstack credentials from. If not set it take the environemnt variables"
        )
        self.add_argument(
            "-v",
            "--verbose",
            action="count",
            default=0,
            help="increase output verbosity (use up to 3 times)" "(not everywhere implemented)",
        )
        self.add_argument(
            "--timeout",
            type=int,
            default=20,
            help="amount of seconds until execution stops with unknow state (default 10 seconds)",
        )
        self.add_argument(
            "--insecure",
            default=False,
            action="store_true",
            help='Explicitly allow novaclient to perform "insecure" '
            "SSL (https) requests. The server's certificate will "
            "not be verified against any certificate authorities. "
            "This option should be used with caution.",
        )
        self.add_argument(
            "--cacert", help="Specify a CA bundle file to use in verifying a TLS" "(https) server certificate."
        )
Example #17
0
 def __init__(self, apphome, desc, appname):
     self.apphome = apphome
     self.appname = appname
     ArgumentParser.__init__(self, description=desc)
     ArgumentParser.add_argument(self,
                                 '--api-proto',
                                 help="API protocol",
                                 choices=PROTOCOLS,
                                 default=DEFAULT_PROTO)
     ArgumentParser.add_argument(
         self,
         '--api-ipcpath',
         help="Path to directory of IPC files (only for IPC protocol)",
         default=DEFAULT_IPCPATH)
     ArgumentParser.add_argument(
         self,
         '--api-host',
         help="Host or IP address of the RPC server (only for TCP protocol)",
         default=DEFAULT_HOST)
     ArgumentParser.add_argument(
         self,
         '--api-port',
         help="Base port for RPC services (only for TCP protocol)",
         default=DEFAULT_PORT)
     ArgumentParser.add_argument(self,
                                 '-c',
                                 '--config-file',
                                 help="Configuration file")
     ArgumentParser.add_argument(self, '-u', '--username', help="User name")
     ArgumentParser.add_argument(self,
                                 '--password',
                                 help="Password for user authentication")
     self.errmsg = ''
Example #18
0
    def __init__(self,
                 prog_version,
                 prog_version_date,
                 prog_description,
                 copyright_year,
                 copyright_authors,
                 use_config_parser_name=""
                 ):

        self.__version = "%(prog)s v" + prog_version + " from " + \
            prog_version_date

        # format copyright authors:
        # indent from second author
        copyright_authors = copyright_authors.splitlines()
        for i in range(len(copyright_authors)):
            copyright_authors[i] = "            " + copyright_authors[i]
        copyright_authors = "\n".join(map(unicode, copyright_authors))

        epilog = ":copyright: (c) " + copyright_year + " by \n" + \
        copyright_authors + \
        "\n:license: GPL v2 or any later version\n" + \
        ":bugreports: https://github.com/novoid/Memacs\n" + \
        ":version: " + prog_version + " from " + prog_version_date + "\n"

        self.__use_config_parser_name = use_config_parser_name

        ArgumentParser.__init__(self,
                              description=prog_description,
                              add_help=True,
                              epilog=epilog,
                              formatter_class=RawDescriptionHelpFormatter
                              )
        self.__add_arguments()
Example #19
0
 def __init__(self):
     ArgumentParser.__init__(self,
                             prog="ls",
                             description="Show episodes information",
                             epilog="example: ls -as lost*")
     self.add_argument("-n",
                       "--new",
                       action="store_true",
                       help="list NEW episodes (default)")
     self.add_argument("-i",
                       "--ignored",
                       action="store_true",
                       help="list IGNORED episodes")
     self.add_argument("-a",
                       "--acquired",
                       action="store_true",
                       help="list ACQUIRED episodes (default)")
     self.add_argument("-s",
                       "--seen",
                       action="store_true",
                       help="list SEEN episodes")
     self.add_argument("-f",
                       "--future",
                       action="store_true",
                       help="list episodes not aired to date, implies -nas")
     self.add_argument("filters",
                       metavar="EPISODE",
                       nargs="*",
                       default=["*"],
                       help="episode name or filter, ex: lost.s01e0*")
Example #20
0
 def __init__(self):
     ArgumentParser.__init__(self, prog="ls", description="Show episodes information", epilog="example: ls -as lost*")
     self.add_argument("-n", "--new", action="store_true", help="list NEW episodes (default)")
     self.add_argument("-a", "--adquired", action="store_true", help="list ADQUIRED episodes (default)")
     self.add_argument("-s", "--seen", action="store_true", help="list SEEN episodes")
     self.add_argument("-f", "--future", action="store_true", help="list episodes not aired to date, implies -nas")
     self.add_argument("filters", metavar="EPISODE", nargs="*", default=["*"], help="episode name or filter, ex: lost.s01e0*")
Example #21
0
 def __init__(self):
     ArgumentParser.__init__(
         self, prog="format", description="print episodes with given formats", epilog="example: format lost*"
     )
     self.add_argument(
         "filters", metavar="EPISODE", nargs="*", default=["*"], help="episode name or filter, ex: lost.s01e0*"
     )
Example #22
0
 def __init__(self, *args, **kwargs):
     ArgumentParser.__init__(self,
                             add_help=False,
                             conflict_handler="resolve",
                             *args,
                             **kwargs)
     self.lineno = None
Example #23
0
    def __init__(self,
                 definition_document=None,
                 prog=None,
                 usage=None,
                 description=None,
                 epilog=None,
                 version=None,
                 parents=[],
                 formatter_class=DargeHelpFormatter,
                 prefix_chars='-',
                 fromfile_prefix_chars=None,
                 argument_default=None,
                 conflict_handler='error',
                 add_help=True,
                 parent_dargeparser=None):
        ArgumentParser.__init__(
            self,
            prog=prog,
            usage=usage,
            description=description,
            epilog=epilog,
            version=version,
            parents=parents,
            formatter_class=formatter_class,
            prefix_chars=prefix_chars,
            fromfile_prefix_chars=fromfile_prefix_chars,
            argument_default=argument_default,
            conflict_handler=conflict_handler,
            add_help=add_help)

        if definition_document is None:
            raise Exception("definition_document cannot be None")
        self._definition_document = definition_document
        self.parent_dargeparser = parent_dargeparser
        self.current_parsing_child = None
Example #24
0
    def __init__(self, **kwargs):
        """Follow normal initialization and add BACpypes arguments."""
        if _debug: ArgumentParser._debug("__init__")

        if not _argparse_success:
            raise ImportError(
                "No module named argparse, install via pip or easy_install: https://pypi.python.org/pypi/argparse\n"
            )

        _ArgumentParser.__init__(self, **kwargs)

        # add a way to get a list of the debugging hooks
        self.add_argument(
            "--buggers",
            help="list the debugging logger names",
            action="store_true",
        )

        # add a way to attach debuggers
        self.add_argument(
            '--debug',
            nargs='*',
            help="add a log handler to each debugging logger",
        )

        # add a way to turn on color debugging
        self.add_argument(
            "--color",
            help="turn on color debugging",
            action="store_true",
        )
Example #25
0
    def __init__(self, description, epilog=''):
        ArgArgumentParser.__init__(self,
                                   description=description,
                                   epilog=epilog)
        argv = sys.argv[1:]
        loading.cli.register_argparse_arguments(self, argv, DEFAULT_AUTH_TYPE)
        loading.session.register_argparse_arguments(self)

        # (diurnalist) It would be nicer to load adapter arguments automatically
        # using `loading.adapter.register_argparse_arguments`, but there is
        # currently no way to automatically _load_ those arguments after they've
        # been registered. Also, using the adapter doesn't work very well with
        # all clients (neutronclient in particular hard-codes a version prefix
        # into all endpoint URLs, breaking the version discovery done in the
        # adapter by default.) So we just provide a few arguments that are
        # useful to us and ignore the rest.
        self.add_argument('--os-api-version',
                          default=getenv('OS_API_VERSION',
                                         DEFAULT_API_VERSION),
                          help='Minimum Major API version within a given '
                          'Major API version for client selection and '
                          'endpoint URL discovery.')
        self.add_argument('--os-interface', default=getenv('OS_INTERFACE'))
        self.add_argument('--os-region-name',
                          default=getenv('OS_REGION_NAME'),
                          help='The default region_name for endpoint URL '
                          'discovery.')

        self.add_argument('-v',
                          '--verbose',
                          action='count',
                          default=0,
                          help='increase output verbosity (use up to 3 times)')
Example #26
0
    def __init__(self, other=None):
        ArgumentParser.__init__(self)

        # Copy other dictionary entries to self._entries
        if other is not None and isinstance(other, Configuration):
            self._entries = dict(other._entries)
        else:
            self._entries = dict()  # 1 SECTION -> n KEY -> pair(value,comment)
Example #27
0
 def __init__(self):
     ArgumentParser.__init__(self,
                             prog="search",
                             description="Search tv shows in sources",
                             epilog="example: search the offi")
     self.add_argument("filter",
                       metavar="SHOW",
                       help="show name or part, ex: the offi")
Example #28
0
    def __init__(self, other=None):
        ArgumentParser.__init__(self)

        # Copy other dictionary entries to self._entries
        if other is not None and isinstance(other, Configuration):
            self._entries = dict(other._entries)
        else:
            self._entries = dict()  # 1 SECTION -> n KEY -> pair(value,comment)
Example #29
0
 def __init__(self, **kwargs):
     ArgumentParser.__init__(self, usage=self.__doc__, **kwargs)
     for option, value in self.mochitest_options:
         # Allocate new lists so references to original don't get mutated.
         # allowing multiple uses within a single process.
         if "default" in value and isinstance(value["default"], list):
             value["default"] = []
         self.add_argument(*option, **value)
Example #30
0
 def __init__(self, **kwargs):
     ArgumentParser.__init__(self, usage=self.__doc__, **kwargs)
     for option, value in self.mochitest_options:
         # Allocate new lists so references to original don't get mutated.
         # allowing multiple uses within a single process.
         if "default" in value and isinstance(value["default"], list):
             value["default"] = []
         self.add_argument(*option, **value)
Example #31
0
	def __init__(self):
		"""Initializes a sudoku argument parser instance.
		
		Uses RawDescriptionHelpFormatter as formatter class for epilog.
		epilog contains the information about the project and its authors.
		Construct parser using the following optional arguments:
		-g, --gui -- To start sudoku game in GUI mode.
		-c XML, --config XML -- To use XML file as config.
		
		If optional arguments are not specified, game will start in console
		mode and will use default 'config.xml' file.
		
		If the config file specified (or default config.xml) does not exist,
		create a new empty file.
		
		To save config to this file use main.Interface.save_config_to_file
		attribute method.

		"""
		ArgumentParser.__init__(
			self,
			formatter_class=RawDescriptionHelpFormatter,
			prog="pacsudoku",
			description="Play PAC Sudoku using console or user interface.",
			epilog=textwrap.dedent('''\
				
				----------------------------------------------------
				Sudoku project developed in Python. It features:
				
				- Load sudoku from TXT or CSV
				- Solve interactively using console or UI
				- Get hints during play
				- Export solution to TXT or display in console
				- Solver supporting 3 algorithms:
				    * Backtracking
				    * Peter Novig
				    * X Algorithm
				
				Authors: Ariel Dorado, Claudia Mercado, Pablo Studer
				----------------------------------------------------
				
			''')
		)
		self.add_argument(
			'-c',
			'--config',
			metavar= 'XML',
			default='config.xml',
			help="XML Config File to be used. Defaults to 'config.xml'"
			
		)
		self.add_argument(
			'-g',
			'--gui',
			help="Launch PAC Sudoku grapical user interface",
			action="store_true"
		)
Example #32
0
 def __init__(self, *args, **kwargs):
     if 'config' in kwargs:
         config = kwargs['config']
         del kwargs['config']
     else:
         config = []
     ArgumentParser.__init__(self, *args, **kwargs)
     self.config = DefaultConfig()
     self.config.read(config)
Example #33
0
    def __init__(self, arguments, **kwargs):
        """
        Prepare the decorator with a :class:`zetup.with_arguments` object.

        All `kwargs` are delegated to the ``ArgumentParser`` base constructor
        """
        ArgumentParser.__init__(self, **kwargs)
        for args, kwargs in arguments:
            self.add_argument(*args, **kwargs)
Example #34
0
    def __init__(self):
        ArgumentParser.__init__(self)

        self.description="""Test morphological transducers for consistency.
            `hfst-lookup` (or Xerox' `lookup` with argument -x) must be
            available on the PATH."""
        self.epilog="Will run all tests in the test_file by default."

        self.add_argument("-c", "--colour", dest="colour",
            action="store_true", help="Colours the output")
        self.add_argument("-o", "--output",
            dest="output", default="normal",
            help="Desired output style: compact, terse, final, normal (Default: normal)")
        self.add_argument("-q", "--silent",
            dest="silent", action="store_true",
            help="Hide all output; exit code only")
        self.add_argument("-i", "--ignore-extra-analyses",
            dest="ignore_analyses", action="store_true",
            help="""Ignore extra analyses when there are more than expected,
            will PASS if the expected one is found.""")
        self.add_argument("-s", "--surface",
            dest="surface", action="store_true",
            help="Surface input/analysis tests only")
        self.add_argument("-l", "--lexical",
            dest="lexical", action="store_true",
            help="Lexical input/generation tests only")
        self.add_argument("-f", "--hide-fails",
            dest="hide_fail", action="store_true",
            help="Suppresses passes to make finding failures easier")
        self.add_argument("-p", "--hide-passes",
            dest="hide_pass", action="store_true",
            help="Suppresses failures to make finding passes easier")
        self.add_argument("-S", "--section", default=["hfst"],
            dest="section", nargs='?', required=False,
            help="The section to be used for testing (default is `hfst`)")
        self.add_argument("-t", "--test",
            dest="test", nargs='?', required=False,
            help="""Which test to run (Default: all). TEST = test ID, e.g.
            'Noun - g\u00E5etie' (remember quotes if the ID contains spaces)""")
        self.add_argument("-F", "--fallback",
            dest="transducer", nargs='?', required=False,
            help="""Which fallback transducer to use.""")
        self.add_argument("-v", "--verbose",
            dest="verbose", action="store_true",
            help="More verbose output.")

        self.add_argument("--app", dest="app", nargs='?', required=False,
            help="Override application used for test")
        self.add_argument("--gen", dest="gen", nargs='?', required=False,
            help="Override generation transducer used for test")
        self.add_argument("--morph", dest="morph", nargs='?', required=False,
            help="Override morph transducer used for test")

        self.add_argument("test_file", nargs='?',
            help="YAML file with test rules")

        self.test = MorphTest(self.parse_args())
Example #35
0
 def __init__(self):
     """
     The constructor of this app.
     """
     ArgumentParser.__init__(self, description=self.DESCRIPTION)
     # the custom parameter list
     self._parameters = []
     # operations on automatically computed JSON representation of the app
     ArgumentParser.add_argument(
         self,
         '--json',
         action=JsonAction,
         dest='json',
         default=False,
         help='show json representation of app and exit')
     ArgumentParser.add_argument(
         self,
         '--savejson',
         action=SaveJsonAction,
         type=ChrisApp.path,
         dest='savejson',
         metavar='DIR',
         help='save json representation file to DIR and exit')
     if self.TYPE == 'ds':
         # 'ds' plugins require an input directory
         ArgumentParser.add_argument(
             self,
             'inputdir',
             action='store',
             type=str,
             help='directory containing the input files')
     # all plugins require an output directory
     ArgumentParser.add_argument(
         self,
         'outputdir',
         action='store',
         type=str,
         help='directory containing the output files/folders')
     ArgumentParser.add_argument(
         self,
         '--inputmeta',
         action='store',
         dest='inputmeta',
         help='meta data file containing the arguments passed to this app')
     ArgumentParser.add_argument(self,
                                 '--saveinputmeta',
                                 action='store_true',
                                 dest='saveinputmeta',
                                 help='save arguments to a JSON file')
     ArgumentParser.add_argument(
         self,
         '--saveoutputmeta',
         action='store_true',
         dest='saveoutputmeta',
         help='save output meta data to a JSON file')
     self.define_parameters()
Example #36
0
	def __init__(self, stats=True, colour=False):
		ArgumentParser.__init__(self)
		Test.__init__(self)
		if colour:
			self.add_argument("-c", "--colour", dest="colour", action="store_true",
							  help="Colours the output") 
		if stats:
			self.add_argument("-X", "--statistics", dest="statfile", 
							  nargs='?', const='quality-stats.xml', default=None,
							  help="XML file that statistics are to be stored in (Default: quality-stats.xml)")
Example #37
0
 def __init__(self):
     ArgumentParser.__init__(self,
                             prog="see",
                             description="Mark episodes as SEEN",
                             epilog="example: see lost.s01* lost.s02*")
     self.add_argument("filters",
                       metavar="EPISODE",
                       nargs="+",
                       default=[""],
                       help="episode name or filter, ex: lost.s01e0*")
Example #38
0
    def __init__(self, *args, **kwargs):
        """Create a new KSOptionParser instance.  Each KickstartCommand
           subclass should create one instance of KSOptionParser, providing
           at least the lineno attribute.  version is not required.

           Instance attributes:

           version -- The version when the kickstart command was introduced.

        """
        # Overridden to allow for the version kwargs, to skip help option generation,
        # and to resolve conflicts instead of override earlier options.
        int_version = kwargs.pop(
            "version")  # fail fast if no version is specified
        version = versionToLongString(int_version)

        # always document the version
        if "addVersion" in kwargs:
            warnings.warn(
                "The option 'addVersion' will be removed in a future release.",
                PendingDeprecationWarning)

        addVersion = kwargs.pop('addVersion', True)

        # remove leading spaced from description and epilog.
        # fail fast if we forgot to add description
        kwargs['description'] = textwrap.dedent(kwargs.pop("description"))
        if addVersion:
            kwargs['description'] = "\n.. versionadded:: %s\n\n%s" % (
                version, kwargs['description'])
        kwargs['epilog'] = textwrap.dedent(kwargs.pop("epilog", ""))

        # fail fast if we forgot to add prog
        kwargs['prog'] = kwargs.pop("prog")

        # remove leading spaced from description and epilog.
        # fail fast if we forgot to add description
        kwargs['description'] = textwrap.dedent(kwargs.pop("description"))
        kwargs['epilog'] = textwrap.dedent(kwargs.pop("epilog", ""))

        # fail fast if we forgot to add prog
        kwargs['prog'] = kwargs.pop("prog")

        ArgumentParser.__init__(self,
                                add_help=False,
                                conflict_handler="resolve",
                                formatter_class=KSHelpFormatter,
                                *args,
                                **kwargs)
        # NOTE: On Python 2.7 ArgumentParser has a deprecated version parameter
        # which always defaults to self.version = None which breaks deprecation
        # warnings in pykickstart. That's why we always set this value after
        # ArgumentParser.__init__ has been executed
        self.version = int_version
        self.lineno = None
Example #39
0
    def config(self, version='0.1', description='Description Here', arguments=None, usage=None):

        # Calling Parent
        ArgumentParser.__init__(self, version=version, description=description, usage=usage);

        # Adding Options
        if arguments is not None and len(arguments) > 0:
            self._add_arguments(arguments)

        # Parsing
        self.opts = self.parse_args()
Example #40
0
 def __init__(self, *args, **kwargs):
     ArgumentParser.__init__(self, *args, **kwargs)
     defaultConfig = os.path.join(cheshire3Root,
                                  'configs',
                                  'serverConfig.xml')
     self.add_argument('-s', '--server-config', type=str,
                       action='store', dest='serverconfig',
                       default=defaultConfig, metavar='PATH',
                       help=("path to Cheshire3 server configuration "
                             "file. default: {0}".format(defaultConfig))
                       )
Example #41
0
    def __init__(self, *args, **kwargs):
        ArgumentParser.__init__(self, *args, **kwargs)

        self.add_argument('recipe', nargs='?', help="Recipe to run.")
        self.add_argument('-l', '--list', action='store_true', default=False,
                          help="List available recipes.")
        self.add_argument('-f', '--format', dest='fmt', default='table',
                          choices=all_formatters.keys(),
                          help="Format to print data in, defaults to 'table'.")
        self.add_argument('-v', '--verbose', action='store_true', default=False,
                          help="Print the query and other debugging information.")
Example #42
0
    def config(self, version='0.1', description='Description Here', arguments=None, usage=None):

        # Calling Parent
        ArgumentParser.__init__(self, version=version, description=description, usage=usage);

        # Adding Options
        if arguments is not None and len(arguments) > 0:
            self._add_arguments(arguments)

        # Parsing
        self.opts = self.parse_args()
Example #43
0
 def __init__(self):
     ArgumentParser.__init__(
         self,
         prog="format",
         description="print episodes with given formats",
         epilog="example: format lost*")
     self.add_argument("filters",
                       metavar="EPISODE",
                       nargs="*",
                       default=["*"],
                       help="episode name or filter, ex: lost.s01e0*")
Example #44
0
    def __init__(self, *largs, **kwargs):

        args = kwargs.pop('args', None)
        self.ns, unknown = self.preparser.parse_known_args(args)
        for a in self.actions:
            if getattr(self.ns, a.dest) == a.default:
                a(self.preparser, self.ns, a.default)

        BaseArgumentParser.__init__(self, *largs, **kwargs)
        for name in self._preparser_args:
            self.add_argument(name, **self._preparser_args[name])
Example #45
0
    def __init__(self, *groups, **kwargs):
        ArgumentParser.__init__(self, **kwargs)

        for cli, kwargs in self.arguments:
            self.add_argument(*cli, **kwargs)

        for name in groups:
            group = self.add_argument_group("{} arguments".format(name))
            arguments = ARGUMENT_GROUPS[name]
            for cli, kwargs in arguments:
                group.add_argument(*cli, **kwargs)
Example #46
0
	def __init__(self, *args, **kwargs):
		ArgumentParser.__init__(self, *args, **kwargs)
		group = self.add_argument_group('global-modifiers', 'Modifiers that are common for all the git dist-* commands')
		group.add_argument('--debug', action='store_true', default=False, help='Be very verbose')
		group.add_argument('--config', dest='config_name', default=None, action='store', help='Specify a config file to use')
		group.add_argument('--path', metavar='DIR', action='store', default='./', help='Define the directory to work in (defaults to cwd)')
		group.add_argument('--noask', action='store_true', help='Always choose the default option')
		group.add_argument('--dist', action='store', help='Override the discovered distribution')
		group.add_argument('--target', action='store', help='Define build target to build into')
		#group.add_argument('--module-name', action='store', help='Override the module name')
		group.add_argument('--user', action='store', help='Override the discovered user name')
		group.add_argument('--dist-git', action='store', help='Specify the dist-git to use, do not auto-detect')
Example #47
0
    def __init__(self, nested_namespace_name=None, **kwargs):
        """
        :param nested_namespace_name: When used as a subparser, options from this parser will be stored nested under
            this attribute name in the root parser's namespace
        """
        # Do this early, so even option processing stuff is caught
        if '--bugreport' in sys.argv:
            self._debug_tb_callback()

        self.subparsers = None
        self.nested_namespace_name = nested_namespace_name
        self.raise_errors = None
        ArgParser.__init__(self, **kwargs)
Example #48
0
 def __init__(self, *args, **kwargs):
     ArgumentParser.__init__(self, *args, **kwargs)
     defaultConfig = os.path.join(cheshire3Root, 'configs',
                                  'serverConfig.xml')
     self.add_argument('-s',
                       '--server-config',
                       type=str,
                       action='store',
                       dest='serverconfig',
                       default=defaultConfig,
                       metavar='PATH',
                       help=("path to Cheshire3 server configuration "
                             "file. default: {0}".format(defaultConfig)))
 def __init__(self):
     usage = "Downloads and decodes Mailman archives into .mbox files"
     ArgumentParser.__init__(self, usage,
                           version="Mailman Downloader %s" % __version__)
     self.add_argument("list_archive_urls", nargs='+', 
                       help="Root url(s) for archive")
     self.add_argument("--username", help="login name [default: empty]")
     self.add_argument("--password", help="login password")
     self.add_argument("--dest", help="Destination for archives",
                       default = './archives')
     self.add_argument("--force",
                       help="Flag to overwrites files stored locally", 
                       action = 'store_const', const=True)
Example #50
0
    def __init__(self, definitions, **kwargs):
        ArgumentParser.__init__(self,
                                formatter_class=RawDescriptionHelpFormatter,
                                **kwargs)

        for name, definition in definitions.items():
            definition.setdefault("dest", name)
            flags = definition.pop("flags", [])

            if definition.pop("hidden", None):
                definition["help"] = SUPPRESS

            self.add_argument(*flags, **definition)
Example #51
0
    def __init__(self, nested_namespace_name=None, **kwargs):
        """
        :param nested_namespace_name: When used as a subparser, options from this parser will be stored nested under
            this attribute name in the root parser's namespace
        """
        # Do this early, so even option processing stuff is caught
        if '--bugreport' in sys.argv:
            self._debug_tb_callback()

        self.subparsers = None
        self.nested_namespace_name = nested_namespace_name
        self.raise_errors = None
        ArgParser.__init__(self, **kwargs)
Example #52
0
 def __init__(self, *args, **kwargs):
     suppress = kwargs.has_key('add_help') and kwargs['add_help'] is None
     kwargs.update({
         'add_help':
         False,
         'formatter_class':
         lambda prog: HelpFormatter(prog, max_help_position=30)
     })
     ArgumentParser.__init__(self, *args, **kwargs)
     if not (suppress or self.add_help):
         self.add_help_argument("-h",
                                "--help",
                                action="store_true",
                                help="Show this help message")
Example #53
0
 def __init__(self, 
     prog=None, 
     usage=None, 
     description=None, 
     epilog=None, 
     version=None, 
     parents=[], 
     formatter_class=HelpFormatter, 
     prefix_chars='-', 
     fromfile_prefix_chars=None, 
     argument_default=None, 
     conflict_handler='error', 
     add_help=False):
     ArgumentParser.__init__(self, prog=prog, usage=usage, description=description, epilog=epilog, version=version, parents=parents, formatter_class=formatter_class, prefix_chars=prefix_chars, fromfile_prefix_chars=fromfile_prefix_chars, argument_default=argument_default, conflict_handler=conflict_handler, add_help=add_help)
Example #54
0
    def __init__(self, *args, **kwargs):
        """Create a new KSOptionParser instance.  Each KickstartCommand
           subclass should create one instance of KSOptionParser, providing
           at least the lineno attribute.  version is not required.

           Instance attributes:

           version -- The version when the kickstart command was introduced.

        """
        # Overridden to allow for the version kwargs, to skip help option generation,
        # and to resolve conflicts instead of override earlier options.
        int_version = kwargs.pop("version")  # fail fast if no version is specified
        version = versionToLongString(int_version)

        # always document the version
        if "addVersion" in kwargs:
            warnings.warn("The option 'addVersion' will be removed in a future release.",
                          PendingDeprecationWarning)

        addVersion = kwargs.pop('addVersion', True)

        # remove leading spaced from description and epilog.
        # fail fast if we forgot to add description
        kwargs['description'] = textwrap.dedent(kwargs.pop("description"))
        if addVersion:
            kwargs['description'] = "\n.. versionadded:: %s\n%s" % (version,
                                                                    kwargs['description'])
        kwargs['epilog'] = textwrap.dedent(kwargs.pop("epilog", ""))

        # fail fast if we forgot to add prog
        kwargs['prog'] = kwargs.pop("prog")

        # remove leading spaced from description and epilog.
        # fail fast if we forgot to add description
        kwargs['description'] = textwrap.dedent(kwargs.pop("description"))
        kwargs['epilog'] = textwrap.dedent(kwargs.pop("epilog", ""))

        # fail fast if we forgot to add prog
        kwargs['prog'] = kwargs.pop("prog")

        ArgumentParser.__init__(self, add_help=False, conflict_handler="resolve",
                                formatter_class=KSHelpFormatter, *args, **kwargs)
        # NOTE: On Python 2.7 ArgumentParser has a deprecated version parameter
        # which always defaults to self.version = None which breaks deprecation
        # warnings in pykickstart. That's why we always set this value after
        # ArgumentParser.__init__ has been executed
        self.version = int_version
        self.lineno = None
    def __init__(self):
        usage = "Uploads mbox files to Gmail"
        ArgumentParser.__init__(self, usage,
                              version="Gmail Uploader %s" % __version__)
        self.add_argument("root_dir",  
                          help="Root directory for mbox archives")
        self.add_argument("gmail_address", help="Gmail email address")
        self.add_argument("password", help="Gmail password")
        self.add_argument("destinationFolder", help=("Destination Gmail folder" 
            " to upload archives to"))
        self.add_argument("--retries", help="Number of times to retry upload", 
             default=3)

        self.add_argument("--v", help="Verbose output", 
            action='store_const', const=True, default=False)
Example #56
0
    def __init__(self, *args, **kwargs):
        ArgumentParser.__init__(self, *args, **kwargs)

        group = self.add_argument_group("{} arguments".format(self.name))
        for cli, kwargs in self.arguments:
            group.add_argument(*cli, **kwargs)

        for name in self.common_groups:
            group = self.add_argument_group("{} arguments".format(name))
            arguments = COMMON_ARGUMENT_GROUPS[name]
            for cli, kwargs in arguments:
                group.add_argument(*cli, **kwargs)

        group = self.add_argument_group("template arguments")
        self.templates = {t: all_templates[t]() for t in self.templates}
        for template in self.templates.values():
            template.add_arguments(group)
Example #57
0
    def __init__(self):
        ArgumentParser.__init__(self, description='''This program will sync one
        folder to another''')

        self.add_argument(
                '-c',
                dest='configfile',
                type=file,
                help='''config file to read sync info from'''
                )
        self.add_argument(
                '-s',
                '--simulate',
                action='store_true',
                help='''Simulates the sync, does not actually do folder
                syncing'''
                )
Example #58
0
    def __init__(self, *args, **kwargs):
        """Create a new KSOptionParser instance.  Each KickstartCommand
           subclass should create one instance of KSOptionParser, providing
           at least the lineno attribute.  version is not required.

           Instance attributes:

           version -- The version of the kickstart syntax we are checking
                      against.
        """
        # Overridden to allow for the version kwargs, to skip help option generation,
        # and to resolve conflicts instead of override earlier options.
        version = kwargs.pop("version", None)

        ArgumentParser.__init__(self, add_help=False, conflict_handler="resolve", *args, **kwargs)
        self.lineno = None
        self.version = version
Example #59
0
   def __init__(self):
      ArgumentParser.__init__(self)

      usage = 'usage: %(prog)s [options] PROJECT'
      parser = ArgumentParser(usage=usage)

      self.add_argument('-b', '--builders', type=str, action=Parser.ListAction,
            help='list (comma separated) of builder config files')
      
      self.add_argument('-p', '--publishers', type=str, action=Parser.ListAction,
            help='list (comma seperated) of publisher config files.')

      self.add_argument('--config-dir', dest='config_dir', type=str, default='./share',
            help='specify root directory where config files are located.')

      #self.add_argument('--builder-config-dir', dest='builder_dir', type=str, default='builders',
            #help='specify directory where builder config files are located')

      #self.add_argument('--project-config-dir', dest='project_dir', type=str, default='projects',
            #help='specify directory where project config files are located')

      #self.add_argument('--publisher-config-dir', dest='publisher_dir', type=str, default='publishers',
            #help='specify directory where publisher config files are located')

      self.add_argument('--list-all-builders', action='store_true', dest='list_all_builders', default=False,
            help='print a list of all builders')

      self.add_argument('--list-all-projects', action='store_true', dest='list_all_projects', default=False,
            help='print a list of all projects')

      self.add_argument('--list-all-publishers', action='store_true', dest='list_all_publishers', default=False,
            help='print a list of all publishers')

      self.add_argument('--dry-run', action='store_true', dest='dry_run', default=False)

      group = self.add_argument_group('Advanced Options')

      group.add_argument('--all-projects', action='store_true', dest='build_all', default=False,
            help='build all projects')

      group.add_argument('--init-project', action='store_true', dest='init_project', default=False,
            help='initialize a project')


      self.add_argument('project_config', nargs='?')
Example #60
0
 def __init__(self,*args,**kwargs):
     '''
     Typical arguments
     \param description a text string saying what the program does. Optional.
     \param suite a function that returns a unittest test suite. Optional.
     '''
     self.tests=None
     if 'suite' in kwargs:
         self.tests=kwargs['suite']
         del kwargs['suite']
     ArgumentParser.__init__(self,*args,**kwargs)
     self.add_argument('-v','--verbose',dest='verbose',action='store_true',
                       default=False,help='print debug messages')
     self.add_argument('-q','--quiet',dest='quiet',action='store_true',
                       default=False,help='print only exceptions')
     self._functions=list()
     if self.tests:
         self.add_function('test','run unit tests in this module')