def test_gencodemap(tmp_path):
    rootdir = os.path.abspath(os.path.dirname(os.path.dirname(__file__)))
    unihan_source = os.path.join(rootdir, 'src', 'unihandecode', 'data',
                                 'Unihan_Readings.txt')
    dest = os.path.join(tmp_path, 'krcodepoints.pickle')
    u = gencodemap.UnihanConv('kr')
    u.run(source=unihan_source, dest=dest)
    with open(os.path.join(tmp_path, 'krcodepoints.pickle'), 'rb') as f:
        dic = pickle.load(f)
        assert isinstance(dic, dict)
示例#2
0
    def test_gencodemap(self):
        unihan_source = os.path.join('unihandecode', 'data',
                                     'Unihan_Readings.txt')
        dest = os.path.join(self.workspace, 'krcodepoints.pickle')
        u = gencodemap.UnihanConv('kr')
        u.run(source=unihan_source, dest=dest)

        f = open(os.path.join(self.workspace, 'krcodepoints.pickle.bz2'), 'rb')
        buf = f.read()
        buf = bz2.decompress(buf)
        (dic, dlen) = cPickle.loads(buf)
        self.assertTrue(isinstance(dic, dict))
示例#3
0
 def pre_build(self):
     sys.path.insert(1, os.path.join(os.path.abspath(os.path.dirname(__file__)), 'src'))
     import unihandecode.gencodemap as gencodemap
     os.makedirs(os.path.join(self.build_lib, 'unihandecode', 'data'), exist_ok=True)
     dest = os.path.join(self.build_lib, 'unihandecode', 'data', 'unicodepoints.pickle')
     u = gencodemap.Unicodepoints()
     u.run(dest)
     unihan_source = os.path.join('src', 'unihandecode', 'data', 'Unihan_Readings.txt')
     SUPPORTED_LANG = ['kr', 'ja', 'zh', 'vn', 'yue']
     for lang in SUPPORTED_LANG:
         dest = os.path.join(self.build_lib, 'unihandecode', 'data', lang + 'codepoints.pickle')
         u = gencodemap.UnihanConv(lang)
         u.run(source=unihan_source, dest=dest)
示例#4
0
def dictionary_setup_fixture():
    if "TOX_ENV_DIR" not in os.environ:
        root_dir = os.path.abspath(os.path.dirname(os.path.dirname(__file__)))
        sys.path.insert(1, os.path.join(root_dir, 'src'))
        import unihandecode.gencodemap as gencodemap
        dpath = os.path.join(root_dir, 'build', 'lib', 'unihandecode')
        os.makedirs(dpath, exist_ok=True)
        dest = os.path.join(dpath, 'unicodepoints.pickle')
        u = gencodemap.Unicodepoints()
        u.run(dest)
        unihan_source = os.path.join(root_dir, 'src', 'unihandecode', 'data', 'Unihan_Readings.txt')
        SUPPORTED_LANG = ['kr', 'ja', 'zh', 'vn', 'yue']
        for lang in SUPPORTED_LANG:
            dest = os.path.join(dpath, lang + 'codepoints.pickle')
            u = gencodemap.UnihanConv(lang)
            u.run(source=unihan_source, dest=dest)
        from unihandecode import Configurations
        Configurations()._data_path = dpath
示例#5
0
def gen_map():
    unihan_source = os.path.join('unihandecode', 'data', 'Unihan_Readings.txt')
    for lang in SUPPORTED_LANG:
        dest = os.path.join('unihandecode', lang + 'codepoints.pickle')
        u = gencodemap.UnihanConv(lang)
        u.run(source=unihan_source, dest=dest)
示例#6
0
 def test_checkcategory(self):
     u = gencodemap.UnihanConv('zh')
     u.check_category("key", 'kHanyuPinyin', u"10038.080:yǐn")
示例#7
0
 def test_default_lang(self):
     u = gencodemap.UnihanConv('ru')
     self.assertTrue(isinstance(u, gencodemap.UnihanConv))
def test_default_lang():
    u = gencodemap.UnihanConv('ru')
    assert isinstance(u, gencodemap.UnihanConv)