Merge from trunk

This commit is contained in:
Charles Haley 2012-07-26 08:32:42 +02:00
commit cff772efbc
6 changed files with 45 additions and 34 deletions

View File

@ -150,9 +150,8 @@ the previously checked out |app| code directory, for example::
calibre is the directory that contains the src and resources sub-directories. Ensure you have installed the |app| commandline tools via :guilabel:`Preferences->Advanced->Miscellaneous` in the |app| GUI. calibre is the directory that contains the src and resources sub-directories. Ensure you have installed the |app| commandline tools via :guilabel:`Preferences->Advanced->Miscellaneous` in the |app| GUI.
The next step is to set the environment variable ``CALIBRE_DEVELOP_FROM`` to the absolute path of the src directory. The next step is to set the environment variable ``CALIBRE_DEVELOP_FROM`` to the absolute path of the src directory.
So, following the example above, it would be ``/Users/kovid/work/calibre/src``. Apple So, following the example above, it would be ``/Users/kovid/work/calibre/src``.
`documentation <http://developer.apple.com/mac/library/documentation/MacOSX/Conceptual/BPRuntimeConfig/Articles/EnvironmentVars.html#//apple_ref/doc/uid/20002093-BCIJIJBH>`_ `How to set environment variables <http://www.dowdandassociates.com/content/howto-set-environment-variable-mac-os-x-etclaunchdconf>`_.
on how to set environment variables.
Once you have set the environment variable, open a new Terminal and check that it was correctly set by using Once you have set the environment variable, open a new Terminal and check that it was correctly set by using
the command:: the command::

View File

@ -1,4 +1,4 @@
import re, random import random
from calibre import browser from calibre import browser
from calibre.web.feeds.recipes import BasicNewsRecipe from calibre.web.feeds.recipes import BasicNewsRecipe
@ -8,46 +8,44 @@ class AdvancedUserRecipe1325006965(BasicNewsRecipe):
title = u'The Sun UK' title = u'The Sun UK'
description = 'Articles from The Sun tabloid UK' description = 'Articles from The Sun tabloid UK'
__author__ = 'Dave Asbury' __author__ = 'Dave Asbury'
# last updated 15/7/12 # last updated 25/7/12
language = 'en_GB' language = 'en_GB'
oldest_article = 1 oldest_article = 1
max_articles_per_feed = 15 max_articles_per_feed = 12
remove_empty_feeds = True remove_empty_feeds = True
no_stylesheets = True no_stylesheets = True
masthead_url = 'http://www.thesun.co.uk/sol/img/global/Sun-logo.gif' masthead_url = 'http://www.thesun.co.uk/sol/img/global/Sun-logo.gif'
encoding = 'UTF-8' encoding = 'UTF-8'
remove_empty_feeds = True
remove_javascript = True remove_javascript = True
no_stylesheets = True no_stylesheets = True
#preprocess_regexps = [
# (re.compile(r'<div class="foot-copyright".*?</div>', re.IGNORECASE | re.DOTALL), lambda match: '')]
extra_css = ''' extra_css = '''
body{ text-align: justify; font-family:Arial,Helvetica,sans-serif; font-size:11px; font-size-adjust:none; font-stretch:normal; font-style:normal; font-variant:normal; font-weight:normal;} body{ text-align: justify; font-family:Arial,Helvetica,sans-serif; font-size:11px; font-size-adjust:none; font-stretch:normal; font-style:normal; font-variant:normal; font-weight:normal;}
''' '''
preprocess_regexps = [
(re.compile(r'<div class="foot-copyright".*?</div>', re.IGNORECASE | re.DOTALL), lambda match: '')]
keep_only_tags = [ keep_only_tags = [
dict(name='h1'),dict(name='h2',attrs={'class' : ['large','large centered','medium centered','medium']}),dict(name='h3'), dict(name='div',attrs={'class' : 'intro'}),
dict(name='div',attrs={'class' : 'text-center'}), dict(name='h3'),
dict(name='div',attrs={'id' : 'bodyText'}) dict(name='div',attrs={'id' : 'articlebody'}),
# dict(name='p') #dict(attrs={'class' : ['right_col_branding','related-stories','mystery-meat-link','ltbx-container','ltbx-var ltbx-hbxpn','ltbx-var ltbx-nav-loop','ltbx-var ltbx-url']}),
# dict(name='div',attrs={'class' : 'cf'}),
# dict(attrs={'title' : 'download flash'}),
# dict(attrs={'style' : 'padding: 5px'})
] ]
remove_tags_after = [dict(id='bodyText')]
remove_tags=[ remove_tags=[
#dict(name='head'), dict(name='li'),
dict(attrs={'class' : ['mystery-meat-link','ltbx-container','ltbx-var ltbx-hbxpn','ltbx-var ltbx-nav-loop','ltbx-var ltbx-url']}), dict(attrs={'class' : 'grid-4 right-hand-column'}),
dict(name='div',attrs={'class' : 'cf'}),
dict(attrs={'title' : 'download flash'}),
dict(attrs={'style' : 'padding: 5px'})
] ]
feeds = [ feeds = [
(u'News', u'http://www.thesun.co.uk/sol/homepage/news/rss'), (u'News', u'http://www.thesun.co.uk/sol/homepage/news/rss'),
(u'Sport', u'http://www.thesun.co.uk/sol/homepage/sport/rss'), (u'Sport', u'http://www.thesun.co.uk/sol/homepage/sport/rss'),

View File

@ -5,7 +5,7 @@ __copyright__ = '2010, Gregory Riker'
__docformat__ = 'restructuredtext en' __docformat__ = 'restructuredtext en'
import cStringIO, ctypes, datetime, os, re, shutil, sys, tempfile, time import cStringIO, ctypes, datetime, os, platform, re, shutil, sys, tempfile, time
from calibre.constants import __appname__, __version__, DEBUG from calibre.constants import __appname__, __version__, DEBUG
from calibre import fit_image, confirm_config_name, strftime as _strftime from calibre import fit_image, confirm_config_name, strftime as _strftime
@ -2427,8 +2427,9 @@ class ITUNES(DriverBase):
if DEBUG: if DEBUG:
logger().info(" %s %s" % (__appname__, __version__)) logger().info(" %s %s" % (__appname__, __version__))
logger().info(" [OSX %s - %s (%s), driver version %d.%d.%d]" % logger().info(" [OSX %s, %s %s (%s), driver version %d.%d.%d]" %
(self.iTunes.name(), self.iTunes.version(), self.initial_status, (platform.mac_ver()[0],
self.iTunes.name(), self.iTunes.version(), self.initial_status,
self.version[0],self.version[1],self.version[2])) self.version[0],self.version[1],self.version[2]))
logger().info(" communicating with iTunes via %s %s using %s binding" % (as_name, as_version, as_binding)) logger().info(" communicating with iTunes via %s %s using %s binding" % (as_name, as_version, as_binding))
logger().info(" calibre_library_path: %s" % self.calibre_library_path) logger().info(" calibre_library_path: %s" % self.calibre_library_path)

View File

@ -135,6 +135,7 @@ class GuiRunner(QObject):
main = Main(self.opts, gui_debug=self.gui_debug) main = Main(self.opts, gui_debug=self.gui_debug)
if self.splash_screen is not None: if self.splash_screen is not None:
self.splash_screen.showMessage(_('Initializing user interface...')) self.splash_screen.showMessage(_('Initializing user interface...'))
with gprefs: # Only write gui.json after initialization is complete
main.initialize(self.library_path, db, self.listener, self.actions) main.initialize(self.library_path, db, self.listener, self.actions)
if self.splash_screen is not None: if self.splash_screen is not None:
self.splash_screen.finish(main) self.splash_screen.finish(main)

View File

@ -367,6 +367,8 @@ class Main(MainWindow, MainWindowMixin, DeviceMixin, EmailMixin, # {{{
self.keyboard.finalize() self.keyboard.finalize()
self.auto_adder = AutoAdder(gprefs['auto_add_path'], self) self.auto_adder = AutoAdder(gprefs['auto_add_path'], self)
self.save_layout_state()
# Collect cycles now # Collect cycles now
gc.collect() gc.collect()
@ -702,6 +704,7 @@ class Main(MainWindow, MainWindowMixin, DeviceMixin, EmailMixin, # {{{
self.read_layout_settings() self.read_layout_settings()
def write_settings(self): def write_settings(self):
with gprefs: # Only write to gprefs once
config.set('main_window_geometry', self.saveGeometry()) config.set('main_window_geometry', self.saveGeometry())
dynamic.set('sort_history', self.library_view.model().sort_history) dynamic.set('sort_history', self.library_view.model().sort_history)
self.save_layout_state() self.save_layout_state()

View File

@ -240,6 +240,7 @@ class XMLConfig(dict):
def __init__(self, rel_path_to_cf_file): def __init__(self, rel_path_to_cf_file):
dict.__init__(self) dict.__init__(self)
self.no_commit = False
self.defaults = {} self.defaults = {}
self.file_path = os.path.join(config_dir, self.file_path = os.path.join(config_dir,
*(rel_path_to_cf_file.split('/'))) *(rel_path_to_cf_file.split('/')))
@ -304,6 +305,7 @@ class XMLConfig(dict):
self.commit() self.commit()
def commit(self): def commit(self):
if self.no_commit: return
if hasattr(self, 'file_path') and self.file_path: if hasattr(self, 'file_path') and self.file_path:
dpath = os.path.dirname(self.file_path) dpath = os.path.dirname(self.file_path)
if not os.path.exists(dpath): if not os.path.exists(dpath):
@ -314,6 +316,13 @@ class XMLConfig(dict):
f.truncate() f.truncate()
f.write(raw) f.write(raw)
def __enter__(self):
self.no_commit = True
def __exit__(self, *args):
self.no_commit = False
self.commit()
def to_json(obj): def to_json(obj):
if isinstance(obj, bytearray): if isinstance(obj, bytearray):
return {'__class__': 'bytearray', return {'__class__': 'bytearray',