| 1757 | |
| 1758 | # 字典转化,csv sqlite之间互转 |
| 1759 | def 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 下面打开词典 |