mirror of
https://github.com/gryf/ebook-converter.git
synced 2026-04-16 02:53:33 +02:00
Removed facade on os.walk.
This commit is contained in:
@@ -5,7 +5,6 @@ import sys
|
||||
|
||||
from lxml import etree
|
||||
|
||||
from ebook_converter import walk
|
||||
from ebook_converter.ebooks.metadata import authors_to_sort_string
|
||||
from ebook_converter.ebooks.metadata import string_to_authors
|
||||
from ebook_converter.ebooks.metadata.book.base import Metadata
|
||||
@@ -113,9 +112,11 @@ class DOCX(object):
|
||||
extractall(stream, self.tdir)
|
||||
|
||||
self.names = {}
|
||||
for f in walk(self.tdir):
|
||||
name = os.path.relpath(f, self.tdir).replace(os.sep, '/')
|
||||
self.names[name] = f
|
||||
for root, _, fnames in os.walk(self.tdir):
|
||||
for f in fnames:
|
||||
f = os.path.join(root, f)
|
||||
name = os.path.relpath(f, self.tdir).replace(os.sep, '/')
|
||||
self.names[name] = f
|
||||
|
||||
def exists(self, name):
|
||||
return name in self.names
|
||||
|
||||
@@ -3,23 +3,24 @@ import shutil
|
||||
|
||||
from lxml import etree
|
||||
|
||||
from ebook_converter import walk
|
||||
from ebook_converter.utils.zipfile import ZipFile
|
||||
from ebook_converter.utils.xml_parse import safe_xml_fromstring
|
||||
|
||||
|
||||
def pretty_all_xml_in_dir(path):
|
||||
for f in walk(path):
|
||||
if f.endswith('.xml') or f.endswith('.rels'):
|
||||
with open(f, 'r+b') as stream:
|
||||
raw = stream.read()
|
||||
if raw:
|
||||
root = safe_xml_fromstring(raw)
|
||||
stream.seek(0)
|
||||
stream.truncate()
|
||||
stream.write(etree.tostring(root, pretty_print=True,
|
||||
encoding='utf-8',
|
||||
xml_declaration=True))
|
||||
for root, _, fnames in os.walk(path):
|
||||
for f in fnames:
|
||||
f = os.path.join(root, f)
|
||||
if f.endswith('.xml') or f.endswith('.rels'):
|
||||
with open(f, 'r+b') as stream:
|
||||
raw = stream.read()
|
||||
if raw:
|
||||
root = safe_xml_fromstring(raw)
|
||||
stream.seek(0)
|
||||
stream.truncate()
|
||||
stream.write(etree.tostring(root, pretty_print=True,
|
||||
encoding='utf-8',
|
||||
xml_declaration=True))
|
||||
|
||||
|
||||
def do_dump(path, dest):
|
||||
|
||||
Reference in New Issue
Block a user