mirror of
https://github.com/ankitects/anki.git
synced 2025-09-24 16:56:36 -04:00
convert some list comps to generators
This commit is contained in:
parent
d7b86da811
commit
572fe6041a
1 changed files with 6 additions and 6 deletions
|
@ -110,15 +110,15 @@ insert or replace into models values (?, ?, ?, ?, ?, ?, ?)""",
|
||||||
if not self.id:
|
if not self.id:
|
||||||
return ""
|
return ""
|
||||||
# fields
|
# fields
|
||||||
css = "".join([self._fieldCSS(
|
css = "".join(self._fieldCSS(
|
||||||
".fm%s-%s" % (hexifyID(self.id), hexifyID(f['ord'])),
|
".fm%s-%s" % (hexifyID(self.id), hexifyID(f['ord'])),
|
||||||
(f['font'], f['qsize'], f['qcol'], f['rtl'], f['pre']))
|
(f['font'], f['qsize'], f['qcol'], f['rtl'], f['pre']))
|
||||||
for f in self.fields])
|
for f in self.fields)
|
||||||
# templates
|
# templates
|
||||||
css += "".join([".cm%s-%s {text-align:%s;background:%s}\n" % (
|
css += "".join(".cm%s-%s {text-align:%s;background:%s}\n" % (
|
||||||
hexifyID(self.id), hexifyID(t['ord']),
|
hexifyID(self.id), hexifyID(t['ord']),
|
||||||
("center", "left", "right")[t['align']], t['bg'])
|
("center", "left", "right")[t['align']], t['bg'])
|
||||||
for t in self.templates])
|
for t in self.templates)
|
||||||
return css
|
return css
|
||||||
|
|
||||||
def _rewriteFont(self, font):
|
def _rewriteFont(self, font):
|
||||||
|
@ -147,7 +147,7 @@ insert or replace into models values (?, ?, ?, ?, ?, ?, ?)""",
|
||||||
|
|
||||||
def fieldMap(self):
|
def fieldMap(self):
|
||||||
"Mapping of field name -> (ord, field)."
|
"Mapping of field name -> (ord, field)."
|
||||||
return dict([(f['name'], (f['ord'], f)) for f in self.fields])
|
return dict((f['name'], (f['ord'], f)) for f in self.fields)
|
||||||
|
|
||||||
def sortIdx(self):
|
def sortIdx(self):
|
||||||
return self.conf['sortf']
|
return self.conf['sortf']
|
||||||
|
@ -262,7 +262,7 @@ where mid = ?) and ord > ?""", self.id, ord)
|
||||||
oldidx = self.templates.index(template)
|
oldidx = self.templates.index(template)
|
||||||
if oldidx == idx:
|
if oldidx == idx:
|
||||||
return
|
return
|
||||||
oldidxs = dict([(id(t), t['ord']) for t in self.templates])
|
oldidxs = dict((id(t), t['ord']) for t in self.templates)
|
||||||
self.templates.remove(template)
|
self.templates.remove(template)
|
||||||
self.templates.insert(idx, template)
|
self.templates.insert(idx, template)
|
||||||
self._updateTemplOrds()
|
self._updateTemplOrds()
|
||||||
|
|
Loading…
Reference in a new issue