Fix #1549 (Metadata plugin not working)

This commit is contained in:
Kovid Goyal 2009-01-05 09:22:33 -08:00
parent b1594e46c9
commit c524170f71
4 changed files with 32 additions and 18 deletions

View File

@ -105,30 +105,43 @@ def reread_metadata_plugins():
for plugin in _initialized_plugins:
if isinstance(plugin, MetadataReaderPlugin):
for ft in plugin.file_types:
_metadata_readers[ft] = plugin
if not _metadata_readers.has_key(ft):
_metadata_readers[ft] = []
_metadata_readers[ft].append(plugin)
elif isinstance(plugin, MetadataWriterPlugin):
for ft in plugin.file_types:
_metadata_writers[ft] = plugin
if not _metadata_writers.has_key(ft):
_metadata_writers[ft] = []
_metadata_writers[ft].append(plugin)
def get_file_type_metadata(stream, ftype):
mi = MetaInformation(None, None)
try:
plugin = _metadata_readers[ftype.lower().strip()]
if not is_disabled(plugin):
with plugin:
mi = plugin.get_metadata(stream, ftype.lower().strip())
except:
pass
ftype = ftype.lower().strip()
if _metadata_readers.has_key(ftype):
for plugin in _metadata_readers[ftype]:
if not is_disabled(plugin):
with plugin:
try:
mi = plugin.get_metadata(stream, ftype.lower().strip())
break
except:
continue
return mi
def set_file_type_metadata(stream, mi, ftype):
try:
plugin = _metadata_writers[ftype.lower().strip()]
if not is_disabled(plugin):
with plugin:
plugin.set_metadata(stream, mi, ftype.lower().strip())
except:
traceback.print_exc()
ftype = ftype.lower().strip()
if _metadata_writers.has_key(ftype):
for plugin in _metadata_writers[ftype]:
if not is_disabled(plugin):
with plugin:
try:
plugin.set_metadata(stream, mi, ftype.lower().strip())
break
except:
traceback.print_exc()
def _run_filetype_plugins(path_to_file, ft=None, occasion='preprocess'):
occasion = {'import':_on_import, 'preprocess':_on_preprocess,

View File

@ -88,7 +88,7 @@ def render_table(soup, table, css, base_dir, width, height, dpi, factor=1.0):
def do_render(html, base_dir, width, height, dpi, factor):
if QApplication.instance() is None:
QApplication([])
QApplication([])
tr = HTMLTableRenderer(html, base_dir, width, height, dpi, factor)
tr.loop.exec_()
return tr.images, tr.tdir

View File

@ -231,7 +231,7 @@ NULL = DevNull()
def do_add(db, paths, one_book_per_directory, recurse, add_duplicates):
orig = sys.stdout
sys.stdout = NULL
#sys.stdout = NULL
try:
files, dirs = [], []
for path in paths:

View File

@ -34,6 +34,7 @@ except:
iswindows = 'win32' in sys.platform or 'win64' in sys.platform
isosx = 'darwin' in sys.platform
isbsd = 'bsd' in sys.platform
DISABLED = False
#if isosx:
# libc = ctypes.cdll.LoadLibrary(ctypes.util.find_library('c'))