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

Method compile_css

dictutils.py:426–449  ·  view source on GitHub ↗
(self, dictionary, filename, css = None)

Source from the content-addressed store, hash-verified

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 = {}

Callers

nothing calls this directly

Calls 6

_generate_htmlMethod · 0.95
progressMethod · 0.80
nextMethod · 0.80
doneMethod · 0.80
queryMethod · 0.45
closeMethod · 0.45

Tested by

no test coverage detected