Ejemplo n.º 1
0
    def test_rewrite(self):
        from clldutils.dsv import reader, rewrite

        tmp = self.tmp_path('test')
        shutil.copy(FIXTURES.joinpath('tsv.txt').as_posix(), tmp.as_posix())
        rewrite(tmp.as_posix(), lambda i, row: [len(row)], delimiter='\t')
        self.assertEquals(list(reader(tmp))[0], ['2'])

        shutil.copy(FIXTURES.joinpath('csv.txt').as_posix(), tmp.as_posix())
        rewrite(tmp, lambda i, row: row)
        self.assertEquals(list(reader(tmp)), list(reader(FIXTURES.joinpath('csv.txt'))))
Ejemplo n.º 2
0
def link():
    parser = argparse.ArgumentParser(description="""\
Complete linking of concepts to concept sets. If either CONCEPTICON_GLOSS or
CONCEPTICON_ID is given, the other is added.""")
    parser.add_argument('conceptlist', help='path to conceptlist to complete')
    args = parser.parse_args()

    if not os.path.exists(args.conceptlist):
        args.conceptlist = data_path('conceptlists', args.conceptlist)
        assert os.path.exists(args.conceptlist)

    rewrite(args.conceptlist,
            Linker(os.path.basename(args.conceptlist).replace('.tsv', '')),
            delimiter='\t')
Ejemplo n.º 3
0
def link():
    parser = argparse.ArgumentParser(
        description="""\
Complete linking of concepts to concept sets. If either CONCEPTICON_GLOSS or
CONCEPTICON_ID is given, the other is added.""")
    parser.add_argument('conceptlist', help='path to conceptlist to complete')
    args = parser.parse_args()

    if not os.path.exists(args.conceptlist):
        args.conceptlist = data_path('conceptlists', args.conceptlist)
        assert os.path.exists(args.conceptlist)

    rewrite(
        args.conceptlist,
        Linker(os.path.basename(args.conceptlist).replace('.tsv', '')),
        delimiter='\t')
Ejemplo n.º 4
0
def visit(visitor, fname):
    return rewrite(fname, visitor, delimiter='\t')
Ejemplo n.º 5
0
def visit(visitor, fname):
    return rewrite(fname, visitor, delimiter='\t')