Esempio n. 1
0
def makeParser():
    '''Creates and returns argument parser (argparse module).'''
    parser = argparse.ArgumentParser(
        description='Changes post tags according to specified rules.',
        usage='\t%(prog)s -b BLOG [options] [-- action [action [...]]]\n\t%(prog)s --help',
        parents = [args.baseParser(skipfailignore = True, format = True)],
        )
    parser.add_argument('--id',
        dest = 'id',
        action = 'store',
        default = '-',
        required = False,
        help = 'Post ID. If set to "-" (default), list of the post IDs will be read from stdin.'
        )
    parser.add_argument('actions',
        action = 'store',
        nargs = '*',
        type = args.taglist('+-!'),
        default = [],
        metavar = 'action',
        help = 'Actions to perform. Syntax: +tag_to_add, -tag_to_remove, !tag_to_toggle.'
        )
    return parser
Esempio n. 2
0
def makeParser():
    '''Creates and returns argument parser (argparse module).'''
    parser = argparse.ArgumentParser(
        description='Retrieves posts list from specified blog. OAuth is not required.',
        parents = [args.baseParser(skipfailignore = False, format = True)],
        #add_help=False,
        )
    group = parser.add_argument_group(title='Basic filters')
    group.add_argument('--id',
        dest = 'id',
        action = 'store',
        default = None,
        required = False,
        help = 'Post ID. If specified, then results will be limited by that post.'
        )
    group.add_argument('--type',
        dest = 'type',
        action = 'store',
        type = unicode.lower,
        choices = (u'all', u'text', u'photo', u'quote', u'link', u'chat', u'audio', u'video', u'answer'),
        default = u'all',
        required = False,
        metavar = 'TYPE',
        help = 'Determines type of the retrieved posts. Possible values are %(choices)s. Defaults to "%(default)s".',
        )
    group.add_argument('--tag',
        dest = 'tags',
        action = 'append',
        type = args.taglist('+-'),
        default = [],
        required = False,
        metavar = 'TAG',
        help = 'Tag restrictions. Syntax: --tag=+required_tag --tag=-prohibited_tag',
        )
    group = parser.add_argument_group(title='Regexp filters')
    group.add_argument('--body',
        dest = 'body',
        action = 'store',
        default = u'',
        type = args.match_regexp,
        required = False,
        help = 'Regular expression to match the post body (quote text, link description, answer) against.'
        )
    group.add_argument('--title',
        dest = 'title',
        action = 'store',
        type = args.match_regexp,
        default = u'',
        required = False,
        help = 'Regular expression to match the post title (quote source, photo/audio/video caption, link title, question) against.'
        )
    group.add_argument('--source',
        dest = 'source',
        action = 'store',
        type = args.match_regexp,
        default = u'',
        required = False,
        help = 'Regular expression to match the post source or question source URL against.'
        )
    group.add_argument('--plain',
        dest = 'plaintext',
        action = 'store_const',
        const = True,
        default = False,
        required = False,
        help = 'Work with plain text version of the post, not with HTML.'
        )
    group = parser.add_argument_group(title='Date filters')
    group.add_argument('--before',
        dest = 'before',
        action = 'store',
        type = args.timestamp,
        default = None,
        required = False,
        help = 'Retrieve only posts with timestamp earlier than specified. Format is 1999-12-31T23:59:59.'
        )
    group.add_argument('--after',
        dest = 'after',
        action = 'store',
        type = args.timestamp,
        default = None,
        required = False,
        help = 'Retrieve only posts with timestamp later than specified. Format is 1999-12-31T23:59:59.'
        )
    group = parser.add_argument_group(title='Query limits')
    group.add_argument('-N', '--count', '--limit',
        dest = 'count',
        action = 'store',
        type = int,
        default = None,
        required = False,
        help = 'How many posts should be retrieved.',
        )
    group.add_argument('-S', '--offset', '--start',
        dest = 'offset',
        action = 'store',
        type = int,
        default = 0,
        required = False,
        help = 'How many posts should be skipped.',
        )
    group.add_argument('--slice',
        dest = 'slice',
        action = 'store',
        type = int,
        default = None,
        required = False,
        help = 'Receive data in portions no bigger than SLICE posts.'
        )
    return parser