Example #1
0
 def _create_page(self, title, idref, filename, f, archive, order):
     '''Create an HTML page and associate it with the archive'''
     html = HTMLFile(
                     title=title, 
                     idref=idref,
                     filename=filename,
                     file=f,
                     archive=archive,
                     order=order)
     try:
         html.save()
     except DjangoUnicodeDecodeError:
         raise InvalidEpubException(_("There was a problem related to the encoding of one of the documents in your ePub. All ePub documents must be in UTF-8."))
     except _mysql_exceptions.Warning:
         raise InvalidEpubException(_("There was a problem related to the encoding of one of the documents in your ePub. All ePub documents must be in UTF-8."))
     except MySQLdb.OperationalError, e:
         if 'Incorrect string value' in str(e):
             raise InvalidEpubException(_("There was a problem related to the encoding of one of the documents in your ePub. All ePub documents must be in UTF-8."))
         else:
             raise e
Example #2
0
    def insert_html(self, html_string, url, url_id):
        xpath = self.get_xpath_by_url_id(url_id)
        try:
            if xpath != '':
                div = self.get_div_content_by_xpath(html_string, xpath)
            else:
                div = self.get_div_content(html_string)
        except Exception as ex:
            log.error(ex.message)
            return

        if html_string == "could not open page":
            return
        dt = datetime.now()
        try:
            html = Htmls(html=html_string, datetime=dt, urlType=url_id, checked=0,
                         date=dt.strftime("%d.%m.%Y"), time=dt.strftime("%X"), url=url, div=div)
            html.save()
        except:
            log.error('Error inserting data' + sys.exc_info()[0])
Example #3
0
        html.save()
        

    def _blob_class(self):
        return EpubBlob

    class Meta:
        ordering = ('-created_time', 'title')

    def __unicode__(self):
        return u'%s by %s (%s)' % (self.title, self.author, self.name)


class BookAuthor(BookwormModel):
    '''Authors are not normalized as there is try:
            html.save()
        except DjangoUnicodeDecodeError:
            raise InvalidEpubException(_("There was a problem related to the encoding of one of the documents in your ePub. All ePub documents must be in UTF-8."))
        except _mysql_exceptions.Warning:
            raise InvalidEpubException(_("There was a problem related to the encoding of one of the documents in your ePub. All ePub documents must be in UTF-8."))
        except MySQLdb.OperationalError, e:
            if 'Incorrect string value' in str(e):
                raise InvalidEpubException(_("There was a problem related to the encoding of one of the documents in your ePub. All ePub documents must be in UTF-8."))
            else:
                raise e
u    def _get_metadata(self, metadata_tag, opf, plural=False, as_string=False, as_list=False):
        '''Returns a metdata item's text content by tag name, or a list if mulitple names match.
        If as_string is set to True, then always return a comma-delimited string.'''
        if self._parsed_metadata is None:
            try:
                self._parsed_metadata = util.xml_from_string(opf)