mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-08-11 09:13:57 -04:00
IGN:Misc fixes
This commit is contained in:
parent
4f2644f3ef
commit
96851834cd
@ -93,7 +93,7 @@ def freeze():
|
||||
|
||||
includes = [x[0] for x in executables.values()]
|
||||
includes += ['calibre.ebooks.lrf.fonts.prs500.'+x for x in FONT_MAP.values()]
|
||||
includes += ['email.iterators', 'email.generator']
|
||||
includes += ['email.iterators', 'email.generator', 'sqlite3.dump']
|
||||
|
||||
|
||||
excludes = ['matplotlib', "Tkconstants", "Tkinter", "tcl", "_imagingtk",
|
||||
|
@ -353,7 +353,7 @@ def main():
|
||||
'keyword', 'codeop', 'pydoc', 'readline',
|
||||
'BeautifulSoup', 'calibre.ebooks.lrf.fonts.prs500.*',
|
||||
'dateutil', 'email.iterators',
|
||||
'email.generator',
|
||||
'email.generator', 'sqlite3.dump',
|
||||
'calibre.ebooks.metadata.amazon',
|
||||
],
|
||||
'packages' : ['PIL', 'Authorization', 'lxml', 'dns'],
|
||||
|
@ -158,7 +158,7 @@ def main(args=sys.argv):
|
||||
'email.iterators',
|
||||
'email.generator',
|
||||
'win32process', 'win32api', 'msvcrt',
|
||||
'win32event',
|
||||
'win32event', 'sqlite3.dump',
|
||||
'BeautifulSoup', 'pyreadline',
|
||||
'pydoc', 'IPython.Extensions.*',
|
||||
'calibre.web.feeds.recipes.*',
|
||||
|
@ -1,66 +0,0 @@
|
||||
#!/usr/bin/env python
|
||||
# vim:fileencoding=UTF-8:ts=4:sw=4:sta:et:sts=4:ai
|
||||
from __future__ import with_statement
|
||||
|
||||
__license__ = 'GPL v3'
|
||||
__copyright__ = '2009, Kovid Goyal <kovid@kovidgoyal.net>'
|
||||
__docformat__ = 'restructuredtext en'
|
||||
|
||||
import textwrap
|
||||
|
||||
from PyQt4.Qt import QTabWidget
|
||||
|
||||
from calibre.gui2.dialogs.add_save_ui import Ui_TabWidget
|
||||
from calibre.library.save_to_disk import config, FORMAT_ARG_DESCS
|
||||
|
||||
|
||||
class AddSave(QTabWidget, Ui_TabWidget):
|
||||
|
||||
def __init__(self, parent=None):
|
||||
QTabWidget.__init__(self, parent)
|
||||
self.setupUi(self)
|
||||
c = config()
|
||||
opts = c.parse()
|
||||
for x in ('asciiize', 'update_metadata', 'save_cover', 'write_opf'):
|
||||
g = getattr(self, 'opt_'+x)
|
||||
g.setChecked(getattr(opts, x))
|
||||
help = '\n'.join(textwrap.wrap(c.get_option(x).help, 75))
|
||||
g.setToolTip(help)
|
||||
g.setWhatsThis(help)
|
||||
|
||||
for x in ('formats', 'timefmt'):
|
||||
g = getattr(self, 'opt_'+x)
|
||||
g.setText(getattr(opts, x))
|
||||
help = '\n'.join(textwrap.wrap(c.get_option(x).help, 75))
|
||||
g.setToolTip(help)
|
||||
g.setWhatsThis(help)
|
||||
|
||||
help = '\n'.join(textwrap.wrap(c.get_option('template').help, 75))
|
||||
self.opt_template.initialize('save_to_disk_template_history',
|
||||
opts.template, help=help)
|
||||
|
||||
variables = sorted(FORMAT_ARG_DESCS.keys())
|
||||
rows = []
|
||||
for var in variables:
|
||||
rows.append(u'<tr><td>%s</td><td>%s</td></tr>'%
|
||||
(var, FORMAT_ARG_DESCS[var]))
|
||||
table = u'<table>%s</table>'%(u'\n'.join(rows))
|
||||
self.template_variables.setText(table)
|
||||
|
||||
def save_settings(self):
|
||||
c = config()
|
||||
for x in ('asciiize', 'update_metadata', 'save_cover', 'write_opf'):
|
||||
c.set(x, getattr(self, 'opt_'+x).isChecked())
|
||||
for x in ('formats', 'template', 'timefmt'):
|
||||
c.set(x, unicode(getattr(self, 'opt_'+x).text()).strip())
|
||||
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
from PyQt4.Qt import QApplication
|
||||
app=QApplication([])
|
||||
a = AddSave()
|
||||
a.show()
|
||||
app.exec_()
|
||||
a.save_settings()
|
||||
|
@ -424,7 +424,8 @@ def move_library(oldloc, newloc, parent, callback_on_complete):
|
||||
callback)
|
||||
else:
|
||||
rq = Queue()
|
||||
m = MoveLibrary(oldloc, newloc, db.data.count(), rq)
|
||||
m = MoveLibrary(oldloc, newloc,
|
||||
len(db.get_top_level_move_items()[0]), rq)
|
||||
global _mm
|
||||
_mm = MoveMonitor(m, rq, callback, parent)
|
||||
return
|
||||
|
@ -1444,9 +1444,7 @@ class LibraryDatabase2(LibraryDatabase):
|
||||
if notify:
|
||||
self.notify('add', [id])
|
||||
|
||||
def move_library_to(self, newloc, progress=lambda x: x):
|
||||
if not os.path.exists(newloc):
|
||||
os.makedirs(newloc)
|
||||
def get_top_level_move_items(self):
|
||||
items = set(os.listdir(self.library_path))
|
||||
paths = set([])
|
||||
for x in self.data.universal_set():
|
||||
@ -1454,15 +1452,25 @@ class LibraryDatabase2(LibraryDatabase):
|
||||
path = path.split(os.sep)[0]
|
||||
paths.add(path)
|
||||
paths.add('metadata.db')
|
||||
path_map = {}
|
||||
for x in paths:
|
||||
path_map[x] = x
|
||||
if not self.is_case_sensitive:
|
||||
items = set([x.lower() for x in items])
|
||||
for x in items:
|
||||
path_map[x.lower()] = x
|
||||
items = set(path_map)
|
||||
paths = set([x.lower() for x in paths])
|
||||
items = items.intersection(paths)
|
||||
return items, path_map
|
||||
|
||||
def move_library_to(self, newloc, progress=lambda x: x):
|
||||
if not os.path.exists(newloc):
|
||||
os.makedirs(newloc)
|
||||
old_dirs = set([])
|
||||
for i, x in enumerate(items):
|
||||
items, path_map = self.get_top_level_move_items()
|
||||
for x in items:
|
||||
src = os.path.join(self.library_path, x)
|
||||
dest = os.path.join(newloc, x)
|
||||
dest = os.path.join(newloc, path_map[x])
|
||||
if os.path.isdir(src):
|
||||
if os.path.exists(dest):
|
||||
shutil.rmtree(dest)
|
||||
@ -1472,6 +1480,7 @@ class LibraryDatabase2(LibraryDatabase):
|
||||
if os.path.exists(dest):
|
||||
os.remove(dest)
|
||||
shutil.copyfile(src, dest)
|
||||
x = path_map[x]
|
||||
if not isinstance(x, unicode):
|
||||
x = x.decode(filesystem_encoding, 'replace')
|
||||
progress(x)
|
||||
@ -1686,13 +1695,12 @@ books_series_link feeds
|
||||
user_version = self.user_version
|
||||
sql = self.conn.dump()
|
||||
self.conn.close()
|
||||
dest = self.dbpath+'.old'
|
||||
dest = self.dbpath+'.tmp'
|
||||
if os.path.exists(dest):
|
||||
os.remove(dest)
|
||||
shutil.copyfile(self.dbpath, dest)
|
||||
conn = None
|
||||
try:
|
||||
os.remove(self.dbpath)
|
||||
ndb = DBThread(self.dbpath, None)
|
||||
ndb = DBThread(dest, None)
|
||||
ndb.connect()
|
||||
conn = ndb.conn
|
||||
conn.executescript(sql)
|
||||
@ -1701,15 +1709,21 @@ books_series_link feeds
|
||||
conn.commit()
|
||||
conn.close()
|
||||
except:
|
||||
if os.path.exists(self.dbpath):
|
||||
os.remove(self.dbpath)
|
||||
shutil.copyfile(dest, self.dbpath)
|
||||
if conn is not None:
|
||||
try:
|
||||
conn.close()
|
||||
except:
|
||||
pass
|
||||
if os.path.exists(dest):
|
||||
os.remove(dest)
|
||||
raise
|
||||
else:
|
||||
os.remove(dest)
|
||||
os.remove(self.dbpath)
|
||||
shutil.copyfile(dest, self.dbpath)
|
||||
self.connect()
|
||||
self.refresh()
|
||||
if os.path.exists(dest):
|
||||
os.remove(dest)
|
||||
callback(0.1, _('Checking for missing files.'))
|
||||
bad = {}
|
||||
us = self.data.universal_set()
|
||||
|
@ -157,6 +157,8 @@ class DatabaseException(Exception):
|
||||
def proxy(fn):
|
||||
''' Decorator to call methods on the database connection in the proxy thread '''
|
||||
def run(self, *args, **kwargs):
|
||||
if self.closed:
|
||||
raise DatabaseException('Connection closed', '')
|
||||
with global_lock:
|
||||
if self.proxy.unhandled_error[0] is not None:
|
||||
raise DatabaseException(*self.proxy.unhandled_error)
|
||||
@ -174,10 +176,12 @@ class ConnectionProxy(object):
|
||||
|
||||
def __init__(self, proxy):
|
||||
self.proxy = proxy
|
||||
self.closed = False
|
||||
|
||||
def close(self):
|
||||
if self.proxy.unhandled_error is None:
|
||||
if self.proxy.unhandled_error[0] is None:
|
||||
self.proxy.requests.put((self.proxy.CLOSE, [], {}))
|
||||
self.closed = True
|
||||
|
||||
@proxy
|
||||
def get(self, query, all=True): pass
|
||||
|
@ -9,7 +9,7 @@ __docformat__ = 'restructuredtext en'
|
||||
import os, sys
|
||||
from threading import Thread
|
||||
|
||||
from calibre.constants import plugins
|
||||
from calibre.constants import plugins, iswindows
|
||||
|
||||
_fc, _fc_err = plugins['fontconfig']
|
||||
|
||||
@ -31,6 +31,12 @@ class FontConfig(Thread):
|
||||
if isinstance(config_dir, unicode):
|
||||
config_dir = config_dir.encode(sys.getfilesystemencoding())
|
||||
config = os.path.join(config_dir, 'fonts.conf')
|
||||
if iswindows and getattr(sys, 'frozen', False):
|
||||
config_dir = os.path.join(os.path.dirname(sys.executable),
|
||||
'etc', 'fonts')
|
||||
if isinstance(config_dir, unicode):
|
||||
config_dir = config_dir.encode(sys.getfilesystemencoding())
|
||||
config = os.path.join(config_dir, 'fonts.conf')
|
||||
try:
|
||||
_fc.initialize(config)
|
||||
except:
|
||||
|
@ -929,6 +929,7 @@ initwinutil(void) {
|
||||
PyModule_AddIntConstant(m, "CSIDL_COOKIES", CSIDL_COOKIES);
|
||||
PyModule_AddIntConstant(m, "CSIDL_FLAG_CREATE", CSIDL_FLAG_CREATE);
|
||||
PyModule_AddIntConstant(m, "CSIDL_FLAG_DONT_VERIFY", CSIDL_FLAG_DONT_VERIFY);
|
||||
PyModule_AddIntConstant(m, "CSIDL_FONTS", CSIDL_FONTS);
|
||||
PyModule_AddIntConstant(m, "CSIDL_HISTORY", CSIDL_HISTORY);
|
||||
PyModule_AddIntConstant(m, "CSIDL_INTERNET_CACHE", CSIDL_INTERNET_CACHE);
|
||||
PyModule_AddIntConstant(m, "CSIDL_LOCAL_APPDATA", CSIDL_LOCAL_APPDATA);
|
||||
|
@ -6,10 +6,9 @@ Fetch Linuxdevices.
|
||||
'''
|
||||
import re
|
||||
from calibre.web.feeds.news import BasicNewsRecipe
|
||||
from calibre.ebooks.BeautifulSoup import BeautifulSoup
|
||||
|
||||
|
||||
class Sueddeutsche(BasicNewsRecipe):
|
||||
class LinuxDevices(BasicNewsRecipe):
|
||||
|
||||
title = u'Linuxdevices'
|
||||
description = 'News about Linux driven Hardware'
|
||||
@ -20,7 +19,7 @@ class Sueddeutsche(BasicNewsRecipe):
|
||||
no_stylesheets = True
|
||||
language = _('English')
|
||||
remove_javascript = True
|
||||
conversion_options {' linearize_tables' : True}
|
||||
conversion_options = { 'linearize_tables' : True}
|
||||
encoding = 'latin1'
|
||||
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user