예제 #1
0
파일: books.py 프로젝트: Eksmo/calibre
    def __init__(self, root="/Data/media/", sfile=None):
        _BookList.__init__(self)
        self.tag_order = {}
        self.root = self.document = self.proot = None
        if sfile:
            sfile.seek(0)
            src = sfile.read()
            try:
                src = src.decode('utf8')
            except UnicodeDecodeError:
                try:
                    src = src.decode('latin1')
                except UnicodeDecodeError:
                    src = src.decode('cp1252')
            src = src.replace('<cache:', '<xs1:').replace('</cache:', '</xs1:').replace('xmlns:cache', 'xmlns:xs1')
            self.document = dom.parseString(src.encode('utf8'))
            self.root = self.document.documentElement
            self.prefix = ''
            records = self.root.getElementsByTagName('records')
            if records:
                self.prefix = 'xs1:'
                self.root = records[0]
            self.proot = root

            for book in self.document.getElementsByTagName(self.prefix + "text"):
                id = book.getAttribute('id')
                pl = [i.getAttribute('title') for i in self.get_playlists(id)]
                self.append(Book(book, root=root, prefix=self.prefix, tags=pl))
예제 #2
0
파일: books.py 프로젝트: j-howell/calibre
 def __init__(self, oncard, prefix, settings):
     _BookList.__init__(self, oncard, prefix, settings)
     self._bookmap = {}
예제 #3
0
 def __init__(self, oncard, prefix, settings):
     _BookList.__init__(self, oncard, prefix, settings)
     self._bookmap = {}