mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
Fix #1549 (Metadata plugin not working)
This commit is contained in:
parent
b1594e46c9
commit
c524170f71
@ -105,30 +105,43 @@ def reread_metadata_plugins():
|
|||||||
for plugin in _initialized_plugins:
|
for plugin in _initialized_plugins:
|
||||||
if isinstance(plugin, MetadataReaderPlugin):
|
if isinstance(plugin, MetadataReaderPlugin):
|
||||||
for ft in plugin.file_types:
|
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):
|
elif isinstance(plugin, MetadataWriterPlugin):
|
||||||
for ft in plugin.file_types:
|
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):
|
def get_file_type_metadata(stream, ftype):
|
||||||
mi = MetaInformation(None, None)
|
mi = MetaInformation(None, None)
|
||||||
try:
|
ftype = ftype.lower().strip()
|
||||||
plugin = _metadata_readers[ftype.lower().strip()]
|
if _metadata_readers.has_key(ftype):
|
||||||
if not is_disabled(plugin):
|
for plugin in _metadata_readers[ftype]:
|
||||||
with plugin:
|
if not is_disabled(plugin):
|
||||||
mi = plugin.get_metadata(stream, ftype.lower().strip())
|
with plugin:
|
||||||
except:
|
try:
|
||||||
pass
|
mi = plugin.get_metadata(stream, ftype.lower().strip())
|
||||||
|
break
|
||||||
|
except:
|
||||||
|
continue
|
||||||
return mi
|
return mi
|
||||||
|
|
||||||
def set_file_type_metadata(stream, mi, ftype):
|
def set_file_type_metadata(stream, mi, ftype):
|
||||||
try:
|
ftype = ftype.lower().strip()
|
||||||
plugin = _metadata_writers[ftype.lower().strip()]
|
if _metadata_writers.has_key(ftype):
|
||||||
if not is_disabled(plugin):
|
for plugin in _metadata_writers[ftype]:
|
||||||
with plugin:
|
if not is_disabled(plugin):
|
||||||
plugin.set_metadata(stream, mi, ftype.lower().strip())
|
with plugin:
|
||||||
except:
|
try:
|
||||||
traceback.print_exc()
|
plugin.set_metadata(stream, mi, ftype.lower().strip())
|
||||||
|
break
|
||||||
|
except:
|
||||||
|
traceback.print_exc()
|
||||||
|
|
||||||
|
|
||||||
def _run_filetype_plugins(path_to_file, ft=None, occasion='preprocess'):
|
def _run_filetype_plugins(path_to_file, ft=None, occasion='preprocess'):
|
||||||
occasion = {'import':_on_import, 'preprocess':_on_preprocess,
|
occasion = {'import':_on_import, 'preprocess':_on_preprocess,
|
||||||
|
@ -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):
|
def do_render(html, base_dir, width, height, dpi, factor):
|
||||||
if QApplication.instance() is None:
|
if QApplication.instance() is None:
|
||||||
QApplication([])
|
QApplication([])
|
||||||
tr = HTMLTableRenderer(html, base_dir, width, height, dpi, factor)
|
tr = HTMLTableRenderer(html, base_dir, width, height, dpi, factor)
|
||||||
tr.loop.exec_()
|
tr.loop.exec_()
|
||||||
return tr.images, tr.tdir
|
return tr.images, tr.tdir
|
@ -231,7 +231,7 @@ NULL = DevNull()
|
|||||||
|
|
||||||
def do_add(db, paths, one_book_per_directory, recurse, add_duplicates):
|
def do_add(db, paths, one_book_per_directory, recurse, add_duplicates):
|
||||||
orig = sys.stdout
|
orig = sys.stdout
|
||||||
sys.stdout = NULL
|
#sys.stdout = NULL
|
||||||
try:
|
try:
|
||||||
files, dirs = [], []
|
files, dirs = [], []
|
||||||
for path in paths:
|
for path in paths:
|
||||||
|
@ -34,6 +34,7 @@ except:
|
|||||||
|
|
||||||
iswindows = 'win32' in sys.platform or 'win64' in sys.platform
|
iswindows = 'win32' in sys.platform or 'win64' in sys.platform
|
||||||
isosx = 'darwin' in sys.platform
|
isosx = 'darwin' in sys.platform
|
||||||
|
isbsd = 'bsd' in sys.platform
|
||||||
DISABLED = False
|
DISABLED = False
|
||||||
#if isosx:
|
#if isosx:
|
||||||
# libc = ctypes.cdll.LoadLibrary(ctypes.util.find_library('c'))
|
# libc = ctypes.cdll.LoadLibrary(ctypes.util.find_library('c'))
|
||||||
|
Loading…
x
Reference in New Issue
Block a user