예제 #1
0
파일: mello.py 프로젝트: whitef0x0/gtd.py
def grep(config, pattern, insensitive, count, regexp):
    '''egrep through titles of cards on this board. This command attemps to replicate a couple of grep flags
    faithfully, so if you're a power-user of grep this command will feel familiar.
    '''
    if not (pattern or regexp):
        click.secho('No pattern provided to grep: use either the argument or -e', fg='red')
        raise GTDException(1)
    # Merge together the different regex arguments
    final_pattern = '|'.join(regexp) if regexp else ''
    if pattern and final_pattern:
        final_pattern = final_pattern + '|' + pattern
    elif pattern:
        final_pattern = pattern
    flags = re.I if insensitive else 0
    connection, board = BoardTool.start(config)
    cards = BoardTool.filter_cards(
        board,
        title_regex=final_pattern,
        regex_flags=flags
    )
    if count:
        print(sum(1 for _ in cards))
        raise GTDException(0)
    display = Display(config.color)
    if config.banner:
        display.banner()
    display.show_cards(cards)
예제 #2
0
파일: mello.py 프로젝트: whitef0x0/gtd.py
def show_cards(config, json, tsv, tags, no_tags, match, listname, attachments, has_due, assigned, completed, include_closed):
    '''Display cards
    The show command prints a table of all the cards with fields that will fit on the terminal you're using.
    You can change this formatting by passing one of --tsv or --json, which will output as a tab-separated value sheet or JSON.
    This command along with the batch & review commands share a flexible argument scheme for getting card information.
    Mutually exclusive arguments include -t/--tags & --no-tags along with -j/--json & --tsv
    '''
    _, board, current_user = BoardTool.start(config)
    display = Display(config.color)
    if config.banner and not json:
        display.banner()
    cards = BoardTool.filter_cards(
        board,
        tags=tags,
        no_tags=no_tags,
        current_user=current_user,
        title_regex=match,
        list_regex=listname,
        has_attachments=attachments,
        has_due_date=has_due,
        assigned=assigned,
        completed=completed,
        include_closed=include_closed
    )
    display.show_cards(cards, use_json=json, tsv=tsv)
예제 #3
0
파일: gtd.py 프로젝트: robeastham/gtd.py
def grep(config, pattern, insensitive, count, regexp):
    '''egrep through titles of cards on this board. This command attemps to replicate a couple of grep flags
    faithfully, so if you're a power-user of grep this command will feel familiar.
    '''
    if not (pattern or regexp):
        click.secho('No pattern provided to grep: use either the argument or -e', fg='red')
        raise GTDException(1)
    # Merge together the different regex arguments
    final_pattern = '|'.join(regexp) if regexp else ''
    if pattern and final_pattern:
        final_pattern = final_pattern + '|' + pattern
    elif pattern:
        final_pattern = pattern
    flags = re.I if insensitive else 0
    connection, board = BoardTool.start(config)
    cards = BoardTool.filter_cards(
        board,
        title_regex=final_pattern,
        regex_flags=flags
    )
    if count:
        print(sum(1 for _ in cards))
        raise GTDException(0)
    display = Display(config.color)
    if config.banner:
        display.banner()
    display.show_cards(cards)
예제 #4
0
파일: gtd.py 프로젝트: inirudebwoy/gtd.py
def grep(config, pattern, insensitive, count, regexp, by, fields, json):
    '''egrep through titles of cards on this board. This command attemps to replicate a couple of grep flags
    faithfully, so if you're a power-user of grep this command will feel familiar.
    One deviation from grep is the --json flag, which outputs all matching cards in full JSON format.
    '''
    if not (pattern or regexp):
        click.secho(
            'No pattern provided to grep: use either the argument or -e',
            fg='red')
        raise GTDException(1)
    # Merge together the different regex arguments
    final_pattern = '|'.join(regexp) if regexp else ''
    if pattern and final_pattern:
        final_pattern = final_pattern + '|' + pattern
    elif pattern:
        final_pattern = pattern
    flags = re.I if insensitive else 0
    connection, board = BoardTool.start(config)
    cards = BoardTool.filter_cards(board,
                                   title_regex=final_pattern,
                                   regex_flags=flags)
    if count:
        print(sum(1 for _ in cards))
        return
    display = Display(config.color)
    if config.banner and not json:
        display.banner()
    display.show_cards(cards, use_json=json, sort=by, table_fields=fields)
예제 #5
0
파일: gtd.py 프로젝트: inirudebwoy/gtd.py
def show_soon(config, json, tsv):
    _, board = BoardTool.start(config)
    display = Display(config.color)
    if config.banner and not json:
        display.banner()
    cards = BoardTool.filter_cards(board, has_due_date=True)
    display.show_cards(cards, use_json=json, tsv=tsv, sort='due')
예제 #6
0
파일: gtd.py 프로젝트: robeastham/gtd.py
def show_cards(config, json, tsv, tags, no_tags, match, listname, attachments, has_due):
    '''Display cards
    The show command prints a table of all the cards with fields that will fit on the terminal you're using.
    You can change this formatting by passing one of --tsv or --json, which will output as a tab-separated value sheet or JSON.
    This command along with the batch & review commands share a flexible argument scheme for getting card information.
    Mutually exclusive arguments include -t/--tags & --no-tags along with -j/--json & --tsv
    '''
    _, board = BoardTool.start(config)
    display = Display(config.color)
    if config.banner and not json:
        display.banner()
    cards = BoardTool.filter_cards(
        board,
        tags=tags,
        no_tags=no_tags,
        title_regex=match,
        list_regex=listname,
        has_attachments=attachments,
        has_due_date=has_due
    )
    display.show_cards(cards, use_json=json, tsv=tsv)