Exemple #1
0
def load_vocab(vocab: Path) -> List[List[str]]:
    """loads vocab from `vocab` and returns as list contaning lists of vocab"""
    with open(vocab, "r") as f:
        raw_vocab = [line.strip("\n") for line in f.readlines()]
        return list(
            map(
                list,
                (itertoolz.remove(is_pipe, (recipes.partitionby(is_pipe, raw_vocab)))),
            )
        )
Exemple #2
0
def resort(files):
    """
    make Readme and PDF files appear first in file list
    """
    def is_text(f):
        kw = ['.pdf', '.txt', '.docx', 'README', 'readme', 'Readme', 'ReadMe']
        return any(map(lambda k: k in f['filename'], kw))

    text = filter(is_text, files)
    data = remove(lambda x: x in text, files)
    return tuple(concat([text, data]))
Exemple #3
0
def test_remove():
    r = remove(iseven, range(5))
    assert type(r) is not list
    assert list(r) == list(filter(isodd, range(5)))