From: Jan Szejko Date: Wed, 29 Jun 2016 16:17:34 +0000 (+0200) Subject: clean unused and non-working methods X-Git-Url: https://git.mdrn.pl/librarian.git/commitdiff_plain/d261b56ed55aad8c4f2111570c8a21feae4b9937?ds=inline clean unused and non-working methods --- diff --git a/librarian/epub.py b/librarian/epub.py index 0c7a16c..8141eea 100644 --- a/librarian/epub.py +++ b/librarian/epub.py @@ -17,7 +17,6 @@ from tempfile import mkdtemp, NamedTemporaryFile from shutil import rmtree from librarian import RDFNS, WLNS, NCXNS, OPFNS, XHTMLNS, IOFile -from librarian.cover import WLCover from librarian import functions, get_resource @@ -396,11 +395,11 @@ def transform(wldoc, verbose=False, add_to_spine(spine, chunk_counter) chunk_counter += 1 - for child in wldoc.parts(): - child_toc, chunk_counter, chunk_chars, sample = transform_file( - child, chunk_counter, first=False, sample=sample) - toc.append(child_toc) - chars = chars.union(chunk_chars) + # for child in wldoc.parts(): + # child_toc, chunk_counter, chunk_chars, sample = transform_file( + # child, chunk_counter, first=False, sample=sample) + # toc.append(child_toc) + # chars = chars.union(chunk_chars) return toc, chunk_counter, chars, sample @@ -413,8 +412,8 @@ def transform(wldoc, verbose=False, document.edoc.getroot().set(flag, 'yes') # add editors info - document.edoc.getroot().set('editors', u', '.join(sorted( - editor.readable() for editor in document.editors()))) + # document.edoc.getroot().set('editors', u', '.join(sorted( + # editor.readable() for editor in document.editors()))) opf = xslt(document.book_info.to_etree(), get_resource('epub/xsltContent.xsl')) manifest = opf.find('.//' + OPFNS('manifest')) @@ -442,9 +441,6 @@ def transform(wldoc, verbose=False, zip.write(style, os.path.join('OPS', 'style.css')) if cover: - if cover is True: - cover = WLCover - cover_file = StringIO() bound_cover = cover(document.book_info) bound_cover.save(cover_file) diff --git a/librarian/parser.py b/librarian/parser.py index fb2f986..9300aa6 100644 --- a/librarian/parser.py +++ b/librarian/parser.py @@ -75,10 +75,7 @@ class WLDocument(object): @classmethod def from_file(cls, xmlfile, *args, **kwargs): - if isinstance(xmlfile, basestring): - iofile = IOFile.from_filename(xmlfile) - else: - iofile = IOFile.from_file(xmlfile) + iofile = IOFile.from_filename(xmlfile) return cls(iofile, *args, **kwargs) @@ -103,15 +100,6 @@ class WLDocument(object): elem.insert(0, ins) elem.text = chunks.pop(0) - def parts(self): - if self.book_info is None: - raise NoDublinCore('No Dublin Core in document.') - if self.book_info.parts and self.provider is None: - raise NoProvider('No document provider supplied.') - for part_uri in self.book_info.parts: - yield self.from_file(self.provider.by_uri(part_uri), - provider=self.provider) - def chunk(self, path): # convert the path to XPath expr = self.path_to_xpath(path) @@ -174,21 +162,6 @@ class WLDocument(object): node.tag = 'span' node.tail = tail - def editors(self): - """Returns a set of all editors for book and its children. - - :returns: set of dcparser.Person objects - """ - if self.book_info is None: - raise NoDublinCore('No Dublin Core in document.') - persons = set(self.book_info.editors + - self.book_info.technical_editors) - for child in self.parts(): - persons.update(child.editors()) - if None in persons: - persons.remove(None) - return persons - # Converters def as_html(self, *args, **kwargs): diff --git a/librarian/pdf.py b/librarian/pdf.py index 03879fe..7889a22 100644 --- a/librarian/pdf.py +++ b/librarian/pdf.py @@ -173,6 +173,7 @@ def package_available(package, args='', verbose=False): return p == 0 +# not used def load_including_children(wldoc=None, provider=None, uri=None): """ Makes one big xml file with children inserted at end. @@ -181,6 +182,7 @@ def load_including_children(wldoc=None, provider=None, uri=None): if uri and provider: f = provider.by_uri(uri) + # WTF DocProvider.by_uri() returns IOFile, so no .read() there text = f.read().decode('utf-8') f.close() elif wldoc is not None: @@ -229,29 +231,8 @@ class PDFFormat(Format): """ For use in XSLT. """ return u','.join(k for k, v in self.customization.items() if v) - def get_document(self): - document = load_including_children(self.wldoc) - root = document.edoc.getroot() - root.set('editors', u', '.join(sorted( - editor.readable() for editor in document.editors()))) - - # hack the tree - move_motifs_inside(document.edoc) - hack_motifs(document.edoc) - parse_creator(document.edoc) - substitute_hyphens(document.edoc) - fix_hanging(document.edoc) - return document - def get_texml(self): - style_filename = get_stylesheet("wl2tex") - functions.reg_get(self) - try: - style = etree.parse(style_filename) - texml = self.get_document().transform(style) - return texml - except (XMLSyntaxError, XSLTApplyError), e: - raise ParseError(e) + raise NotImplementedError def get_tex_dir(self): texml = self.get_texml()