Exemplo n.º 1
0
def verbose():
    global DEBUG
    DEBUG = 1
    try:
        with ctx_redirect_io() as io:
            yield
    except:
        raise
    else:
        print colors.yellow % io.getvalue()
    finally:
        DEBUG = 0

        sys.stdout.flush()
Exemplo n.º 2
0
def verbose():
    global DEBUG
    DEBUG = 1
    try:
        with ctx_redirect_io() as io:
            yield
    except:
        raise
    else:
        print colors.yellow % io.getvalue()
    finally:
        DEBUG = 0

        sys.stdout.flush()
Exemplo n.º 3
0
        key = '%s-%s-%s' % (author, year, title)
        key = key.lower()
        print key.encode('utf8')


if __name__ == '__main__':
    from argparse import ArgumentParser
    p = ArgumentParser()
    p.add_argument('action', choices=('dump', 'search', 'complete'))
    p.add_argument('filters', nargs='*', help='filters, each is a regex')
    args = p.parse_args()

    d = config.ROOT / 'bibkeys'
    if args.action == 'dump':
        with ctx_redirect_io(file(d, 'wb')) as f:
            dump()

    else:
        # TODO: consider ordered completions "author - year - title"
        from env.bin.filter import main
        with file(d) as f:
            matches = list(main(args.filters, f.readlines(), color=args.action != 'complete'))
            for m in matches:
                print yellow % m

                [a, y, t] = m.split('-')

                q = ''
                if a:
                    q += ''.join(map(' author:%s'.__mod__, a.split(' ')))
Exemplo n.º 4
0
        key = '%s-%s-%s' % (author, year, title)
        key = key.lower()
        print key.encode('utf8')


if __name__ == '__main__':
    from argparse import ArgumentParser
    p = ArgumentParser()
    p.add_argument('action', choices=('dump', 'search', 'complete'))
    p.add_argument('filters', nargs='*', help='filters, each is a regex')
    args = p.parse_args()

    d = config.ROOT / 'bibkeys'
    if args.action == 'dump':
        with ctx_redirect_io(file(d, 'wb')) as f:
            dump()

    else:
        # TODO: consider ordered completions "author - year - title"
        from env.bin.filter import main
        with file(d) as f:
            matches = list(main(args.filters, f.readlines(), color=args.action != 'complete'))
            for m in matches:
                print yellow % m

                [a, y, t] = m.split('-')

                q = ''
                if a:
                    q += ''.join(map(' author:%s'.__mod__, a.split(' ')))
Exemplo n.º 5
0
        key = '%s-%s-%s' % (author, year, title)
        key = key.lower()
        print(key.encode('utf8'))


if __name__ == '__main__':
    from argparse import ArgumentParser
    p = ArgumentParser()
    p.add_argument('action', choices=('dump', 'search', 'complete'))
    p.add_argument('filters', nargs='*', help='filters, each is a regex')
    args = p.parse_args()

    d = config.ROOT / 'bibkeys'
    if args.action == 'dump':
        with ctx_redirect_io(open(d, 'wb')) as f:
            dump()

    else:
        # TODO: consider ordered completions "author - year - title"
        from env.bin.filter import main
        with open(d) as f:
            matches = list(
                main(args.filters,
                     f.readlines(),
                     color=args.action != 'complete'))
            for m in matches:
                print(colors.yellow % m)

                [a, y, t] = m.split('-')
Exemplo n.º 6
0
        key = '%s-%s-%s' % (author, year, title)
        key = key.lower()
        print(key.encode('utf8'))


if __name__ == '__main__':
    from argparse import ArgumentParser
    p = ArgumentParser()
    p.add_argument('action', choices=('dump', 'search', 'complete'))
    p.add_argument('filters', nargs='*', help='filters, each is a regex')
    args = p.parse_args()

    d = config.ROOT / 'bibkeys'
    if args.action == 'dump':
        with ctx_redirect_io(open(d, 'wb')) as f:
            dump()

    else:
        # TODO: consider ordered completions "author - year - title"
        from env.bin.filter import main
        with open(d) as f:
            matches = list(main(args.filters, f.readlines(), color=args.action != 'complete'))
            for m in matches:
                print(colors.yellow % m)

                [a, y, t] = m.split('-')

                q = ''
                if a:
                    q += ''.join(map(' author:%s'.__mod__, a.split(' ')))