MCPcopy
hub / github.com/skywind3000/ECDICT / read_mdx

Method read_mdx

stardict.py:1440–1458  ·  view source on GitHub ↗
(self, mdxname, mdd = False)

Source from the content-addressed store, hash-verified

1438 # 读取 .mdx 文件,需要 readmdict 支持:
1439 # https://github.com/skywind3000/writemdict (包含readmdict)
1440 def read_mdx (self, mdxname, mdd = False):
1441 try:
1442 import readmdict
1443 except ImportError:
1444 print('ERROR: can\'t import readmdict module, please install it:')
1445 print('https://github.com/skywind3000/writemdict')
1446 sys.exit(1)
1447 words = {}
1448 if not mdd:
1449 mdx = readmdict.MDX(mdxname)
1450 else:
1451 mdx = readmdict.MDD(mdxname)
1452 for key, value in mdx.items():
1453 key = key.decode('utf-8', 'ignore')
1454 if not mdd:
1455 words[key] = value.decode('utf-8', 'ignore')
1456 else:
1457 words[key] = value
1458 return words
1459
1460 # 导出词形变换字符串
1461 def exchange_dumps (self, obj):

Callers

nothing calls this directly

Calls 1

decodeMethod · 0.80

Tested by

no test coverage detected