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

Function convert_dict

stardict.py:1759–1784  ·  view source on GitHub ↗
(dstname, srcname)

Source from the content-addressed store, hash-verified

1757
1758# 字典转化,csv sqlite之间互转
1759def convert_dict(dstname, srcname):
1760 dst = open_dict(dstname)
1761 src = open_dict(srcname)
1762 dst.delete_all()
1763 pc = tools.progress(len(src))
1764 for word in src.dumps():
1765 pc.next()
1766 data = src[word]
1767 x = data['oxford']
1768 if isinstance(x, int) or isinstance(x, long):
1769 if x <= 0:
1770 data['oxford'] = None
1771 elif isinstance(x, str) or isinstance(x, unicode):
1772 if x == '' or x == '0':
1773 data['oxford'] = None
1774 x = data['collins']
1775 if isinstance(x, int) or isinstance(x, long):
1776 if x <= 0:
1777 data['collins'] = None
1778 elif isinstance(x, str) or isinstance(x, unicode):
1779 if x == '' or x == '0':
1780 data['collins'] = None
1781 dst.register(word, data, False)
1782 dst.commit()
1783 pc.done()
1784 return True
1785
1786
1787# 从 ~/.local/share/stardict 下面打开词典

Callers

nothing calls this directly

Calls 8

open_dictFunction · 0.85
progressMethod · 0.80
nextMethod · 0.80
doneMethod · 0.80
delete_allMethod · 0.45
dumpsMethod · 0.45
registerMethod · 0.45
commitMethod · 0.45

Tested by

no test coverage detected