Merge from custcol trunk

This commit is contained in:
Charles Haley 2010-05-11 18:10:50 +01:00
commit 49e1ca506e
8 changed files with 24 additions and 20 deletions

View File

@ -4,7 +4,6 @@ __license__ = 'GPL v3'
__copyright__ = '2009, Kovid Goyal <kovid@kovidgoyal.net>' __copyright__ = '2009, Kovid Goyal <kovid@kovidgoyal.net>'
__docformat__ = 'restructuredtext en' __docformat__ = 'restructuredtext en'
import os
from calibre.devices.usbms.driver import USBMS from calibre.devices.usbms.driver import USBMS
class HTC_TD2(USBMS): class HTC_TD2(USBMS):
@ -13,7 +12,7 @@ class HTC_TD2(USBMS):
gui_name = 'HTC TD2' gui_name = 'HTC TD2'
description = _('Communicate with HTC TD2 phones.') description = _('Communicate with HTC TD2 phones.')
author = 'Charles Haley' author = 'Charles Haley'
supported_platforms = ['windows'] supported_platforms = ['osx', 'linux']
# Ordered list of supported formats # Ordered list of supported formats
FORMATS = ['epub', 'pdf'] FORMATS = ['epub', 'pdf']
@ -31,8 +30,7 @@ class HTC_TD2(USBMS):
VENDOR_NAME = [''] VENDOR_NAME = ['']
WINDOWS_MAIN_MEM = [''] WINDOWS_MAIN_MEM = ['']
# OSX_MAIN_MEM = 'HTC TD2 Phone Media' MAIN_MEMORY_VOLUME_LABEL = 'HTC Phone Internal Memory'
# MAIN_MEMORY_VOLUME_LABEL = 'HTC Phone Internal Memory'
SUPPORTS_SUB_DIRS = True SUPPORTS_SUB_DIRS = True

View File

@ -11,6 +11,7 @@ import time
from calibre.ebooks.metadata import MetaInformation from calibre.ebooks.metadata import MetaInformation
from calibre.devices.mime import mime_type_ext from calibre.devices.mime import mime_type_ext
from calibre.devices.interface import BookList as _BookList from calibre.devices.interface import BookList as _BookList
from calibre.constants import filesystem_encoding
class Book(MetaInformation): class Book(MetaInformation):
@ -51,7 +52,7 @@ class Book(MetaInformation):
spath = unicode(self.path) spath = unicode(self.path)
except: except:
try: try:
spath = self.path.decode('utf-8') spath = self.path.decode(filesystem_encoding)
except: except:
spath = self.path spath = self.path
if not isinstance(other.path, unicode): if not isinstance(other.path, unicode):
@ -59,7 +60,7 @@ class Book(MetaInformation):
opath = unicode(other.path) opath = unicode(other.path)
except: except:
try: try:
opath = other.path.decode('utf-8') opath = other.path.decode(filesystem_encoding)
except: except:
opath = other.path opath = other.path

View File

@ -14,7 +14,6 @@ import os
import re import re
import json import json
from itertools import cycle from itertools import cycle
from calibre.utils.date import now
from calibre.devices.usbms.cli import CLI from calibre.devices.usbms.cli import CLI
from calibre.devices.usbms.device import Device from calibre.devices.usbms.device import Device
@ -38,7 +37,6 @@ class USBMS(CLI, Device):
def books(self, oncard=None, end_session=True): def books(self, oncard=None, end_session=True):
from calibre.ebooks.metadata.meta import path_to_ext from calibre.ebooks.metadata.meta import path_to_ext
start_time = now()
bl = BookList() bl = BookList()
metadata = BookList() metadata = BookList()
need_sync = False need_sync = False
@ -58,16 +56,13 @@ class USBMS(CLI, Device):
self.EBOOK_DIR_CARD_B if oncard == 'cardb' else \ self.EBOOK_DIR_CARD_B if oncard == 'cardb' else \
self.get_main_ebook_dir() self.get_main_ebook_dir()
#print 'after booklist get', now() - start_time
bl, need_sync = self.parse_metadata_cache(prefix, self.METADATA_CACHE) bl, need_sync = self.parse_metadata_cache(prefix, self.METADATA_CACHE)
#print 'after parse_metadata_cache', now() - start_time
# make a dict cache of paths so the lookup in the loop below is faster. # make a dict cache of paths so the lookup in the loop below is faster.
bl_cache = {} bl_cache = {}
for idx,b in enumerate(bl): for idx,b in enumerate(bl):
bl_cache[b.path] = idx bl_cache[b.path] = idx
self.count_found_in_bl = 0 self.count_found_in_bl = 0
#print 'after make cache', now() - start_time
def update_booklist(filename, path, prefix): def update_booklist(filename, path, prefix):
changed = False changed = False
@ -122,7 +117,6 @@ class USBMS(CLI, Device):
self.sync_booklists((metadata, None, None)) self.sync_booklists((metadata, None, None))
self.report_progress(1.0, _('Getting list of books on device...')) self.report_progress(1.0, _('Getting list of books on device...'))
#print 'at return', now() - start_time
return metadata return metadata
def upload_books(self, files, names, on_card=None, end_session=True, def upload_books(self, files, names, on_card=None, end_session=True,
@ -218,7 +212,6 @@ class USBMS(CLI, Device):
self.report_progress(1.0, _('Removing books from device metadata listing...')) self.report_progress(1.0, _('Removing books from device metadata listing...'))
def sync_booklists(self, booklists, end_session=True): def sync_booklists(self, booklists, end_session=True):
print 'in sync_booklists'
if not os.path.exists(self._main_prefix): if not os.path.exists(self._main_prefix):
os.makedirs(self._main_prefix) os.makedirs(self._main_prefix)
@ -270,7 +263,6 @@ class USBMS(CLI, Device):
@classmethod @classmethod
def metadata_from_path(cls, path): def metadata_from_path(cls, path):
print 'here'
return cls.metadata_from_formats([path]) return cls.metadata_from_formats([path])
@classmethod @classmethod

View File

@ -10,7 +10,7 @@ import os, mimetypes, sys, re
from urllib import unquote, quote from urllib import unquote, quote
from urlparse import urlparse from urlparse import urlparse
from calibre import relpath from calibre import relpath, prints
from calibre.utils.config import tweaks from calibre.utils.config import tweaks
from calibre.utils.date import isoformat from calibre.utils.date import isoformat
@ -254,14 +254,13 @@ class MetaInformation(object):
setattr(self, x, getattr(mi, x, None)) setattr(self, x, getattr(mi, x, None))
def print_all_attributes(self): def print_all_attributes(self):
print 'here'
for x in ('author_sort', 'title_sort', 'comments', 'category', 'publisher', for x in ('author_sort', 'title_sort', 'comments', 'category', 'publisher',
'series', 'series_index', 'rating', 'isbn', 'language', 'series', 'series_index', 'rating', 'isbn', 'language',
'application_id', 'manifest', 'toc', 'spine', 'guide', 'cover', 'application_id', 'manifest', 'toc', 'spine', 'guide', 'cover',
'book_producer', 'timestamp', 'lccn', 'lcc', 'ddc', 'pubdate', 'book_producer', 'timestamp', 'lccn', 'lcc', 'ddc', 'pubdate',
'rights', 'publication_type', 'uuid', 'rights', 'publication_type', 'uuid',
): ):
print x, getattr(self, x, 'None') prints(x, getattr(self, x, 'None'))
def smart_update(self, mi): def smart_update(self, mi):
''' '''

View File

@ -17,7 +17,7 @@ from PyQt4.QtCore import QAbstractTableModel, QVariant, Qt, pyqtSignal, \
SIGNAL, QObject, QSize, QModelIndex, QDate SIGNAL, QObject, QSize, QModelIndex, QDate
from calibre import strftime from calibre import strftime
from calibre.ebooks.metadata import string_to_authors, fmt_sidx, authors_to_string from calibre.ebooks.metadata import fmt_sidx, authors_to_string
from calibre.ebooks.metadata.meta import set_metadata as _set_metadata from calibre.ebooks.metadata.meta import set_metadata as _set_metadata
from calibre.gui2 import NONE, TableView, config, error_dialog, UNDEFINED_QDATE from calibre.gui2 import NONE, TableView, config, error_dialog, UNDEFINED_QDATE
from calibre.gui2.dialogs.comments_dialog import CommentsDialog from calibre.gui2.dialogs.comments_dialog import CommentsDialog

View File

@ -73,7 +73,7 @@ def get_library_path():
except: except:
error_dialog(None, _('Failed to create library'), error_dialog(None, _('Failed to create library'),
_('Failed to create calibre library at: %r. Aborting.')%library_path, _('Failed to create calibre library at: %r. Aborting.')%library_path,
det_msg = traceback.print_exc(), show=True) det_msg=traceback.format_exc(), show=True)
library_path = None library_path = None
return library_path return library_path

View File

@ -533,3 +533,17 @@ The .cbc file will then contain::
|app| will automatically convert this .cbc file into a e-book with a Table of Contents pointing to each entry in comics.txt. |app| will automatically convert this .cbc file into a e-book with a Table of Contents pointing to each entry in comics.txt.
EPUB advanced formatting demo
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Various advanced formatting for EPUB files is demonstrated in this `demo file <http://calibre-ebook.com/downloads/demos/demo.epub>`_.
The file was created from hand coded HTML using calibre and is meant to be used as a template for your own EPUB creation efforts.
The source HTML it was created from is available `here <http://calibre-ebook.com/downloads/demos/demo.zip>`_. The settings used to create the
EPUB from the ZIP file are::
ebook-convert demo.zip .epub -vv --authors "Kovid Goyal" --language en --level1-toc '//*[@class="title"]' --disable-font-rescaling --page-breaks-before / --no-default-epub-cover
Note that because this file explores the potential of EPUB, most of the advanced formatting is not going to work on readers less capable than |app|'s builtin EPUB viewer.

View File

@ -1266,7 +1266,7 @@ class BasicNewsRecipe(Recipe):
feed = Feed() feed = Feed()
msg = 'Failed feed: %s'%(title if title else url) msg = 'Failed feed: %s'%(title if title else url)
feed.populate_from_preparsed_feed(msg, []) feed.populate_from_preparsed_feed(msg, [])
feed.description = unicode(err) feed.description = repr(err)
parsed_feeds.append(feed) parsed_feeds.append(feed)
self.log.exception(msg) self.log.exception(msg)