| 424 | return True |
| 425 | |
| 426 | def compile_css (self, dictionary, filename, css = None): |
| 427 | fp = codecs.open(filename, 'w', 'utf-8') |
| 428 | text2html = self.text2html |
| 429 | pc = stardict.tools.progress(len(dictionary)) |
| 430 | if not css: |
| 431 | main = os.path.split(filename)[-1] |
| 432 | css = os.path.splitext(main)[0] + '.css' |
| 433 | for _, word in dictionary: |
| 434 | pc.next() |
| 435 | data = dictionary.query(word) |
| 436 | translation = data['translation'] |
| 437 | if not translation: |
| 438 | translation = data['definition'] |
| 439 | if not translation: |
| 440 | continue |
| 441 | fp.write(word.replace('\r', '').replace('\n', '') + '\r\n') |
| 442 | fp.write('<link href="%s" rel="stylesheet" type="text/css"/>\r\n'%css) |
| 443 | self._generate_html(fp, data) |
| 444 | fp.write('</>') |
| 445 | if pc.count < pc.total: |
| 446 | fp.write('\r\n') |
| 447 | fp.close() |
| 448 | pc.done() |
| 449 | return 0 |
| 450 | |
| 451 | def list_load (self, filename, encoding = 'utf-8'): |
| 452 | words = {} |