mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
pep8
This commit is contained in:
parent
050583ba9d
commit
a939e721d1
@ -18,12 +18,14 @@ def get_opts_from_parser(parser):
|
|||||||
for x in opt._short_opts:
|
for x in opt._short_opts:
|
||||||
yield x
|
yield x
|
||||||
for o in parser.option_list:
|
for o in parser.option_list:
|
||||||
for x in do_opt(o): yield x
|
for x in do_opt(o):
|
||||||
|
yield x
|
||||||
for g in parser.option_groups:
|
for g in parser.option_groups:
|
||||||
for o in g.option_list:
|
for o in g.option_list:
|
||||||
for x in do_opt(o): yield x
|
for x in do_opt(o):
|
||||||
|
yield x
|
||||||
|
|
||||||
class Coffee(Command): # {{{
|
class Coffee(Command): # {{{
|
||||||
|
|
||||||
description = 'Compile coffeescript files into javascript'
|
description = 'Compile coffeescript files into javascript'
|
||||||
COFFEE_DIRS = ('ebooks/oeb/display', 'ebooks/oeb/polish')
|
COFFEE_DIRS = ('ebooks/oeb/display', 'ebooks/oeb/polish')
|
||||||
@ -112,7 +114,7 @@ class Coffee(Command): # {{{
|
|||||||
os.remove(x)
|
os.remove(x)
|
||||||
# }}}
|
# }}}
|
||||||
|
|
||||||
class Kakasi(Command): # {{{
|
class Kakasi(Command): # {{{
|
||||||
|
|
||||||
description = 'Compile resources for unihandecode'
|
description = 'Compile resources for unihandecode'
|
||||||
|
|
||||||
@ -155,29 +157,29 @@ class Kakasi(Command): # {{{
|
|||||||
dic = {}
|
dic = {}
|
||||||
for line in open(src, "r"):
|
for line in open(src, "r"):
|
||||||
line = line.decode("utf-8").strip()
|
line = line.decode("utf-8").strip()
|
||||||
if line.startswith(';;'): # skip comment
|
if line.startswith(';;'): # skip comment
|
||||||
continue
|
continue
|
||||||
if re.match(r"^$",line):
|
if re.match(r"^$",line):
|
||||||
continue
|
continue
|
||||||
pair = re.sub(r'\\u([0-9a-fA-F]{4})', lambda x:unichr(int(x.group(1),16)), line)
|
pair = re.sub(r'\\u([0-9a-fA-F]{4})', lambda x:unichr(int(x.group(1),16)), line)
|
||||||
dic[pair[0]] = pair[1]
|
dic[pair[0]] = pair[1]
|
||||||
cPickle.dump(dic, open(dst, 'wb'), protocol=-1) #pickle
|
cPickle.dump(dic, open(dst, 'wb'), protocol=-1) # pickle
|
||||||
|
|
||||||
def mkkanadict(self, src, dst):
|
def mkkanadict(self, src, dst):
|
||||||
dic = {}
|
dic = {}
|
||||||
for line in open(src, "r"):
|
for line in open(src, "r"):
|
||||||
line = line.decode("utf-8").strip()
|
line = line.decode("utf-8").strip()
|
||||||
if line.startswith(';;'): # skip comment
|
if line.startswith(';;'): # skip comment
|
||||||
continue
|
continue
|
||||||
if re.match(r"^$",line):
|
if re.match(r"^$",line):
|
||||||
continue
|
continue
|
||||||
(alpha, kana) = line.split(' ')
|
(alpha, kana) = line.split(' ')
|
||||||
dic[kana] = alpha
|
dic[kana] = alpha
|
||||||
cPickle.dump(dic, open(dst, 'wb'), protocol=-1) #pickle
|
cPickle.dump(dic, open(dst, 'wb'), protocol=-1) # pickle
|
||||||
|
|
||||||
def parsekdict(self, line):
|
def parsekdict(self, line):
|
||||||
line = line.decode("utf-8").strip()
|
line = line.decode("utf-8").strip()
|
||||||
if line.startswith(';;'): # skip comment
|
if line.startswith(';;'): # skip comment
|
||||||
return
|
return
|
||||||
(yomi, kanji) = line.split(' ')
|
(yomi, kanji) = line.split(' ')
|
||||||
if ord(yomi[-1:]) <= ord('z'):
|
if ord(yomi[-1:]) <= ord('z'):
|
||||||
@ -193,7 +195,7 @@ class Kakasi(Command): # {{{
|
|||||||
if kanji in self.records[key]:
|
if kanji in self.records[key]:
|
||||||
rec = self.records[key][kanji]
|
rec = self.records[key][kanji]
|
||||||
rec.append((yomi,tail))
|
rec.append((yomi,tail))
|
||||||
self.records[key].update( {kanji: rec} )
|
self.records[key].update({kanji: rec})
|
||||||
else:
|
else:
|
||||||
self.records[key][kanji]=[(yomi, tail)]
|
self.records[key][kanji]=[(yomi, tail)]
|
||||||
else:
|
else:
|
||||||
@ -213,7 +215,7 @@ class Kakasi(Command): # {{{
|
|||||||
shutil.rmtree(kakasi)
|
shutil.rmtree(kakasi)
|
||||||
# }}}
|
# }}}
|
||||||
|
|
||||||
class Resources(Command): # {{{
|
class Resources(Command): # {{{
|
||||||
|
|
||||||
description = 'Compile various needed calibre resources'
|
description = 'Compile various needed calibre resources'
|
||||||
sub_commands = ['kakasi', 'coffee']
|
sub_commands = ['kakasi', 'coffee']
|
||||||
@ -255,7 +257,6 @@ class Resources(Command): # {{{
|
|||||||
with open(n, 'rb') as f:
|
with open(n, 'rb') as f:
|
||||||
zf.writestr(os.path.basename(n), f.read())
|
zf.writestr(os.path.basename(n), f.read())
|
||||||
|
|
||||||
|
|
||||||
dest = self.j(self.RESOURCES, 'ebook-convert-complete.pickle')
|
dest = self.j(self.RESOURCES, 'ebook-convert-complete.pickle')
|
||||||
files = []
|
files = []
|
||||||
for x in os.walk(self.j(self.SRC, 'calibre')):
|
for x in os.walk(self.j(self.SRC, 'calibre')):
|
||||||
|
Loading…
x
Reference in New Issue
Block a user