예제 #1
0
def dispatch_command(function, *args, **kwargs):
    """ A wrapper for :func:`dispatch` that creates a one-command parser.
    Uses :attr:`PARSER_FORMATTER`.

    This::

        dispatch_command(foo)

    ...is a shortcut for::

        parser = ArgumentParser()
        set_default_command(parser, foo)
        dispatch(parser)

    This function can be also used as a decorator.
    """
    parser = argparse.ArgumentParser(formatter_class=PARSER_FORMATTER)
    set_default_command(parser, function)
    dispatch(parser, *args, **kwargs)
예제 #2
0
파일: dispatching.py 프로젝트: saaros/argh
def dispatch_command(function, *args, **kwargs):
    """ A wrapper for :func:`dispatch` that creates a one-command parser.
    Uses :attr:`PARSER_FORMATTER`.

    This::

        dispatch_command(foo)

    ...is a shortcut for::

        parser = ArgumentParser()
        set_default_command(parser, foo)
        dispatch(parser)

    This function can be also used as a decorator.
    """
    parser = argparse.ArgumentParser(formatter_class=PARSER_FORMATTER)
    set_default_command(parser, function)
    dispatch(parser, *args, **kwargs)
예제 #3
0
 def set_default_command(self, *args, **kwargs):
     "Wrapper for :func:`set_default_command`."
     return set_default_command(self, *args, **kwargs)
예제 #4
0
@argh.arg('--host', default='jira.findmeals.ru')
@argh.arg('--port', default=443)
@argh.arg('--user')
@argh.arg('--password')
@argh.arg('commit_msg_file')
def main(args):
    connobj = JiraConnection(args.host, args.port, args.user, args.password)
    connobj.login()

    with open(args.commit_msg_file, 'r+') as f:
        text = ''.join(f.readlines()).strip()
        text = re.sub('^#.*\n', '', text, flags=re.M)  # strip comments
        f.seek(0)
        f.truncate()

        regexp = re.compile(r'\s*refs #newissue\s+(?P<project>\w+)(?P<parent>-\d+)?\s*')
        matchobj = regexp.search(text)
        if matchobj:
            text = create_issue(connobj, matchobj, text)

        else:
            text = re.sub(r'refs #(\w+-\d+)', lambda x: replace_func(connobj, text, x), text)
        f.write(text+'\n')


if __name__ == '__main__':
    parser = argh.ArghParser()
    set_default_command(parser, main)
    parser.dispatch()

예제 #5
0
파일: helpers.py 프로젝트: tanriol/argh
 def set_default_command(self, *args, **kwargs):
     "Wrapper for :func:`set_default_command`."
     return set_default_command(self, *args, **kwargs)
예제 #6
0
파일: helpers.py 프로젝트: ach5910/KivyApp
 def set_default_command(self, *args, **kwargs):
     "Wrapper for :func:`~argh.assembling.set_default_command`."
     return set_default_command(self, *args, **kwargs)