From cced0c3391e7efa85a46ac76767622ef8f5e31f3 Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Sun, 10 Oct 2010 11:53:08 -0600 Subject: [PATCH 1/5] Fix #7125 (Request: Date/time added sort in interface) --- src/calibre/gui2/dialogs/metadata_single.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/calibre/gui2/dialogs/metadata_single.py b/src/calibre/gui2/dialogs/metadata_single.py index b39b752ac6..4c24365196 100644 --- a/src/calibre/gui2/dialogs/metadata_single.py +++ b/src/calibre/gui2/dialogs/metadata_single.py @@ -25,7 +25,7 @@ from calibre.ebooks.metadata.covers import download_cover from calibre.ebooks.metadata.meta import get_metadata from calibre.ebooks.metadata import MetaInformation from calibre.utils.config import prefs, tweaks -from calibre.utils.date import qt_to_dt, local_tz, utcfromtimestamp +from calibre.utils.date import qt_to_dt, local_tz, utcfromtimestamp, utc_tz from calibre.customize.ui import run_plugins_on_import, get_isbndb_key from calibre.gui2.preferences.social import SocialMetadata from calibre.gui2.custom_column_widgets import populate_metadata_page @@ -434,7 +434,7 @@ class MetadataSingleDialog(ResizableDialog, Ui_MetadataSingleDialog): self.pubdate.setDate(QDate(pubdate.year, pubdate.month, pubdate.day)) timestamp = db.timestamp(self.id, index_is_id=True) - self.orig_timestamp = timestamp + self.orig_timestamp = timestamp.astimezone(utc_tz) self.date.setDate(QDate(timestamp.year, timestamp.month, timestamp.day)) From 9d0121b8e3fec7caafa5b4ca99cdd02d558cd9d1 Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Sun, 10 Oct 2010 11:57:21 -0600 Subject: [PATCH 2/5] Revista El Cultural by Jefferson Frantz --- resources/recipes/el_cultural.recipe | 86 ++++++++++++++++++++++++++++ 1 file changed, 86 insertions(+) create mode 100644 resources/recipes/el_cultural.recipe diff --git a/resources/recipes/el_cultural.recipe b/resources/recipes/el_cultural.recipe new file mode 100644 index 0000000000..124343398b --- /dev/null +++ b/resources/recipes/el_cultural.recipe @@ -0,0 +1,86 @@ +from calibre.web.feeds.recipes import BasicNewsRecipe + +class RevistaElCultural(BasicNewsRecipe): + + title = 'Revista El Cultural' + __author__ = 'Jefferson Frantz' + description = 'Revista de cultura' + timefmt = ' [%d %b, %Y]' + language = 'es' + + no_stylesheets = True + remove_javascript = True + + extra_css = 'h1{ font-family: sans-serif; font-size: large; font-weight: bolder; text-align: justify } h2{ font-family: sans-serif; font-size: small; font-weight: 500; text-align: justify } h3{ font-family: sans-serif; font-size: small; font-weight: 500; text-align: justify } h4{ font-family: sans-serif; font-weight: lighter; font-size: medium; font-style: italic; text-align: justify } .rtsArticuloFirma{ font-family: sans-serif; font-size: small; text-align: justify } .column span-13 last{ font-family: sans-serif; font-size: medium; text-align: justify } .rtsImgArticulo{font-family: serif; font-size: small; color: #000000; text-align: justify}' + + + def preprocess_html(self, soup): + for item in soup.findAll(style=True): + del item['style'] + + return soup + + keep_only_tags = [dict(name='div', attrs={'class':['column span-13 last']}),dict(name='div', attrs={'class':['rtsImgArticulo']})] + + remove_tags = [ + dict(name=['object','link','script','ul']) + ,dict(name='div', attrs={'class':['rtsRating']}) + + ] + + + #TO GET ARTICLES IN SECTION + def ec_parse_section(self, url, titleSection): + print 'Section: '+ titleSection + soup = self.index_to_soup(url) + div = soup.find(attrs={'id':'gallery'}) + current_articles = [] + + for a in div.findAllNext('a', href=True): + if a is None: + continue + title = self.tag_to_string(a) + + url = a.get('href', False) + if not url or not title: + continue + + if not url.startswith('/version_papel/'+titleSection+'/'): + if len(current_articles) > 0 and not url.startswith('/secciones/'): + break + continue + + if url.startswith('/version_papel/'+titleSection+'/'): + url = 'http://www.elcultural.es'+url + + self.log('\t\tFound article:', title[0:title.find("|")-1]) + self.log('\t\t\t', url) + current_articles.append({'title': title[0:title.find("|")-1], 'url':url, + 'description':'', 'date':''}) + + return current_articles + + + # To GET SECTIONS + def parse_index(self): + feeds = [] + for title, url in [ + ('LETRAS', + 'http://www.elcultural.es/pdf_sumario/cultural/Sumario_El_Cultural_en_PDF'), + ('ARTE', + 'http://www.elcultural.es/pdf_sumario/cultural/Sumario_El_Cultural_en_PDF'), + ('CINE', + 'http://www.elcultural.es/pdf_sumario/cultural/Sumario_El_Cultural_en_PDF'), + ('CIENCIA', + 'http://www.elcultural.es/pdf_sumario/cultural/Sumario_El_Cultural_en_PDF'), +## ('OPINION', +## 'http://www.elcultural.es/pdf_sumario/cultural/Sumario_El_Cultural_en_PDF'), + ('ESCENARIOS', + 'http://www.elcultural.es/pdf_sumario/cultural/Sumario_El_Cultural_en_PDF'), + ]: + articles = self.ec_parse_section(url,title) + if articles: + feeds.append((title, articles)) + + + return feeds From 85ee22a1fca70b5ff7e69749732c5f077c829878 Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Sun, 10 Oct 2010 12:10:07 -0600 Subject: [PATCH 3/5] ... --- src/calibre/manual/index.rst | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/calibre/manual/index.rst b/src/calibre/manual/index.rst index d63b0b71a9..bc8e8a97c2 100644 --- a/src/calibre/manual/index.rst +++ b/src/calibre/manual/index.rst @@ -17,10 +17,10 @@ To get started with more advanced usage, you should read about the :ref:`Graphic You will find the list of :ref:`Frequently Asked Questions ` useful as well. -.. only:: html and online +.. only:: online + + An e-book version of this User Manual is available in `EPUB format `_. - An e-book version of this User Manual is available in `EPUB format `_. Because the User Manual uses advanced formatting, it is only suitable for use with the |app| e-book viewer. - Sections ------------ From 0030630453fa6efbcb7202bc56e740c266280b3f Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Sun, 10 Oct 2010 12:24:29 -0600 Subject: [PATCH 4/5] Fix #7114 (Problem with title in metadata download) --- src/calibre/ebooks/metadata/isbndb.py | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/src/calibre/ebooks/metadata/isbndb.py b/src/calibre/ebooks/metadata/isbndb.py index 07a054eeaa..83cf6ee0ed 100644 --- a/src/calibre/ebooks/metadata/isbndb.py +++ b/src/calibre/ebooks/metadata/isbndb.py @@ -45,7 +45,7 @@ def fetch_metadata(url, max=100, timeout=5.): class ISBNDBMetadata(Metadata): def __init__(self, book): - Metadata.__init__(self, None, []) + Metadata.__init__(self, None) def tostring(e): if not hasattr(e, 'string'): @@ -58,21 +58,21 @@ class ISBNDBMetadata(Metadata): return ans self.isbn = unicode(book.get('isbn13', book.get('isbn'))) - self.title = tostring(book.find('titlelong')) - if not self.title: - self.title = tostring(book.find('title')) - if not self.title: - self.title = _('Unknown') + title = tostring(book.find('titlelong')) + if not title: + title = tostring(book.find('title')) + self.title = title self.title = unicode(self.title).strip() - self.authors = [] + authors = [] au = tostring(book.find('authorstext')) if au: au = au.strip() temp = au.split(',') for au in temp: if not au: continue - self.authors.extend([a.strip() for a in au.split('&')]) - + authors.extend([a.strip() for a in au.split('&')]) + if authors: + self.authors = authors try: self.author_sort = tostring(book.find('authors').find('person')) if self.authors and self.author_sort == self.authors[0]: From c650488bce88b105e25a8a3e3ef0cb2d0f3ff368 Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Sun, 10 Oct 2010 12:56:48 -0600 Subject: [PATCH 5/5] RTF Input: Fix regression in conversion of WMF images on linux at least, maybe on other platforms as well --- src/calibre/utils/magick/__init__.py | 7 +++++++ src/calibre/utils/magick/magick.c | 22 ++++++++++++++++++++++ 2 files changed, 29 insertions(+) diff --git a/src/calibre/utils/magick/__init__.py b/src/calibre/utils/magick/__init__.py index 3a4fca09c0..bf0f48db7d 100644 --- a/src/calibre/utils/magick/__init__.py +++ b/src/calibre/utils/magick/__init__.py @@ -109,6 +109,13 @@ class Image(_magick.Image): # {{{ return _magick.Image.load(self, bytes(data)) def open(self, path_or_file): + if not hasattr(path_or_file, 'read') and \ + path_or_file.lower().endswith('.wmf'): + # Special handling for WMF files as ImageMagick seems + # to hand while reading them from a blob on linux + if isinstance(path_or_file, unicode): + path_or_file = path_or_file.encode(filesystem_encoding) + return _magick.Image.read(self, path_or_file) data = path_or_file if hasattr(data, 'read'): data = data.read() diff --git a/src/calibre/utils/magick/magick.c b/src/calibre/utils/magick/magick.c index b1436a830b..0aab5f1fd7 100644 --- a/src/calibre/utils/magick/magick.c +++ b/src/calibre/utils/magick/magick.c @@ -414,6 +414,24 @@ magick_Image_load(magick_Image *self, PyObject *args, PyObject *kwargs) { // }}} +// Image.load {{{ +static PyObject * +magick_Image_read(magick_Image *self, PyObject *args, PyObject *kwargs) { + const char *data; + MagickBooleanType res; + + if (!PyArg_ParseTuple(args, "s", &data)) return NULL; + + res = MagickReadImage(self->wand, data); + + if (!res) + return magick_set_exception(self->wand); + + Py_RETURN_NONE; +} + +// }}} + // Image.create_canvas {{{ static PyObject * magick_Image_create_canvas(magick_Image *self, PyObject *args, PyObject *kwargs) @@ -873,6 +891,10 @@ static PyMethodDef magick_Image_methods[] = { "Load an image from a byte buffer (string)" }, + {"read", (PyCFunction)magick_Image_read, METH_VARARGS, + "Read image from path. Path must be a bytestring in the filesystem encoding" + }, + {"export", (PyCFunction)magick_Image_export, METH_VARARGS, "export(format) -> bytestring\n\n Export the image as the specified format" },