mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
pep8
This commit is contained in:
parent
26ad1042a0
commit
6c04e010a5
@ -32,7 +32,7 @@ def check_all_prev_empty(tag):
|
|||||||
return False
|
return False
|
||||||
return check_all_prev_empty(tag.previousSibling)
|
return check_all_prev_empty(tag.previousSibling)
|
||||||
|
|
||||||
def check_empty(s, rex = re.compile(r'\S')):
|
def check_empty(s, rex=re.compile(r'\S')):
|
||||||
return rex.search(s) is None
|
return rex.search(s) is None
|
||||||
|
|
||||||
|
|
||||||
@ -40,6 +40,7 @@ class CHMError(Exception):
|
|||||||
pass
|
pass
|
||||||
|
|
||||||
class CHMReader(CHMFile):
|
class CHMReader(CHMFile):
|
||||||
|
|
||||||
def __init__(self, input, log, input_encoding=None):
|
def __init__(self, input, log, input_encoding=None):
|
||||||
CHMFile.__init__(self)
|
CHMFile.__init__(self)
|
||||||
if isinstance(input, unicode):
|
if isinstance(input, unicode):
|
||||||
@ -73,17 +74,16 @@ class CHMReader(CHMFile):
|
|||||||
else:
|
else:
|
||||||
frag = None
|
frag = None
|
||||||
name = self._deentity(li.object('param', {'name': 'Name'})[0]['value'])
|
name = self._deentity(li.object('param', {'name': 'Name'})[0]['value'])
|
||||||
#print "========>", name
|
# print "========>", name
|
||||||
toc.add_item(href, frag, name, play_order=self._playorder)
|
toc.add_item(href, frag, name, play_order=self._playorder)
|
||||||
self._playorder += 1
|
self._playorder += 1
|
||||||
if li.ul:
|
if li.ul:
|
||||||
child = self._parse_toc(li.ul)
|
child = self._parse_toc(li.ul)
|
||||||
child.parent = toc
|
child.parent = toc
|
||||||
toc.append(child)
|
toc.append(child)
|
||||||
#print toc
|
# print toc
|
||||||
return toc
|
return toc
|
||||||
|
|
||||||
|
|
||||||
def GetFile(self, path):
|
def GetFile(self, path):
|
||||||
# have to have abs paths for ResolveObject, but Contents() deliberately
|
# have to have abs paths for ResolveObject, but Contents() deliberately
|
||||||
# makes them relative. So we don't have to worry, re-add the leading /.
|
# makes them relative. So we don't have to worry, re-add the leading /.
|
||||||
@ -226,7 +226,8 @@ class CHMReader(CHMFile):
|
|||||||
if os.path.exists(ipath):
|
if os.path.exists(ipath):
|
||||||
continue
|
continue
|
||||||
src = src.split(';')[0]
|
src = src.split(';')[0]
|
||||||
if not src: continue
|
if not src:
|
||||||
|
continue
|
||||||
ipath = os.path.join(base, *src.split('/'))
|
ipath = os.path.join(base, *src.split('/'))
|
||||||
if not os.path.exists(ipath):
|
if not os.path.exists(ipath):
|
||||||
while src.startswith('../'):
|
while src.startswith('../'):
|
||||||
@ -277,6 +278,3 @@ class CHMReader(CHMFile):
|
|||||||
|
|
||||||
def extract_content(self, output_dir=os.getcwdu(), debug_dump=False):
|
def extract_content(self, output_dir=os.getcwdu(), debug_dump=False):
|
||||||
self.ExtractFiles(output_dir=output_dir, debug_dump=debug_dump)
|
self.ExtractFiles(output_dir=output_dir, debug_dump=debug_dump)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user