コード例 #1
0
    def test_glottocode_from_name(self):
        from pyglottolog.languoids import Glottocode, Glottocodes

        gc = Glottocode.from_name('a', dry_run=True)
        # only a dry-run, so not really added to glottocodes:
        self.assertNotIn(gc, Glottocodes())
        self.assertEqual(gc.split()[0], 'aaaa')
コード例 #2
0
ファイル: cli.py プロジェクト: billbrasky1/glottolog
def new_languoid(args):
    """Create a new languoid directory for a languoid specified by name and level.

    glottolog new_languoid <name> <level>
    """
    assert args.args[1] in ['family', 'language', 'dialect']
    lang = Languoid.from_name_id_level(
        args.args[0],
        Glottocode.from_name(args.args[0]),
        args.args[1],
        **dict(prop.split('=') for prop in args.args[2:]))
    #
    # FIXME: how to specify parent? Just mv there?
    #
    print("Info written to %s" % lang.write_info())
コード例 #3
0
ファイル: cli.py プロジェクト: billbrasky1/glottolog
def recode(args):
    """Assign a new glottocode to an existing languoid.

    glottolog recode <code>
    """
    lang = find_languoid(glottocode=args.args[0])
    if not lang:
        raise ParserError('languoid not found')
    lang.id = Glottocode.from_name(lang.name)
    new_dir = lang.dir.parent.joinpath(lang.id)
    copytree(lang.dir, new_dir)
    lang.write_info(new_dir)
    remove(new_dir.joinpath('%s.ini' % args.args[0]))
    rmtree(lang.dir)
    print("%s -> %s" % (args.args[0], lang.id))