Exemplo n.º 1
0
def test_dump(Record):
    # Assume our db contains following words
    Record.select.return_value = [Mock(word='apple'), Mock(word='apply')]

    # init query
    ret = dump()
    assert ret == ['apple', 'apply']

    ret = dump(pattern='^.*e$')
    assert ret == ['apple']
Exemplo n.º 2
0
def test_dump(Record):
    # Assume our db contains following words
    Record.select.return_value = [
        Mock(word='apple'),
        Mock(word='apply')]

    # init query
    ret = dump()
    assert ret == ['apple', 'apply']

    ret = dump(pattern='^.*e$')
    assert ret == ['apple']
Exemplo n.º 3
0
def execute_zdict(args):
    if args.list_dicts:
        for provider in sorted(
            dictionary_map,
            key=lambda x: {'yahoo': 0, 'pyjokes': 2}.get(x, 1)
        ):
            print(
                '{}: {}'.format(
                    provider,
                    dictionary_map[provider](args).title
                )
            )
        exit()

    if args.pattern:
        for word in dump(pattern=args.pattern):
            print(word)
        exit()

    try:
        if args.words:
            normal_mode(args)
        else:
            interactive_mode(args)
    except (KeyboardInterrupt, EOFError):
        print()
        return
Exemplo n.º 4
0
Arquivo: zdict.py Projeto: zdict/zdict
def execute_zdict(args):
    if args.list_dicts:
        for provider in sorted(
            dictionary_map,
            key=lambda x: {'yahoo': 0, 'pyjokes': 2}.get(x, 1)
        ):
            print(
                '{}: {}'.format(
                    provider,
                    dictionary_map[provider](args).title
                )
            )
        exit()

    if args.pattern:
        for word in dump(pattern=args.pattern):
            print(word)
        exit()

    try:
        if args.words:
            normal_mode(args)
        else:
            interactive_mode(args)
    except (KeyboardInterrupt, EOFError):
        print()
        return
Exemplo n.º 5
0
def set_args(args):
    if args.list_dicts:
        for provider in sorted(dictionary_map,
                               key=lambda x: {
                                   'yahoo': 0,
                                   'pyjokes': 2
                               }.get(x, 1)):
            print('{}: {}'.format(provider, dictionary_map[provider]().title))
        exit()

    if args.pattern:
        for word in dump(pattern=args.pattern):
            print(word)
        exit()

    if args.force_color:
        utils.Color.set_force_color()

    args.dict = args.dict.split(',')

    if 'all' in args.dict:
        args.dict = tuple(dictionary_map.keys())
    else:
        # Uniq and Filter the dict not in supported dictionary list then sort.
        args.dict = sorted(set(d for d in args.dict if d in dictionary_map))

    if len(args.dict) > 1:
        args.show_provider = True

    return args
Exemplo n.º 6
0
def set_args():
    if args.list_dicts:
        for provider in sorted(
                dictionary_map,
                key=lambda x: {'yahoo': 0, 'pyjokes': 2}.get(x, 1)):
            print('{}: {}'.format(provider, dictionary_map[provider]().title))
        exit()

    if args.pattern:
        for word in dump(pattern=args.pattern):
            print(word)
        exit()

    if args.force_color:
        utils.Color.set_force_color()

    args.dict = args.dict.split(',')

    if 'all' in args.dict:
        args.dict = tuple(dictionary_map.keys())
    else:
        # Uniq and Filter the dict not in supported dictionary list then sort.
        args.dict = sorted(set(d for d in args.dict if d in dictionary_map))

    if len(args.dict) > 1:
        args.show_provider = True
Exemplo n.º 7
0
Arquivo: zdict.py Projeto: zdict/zdict
def execute_zdict(args):
    if args.list_dicts:
        for provider in sorted(dictionary_map):
            print('{}: {}\n{}\n'.format(
                provider,
                dictionary_map[provider](args).title,
                dictionary_map[provider](args).HOMEPAGE_URL,
            ))
        exit()

    if args.pattern:
        for word in dump(pattern=args.pattern):
            print(word)
        exit()

    try:
        if args.words:
            normal_mode(args)
        else:
            interactive_mode(args)
    except (KeyboardInterrupt, EOFError):
        print()
        return