Merge branch 'maintenance/gramps40' of ssh://git.code.sf.net/p/gramps/source into gramps40

This commit is contained in:
Espen Berg 2014-03-08 21:24:53 +01:00
commit dd206b0030
7 changed files with 13666 additions and 13325 deletions

File diff suppressed because it is too large Load Diff

Binary file not shown.

File diff suppressed because it is too large Load Diff

View File

@ -41,6 +41,9 @@ from __future__ import print_function
import os import os
import sys import sys
import re import re
import logging
LOG = logging.getLogger('.' + __name__)
LOG.progagate = True
from ..const import GRAMPS_LOCALE as glocale from ..const import GRAMPS_LOCALE as glocale
_ = glocale.translation.gettext _ = glocale.translation.gettext
@ -250,7 +253,12 @@ class BasePluginManager(object):
if pdata.fpath not in sys.path: if pdata.fpath not in sys.path:
if pdata.mod_name: if pdata.mod_name:
sys.path.insert(0, pdata.fpath) sys.path.insert(0, pdata.fpath)
try:
module = __import__(pdata.mod_name) module = __import__(pdata.mod_name)
except ValueError as err:
LOG.warning('Plugin error: %s', err)
except ImportError as err:
LOG.warning('Plugin error: %s', err)
sys.path.pop(0) sys.path.pop(0)
else: else:
print("WARNING: module cannot be loaded") print("WARNING: module cannot be loaded")

View File

@ -231,10 +231,10 @@ class GrampsLocale(object):
if not self.language: if not self.language:
self.language = [self.lang[:5]] self.language = [self.lang[:5]]
if 'LC_COLLATE' in os.environ: if 'COLLATION' in os.environ:
coll = os.environ['LC_COLLATE'] coll = os.environ['COLLATION']
if HAVE_ICU: if HAVE_ICU:
if coll[:5] in ICU_LOCALES: if coll[:2] in ICU_LOCALES:
self.collation = coll self.collation = coll
else: else:
self.collation = self.lang self.collation = self.lang
@ -341,6 +341,9 @@ class GrampsLocale(object):
else: else:
self.collation = self.lang self.collation = self.lang
if HAVE_ICU and 'COLLATION' in os.environ:
self.collation = os.environ['COLLATION']
loc = locale.getlocale(locale.LC_NUMERIC) loc = locale.getlocale(locale.LC_NUMERIC)
if loc and loc[0]: if loc and loc[0]:
self.numeric = '.'.join(loc) self.numeric = '.'.join(loc)
@ -538,9 +541,6 @@ class GrampsLocale(object):
else: else:
self.language = None self.language = None
#For alternate collation sequences. Works only with ICU, and
#set only on Macs.
self.coll_qualifier = None
_first = self._GrampsLocale__first_instance _first = self._GrampsLocale__first_instance
if self == _first: if self == _first:
self._GrampsLocale__init_first_instance() self._GrampsLocale__init_first_instance()
@ -607,7 +607,7 @@ class GrampsLocale(object):
if not languages or len(languages) == 0: if not languages or len(languages) == 0:
LOG.warning("No language provided, using US English") LOG.warning("No language provided, using US English")
else: else:
raise ValueError("No usable translations in %s" % raise ValueError("No usable translations in %s for " %
':'.join(languages)) ':'.join(languages))
translator = GrampsNullTranslations() translator = GrampsNullTranslations()
translator._language = "en" translator._language = "en"

View File

@ -194,24 +194,27 @@ def mac_setup_localization(glocale):
""" """
Extract the collation (sort order) locale from the defaults string. Extract the collation (sort order) locale from the defaults string.
""" """
apple_collation = _mac_get_gramps_defaults("Gramps", "AppleCollationOrder") # The locale module can't deal with collation-qualified
# locales and setting one blows up setlocale, so we use
# $COLLATION directly instead.
if ('COLLATION') in os.environ:
apple_collation = os.environ['COLLATION']
else:
apple_collation = _mac_get_gramps_defaults("Gramps",
"AppleCollationOrder")
if not apple_collation: if not apple_collation:
apple_collation = _mac_get_gramps_defaults("Global", apple_collation = _mac_get_gramps_defaults("Global",
"AppleCollationOrder") "AppleCollationOrder")
if not apple_collation: if not apple_collation:
return (None, None) print('No apple collation')
return None
apple_collation = apple_collation.strip() apple_collation = apple_collation.strip()
if not apple_collation or apple_collation.startswith("root"): if not apple_collation or apple_collation.startswith("root"):
return (None, None) print('No meaningful apple collation')
div = apple_collation.split(b"@") return None
collation = div[0] print('Got collation %s from defaults' % apple_collation)
qualifier = None return apple_collation
if len(div) > 1:
parts = div[1].split(b"=")
if len(parts) == 2 and parts[0] == 'collation':
qualifier = parts[1]
return (collation, qualifier)
#The action starts here #The action starts here
_locale = None _locale = None
@ -234,12 +237,11 @@ def mac_setup_localization(glocale):
(glocale.lang, glocale.currency, glocale.calendar) = _mac_get_locale() (glocale.lang, glocale.currency, glocale.calendar) = _mac_get_locale()
glocale.coll_qualifier = None glocale.coll_qualifier = None
glocale.collation = locale.getlocale(locale.LC_COLLATE)[0] glocale.collation = _mac_get_collation()
if not glocale.collation:
(glocale.collation, glocale.coll_qualifier) = _mac_get_collation()
if not glocale.lang and glocale.collation: if not glocale.lang and glocale.collation:
glocale.lang = glocale.check_available_translations(glocale.collation) coll_parts = glocale.collation.split('@')
glocale.lang = glocale.check_available_translations(coll_parts[0])
glocale.lang = locale.normalize(glocale.lang) glocale.lang = locale.normalize(glocale.lang)
glocale.encoding = glocale.lang.split('.')[1] glocale.encoding = glocale.lang.split('.')[1]

View File

@ -290,7 +290,17 @@ class EditMedia(EditPrimary):
return return
path = self.file_path.get_text() path = self.file_path.get_text()
if os.path.isfile(path):
self.determine_mime() self.determine_mime()
else:
msg1 = _("There is no media matching the current path value!")
msg2 = _("You have attempted to use the path with "
"value '%(path)s'. This path does not exist!"
" Please enter a different path") % {
'path' : path }
ErrorDialog(msg1, msg2)
self.ok_button.set_sensitive(True)
return
self.obj.set_path(get_unicode_path_from_file_chooser(path)) self.obj.set_path(get_unicode_path_from_file_chooser(path))