Пример #1
0
    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
 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 = {}