Fix #3047 (Metadata on device, fall back to file name)

This commit is contained in:
Kovid Goyal 2009-08-02 09:52:11 -06:00
commit 444f76fc25
4 changed files with 13 additions and 13 deletions

View File

@ -60,17 +60,15 @@ if __name__ == '__main__':
optional = []
qmake = '/Volumes/sw/qt/bin/qmake' if isosx else 'qmake'
qmake = os.environ.get('QMAKE', qmake)
raw = subprocess.Popen([qmake, '-query'],
def qmake_query(arg=''):
return subprocess.Popen([qmake, '-query', arg],
stdout=subprocess.PIPE).stdout.read()
qt_inc = qt_lib = None
for line in raw.splitlines():
q, _, w = line.partition(':')
if q == 'QT_INSTALL_HEADERS':
qt_inc = w
elif q == 'QT_INSTALL_LIBS':
qt_lib = w
qt_inc = qmake_query('QT_INSTALL_HEADERS').splitlines()[0]
qt_inc = qt_inc if qt_inc not in ('', '**Unknown**') and os.path.isdir(qt_inc) else None
qt_lib = qmake_query('QT_INSTALL_LIBS').splitlines()[0]
qt_lib = qt_lib if qt_lib not in ('', '**Unknown**') and os.path.isdir(qt_lib) else None
if iswindows:
optional.append(Extension('calibre.plugins.winutil',
sources=['src/calibre/utils/windows/winutil.c'],

View File

@ -34,7 +34,7 @@ class IREXDR1000(USBMS):
MAIN_MEMORY_VOLUME_LABEL = 'IRex Digital Reader 1000 Main Memory'
EBOOK_DIR_MAIN = ''
EBOOK_DIR_MAIN = 'ebooks'
SUPPORTS_SUB_DIRS = True
def delete_books(self, paths, end_session=True):

View File

@ -8,6 +8,7 @@ for a particular device.
import os
import fnmatch
import re
import shutil
from itertools import cycle
@ -207,8 +208,9 @@ class USBMS(CLI, Device):
if cls.settings().read_metadata or cls.MUST_READ_METADATA:
mi = cls.metadata_from_path(path)
else:
from calibre.ebooks.metadata import MetaInformation
mi = MetaInformation(os.path.basename(path))
from calibre.ebooks.metadata.meta import metadata_from_filename
mi = metadata_from_filename(os.path.basename(path),
re.compile(r'^(?P<title>[ \S]+?)[ _]-[ _](?P<author>[ \S]+?)_+\d+'))
authors = authors_to_string(mi.authors)

View File

@ -94,7 +94,7 @@ def get_metadata(stream, stream_type='lrf', use_libprs_metadata=False):
# The regex is meant to match the standard format filenames are written
# in: title_-_author_number.extension
base.smart_update(metadata_from_filename(name, re.compile(
r'^(?P<title>\S+?)_-_(?P<author>\S+?)_+\d+')))
r'^(?P<title>[ \S]+?)[ _]-[ _](?P<author>[ \S]+?)_+\d+')))
if base.title:
base.title = base.title.replace('_', ' ')
if base.authors: