CamelCase class names the PEP-8 way.

This commit is contained in:
Marshall T. Vandegrift 2008-12-11 08:03:51 -05:00
parent 96dbea5394
commit ee23d9bcde
2 changed files with 12 additions and 12 deletions

View File

@ -417,7 +417,7 @@ class Guide(object):
return elem return elem
class Toc(object): class TOC(object):
def __init__(self, title=None, href=None, klass=None, id=None): def __init__(self, title=None, href=None, klass=None, id=None):
self.title = title self.title = title
self.href = urlnormalize(href) if href else href self.href = urlnormalize(href) if href else href
@ -426,7 +426,7 @@ class Toc(object):
self.nodes = [] self.nodes = []
def add(self, title, href, klass=None, id=None): def add(self, title, href, klass=None, id=None):
node = Toc(title, href, klass, id) node = TOC(title, href, klass, id)
self.nodes.append(node) self.nodes.append(node)
return node return node
@ -468,7 +468,7 @@ class Toc(object):
return parent return parent
class Oeb(object): class OEBBook(object):
def __init__(self, opfpath, container=None): def __init__(self, opfpath, container=None):
if not container: if not container:
container = DirContainer(os.path.dirname(opfpath)) container = DirContainer(os.path.dirname(opfpath))
@ -571,7 +571,7 @@ class Oeb(object):
ncx = self.manifest[id].data ncx = self.manifest[id].data
self.manifest.remove(id) self.manifest.remove(id)
title = xpath(ncx, 'ncx:docTitle/ncx:text/text()')[0] title = xpath(ncx, 'ncx:docTitle/ncx:text/text()')[0]
self.toc = toc = Toc(title) self.toc = toc = TOC(title)
navmaps = xpath(ncx, 'ncx:navMap') navmaps = xpath(ncx, 'ncx:navMap')
for navmap in navmaps: for navmap in navmaps:
self._toc_from_navpoint(toc, navmap) self._toc_from_navpoint(toc, navmap)
@ -582,7 +582,7 @@ class Oeb(object):
if not result: if not result:
return False return False
tour = result[0] tour = result[0]
self.toc = toc = Toc(tour.get('title')) self.toc = toc = TOC(tour.get('title'))
sites = xpath(tour, 'o2:site') sites = xpath(tour, 'o2:site')
for site in sites: for site in sites:
toc.add(site.get('title'), site.get('href')) toc.add(site.get('title'), site.get('href'))
@ -591,7 +591,7 @@ class Oeb(object):
def _toc_from_html(self, opf): def _toc_from_html(self, opf):
if 'toc' not in self.guide: if 'toc' not in self.guide:
return False return False
self.toc = toc = Toc() self.toc = toc = TOC()
itempath, frag = urldefrag(self.guide['toc'].href) itempath, frag = urldefrag(self.guide['toc'].href)
item = self.manifest.hrefs[itempath] item = self.manifest.hrefs[itempath]
html = item.data html = item.data
@ -620,7 +620,7 @@ class Oeb(object):
return True return True
def _toc_from_spine(self, opf): def _toc_from_spine(self, opf):
self.toc = toc = Toc() self.toc = toc = TOC()
titles = [] titles = []
headers = [] headers = []
for item in self.spine: for item in self.spine:
@ -720,7 +720,7 @@ class Oeb(object):
def main(argv=sys.argv): def main(argv=sys.argv):
for arg in argv[1:]: for arg in argv[1:]:
oeb = Oeb(arg) oeb = OEBBook(arg)
for name, doc in oeb.to_opf1().values(): for name, doc in oeb.to_opf1().values():
print etree.tostring(doc, pretty_print=True) print etree.tostring(doc, pretty_print=True)
for name, doc in oeb.to_opf2().values(): for name, doc in oeb.to_opf2().values():

View File

@ -15,10 +15,10 @@ from urllib import unquote as urlunquote
from lxml import etree from lxml import etree
from calibre.ebooks.lit.reader import msguid, DirectoryEntry from calibre.ebooks.lit.reader import msguid, DirectoryEntry
import calibre.ebooks.lit.maps as maps import calibre.ebooks.lit.maps as maps
from calibre.ebooks.lit.oeb import OEB_CSS_MIME, CSS_MIME, XHTML_MIME, \ from calibre.ebooks.lit.oeb import OEB_STYLES, OEB_CSS_MIME, CSS_MIME, \
OPF_MIME, OEB_STYLES, OEB_DOCS, XML_NS, XML XHTML_MIME, OPF_MIME, XML_NS, XML
from calibre.ebooks.lit.oeb import namespace, barename, urlnormalize from calibre.ebooks.lit.oeb import namespace, barename, urlnormalize
from calibre.ebooks.lit.oeb import Oeb from calibre.ebooks.lit.oeb import OEBBook
from calibre.ebooks.lit.stylizer import Stylizer from calibre.ebooks.lit.stylizer import Stylizer
from calibre.ebooks.lit.lzxcomp import Compressor from calibre.ebooks.lit.lzxcomp import Compressor
import calibre import calibre
@ -676,7 +676,7 @@ def main(argv=sys.argv):
if litpath is None: if litpath is None:
litpath = os.path.basename(opfpath) litpath = os.path.basename(opfpath)
litpath = os.path.splitext(litpath)[0] + '.lit' litpath = os.path.splitext(litpath)[0] + '.lit'
lit = LitWriter(Oeb(opfpath)) lit = LitWriter(OEBBook(opfpath))
with open(litpath, 'wb') as f: with open(litpath, 'wb') as f:
lit.dump(f) lit.dump(f)
print _('LIT ebook created at'), litpath print _('LIT ebook created at'), litpath