2620: GEPS 031: Python 3 support - 3.2

This does patch updates Gramps to the 3.2 syntax, it does not yet mean Gramps works with python 3.2
Expect next day commits to fix further issues, but this is the main 2to3 tool created patch changed
where needed to have python 2.7 work. 
Specific issues might be:
  1. next has been changed, must be checked
  2. new division as on the wiki page listed is to do
  3. ...


svn: r20634
This commit is contained in:
Benny Malengier
2012-11-07 17:53:14 +00:00
parent 3b2a0dbe48
commit bb5fc7cb7c
526 changed files with 7561 additions and 6929 deletions

View File

@ -36,6 +36,7 @@ Module responsible for handling the command line arguments for GRAMPS.
# Standard python modules
#
#-------------------------------------------------------------------------
from __future__ import print_function
import os
import sys
from gramps.gen.ggettext import gettext as _
@ -49,12 +50,12 @@ from gramps.gen.recentfiles import recent_files
from gramps.gen.utils.file import (rm_tempdir, get_empty_tempdir,
get_unicode_path_from_env_var)
from gramps.gen.db import DbBsddb
from clidbman import CLIDbManager, NAME_FILE, find_locker_name
from .clidbman import CLIDbManager, NAME_FILE, find_locker_name
from gramps.gen.plug import BasePluginManager
from gramps.gen.plug.report import CATEGORY_BOOK, CATEGORY_CODE, BookList
from plug import cl_report, cl_book
from user import User
from .plug import cl_report, cl_book
from .user import User
#-------------------------------------------------------------------------
#
@ -184,9 +185,9 @@ class ArgHandler(object):
else:
# Need to convert to system file encoding before printing
# For non latin characters in path/file/user names
print >> sys.stderr, msg1.encode(sys.getfilesystemencoding())
print(msg1.encode(sys.getfilesystemencoding()), file=sys.stderr)
if msg2 is not None:
print >> sys.stderr, msg2.encode(sys.getfilesystemencoding())
print(msg2.encode(sys.getfilesystemencoding()), file=sys.stderr)
#-------------------------------------------------------------------------
# Argument parser: sorts out given arguments
@ -288,10 +289,14 @@ class ArgHandler(object):
answer = None
while not answer:
try:
ans = raw_input(_('OK to overwrite? (yes/no) ') \
if sys.version_info[0] < 3:
ask = raw_input
else:
ask = input
ans = ask(_('OK to overwrite? (yes/no) ') \
.encode(sys.getfilesystemencoding()))
except EOFError:
print
print()
sys.exit(0)
if ans.upper() in ('Y', 'YES', _('YES').upper()):
self.__error( _("Will overwrite the existing file: %s")
@ -402,36 +407,36 @@ class ArgHandler(object):
"""
if self.list:
print _('List of known family trees in your database path\n').\
encode(sys.getfilesystemencoding())
print(_('List of known family trees in your database path\n').\
encode(sys.getfilesystemencoding()))
for name, dirname in sorted(self.dbman.family_tree_list(),
key=lambda pair: pair[0].lower()):
print (_("%(full_DB_path)s with name \"%(f_t_name)s\"") % \
print((_("%(full_DB_path)s with name \"%(f_t_name)s\"") % \
{'full_DB_path' : dirname,
'f_t_name' : name}).encode(sys.getfilesystemencoding())
'f_t_name' : name}).encode(sys.getfilesystemencoding()))
sys.exit(0)
if self.list_more:
print _('Gramps Family Trees:').encode(sys.getfilesystemencoding())
print(_('Gramps Family Trees:').encode(sys.getfilesystemencoding()))
summary_list = self.dbman.family_tree_summary()
for summary in sorted(summary_list,
key=lambda sum: sum["Family tree"].lower()):
print _("Family Tree \"%s\":").\
encode(sys.getfilesystemencoding()) % summary["Family tree"]
print(_("Family Tree \"%s\":").\
encode(sys.getfilesystemencoding()) % summary["Family tree"])
for item in sorted(summary):
if item != "Family tree":
print (" %s: %s" % (item, summary[item])).\
encode(sys.getfilesystemencoding())
print((" %s: %s" % (item, summary[item])).\
encode(sys.getfilesystemencoding()))
sys.exit(0)
self.__open_action()
self.__import_action()
for (action, op_string) in self.actions:
print >> sys.stderr, _("Performing action: %s.") % action
print(_("Performing action: %s.") % action, file=sys.stderr)
if op_string:
print >> sys.stderr, _("Using options string: %s") % op_string
print(_("Using options string: %s") % op_string, file=sys.stderr)
self.cl_action(action, op_string)
for expt in self.exports:
@ -439,19 +444,19 @@ class ArgHandler(object):
# For non latin characters in Windows path/file/user names
fn = expt[0].encode(sys.getfilesystemencoding())
fmt = str(expt[1])
print >> sys.stderr, _("Exporting: file %(filename)s, "
print(_("Exporting: file %(filename)s, "
"format %(format)s.") % \
{'filename' : fn,
'format' : fmt}
'format' : fmt}, file=sys.stderr)
self.cl_export(expt[0], expt[1])
if cleanup:
self.cleanup()
print >> sys.stderr, _("Exiting.")
print(_("Exiting."), file=sys.stderr)
sys.exit(0)
def cleanup(self):
print >> sys.stderr, _("Cleaning up.")
print(_("Cleaning up."), file=sys.stderr)
# remove files in import db subdir after use
self.dbstate.db.close()
if self.imp_db_path:
@ -482,10 +487,10 @@ class ArgHandler(object):
try:
self.sm.open_activate(self.imp_db_path)
msg = _("Created empty family tree successfully")
print >> sys.stderr, msg
print(msg, file=sys.stderr)
except:
print >> sys.stderr, _("Error opening the file.")
print >> sys.stderr, _("Exiting...")
print(_("Error opening the file."), file=sys.stderr)
print(_("Exiting..."), file=sys.stderr)
sys.exit(0)
for imp in self.imports:
@ -493,7 +498,7 @@ class ArgHandler(object):
fmt = str(imp[1])
msg = _("Importing: file %(filename)s, format %(format)s.") % \
{'filename' : fn, 'format' : fmt}
print >> sys.stderr, msg
print(msg, file=sys.stderr)
self.cl_import(imp[0], imp[1])
def __open_action(self):
@ -509,10 +514,10 @@ class ArgHandler(object):
# we load this file for use
try:
self.sm.open_activate(self.open)
print >> sys.stderr, _("Opened successfully!")
print(_("Opened successfully!"), file=sys.stderr)
except:
print >> sys.stderr, _("Error opening the file.")
print >> sys.stderr, _("Exiting...")
print(_("Error opening the file."), file=sys.stderr)
print(_("Exiting..."), file=sys.stderr)
sys.exit(0)
def check_db(self, dbpath, force_unlock = False):
@ -584,7 +589,7 @@ class ArgHandler(object):
options_str_dict = _split_options(options_str)
except:
options_str_dict = {}
print >> sys.stderr, _("Ignoring invalid options string.")
print(_("Ignoring invalid options string."), file=sys.stderr)
name = options_str_dict.pop('name', None)
_cl_list = pmgr.get_reg_reports(gui=False)
@ -613,16 +618,15 @@ class ArgHandler(object):
"Please use one of %(donottranslate)s=reportname") % \
{'donottranslate' : '[-p|--options] name'}
print >> sys.stderr, _("%s\n Available names are:") % msg
print(_("%s\n Available names are:") % msg, file=sys.stderr)
for pdata in sorted(_cl_list, key= lambda pdata: pdata.id.lower()):
# Print cli report name ([item[0]), GUI report name (item[4])
if len(pdata.id) <= 25:
print >> sys.stderr, \
" %s%s- %s" % ( pdata.id, " " * (26 - len(pdata.id)),
pdata.name.encode(sys.getfilesystemencoding()))
print(" %s%s- %s" % ( pdata.id, " " * (26 - len(pdata.id)),
pdata.name.encode(sys.getfilesystemencoding())), file=sys.stderr)
else:
print >> sys.stderr, " %s\t- %s" % (pdata.id,
pdata.name.encode(sys.getfilesystemencoding()))
print(" %s\t- %s" % (pdata.id,
pdata.name.encode(sys.getfilesystemencoding())), file=sys.stderr)
elif action == "tool":
from gramps.gui.plug import tool
@ -631,7 +635,7 @@ class ArgHandler(object):
chunk in options_str.split(',') ] )
except:
options_str_dict = {}
print >> sys.stderr, _("Ignoring invalid options string.")
print(_("Ignoring invalid options string."), file=sys.stderr)
name = options_str_dict.pop('name', None)
_cli_tool_list = pmgr.get_reg_tools(gui=False)
@ -654,24 +658,23 @@ class ArgHandler(object):
"Please use one of %(donottranslate)s=toolname.") % \
{'donottranslate' : '[-p|--options] name'}
print >> sys.stderr, _("%s\n Available names are:") % msg
print(_("%s\n Available names are:") % msg, file=sys.stderr)
for pdata in sorted(_cli_tool_list,
key=lambda pdata: pdata.id.lower()):
# Print cli report name ([item[0]), GUI report name (item[4])
if len(pdata.id) <= 25:
print >> sys.stderr, \
" %s%s- %s" % ( pdata.id, " " * (26 - len(pdata.id)),
pdata.name.encode(sys.getfilesystemencoding()))
print(" %s%s- %s" % ( pdata.id, " " * (26 - len(pdata.id)),
pdata.name.encode(sys.getfilesystemencoding())), file=sys.stderr)
else:
print >> sys.stderr, " %s\t- %s" % (pdata.id,
pdata.name.encode(sys.getfilesystemencoding()))
print(" %s\t- %s" % (pdata.id,
pdata.name.encode(sys.getfilesystemencoding())), file=sys.stderr)
elif action == "book":
try:
options_str_dict = _split_options(options_str)
except:
options_str_dict = {}
print >> sys.stderr, _("Ignoring invalid options string.")
print(_("Ignoring invalid options string."), file=sys.stderr)
name = options_str_dict.pop('name', None)
book_list = BookList('books.xml', self.dbstate.db)
@ -686,10 +689,10 @@ class ArgHandler(object):
"Please use one of %(donottranslate)s=bookname.") % \
{'donottranslate' : '[-p|--options] name'}
print >> sys.stderr, _("%s\n Available names are:") % msg
print(_("%s\n Available names are:") % msg, file=sys.stderr)
for name in sorted(book_list.get_book_names()):
print >> sys.stderr, " %s" % name
print(" %s" % name, file=sys.stderr)
else:
print >> sys.stderr, _("Unknown action: %s.") % action
print(_("Unknown action: %s.") % action, file=sys.stderr)
sys.exit(0)

View File

@ -36,6 +36,7 @@ Module responsible for handling the command line arguments for GRAMPS.
# Standard python modules
#
#-------------------------------------------------------------------------
from __future__ import print_function
import sys
import getopt
from gramps.gen.ggettext import gettext as _
@ -219,7 +220,7 @@ class ArgParser(object):
self.args[arg+1] = get_unicode_path_from_env_var(self.args[arg + 1])
options, leftargs = getopt.getopt(self.args[1:],
SHORTOPTS, LONGOPTS)
except getopt.GetoptError, msg:
except getopt.GetoptError as msg:
# Extract the arguments in the list.
# The % operator replaces the list elements with repr() of the list elemements
# which is OK for latin characters, but not for non latin characters in list elements
@ -228,7 +229,7 @@ class ArgParser(object):
cliargs += self.args[arg + 1] + " "
cliargs += "]"
# Must first do str() of the msg object.
msg = unicode(str(msg))
msg = str(msg)
self.errors += [(_('Error parsing the arguments'),
msg + '\n' +
_("Error parsing the arguments: %s \n"
@ -240,7 +241,7 @@ class ArgParser(object):
# if there were an argument without option,
# use it as a file to open and return
self.open_gui = leftargs[0]
print >> sys.stderr, "Trying to open: %s ..." % leftargs[0]
print ("Trying to open: %s ..." % leftargs[0], file=sys.stderr)
#see if force open is on
for opt_ix in range(len(options)):
option, value = options[opt_ix]
@ -273,7 +274,7 @@ class ArgParser(object):
elif option in ( '-a', '--action' ):
action = value
if action not in ('report', 'tool', 'book'):
print >> sys.stderr, "Unknown action: %s. Ignoring." % action
print ("Unknown action: %s. Ignoring." % action, file=sys.stderr)
continue
options_str = ""
if opt_ix < len(options)-1 \
@ -281,7 +282,7 @@ class ArgParser(object):
options_str = options[opt_ix+1][1]
self.actions.append((action, options_str))
elif option in ('-d', '--debug'):
print >> sys.stderr, 'setup debugging', value
print ('setup debugging', value, file=sys.stderr)
logger = logging.getLogger(value)
logger.setLevel(logging.DEBUG)
cleandbg += [opt_ix]
@ -290,14 +291,14 @@ class ArgParser(object):
elif option in ('-L'):
self.list_more = True
elif option in ('-s','--show'):
print "Gramps config settings from %s:" % \
config.filename.encode(sys.getfilesystemencoding())
print ("Gramps config settings from %s:" % \
config.filename.encode(sys.getfilesystemencoding()))
for section in config.data:
for setting in config.data[section]:
print "%s.%s=%s" % (
print ("%s.%s=%s" % (
section, setting,
repr(config.data[section][setting]))
print
repr(config.data[section][setting])))
print ('')
sys.exit(0)
elif option in ('-c', '--config'):
setting_name = value
@ -308,24 +309,24 @@ class ArgParser(object):
set_value = True
if config.has_default(setting_name):
setting_value = config.get(setting_name)
print >> sys.stderr, "Current Gramps config setting: " \
"%s:%s" % (setting_name, repr(setting_value))
print ("Current Gramps config setting: " \
"%s:%s" % (setting_name, repr(setting_value)), file=sys.stderr)
if set_value:
if new_value == "DEFAULT":
new_value = config.get_default(setting_name)
else:
new_value = safe_eval(new_value)
config.set(setting_name, new_value)
print >> sys.stderr, " New Gramps config " \
print (" New Gramps config " \
"setting: %s:%s" % (
setting_name,
repr(config.get(setting_name))
)
), file=sys.stderr)
else:
need_to_quit = True
else:
print >> sys.stderr, "Gramps: no such config setting:" \
" '%s'" % setting_name
print ("Gramps: no such config setting:" \
" '%s'" % setting_name, file=sys.stderr)
need_to_quit = True
cleandbg += [opt_ix]
elif option in ('-h', '-?', '--help'):
@ -401,7 +402,7 @@ class ArgParser(object):
"""
if self.help:
# Convert Help messages to file system encoding before printing
print _HELP.encode(sys.getfilesystemencoding())
print (_HELP.encode(sys.getfilesystemencoding()))
sys.exit(0)
def print_usage(self):
@ -410,5 +411,5 @@ class ArgParser(object):
"""
if self.usage:
# Convert Help messages to file system encoding before printing
print _USAGE.encode(sys.getfilesystemencoding())
print (_USAGE.encode(sys.getfilesystemencoding()))
sys.exit(0)

View File

@ -32,11 +32,17 @@ creating, and deleting of databases.
# Standard python modules
#
#-------------------------------------------------------------------------
from __future__ import print_function
import os
import sys
import time
import urllib2
import urlparse
if sys.version_info[0] < 3:
from urlparse import urlparse
from urllib2 import urlopen, url2pathname
else:
from urllib.parse import urlparse
from urllib.request import urlopen, url2pathname
import tempfile
from gramps.gen.ggettext import gettext as _
#-------------------------------------------------------------------------
@ -55,7 +61,7 @@ LOG = logging.getLogger(".clidbman")
from gramps.gen.db import DbBsddb
from gramps.gen.plug import BasePluginManager
from gramps.gen.config import config
from gramps.gen.constfunc import win
from gramps.gen.constfunc import win, conv_to_unicode
#-------------------------------------------------------------------------
#
# constants
@ -75,9 +81,9 @@ def _errordialog(title, errormessage):
"""
Show the error. A title for the error and an errormessage
"""
print _('ERROR: %(title)s \n %(message)s') % {
print(_('ERROR: %(title)s \n %(message)s') % {
'title': title,
'message': errormessage}
'message': errormessage})
sys.exit()
#-------------------------------------------------------------------------
@ -134,7 +140,7 @@ class CLIDbManager(object):
Returns (people_count, version_number) of current DB.
Returns ("Unknown", "Unknown") if invalid DB or other error.
"""
if config.get('preferences.use-bsddb3'):
if config.get('preferences.use-bsddb3') or sys.version_info[0] >= 3:
from bsddb3 import dbshelve, db
else:
from bsddb import dbshelve, db
@ -240,13 +246,13 @@ class CLIDbManager(object):
"""
Do needed things to start import visually, eg busy cursor
"""
print _('Starting Import, %s') % msg
print(_('Starting Import, %s') % msg)
def __end_cursor(self):
"""
Set end of a busy cursor
"""
print _('Import finished...')
print(_('Import finished...'))
def create_new_db_cli(self, title=None):
"""
@ -298,12 +304,12 @@ class CLIDbManager(object):
"""
pmgr = BasePluginManager.get_instance()
# Allow URL names here; make temp file if necessary
url = urlparse.urlparse(filename)
url = urlparse(filename)
if url.scheme != "":
if url.scheme == "file":
filename = urllib2.url2pathname(filename[7:])
filename = url2pathname(filename[7:])
else:
url_fp = urllib2.urlopen(filename) # open URL
url_fp = urlopen(filename) # open URL
# make a temp local file:
ext = os.path.splitext(url.path)[1]
fd, filename = tempfile.mkstemp(suffix=ext)
@ -367,7 +373,7 @@ class CLIDbManager(object):
name_file = open(filepath, "w")
name_file.write(new_text)
name_file.close()
except (OSError, IOError), msg:
except (OSError, IOError) as msg:
CLIDbManager.ERROR(_("Could not rename family tree"),
str(msg))
return None, None
@ -401,8 +407,8 @@ def make_dbdir(dbdir):
try:
if not os.path.isdir(dbdir):
os.makedirs(dbdir)
except (IOError, OSError), msg:
msg = unicode(str(msg), sys.getfilesystemencoding())
except (IOError, OSError) as msg:
msg = conv_to_unicode(str(msg), sys.getfilesystemencoding())
LOG.error(_("\nERROR: Wrong database path in Edit Menu->Preferences.\n"
"Open preferences and set correct database path.\n\n"
"Details: Could not make database directory:\n %s\n\n") % msg)
@ -473,7 +479,7 @@ def find_locker_name(dirpath):
# Convert username to unicode according to system encoding
# Otherwise problems with non ASCII characters in
# username in Windows
username = unicode(username, sys.getfilesystemencoding())
username = conv_to_unicode(username, sys.getfilesystemencoding())
# feature request 2356: avoid genitive form
last = _("Locked by %s") % username
ifile.close()

View File

@ -33,6 +33,8 @@ Provides also two small base classes: CLIDbLoader, CLIManager
# Python modules
#
#-------------------------------------------------------------------------
from __future__ import print_function
from gramps.gen.ggettext import gettext as _
import os
import sys
@ -74,14 +76,14 @@ class CLIDbLoader(object):
"""
Issue a warning message. Inherit for GUI action
"""
print _('WARNING: %s') % warnmessage
print(_('WARNING: %s') % warnmessage)
def _errordialog(self, title, errormessage):
"""
Show the error. A title for the error and an errormessage
Inherit for GUI action
"""
print _('ERROR: %s') % errormessage
print(_('ERROR: %s') % errormessage)
sys.exit(1)
def _dberrordialog(self, msg):
@ -155,17 +157,17 @@ class CLIDbLoader(object):
try:
self.dbstate.db.load(filename, self._pulse_progress, mode)
self.dbstate.db.set_save_path(filename)
except gen.db.exceptions.DbUpgradeRequiredError, msg:
except gen.db.exceptions.DbUpgradeRequiredError as msg:
self.dbstate.no_database()
self._errordialog( _("Cannot open database"), str(msg))
except gen.db.exceptions.DbVersionError, msg:
except gen.db.exceptions.DbVersionError as msg:
self.dbstate.no_database()
self._errordialog( _("Cannot open database"), str(msg))
except OSError, msg:
except OSError as msg:
self.dbstate.no_database()
self._errordialog(
_("Could not open file: %s") % filename, str(msg))
except Errors.DbError, msg:
except Errors.DbError as msg:
self.dbstate.no_database()
self._dberrordialog(msg)
except Exception:
@ -205,7 +207,7 @@ class CLIManager(object):
"""
Show the error. A title for the error and an errormessage
"""
print _('ERROR: %s') % errormessage
print(_('ERROR: %s') % errormessage)
sys.exit(1)
def _read_recent_file(self, filename):
@ -295,10 +297,10 @@ def startcli(errors, argparser):
# Convert error message to file system encoding before print
errmsg = _('Error encountered: %s') % errors[0][0]
errmsg = errmsg.encode(sys.getfilesystemencoding())
print errmsg
print(errmsg)
errmsg = _(' Details: %s') % errors[0][1]
errmsg = errmsg.encode(sys.getfilesystemencoding())
print errmsg
print(errmsg)
sys.exit(1)
if argparser.errors:
@ -306,10 +308,10 @@ def startcli(errors, argparser):
errmsg = _('Error encountered in argument parsing: %s') \
% argparser.errors[0][0]
errmsg = errmsg.encode(sys.getfilesystemencoding())
print errmsg
print(errmsg)
errmsg = _(' Details: %s') % argparser.errors[0][1]
errmsg = errmsg.encode(sys.getfilesystemencoding())
print errmsg
print(errmsg)
sys.exit(1)
#we need to keep track of the db state
@ -319,7 +321,7 @@ def startcli(errors, argparser):
#load the plugins
climanager.do_reg_plugins(dbstate, uistate=None)
# handle the arguments
from arghandler import ArgHandler
from .arghandler import ArgHandler
handler = ArgHandler(dbstate, argparser, climanager)
# create a manager to manage the database

View File

@ -33,6 +33,8 @@
# Python modules
#
#-------------------------------------------------------------------------
from __future__ import print_function
from gramps.gen.ggettext import gettext as _
import traceback
import os
@ -61,6 +63,7 @@ from gramps.gen.plug.report import (CATEGORY_TEXT, CATEGORY_DRAW, CATEGORY_BOOK,
from gramps.gen.plug.report._paper import paper_sizes
from gramps.gen.const import USER_HOME
from gramps.gen.dbstate import DbState
from gramps.gen.constfunc import STRTYPE, conv_to_unicode_direct
from ..grampscli import CLIManager
from ..user import User
@ -76,26 +79,26 @@ def _convert_str_to_match_type(str_val, type_val):
str_val = str_val.strip()
ret_type = type(type_val)
if ret_type in (str, unicode):
if isinstance(type_val, STRTYPE):
if ( str_val.startswith("'") and str_val.endswith("'") ) or \
( str_val.startswith('"') and str_val.endswith('"') ):
# Remove enclosing quotes
return unicode(str_val[1:-1])
return conv_to_unicode_direct(str_val[1:-1])
else:
return unicode(str_val)
return conv_to_unicode_direct(str_val)
elif ret_type == int:
if str_val.isdigit():
return int(str_val)
else:
print "'%s' is not an integer number" % str_val
print("'%s' is not an integer number" % str_val)
return 0
elif ret_type == float:
try:
return float(str_val)
except ValueError:
print "'%s' is not a decimal number" % str_val
print("'%s' is not a decimal number" % str_val)
return 0.0
elif ret_type == bool:
@ -104,13 +107,13 @@ def _convert_str_to_match_type(str_val, type_val):
elif str_val == str(False):
return False
else:
print "'%s' is not a boolean-- try 'True' or 'False'" % str_val
print("'%s' is not a boolean-- try 'True' or 'False'" % str_val)
return False
elif ret_type == list:
ret_val = []
if not ( str_val.startswith("[") and str_val.endswith("]") ):
print "'%s' is not a list-- try: [%s]" % (str_val, str_val)
print("'%s' is not a list-- try: [%s]" % (str_val, str_val))
return ret_val
entry = ""
@ -160,12 +163,12 @@ def _validate_options(options, dbase):
person = dbase.get_default_person()
if not person:
try:
phandle = dbase.iter_person_handles().next()
phandle = next(dbase.iter_person_handles())
except StopIteration:
phandle = None
person = dbase.get_person_from_handle(phandle)
if not person:
print _("ERROR: Please specify a person")
print(_("ERROR: Please specify a person"))
if person:
option.set_value(person.get_gramps_id())
@ -182,14 +185,14 @@ def _validate_options(options, dbase):
family_handle = family_list[0]
else:
try:
family_handle = dbase.iter_family_handles().next()
family_handle = next(dbase.iter_family_handles())
except StopIteration:
family_handle = None
if family_handle:
family = dbase.get_family_from_handle(family_handle)
option.set_value(family.get_gramps_id())
else:
print _("ERROR: Please specify a family")
print(_("ERROR: Please specify a family"))
#------------------------------------------------------------------------
#
@ -400,12 +403,12 @@ class CommandLineReport(object):
elif isinstance(option, Option):
self.options_help[name].append(option.get_help())
else:
print _("Unknown option: %s") % option
print _(" Valid options are:"), ", ".join(
self.options_dict.keys())
print (_(" Use '%(donottranslate)s' to see description "
print(_("Unknown option: %s") % option)
print(_(" Valid options are:"), ", ".join(
list(self.options_dict.keys())))
print((_(" Use '%(donottranslate)s' to see description "
"and acceptable values") %
{'donottranslate' : "show=option"})
{'donottranslate' : "show=option"}))
def parse_options(self):
"""
@ -430,12 +433,12 @@ class CommandLineReport(object):
option.set_value(self.options_dict[opt])
else:
print _("Ignoring unknown option: %s") % opt
print _(" Valid options are:"), ", ".join(
self.options_dict.keys())
print (_(" Use '%(donottranslate)s' to see description "
print(_("Ignoring unknown option: %s") % opt)
print(_(" Valid options are:"), ", ".join(
list(self.options_dict.keys())))
print((_(" Use '%(donottranslate)s' to see description "
"and acceptable values") %
{'donottranslate' : "show=option"})
{'donottranslate' : "show=option"}))
self.option_class.handler.output = self.options_dict['of']
@ -477,14 +480,14 @@ class CommandLineReport(object):
_chosen_format = graphdoc.FORMATS[0]["ext"]
else:
self.format = None
if _chosen_format and self.options_str_dict.has_key('off'):
print (_("Ignoring '%(notranslate1)s=%(notranslate2)s' "
if _chosen_format and 'off' in self.options_str_dict:
print((_("Ignoring '%(notranslate1)s=%(notranslate2)s' "
"and using '%(notranslate1)s=%(notranslate3)s'.") %
{'notranslate1' : "off",
'notranslate2' : self.options_dict['off'],
'notranslate3' : _chosen_format})
print (_("Use '%(notranslate)s' to see valid values.") %
{'notranslate' : "show=off"})
'notranslate3' : _chosen_format}))
print((_("Use '%(notranslate)s' to see valid values.") %
{'notranslate' : "show=off"}))
for paper in paper_sizes:
if paper.get_name() == self.options_dict['papers']:
@ -517,39 +520,39 @@ class CommandLineReport(object):
if not self.show:
return
elif self.show == 'all':
print _(" Available options:")
print(_(" Available options:"))
for key in sorted(self.options_dict.keys()):
if key in self.options_help:
opt = self.options_help[key]
# Make the output nicer to read, assume a tab has 8 spaces
tabs = '\t\t' if len(key) < 10 else '\t'
optmsg = " %s%s%s (%s)" % (key, tabs, opt[1], opt[0])
print optmsg.encode(sys.getfilesystemencoding())
print(optmsg.encode(sys.getfilesystemencoding()))
else:
optmsg = " %s" % key
print optmsg.encode(sys.getfilesystemencoding())
print (_(" Use '%(donottranslate)s' to see description "
print(optmsg.encode(sys.getfilesystemencoding()))
print((_(" Use '%(donottranslate)s' to see description "
"and acceptable values") %
{'donottranslate' : "show=option"})
{'donottranslate' : "show=option"}))
elif self.show in self.options_help:
opt = self.options_help[self.show]
tabs = '\t\t' if len(self.show) < 10 else '\t'
print ' %s%s%s (%s)' % (self.show, tabs, opt[1], opt[0])
print _(" Available values are:")
print(' %s%s%s (%s)' % (self.show, tabs, opt[1], opt[0]))
print(_(" Available values are:"))
vals = opt[2]
if isinstance(vals, (list, tuple)):
for val in vals:
optmsg = " %s" % val
print optmsg.encode(sys.getfilesystemencoding())
print(optmsg.encode(sys.getfilesystemencoding()))
else:
optmsg = " %s" % opt[2]
print optmsg.encode(sys.getfilesystemencoding())
print(optmsg.encode(sys.getfilesystemencoding()))
else:
#there was a show option given, but the option is invalid
print (_("option '%(optionname)s' not valid. "
print((_("option '%(optionname)s' not valid. "
"Use '%(donottranslate)s' to see all valid options.") %
{'optionname' : self.show, 'donottranslate' : "show=all"})
{'optionname' : self.show, 'donottranslate' : "show=all"}))
#------------------------------------------------------------------------
#
@ -588,17 +591,17 @@ def cl_report(database, name, category, report_class, options_class,
MyReport.write_report()
MyReport.end_report()
return clr
except ReportError, msg:
except ReportError as msg:
(m1, m2) = msg.messages()
print err_msg
print m1
print(err_msg)
print(m1)
if m2:
print m2
print(m2)
except:
if len(log.handlers) > 0:
log.error(err_msg, exc_info=True)
else:
print >> sys.stderr, err_msg
print(err_msg, file=sys.stderr)
## Something seems to eat the exception above.
## Hack to re-get the exception:
try:
@ -712,12 +715,12 @@ def write_book_item(database, report_class, options, user):
All user dialog has already been handled and the output file opened."""
try:
return report_class(database, options, user)
except ReportError, msg:
except ReportError as msg:
(m1, m2) = msg.messages()
print "ReportError", m1, m2
except FilterError, msg:
print("ReportError", m1, m2)
except FilterError as msg:
(m1, m2) = msg.messages()
print "FilterError", m1, m2
print("FilterError", m1, m2)
except:
log.error("Failed to write book item.", exc_info=True)
return None

View File

@ -29,6 +29,8 @@ The User class provides basic interaction with the user.
# Python Modules
#
#------------------------------------------------------------------------
from __future__ import print_function
import sys
#------------------------------------------------------------------------
@ -75,7 +77,7 @@ class User(User):
@type steps: int
@returns: none
"""
print message
print(message)
self.steps = steps
self.current_step = 0;
if self.steps == 0:
@ -140,7 +142,7 @@ class User(User):
@type warning: str
@returns: none
"""
print "%s %s" % (title, warning)
print("%s %s" % (title, warning))
def notify_error(self, title, error=""):
"""
@ -155,7 +157,7 @@ class User(User):
if self.error_function:
self.error_function(title, error)
else:
print "%s %s" % (title, error)
print("%s %s" % (title, error))
def notify_db_error(self, error):
"""
@ -176,5 +178,5 @@ class User(User):
"""
Displays information to the CLI
"""
print msg1
print infotext
print(msg1)
print(infotext)

View File

@ -41,9 +41,9 @@ import logging
# Gramps imports
#
#---------------------------------------------------------------
from ggettext import gettext as _
from const import HOME_DIR, USER_HOME, VERSION_DIR
from utils.configmanager import ConfigManager
from .ggettext import gettext as _
from .const import HOME_DIR, USER_HOME, VERSION_DIR
from .utils.configmanager import ConfigManager
#---------------------------------------------------------------
#

View File

@ -40,7 +40,7 @@ import sys
# Gramps modules
#
#-------------------------------------------------------------------------
from const import WINDOWS, MACOS, LINUX
from .const import WINDOWS, MACOS, LINUX
#-------------------------------------------------------------------------
#
@ -48,6 +48,21 @@ from const import WINDOWS, MACOS, LINUX
#
#-------------------------------------------------------------------------
#python 2 and 3 support, use correct conversion to unicode
if sys.version_info[0] < 3:
conv_to_unicode = unicode
conv_to_unicode_3 = unicode
conv_to_unicode_direct = unicode
STRTYPE = basestring
UNITYPE = unicode
else:
conv_to_unicode = lambda x,y: str(x)
conv_to_unicode_3 = lambda x,y,z: str(x)
conv_to_unicode_direct = str
STRTYPE = str
UNITYPE = str
cuni = conv_to_unicode_direct
#-------------------------------------------------------------------------
#
# Platform determination functions

View File

@ -24,31 +24,33 @@
Class handling language-specific selection for date parser and displayer.
"""
from __future__ import print_function
# import prerequisites for localized handlers
from _datehandler import (LANG, LANG_SHORT, LANG_TO_PARSER, LANG_TO_DISPLAY,
from ._datehandler import (LANG, LANG_SHORT, LANG_TO_PARSER, LANG_TO_DISPLAY,
register_datehandler)
# Import all the localized handlers
import _date_bg
import _date_ca
import _date_cs
import _date_da
import _date_de
import _date_es
import _date_fi
import _date_fr
import _date_hr
import _date_it
import _date_lt
import _date_nb
import _date_nl
import _date_pl
import _date_pt
import _date_ru
import _date_sk
import _date_sl
import _date_sr
import _date_sv
from . import _date_bg
from . import _date_ca
from . import _date_cs
from . import _date_da
from . import _date_de
from . import _date_es
from . import _date_fi
from . import _date_fr
from . import _date_hr
from . import _date_it
from . import _date_lt
from . import _date_nb
from . import _date_nl
from . import _date_pl
from . import _date_pt
from . import _date_ru
from . import _date_sk
from . import _date_sl
from . import _date_sr
from . import _date_sv
# Initialize global parser
try:
@ -57,7 +59,7 @@ try:
else:
parser = LANG_TO_PARSER[LANG_SHORT]()
except:
print "Date parser for", LANG, "not available, using default"
print("Date parser for", LANG, "not available, using default")
parser = LANG_TO_PARSER["C"]()
# Initialize global displayer
@ -73,11 +75,11 @@ try:
else:
displayer = LANG_TO_DISPLAY[LANG_SHORT](val)
except:
print "Date displayer for", LANG, "not available, using default"
print("Date displayer for", LANG, "not available, using default")
displayer = LANG_TO_DISPLAY["C"](val)
# Import utility functions
from _dateutils import *
from _grampslocale import (codeset, month_to_int, long_months, short_months,
from ._dateutils import *
from ._grampslocale import (codeset, month_to_int, long_months, short_months,
long_days, short_days, tformat)

View File

@ -24,7 +24,7 @@
"""
Bulgarian-specific classes for parsing and displaying dates.
"""
from __future__ import unicode_literals
#-------------------------------------------------------------------------
#
# Python modules
@ -38,9 +38,9 @@ import re
#
#-------------------------------------------------------------------------
from ..lib.date import Date
from _dateparser import DateParser
from _datedisplay import DateDisplay
from _datehandler import register_datehandler
from ._dateparser import DateParser
from ._datedisplay import DateDisplay
from ._datehandler import register_datehandler
#-------------------------------------------------------------------------
#
@ -50,124 +50,124 @@ from _datehandler import register_datehandler
class DateParserBG(DateParser):
modifier_to_int = {
u'преди' : Date.MOD_BEFORE,
u'пр.' : Date.MOD_BEFORE,
u'пр' : Date.MOD_BEFORE,
u'след' : Date.MOD_AFTER,
u'сл.' : Date.MOD_AFTER,
u'сл' : Date.MOD_AFTER,
u'ок' : Date.MOD_ABOUT,
u'ок.' : Date.MOD_ABOUT,
u'около' : Date.MOD_ABOUT,
u'примерно' : Date.MOD_ABOUT,
u'прим' : Date.MOD_ABOUT,
u'прим.' : Date.MOD_ABOUT,
u'приблизително' : Date.MOD_ABOUT,
u'приб.' : Date.MOD_ABOUT,
u'прибл.' : Date.MOD_ABOUT,
u'приб' : Date.MOD_ABOUT,
u'прибл' : Date.MOD_ABOUT,
'преди' : Date.MOD_BEFORE,
'пр.' : Date.MOD_BEFORE,
'пр' : Date.MOD_BEFORE,
'след' : Date.MOD_AFTER,
'сл.' : Date.MOD_AFTER,
'сл' : Date.MOD_AFTER,
'ок' : Date.MOD_ABOUT,
'ок.' : Date.MOD_ABOUT,
'около' : Date.MOD_ABOUT,
'примерно' : Date.MOD_ABOUT,
'прим' : Date.MOD_ABOUT,
'прим.' : Date.MOD_ABOUT,
'приблизително' : Date.MOD_ABOUT,
'приб.' : Date.MOD_ABOUT,
'прибл.' : Date.MOD_ABOUT,
'приб' : Date.MOD_ABOUT,
'прибл' : Date.MOD_ABOUT,
}
calendar_to_int = {
u'григориански' : Date.CAL_GREGORIAN,
u'г' : Date.CAL_GREGORIAN,
u'юлиански' : Date.CAL_JULIAN,
u'ю' : Date.CAL_JULIAN,
u'еврейски' : Date.CAL_HEBREW,
u'е' : Date.CAL_HEBREW,
u'ислямски' : Date.CAL_ISLAMIC,
u'и' : Date.CAL_ISLAMIC,
u'френски републикански' : Date.CAL_FRENCH,
u'републикански' : Date.CAL_FRENCH,
u'фр.реп.' : Date.CAL_FRENCH,
u'р' : Date.CAL_FRENCH,
u'френски' : Date.CAL_FRENCH,
u'фр.' : Date.CAL_FRENCH,
u'персийски' : Date.CAL_PERSIAN,
u'п' : Date.CAL_PERSIAN,
'григориански' : Date.CAL_GREGORIAN,
'г' : Date.CAL_GREGORIAN,
'юлиански' : Date.CAL_JULIAN,
'ю' : Date.CAL_JULIAN,
'еврейски' : Date.CAL_HEBREW,
'е' : Date.CAL_HEBREW,
'ислямски' : Date.CAL_ISLAMIC,
'и' : Date.CAL_ISLAMIC,
'френски републикански' : Date.CAL_FRENCH,
'републикански' : Date.CAL_FRENCH,
'фр.реп.' : Date.CAL_FRENCH,
'р' : Date.CAL_FRENCH,
'френски' : Date.CAL_FRENCH,
'фр.' : Date.CAL_FRENCH,
'персийски' : Date.CAL_PERSIAN,
'п' : Date.CAL_PERSIAN,
}
quality_to_int = {
u'приблизително' : Date.QUAL_ESTIMATED,
u'прибл.' : Date.QUAL_ESTIMATED,
u'изчислено' : Date.QUAL_CALCULATED,
u'изчисл.' : Date.QUAL_CALCULATED,
u'изч.' : Date.QUAL_CALCULATED,
'приблизително' : Date.QUAL_ESTIMATED,
'прибл.' : Date.QUAL_ESTIMATED,
'изчислено' : Date.QUAL_CALCULATED,
'изчисл.' : Date.QUAL_CALCULATED,
'изч.' : Date.QUAL_CALCULATED,
}
hebrew_to_int = {
u"тишрей":1,
u"мархешван":2,
u"кислев":3,
u"тевет":4,
u"шват":5,
u"адар":6,
u"адар бет":7,
u"нисан":8,
u"ияр":9,
u"сиван":10,
u"тамуз":11,
u"ав":12,
u"ул":13,
"тишрей":1,
"мархешван":2,
"кислев":3,
"тевет":4,
"шват":5,
"адар":6,
"адар бет":7,
"нисан":8,
"ияр":9,
"сиван":10,
"тамуз":11,
"ав":12,
"ул":13,
}
islamic_to_int = {
u"мухаррам":1,
u"саффар":2,
u"рабиу-л-ауал":3,
u"рабиу-с-сани":4,
u"джумадал-уля":5,
u"джумада-с-сания":6,
u"раджаб":7,
u"шаабан":8,
u"рамадан":9,
u"шауал":10,
u"зу-л-кида":11,
u"зул-л-хиджа":12,
"мухаррам":1,
"саффар":2,
"рабиу-л-ауал":3,
"рабиу-с-сани":4,
"джумадал-уля":5,
"джумада-с-сания":6,
"раджаб":7,
"шаабан":8,
"рамадан":9,
"шауал":10,
"зу-л-кида":11,
"зул-л-хиджа":12,
}
persian_to_int = {
u"фарвардин":1,
u"урдбихищ":2,
u"хурдад":3,
u"тир":4,
u"мурдад":5,
u"шахривар":6,
u"михр":7,
u"абан":8,
u"азар":9,
u"дай":10,
u"бахман":11,
u"исфаидармуз":12,
"фарвардин":1,
"урдбихищ":2,
"хурдад":3,
"тир":4,
"мурдад":5,
"шахривар":6,
"михр":7,
"абан":8,
"азар":9,
"дай":10,
"бахман":11,
"исфаидармуз":12,
}
french_to_int = {
u"вандемер":1,
u"брюмер":2,
u"фример":3,
u"нивоз":4,
u"плювиоз":5,
u"вантоз":6,
u"жерминал":7,
u"флореал":8,
u"прериал":9,
u"месидор":10,
u"термидор":11,
u"фрюктидор":12,
u"допълнителен":13,
"вандемер":1,
"брюмер":2,
"фример":3,
"нивоз":4,
"плювиоз":5,
"вантоз":6,
"жерминал":7,
"флореал":8,
"прериал":9,
"месидор":10,
"термидор":11,
"фрюктидор":12,
"допълнителен":13,
}
bce = [
u'преди Христа', u'пр. Хр.', u'пр.Хр.'
'преди Христа', 'пр. Хр.', 'пр.Хр.'
] + DateParser.bce
def init_strings(self):
DateParser.init_strings(self)
_span_1 = [u'от']
_span_2 = [u'до']
_range_1 = [u'между']
_range_2 = [u'и']
_span_1 = ['от']
_span_2 = ['до']
_range_1 = ['между']
_range_2 = ['и']
self._span = re.compile("(%s)\s+(?P<start>.+)\s+(%s)\s+(?P<stop>.+)" %
('|'.join(_span_1), '|'.join(_span_2)),
re.IGNORECASE)
@ -184,94 +184,94 @@ class DateDisplayBG(DateDisplay):
"""
Bulgarian language date display class.
"""
long_months = ( u"", u"януари", u"февруари", u"март", u"април", u"май",
u"юни", u"юли", u"август", u"септември", u"октомври",
u"ноември", u"декември" )
long_months = ( "", "януари", "февруари", "март", "април", "май",
"юни", "юли", "август", "септември", "октомври",
"ноември", "декември" )
short_months = ( u"", u"яну", u"февр", u"март", u"апр", u"май", u"юни",
u"юли", u"авг", u"септ", u"окт", u"ное", u"дек" )
short_months = ( "", "яну", "февр", "март", "апр", "май", "юни",
"юли", "авг", "септ", "окт", "ное", "дек" )
calendar = (
u"",
u"юлиански",
u"еврейски",
u"републикански",
u"персийски",
u"ислямски",
u"шведски"
"",
"юлиански",
"еврейски",
"републикански",
"персийски",
"ислямски",
"шведски"
)
_mod_str = ("", "преди ", "след ", "около ", "", "", "")
_qual_str = ("", "приблизително ", "изчислено ")
_bce_str = u"%s пр. Хр."
_bce_str = "%s пр. Хр."
formats = (
"ГГГГ-ММ-ДД (ISO)", "Числов", "Месец Ден, Година", "Мес. Ден, Година", "Ден Месец Година", "Ден Мес. Година"
)
hebrew = ( u"",
u"Тишрей",
u"Мархешван",
u"Кислев",
u"Тевет",
u"Шват",
u"Адар",
u"Адар бет",
u"Нисан",
u"Ияр",
u"Сиван",
u"Тамуз",
u"Ав",
u"Елул",
hebrew = ( "",
"Тишрей",
"Мархешван",
"Кислев",
"Тевет",
"Шват",
"Адар",
"Адар бет",
"Нисан",
"Ияр",
"Сиван",
"Тамуз",
"Ав",
"Елул",
)
islamic = ( u"",
u"Мухаррам",
u"Саффар",
u"Рабиу-л-ауал",
u"Рабиу-с-сани",
u"Джумадал-уля",
u"Джумада-с-сания",
u"Раджаб",
u"Шаабан",
u"Рамадан",
u"Шауал",
u"Зу-л-кида",
u"Зул-л-хиджа",
islamic = ( "",
"Мухаррам",
"Саффар",
"Рабиу-л-ауал",
"Рабиу-с-сани",
"Джумадал-уля",
"Джумада-с-сания",
"Раджаб",
"Шаабан",
"Рамадан",
"Шауал",
"Зу-л-кида",
"Зул-л-хиджа",
)
persian = ( u"",
u"Фарвардин",
u"Урдбихищ",
u"Хурдад",
u"Тир",
u"Мурдад",
u"Шахривар",
u"Михр",
u"Абан",
u"Азар",
u"Дай",
u"Бахман",
u"Исфаидармуз",
persian = ( "",
"Фарвардин",
"Урдбихищ",
"Хурдад",
"Тир",
"Мурдад",
"Шахривар",
"Михр",
"Абан",
"Азар",
"Дай",
"Бахман",
"Исфаидармуз",
)
french = ( u"",
u"Вандемер",
u"Брюмер",
u"Фример",
u"Нивоз",
u"Плювиоз",
u"Вантоз",
u"Жерминал",
u"Флореал",
u"Прериал",
u"Мессидор",
u"Термидор",
u"Фрюктидор",
u"Допълнителен"
french = ( "",
"Вандемер",
"Брюмер",
"Фример",
"Нивоз",
"Плювиоз",
"Вантоз",
"Жерминал",
"Флореал",
"Прериал",
"Мессидор",
"Термидор",
"Фрюктидор",
"Допълнителен"
)
def display(self, date):
@ -294,12 +294,12 @@ class DateDisplayBG(DateDisplay):
d1 = self.display_cal[cal](start)
d2 = self.display_cal[cal](date.get_stop_date())
scal = self.format_extras(cal, newyear)
return "%s%s %s %s %s%s" % (qual_str, u'от', d1, u'до', d2, scal)
return "%s%s %s %s %s%s" % (qual_str, 'от', d1, 'до', d2, scal)
elif mod == Date.MOD_RANGE:
d1 = self.display_cal[cal](start)
d2 = self.display_cal[cal](date.get_stop_date())
scal = self.format_extras(cal, newyear)
return "%s%s %s %s %s%s" % (qual_str, u'между', d1, u'и', d2, scal)
return "%s%s %s %s %s%s" % (qual_str, 'между', d1, 'и', d2, scal)
else:
text = self.display_cal[date.get_calendar()](start)
scal = self.format_extras(cal, newyear)

View File

@ -26,7 +26,7 @@
"""
Catalan-specific classes for parsing and displaying dates.
"""
from __future__ import unicode_literals
#-------------------------------------------------------------------------
#
# Python modules
@ -40,9 +40,9 @@ import re
#
#-------------------------------------------------------------------------
from ..lib.date import Date
from _dateparser import DateParser
from _datedisplay import DateDisplay
from _datehandler import register_datehandler
from ._dateparser import DateParser
from ._datedisplay import DateDisplay
from ._datehandler import register_datehandler
#-------------------------------------------------------------------------
#
@ -52,56 +52,56 @@ from _datehandler import register_datehandler
class DateParserCA(DateParser):
modifier_to_int = {
u'abans de' : Date.MOD_BEFORE,
u'abans' : Date.MOD_BEFORE,
u'ab.' : Date.MOD_BEFORE,
u'després de' : Date.MOD_AFTER,
u'després' : Date.MOD_AFTER,
u'desp.' : Date.MOD_AFTER,
u'desp' : Date.MOD_AFTER,
u'aprox.' : Date.MOD_ABOUT,
u'aprox' : Date.MOD_ABOUT,
u'circa' : Date.MOD_ABOUT,
u'ca.' : Date.MOD_ABOUT,
u'ca' : Date.MOD_ABOUT,
u'c.' : Date.MOD_ABOUT,
u'cap a' : Date.MOD_ABOUT,
u'al voltant' : Date.MOD_ABOUT,
u'al voltant de': Date.MOD_ABOUT,
'abans de' : Date.MOD_BEFORE,
'abans' : Date.MOD_BEFORE,
'ab.' : Date.MOD_BEFORE,
'després de' : Date.MOD_AFTER,
'després' : Date.MOD_AFTER,
'desp.' : Date.MOD_AFTER,
'desp' : Date.MOD_AFTER,
'aprox.' : Date.MOD_ABOUT,
'aprox' : Date.MOD_ABOUT,
'circa' : Date.MOD_ABOUT,
'ca.' : Date.MOD_ABOUT,
'ca' : Date.MOD_ABOUT,
'c.' : Date.MOD_ABOUT,
'cap a' : Date.MOD_ABOUT,
'al voltant' : Date.MOD_ABOUT,
'al voltant de': Date.MOD_ABOUT,
}
calendar_to_int = {
u'gregorià' : Date.CAL_GREGORIAN,
u'g' : Date.CAL_GREGORIAN,
u'julià' : Date.CAL_JULIAN,
u'j' : Date.CAL_JULIAN,
u'hebreu' : Date.CAL_HEBREW,
u'h' : Date.CAL_HEBREW,
u'islàmic' : Date.CAL_ISLAMIC,
u'i' : Date.CAL_ISLAMIC,
u'revolucionari': Date.CAL_FRENCH,
u'r' : Date.CAL_FRENCH,
u'persa' : Date.CAL_PERSIAN,
u'p' : Date.CAL_PERSIAN,
u'swedish' : Date.CAL_SWEDISH,
u's' : Date.CAL_SWEDISH,
'gregorià' : Date.CAL_GREGORIAN,
'g' : Date.CAL_GREGORIAN,
'julià' : Date.CAL_JULIAN,
'j' : Date.CAL_JULIAN,
'hebreu' : Date.CAL_HEBREW,
'h' : Date.CAL_HEBREW,
'islàmic' : Date.CAL_ISLAMIC,
'i' : Date.CAL_ISLAMIC,
'revolucionari': Date.CAL_FRENCH,
'r' : Date.CAL_FRENCH,
'persa' : Date.CAL_PERSIAN,
'p' : Date.CAL_PERSIAN,
'swedish' : Date.CAL_SWEDISH,
's' : Date.CAL_SWEDISH,
}
quality_to_int = {
u'estimat' : Date.QUAL_ESTIMATED,
u'est.' : Date.QUAL_ESTIMATED,
u'est' : Date.QUAL_ESTIMATED,
u'calc.' : Date.QUAL_CALCULATED,
u'calc' : Date.QUAL_CALCULATED,
u'calculat' : Date.QUAL_CALCULATED,
'estimat' : Date.QUAL_ESTIMATED,
'est.' : Date.QUAL_ESTIMATED,
'est' : Date.QUAL_ESTIMATED,
'calc.' : Date.QUAL_CALCULATED,
'calc' : Date.QUAL_CALCULATED,
'calculat' : Date.QUAL_CALCULATED,
}
def init_strings(self):
DateParser.init_strings(self)
_span_1 = [u'des de']
_span_2 = [u'fins a']
_range_1 = [u'entre', u'ent\.', u'ent']
_range_2 = [u'i']
_span_1 = ['des de']
_span_2 = ['fins a']
_range_1 = ['entre', 'ent\.', 'ent']
_range_2 = ['i']
self._span = re.compile("(%s)\s+(?P<start>.+)\s+(%s)\s+(?P<stop>.+)" %
('|'.join(_span_1), '|'.join(_span_2)),
re.IGNORECASE)
@ -118,38 +118,38 @@ class DateDisplayCA(DateDisplay):
"""
Catalan language date display class.
"""
long_months = ( u"", u"Gener", u"Febrer", u"Març", u"Abril", u"Maig",
u"Juny", u"Juliol", u"Agost", u"Setembre", u"Octubre",
u"Novembre", u"Desembre" )
long_months = ( "", "Gener", "Febrer", "Març", "Abril", "Maig",
"Juny", "Juliol", "Agost", "Setembre", "Octubre",
"Novembre", "Desembre" )
short_months = ( u"", u"Gen", u"Feb", u"Mar", u"Abr", u"Mai", u"Jun",
u"Jul", u"Ago", u"Set", u"Oct", u"Nov", u"Des" )
short_months = ( "", "Gen", "Feb", "Mar", "Abr", "Mai", "Jun",
"Jul", "Ago", "Set", "Oct", "Nov", "Des" )
calendar = (
"", u"Julià", u"Hebreu",
u"Revolucionari", u"Persa", u"Islàmic",
u"Suec"
"", "Julià", "Hebreu",
"Revolucionari", "Persa", "Islàmic",
"Suec"
)
_mod_str = ("", u"abans de ", u"després de ", u"cap a ", "", "", "")
_mod_str = ("", "abans de ", "després de ", "cap a ", "", "", "")
_qual_str = ("", "estimat ", "calculat ")
french = (
u'',
u"Vendemiari",
u'Brumari',
u'Frimari',
u"Nivós",
u"Pluviós",
u"Ventós",
u'Germinal',
u"Floreal",
u'Pradial',
u'Messidor',
u'Termidor',
u'Fructidor',
u'Extra',
'',
"Vendemiari",
'Brumari',
'Frimari',
"Nivós",
"Pluviós",
"Ventós",
'Germinal',
"Floreal",
'Pradial',
'Messidor',
'Termidor',
'Fructidor',
'Extra',
)
formats = (
@ -177,12 +177,12 @@ class DateDisplayCA(DateDisplay):
d1 = self.display_cal[cal](start)
d2 = self.display_cal[cal](date.get_stop_date())
scal = self.format_extras(cal, newyear)
return "%s%s %s %s %s%s" % (qual_str, u'des de', d1, u'fins a', d2, scal)
return "%s%s %s %s %s%s" % (qual_str, 'des de', d1, 'fins a', d2, scal)
elif mod == Date.MOD_RANGE:
d1 = self.display_cal[cal](start)
d2 = self.display_cal[cal](date.get_stop_date())
scal = self.format_extras(cal, newyear)
return "%s%s %s %s %s%s" % (qual_str, u'entre', d1, u'i', d2, scal)
return "%s%s %s %s %s%s" % (qual_str, 'entre', d1, 'i', d2, scal)
else:
text = self.display_cal[date.get_calendar()](start)
scal = self.format_extras(cal, newyear)

View File

@ -24,7 +24,7 @@
"""
Czech-specific classes for parsing and displaying dates.
"""
from __future__ import unicode_literals
#-------------------------------------------------------------------------
#
# Python modules
@ -38,9 +38,9 @@ import re
#
#-------------------------------------------------------------------------
from ..lib.date import Date
from _dateparser import DateParser
from _datedisplay import DateDisplay
from _datehandler import register_datehandler
from ._dateparser import DateParser
from ._datedisplay import DateDisplay
from ._datehandler import register_datehandler
#-------------------------------------------------------------------------
#
@ -53,131 +53,131 @@ class DateParserCZ(DateParser):
"""
month_to_int = DateParser.month_to_int
month_to_int[u"leden"] = 1
month_to_int[u"ledna"] = 1
month_to_int[u"lednu"] = 1
month_to_int[u"led"] = 1
month_to_int[u"I"] = 1
month_to_int[u"i"] = 1
month_to_int["leden"] = 1
month_to_int["ledna"] = 1
month_to_int["lednu"] = 1
month_to_int["led"] = 1
month_to_int["I"] = 1
month_to_int["i"] = 1
month_to_int[u"únor"] = 2
month_to_int[u"února"] = 2
month_to_int[u"únoru"] = 2
month_to_int[u"ún"] = 2
month_to_int[u"II"] = 2
month_to_int[u"ii"] = 2
month_to_int["únor"] = 2
month_to_int["února"] = 2
month_to_int["únoru"] = 2
month_to_int["ún"] = 2
month_to_int["II"] = 2
month_to_int["ii"] = 2
month_to_int[u"březen"] = 3
month_to_int[u"března"] = 3
month_to_int[u"březnu"] = 3
month_to_int[u"bře"] = 3
month_to_int[u"III"] = 3
month_to_int[u"iii"] = 3
month_to_int["březen"] = 3
month_to_int["března"] = 3
month_to_int["březnu"] = 3
month_to_int["bře"] = 3
month_to_int["III"] = 3
month_to_int["iii"] = 3
month_to_int[u"duben"] = 4
month_to_int[u"dubna"] = 4
month_to_int[u"dubnu"] = 4
month_to_int[u"dub"] = 4
month_to_int[u"IV"] = 4
month_to_int[u"iv"] = 4
month_to_int["duben"] = 4
month_to_int["dubna"] = 4
month_to_int["dubnu"] = 4
month_to_int["dub"] = 4
month_to_int["IV"] = 4
month_to_int["iv"] = 4
month_to_int[u"květen"] = 5
month_to_int[u"května"] = 5
month_to_int[u"květnu"] = 5
month_to_int[u"V"] = 5
month_to_int[u"v"] = 5
month_to_int["květen"] = 5
month_to_int["května"] = 5
month_to_int["květnu"] = 5
month_to_int["V"] = 5
month_to_int["v"] = 5
month_to_int[u"červen"] = 6
month_to_int[u"června"] = 6
month_to_int[u"červnu"] = 6
month_to_int[u"čer"] = 6
month_to_int[u"vi"] = 6
month_to_int["červen"] = 6
month_to_int["června"] = 6
month_to_int["červnu"] = 6
month_to_int["čer"] = 6
month_to_int["vi"] = 6
month_to_int[u"červenec"] = 7
month_to_int[u"července"] = 7
month_to_int[u"červenci"] = 7
month_to_int[u"čvc"] = 7
month_to_int[u"VII"] = 7
month_to_int[u"vii"] = 7
month_to_int["červenec"] = 7
month_to_int["července"] = 7
month_to_int["červenci"] = 7
month_to_int["čvc"] = 7
month_to_int["VII"] = 7
month_to_int["vii"] = 7
month_to_int[u"srpen"] = 8
month_to_int[u"srpna"] = 8
month_to_int[u"srpnu"] = 8
month_to_int[u"srp"] = 8
month_to_int[u"VIII"] = 8
month_to_int[u"viii"] = 8
month_to_int["srpen"] = 8
month_to_int["srpna"] = 8
month_to_int["srpnu"] = 8
month_to_int["srp"] = 8
month_to_int["VIII"] = 8
month_to_int["viii"] = 8
month_to_int[u"září"] = 9
month_to_int[u"zář"] = 9
month_to_int[u"IX"] = 9
month_to_int[u"ix"] = 9
month_to_int["září"] = 9
month_to_int["zář"] = 9
month_to_int["IX"] = 9
month_to_int["ix"] = 9
month_to_int[u"říjen"] = 10
month_to_int[u"října"] = 10
month_to_int[u"říjnu"] = 10
month_to_int[u"říj"] = 10
month_to_int[u"X"] = 10
month_to_int[u"x"] = 10
month_to_int["říjen"] = 10
month_to_int["října"] = 10
month_to_int["říjnu"] = 10
month_to_int["říj"] = 10
month_to_int["X"] = 10
month_to_int["x"] = 10
month_to_int[u"listopad"] = 11
month_to_int[u"listopadu"] = 11
month_to_int[u"lis"] = 11
month_to_int[u"XI"] = 11
month_to_int[u"xi"] = 11
month_to_int["listopad"] = 11
month_to_int["listopadu"] = 11
month_to_int["lis"] = 11
month_to_int["XI"] = 11
month_to_int["xi"] = 11
month_to_int[u"prosinec"] = 12
month_to_int[u"prosince"] = 12
month_to_int[u"prosinci"] = 12
month_to_int[u"pro"] = 12
month_to_int[u"XII"] = 12
month_to_int[u"xii"] = 12
month_to_int["prosinec"] = 12
month_to_int["prosince"] = 12
month_to_int["prosinci"] = 12
month_to_int["pro"] = 12
month_to_int["XII"] = 12
month_to_int["xii"] = 12
modifier_to_int = {
u'před' : Date.MOD_BEFORE,
u'do' : Date.MOD_BEFORE,
u'po' : Date.MOD_AFTER,
u'asi' : Date.MOD_ABOUT,
u'kolem' : Date.MOD_ABOUT,
u'přibl.' : Date.MOD_ABOUT,
'před' : Date.MOD_BEFORE,
'do' : Date.MOD_BEFORE,
'po' : Date.MOD_AFTER,
'asi' : Date.MOD_ABOUT,
'kolem' : Date.MOD_ABOUT,
'přibl.' : Date.MOD_ABOUT,
}
calendar_to_int = {
u'gregoriánský' : Date.CAL_GREGORIAN,
u'greg.' : Date.CAL_GREGORIAN,
u'g' : Date.CAL_GREGORIAN,
u'juliánský' : Date.CAL_JULIAN,
u'jul.' : Date.CAL_JULIAN,
u'j' : Date.CAL_JULIAN,
u'hebrejský' : Date.CAL_HEBREW,
u'hebr.' : Date.CAL_HEBREW,
u'h' : Date.CAL_HEBREW,
u'islámský' : Date.CAL_ISLAMIC,
u'isl.' : Date.CAL_ISLAMIC,
u'i' : Date.CAL_ISLAMIC,
u'francouzský republikánský' : Date.CAL_FRENCH,
u'fr.' : Date.CAL_FRENCH,
u'perský' : Date.CAL_PERSIAN,
u'per.' : Date.CAL_PERSIAN,
u'p' : Date.CAL_PERSIAN,
u'švédský' : Date.CAL_SWEDISH,
u'sve.' : Date.CAL_SWEDISH,
u's' : Date.CAL_SWEDISH,
'gregoriánský' : Date.CAL_GREGORIAN,
'greg.' : Date.CAL_GREGORIAN,
'g' : Date.CAL_GREGORIAN,
'juliánský' : Date.CAL_JULIAN,
'jul.' : Date.CAL_JULIAN,
'j' : Date.CAL_JULIAN,
'hebrejský' : Date.CAL_HEBREW,
'hebr.' : Date.CAL_HEBREW,
'h' : Date.CAL_HEBREW,
'islámský' : Date.CAL_ISLAMIC,
'isl.' : Date.CAL_ISLAMIC,
'i' : Date.CAL_ISLAMIC,
'francouzský republikánský' : Date.CAL_FRENCH,
'fr.' : Date.CAL_FRENCH,
'perský' : Date.CAL_PERSIAN,
'per.' : Date.CAL_PERSIAN,
'p' : Date.CAL_PERSIAN,
'švédský' : Date.CAL_SWEDISH,
'sve.' : Date.CAL_SWEDISH,
's' : Date.CAL_SWEDISH,
}
quality_to_int = {
u'odhadované' : Date.QUAL_ESTIMATED,
u'odh.' : Date.QUAL_ESTIMATED,
u'vypočtené' : Date.QUAL_CALCULATED,
u'vyp.' : Date.QUAL_CALCULATED,
'odhadované' : Date.QUAL_ESTIMATED,
'odh.' : Date.QUAL_ESTIMATED,
'vypočtené' : Date.QUAL_CALCULATED,
'vyp.' : Date.QUAL_CALCULATED,
}
def init_strings(self):
DateParser.init_strings(self)
self._span = re.compile(
u"(od)\s+(?P<start>.+)\s+(do)\s+(?P<stop>.+)",
"(od)\s+(?P<start>.+)\s+(do)\s+(?P<stop>.+)",
re.IGNORECASE)
self._range = re.compile(
u"(mezi)\s+(?P<start>.+)\s+(a)\s+(?P<stop>.+)",
"(mezi)\s+(?P<start>.+)\s+(a)\s+(?P<stop>.+)",
re.IGNORECASE)
@ -190,20 +190,20 @@ class DateDisplayCZ(DateDisplay):
"""
Czech language date display class.
"""
long_months = ( u"", u"leden", u"únor", u"březen", u"duben", u"květen",
u"červen", u"červenec", u"srpen", u"září", u"říjen",
u"listopad", u"prosinec" )
long_months = ( "", "leden", "únor", "březen", "duben", "květen",
"červen", "červenec", "srpen", "září", "říjen",
"listopad", "prosinec" )
short_months = ( u"", u"led", u"úno", u"bře", u"dub", u"kvě", u"čer",
u"čvc", u"srp", u"zář", u"říj", u"lis", u"pro" )
short_months = ( "", "led", "úno", "bře", "dub", "kvě", "čer",
"čvc", "srp", "zář", "říj", "lis", "pro" )
calendar = (
"", u"juliánský", u"hebrejský",
u"francouzský republikánský", u"perský", u"islámský",
u"švédský"
"", "juliánský", "hebrejský",
"francouzský republikánský", "perský", "islámský",
"švédský"
)
_mod_str = ("", u"před ", u"po ", u"kolem ", "", "", "")
_mod_str = ("", "před ", "po ", "kolem ", "", "", "")
_qual_str = ("", "přibližně ", "vypočteno ")
@ -238,24 +238,24 @@ class DateDisplayCZ(DateDisplay):
return ""
elif mod == Date.MOD_NONE:
date_decl_string = self.display_cal[cal](start)
date_decl_string = date_decl_string.replace(u"den ", u"dna ")
date_decl_string = date_decl_string.replace(u"or ", u"ora ")
date_decl_string = date_decl_string.replace(u"en ", u"na ")
date_decl_string = date_decl_string.replace(u"ad ", u"adu ")
date_decl_string = date_decl_string.replace(u"ec ", u"ce ")
date_decl_string = date_decl_string.replace("den ", "dna ")
date_decl_string = date_decl_string.replace("or ", "ora ")
date_decl_string = date_decl_string.replace("en ", "na ")
date_decl_string = date_decl_string.replace("ad ", "adu ")
date_decl_string = date_decl_string.replace("ec ", "ce ")
return date_decl_string
elif mod == Date.MOD_SPAN:
dat1 = self.display_cal[cal](start)
dat2 = self.display_cal[cal](date.get_stop_date())
scal = self.format_extras(cal, newyear)
return "%s%s %s %s %s%s" % (qual_str, u'od', dat1,
u'do', dat2, scal)
return "%s%s %s %s %s%s" % (qual_str, 'od', dat1,
'do', dat2, scal)
elif mod == Date.MOD_RANGE:
dat1 = self.display_cal[cal](start)
dat2 = self.display_cal[cal](date.get_stop_date())
scal = self.format_extras(cal, newyear)
return "%s%s %s %s %s%s" % (qual_str, u'mezi',
dat1, u'a', dat2, scal)
return "%s%s %s %s %s%s" % (qual_str, 'mezi',
dat1, 'a', dat2, scal)
else:
text = self.display_cal[date.get_calendar()](start)
scal = self.format_extras(cal, newyear)

View File

@ -24,7 +24,7 @@
"""
Danish-specific classes for parsing and displaying dates.
"""
from __future__ import unicode_literals
#-------------------------------------------------------------------------
#
# Python modules
@ -38,9 +38,9 @@ import re
#
#-------------------------------------------------------------------------
from ..lib.date import Date
from _dateparser import DateParser
from _datedisplay import DateDisplay
from _datehandler import register_datehandler
from ._dateparser import DateParser
from ._datedisplay import DateDisplay
from ._datehandler import register_datehandler
#-------------------------------------------------------------------------
#
@ -56,44 +56,44 @@ class DateParserDa(DateParser):
# modifiers before the date
modifier_to_int = {
u'før' : Date.MOD_BEFORE,
u'inden' : Date.MOD_BEFORE,
u'efter' : Date.MOD_AFTER,
u'omkring' : Date.MOD_ABOUT,
u'ca.' : Date.MOD_ABOUT
'før' : Date.MOD_BEFORE,
'inden' : Date.MOD_BEFORE,
'efter' : Date.MOD_AFTER,
'omkring' : Date.MOD_ABOUT,
'ca.' : Date.MOD_ABOUT
}
bce = ["f Kr"]
calendar_to_int = {
u'gregoriansk ' : Date.CAL_GREGORIAN,
u'g' : Date.CAL_GREGORIAN,
u'juliansk' : Date.CAL_JULIAN,
u'j' : Date.CAL_JULIAN,
u'hebraisk' : Date.CAL_HEBREW,
u'h' : Date.CAL_HEBREW,
u'islamisk' : Date.CAL_ISLAMIC,
u'muslimsk' : Date.CAL_ISLAMIC,
u'i' : Date.CAL_ISLAMIC,
u'fransk' : Date.CAL_FRENCH,
u'fransk republikansk' : Date.CAL_FRENCH,
u'f' : Date.CAL_FRENCH,
u'persisk' : Date.CAL_PERSIAN,
u'p' : Date.CAL_PERSIAN,
u'svensk' : Date.CAL_SWEDISH,
u's' : Date.CAL_SWEDISH,
'gregoriansk ' : Date.CAL_GREGORIAN,
'g' : Date.CAL_GREGORIAN,
'juliansk' : Date.CAL_JULIAN,
'j' : Date.CAL_JULIAN,
'hebraisk' : Date.CAL_HEBREW,
'h' : Date.CAL_HEBREW,
'islamisk' : Date.CAL_ISLAMIC,
'muslimsk' : Date.CAL_ISLAMIC,
'i' : Date.CAL_ISLAMIC,
'fransk' : Date.CAL_FRENCH,
'fransk republikansk' : Date.CAL_FRENCH,
'f' : Date.CAL_FRENCH,
'persisk' : Date.CAL_PERSIAN,
'p' : Date.CAL_PERSIAN,
'svensk' : Date.CAL_SWEDISH,
's' : Date.CAL_SWEDISH,
}
quality_to_int = {
u'estimeret' : Date.QUAL_ESTIMATED,
u'beregnet' : Date.QUAL_CALCULATED,
'estimeret' : Date.QUAL_ESTIMATED,
'beregnet' : Date.QUAL_CALCULATED,
}
def init_strings(self):
DateParser.init_strings(self)
self._span = re.compile(u"(fra)?\s*(?P<start>.+)\s*(til|--|)\s*(?P<stop>.+)",
self._span = re.compile("(fra)?\s*(?P<start>.+)\s*(til|--|)\s*(?P<stop>.+)",
re.IGNORECASE)
self._range = re.compile(u"(mellem)\s+(?P<start>.+)\s+og\s+(?P<stop>.+)",
self._range = re.compile("(mellem)\s+(?P<start>.+)\s+og\s+(?P<stop>.+)",
re.IGNORECASE)
#-------------------------------------------------------------------------
@ -106,20 +106,20 @@ class DateDisplayDa(DateDisplay):
Danish language date display class.
"""
long_months = ( u"", u"januar", u"februar", u"marts", u"april", u"maj",
u"juni", u"juli", u"august", u"september", u"oktober",
u"november", u"december" )
long_months = ( "", "januar", "februar", "marts", "april", "maj",
"juni", "juli", "august", "september", "oktober",
"november", "december" )
short_months = ( u"", u"jan", u"feb", u"mar", u"apr", u"maj", u"jun",
u"jul", u"aug", u"sep", u"okt", u"nov", u"dec" )
short_months = ( "", "jan", "feb", "mar", "apr", "maj", "jun",
"jul", "aug", "sep", "okt", "nov", "dec" )
formats = (
u"ÅÅÅÅ-MM-DD (ISO)",
u"Numerisk",
u"Måned dag, år",
u"Md Dag År",
u"Dag måned år",
u"Dag md År",
"ÅÅÅÅ-MM-DD (ISO)",
"Numerisk",
"Måned dag, år",
"Md Dag År",
"Dag måned år",
"Dag md År",
)
calendar = (
@ -132,9 +132,9 @@ class DateDisplayDa(DateDisplay):
"svensk"
)
_mod_str = ("", u"før ", u"efter ", u"ca. ", "", "", "")
_mod_str = ("", "før ", "efter ", "ca. ", "", "", "")
_qual_str = ("", u"beregnet ", u"beregnet ")
_qual_str = ("", "beregnet ", "beregnet ")
_bce_str = "%s f. Kr."
@ -153,22 +153,22 @@ class DateDisplayDa(DateDisplay):
if mod == Date.MOD_TEXTONLY:
return date.get_text()
elif start == Date.EMPTY:
return u""
return ""
elif mod == Date.MOD_SPAN:
d1 = self.display_cal[cal](start)
d2 = self.display_cal[cal](date.get_stop_date())
scal = self.format_extras(cal, newyear)
return u"%sfra %s til %s%s" % (qual_str, d1, d2, scal)
return "%sfra %s til %s%s" % (qual_str, d1, d2, scal)
elif mod == Date.MOD_RANGE:
d1 = self.display_cal[cal](start)
d2 = self.display_cal[cal](date.get_stop_date())
scal = self.format_extras(cal, newyear)
return u"%smellem %s og %s%s" % (qual_str, d1, d2,
return "%smellem %s og %s%s" % (qual_str, d1, d2,
scal)
else:
text = self.display_cal[date.get_calendar()](start)
scal = self.format_extras(cal, newyear)
return u"%s%s%s%s" % (qual_str, self._mod_str[mod],
return "%s%s%s%s" % (qual_str, self._mod_str[mod],
text, scal)
#-------------------------------------------------------------------------

View File

@ -24,7 +24,7 @@
"""
German-specific classes for parsing and displaying dates.
"""
from __future__ import unicode_literals
#-------------------------------------------------------------------------
#
# Python modules
@ -38,9 +38,9 @@ import re
#
#-------------------------------------------------------------------------
from ..lib.date import Date
from _dateparser import DateParser
from _datedisplay import DateDisplay
from _datehandler import register_datehandler
from ._dateparser import DateParser
from ._datedisplay import DateDisplay
from ._datehandler import register_datehandler
#-------------------------------------------------------------------------
#
@ -52,124 +52,124 @@ class DateParserDE(DateParser):
month_to_int = DateParser.month_to_int
# Always add german and austrian name variants no matter what the current
# locale is
month_to_int[u"januar"] = 1
month_to_int[u"jan"] = 1
month_to_int[u"jänner"] = 1
month_to_int[u"jän"] = 1
month_to_int["januar"] = 1
month_to_int["jan"] = 1
month_to_int["jänner"] = 1
month_to_int["jän"] = 1
# Add other common latin,
month_to_int[u"januaris"] = 1
month_to_int[u"januarii"] = 1
month_to_int[u"januarius"] = 1
month_to_int[u"februaris"] = 2
month_to_int[u"februarii"] = 2
month_to_int[u"februarius"] = 2
month_to_int[u"martii"] = 3
month_to_int[u"martius"] = 3
month_to_int[u"aprilis"] = 4
month_to_int[u"maius"] = 5
month_to_int[u"maii"] = 5
month_to_int[u"junius"] = 6
month_to_int[u"junii"] = 6
month_to_int[u"julius"] = 7
month_to_int[u"julii"] = 7
month_to_int[u"augustus"] = 8
month_to_int[u"augusti"] = 8
month_to_int[u"septembris"] = 9
month_to_int[u"7bris"] = 9
month_to_int[u"september"] = 9
month_to_int[u"october"] = 10
month_to_int[u"octobris"] = 10
month_to_int[u"8bris"] = 10
month_to_int[u"novembris"] = 11
month_to_int[u"9bris"] = 11
month_to_int[u"november"] = 11
month_to_int[u"decembris"] = 12
month_to_int[u"10bris"] = 12
month_to_int[u"xbris"] = 12
month_to_int[u"december"] = 12
month_to_int["januaris"] = 1
month_to_int["januarii"] = 1
month_to_int["januarius"] = 1
month_to_int["februaris"] = 2
month_to_int["februarii"] = 2
month_to_int["februarius"] = 2
month_to_int["martii"] = 3
month_to_int["martius"] = 3
month_to_int["aprilis"] = 4
month_to_int["maius"] = 5
month_to_int["maii"] = 5
month_to_int["junius"] = 6
month_to_int["junii"] = 6
month_to_int["julius"] = 7
month_to_int["julii"] = 7
month_to_int["augustus"] = 8
month_to_int["augusti"] = 8
month_to_int["septembris"] = 9
month_to_int["7bris"] = 9
month_to_int["september"] = 9
month_to_int["october"] = 10
month_to_int["octobris"] = 10
month_to_int["8bris"] = 10
month_to_int["novembris"] = 11
month_to_int["9bris"] = 11
month_to_int["november"] = 11
month_to_int["decembris"] = 12
month_to_int["10bris"] = 12
month_to_int["xbris"] = 12
month_to_int["december"] = 12
# local and historical variants
month_to_int[u"jenner"] = 1
month_to_int[u"feber"] = 2
month_to_int[u"merz"] = 3
month_to_int[u"augst"] = 8
month_to_int[u"7ber"] = 9
month_to_int[u"8ber"] = 10
month_to_int[u"9ber"] = 11
month_to_int[u"10ber"] = 12
month_to_int[u"xber"] = 12
month_to_int["jenner"] = 1
month_to_int["feber"] = 2
month_to_int["merz"] = 3
month_to_int["augst"] = 8
month_to_int["7ber"] = 9
month_to_int["8ber"] = 10
month_to_int["9ber"] = 11
month_to_int["10ber"] = 12
month_to_int["xber"] = 12
# old german names
month_to_int[u"hartung"] = 1
month_to_int[u"eismond"] = 1
month_to_int[u"hornung"] = 2
month_to_int[u"schmelzmond"] = 2
month_to_int[u"taumond"] = 2
month_to_int[u"narrenmond"] = 2
month_to_int[u"rebmond"] = 2
month_to_int[u"hintester"] = 2
month_to_int[u"lenzing"] = 3
month_to_int[u"lenzmond"] = 3
month_to_int[u"launing"] = 4
month_to_int[u"ostermond"] = 4
month_to_int[u"winnemond"] = 5
month_to_int[u"weidenmonat"] = 5
month_to_int[u"blumenmond"] = 5
month_to_int[u"brachet"] = 6
month_to_int[u"brachmond"] = 6
month_to_int[u"heuert"] = 7
month_to_int[u"heumond"] = 7
month_to_int[u"ernting"] = 8
month_to_int[u"erntemond"] = 8
month_to_int[u"bisemond"] = 8
month_to_int[u"scheiding"] = 9
month_to_int[u"herbstmond"] = 9
month_to_int[u"gilbhard"] = 10
month_to_int[u"gilbhart"] = 10
month_to_int[u"windmond"] = 11
month_to_int[u"nebelung"] = 11
month_to_int[u"wintermond"] = 11
month_to_int[u"julmond"] = 12
month_to_int[u"heilmond"] = 12
month_to_int[u"christmond"] = 12
month_to_int[u"dustermond"] = 12
month_to_int["hartung"] = 1
month_to_int["eismond"] = 1
month_to_int["hornung"] = 2
month_to_int["schmelzmond"] = 2
month_to_int["taumond"] = 2
month_to_int["narrenmond"] = 2
month_to_int["rebmond"] = 2
month_to_int["hintester"] = 2
month_to_int["lenzing"] = 3
month_to_int["lenzmond"] = 3
month_to_int["launing"] = 4
month_to_int["ostermond"] = 4
month_to_int["winnemond"] = 5
month_to_int["weidenmonat"] = 5
month_to_int["blumenmond"] = 5
month_to_int["brachet"] = 6
month_to_int["brachmond"] = 6
month_to_int["heuert"] = 7
month_to_int["heumond"] = 7
month_to_int["ernting"] = 8
month_to_int["erntemond"] = 8
month_to_int["bisemond"] = 8
month_to_int["scheiding"] = 9
month_to_int["herbstmond"] = 9
month_to_int["gilbhard"] = 10
month_to_int["gilbhart"] = 10
month_to_int["windmond"] = 11
month_to_int["nebelung"] = 11
month_to_int["wintermond"] = 11
month_to_int["julmond"] = 12
month_to_int["heilmond"] = 12
month_to_int["christmond"] = 12
month_to_int["dustermond"] = 12
modifier_to_int = {
u'vor' : Date.MOD_BEFORE,
u'nach' : Date.MOD_AFTER,
u'gegen' : Date.MOD_ABOUT,
u'um' : Date.MOD_ABOUT,
u'etwa' : Date.MOD_ABOUT,
u'circa' : Date.MOD_ABOUT,
u'ca.' : Date.MOD_ABOUT,
'vor' : Date.MOD_BEFORE,
'nach' : Date.MOD_AFTER,
'gegen' : Date.MOD_ABOUT,
'um' : Date.MOD_ABOUT,
'etwa' : Date.MOD_ABOUT,
'circa' : Date.MOD_ABOUT,
'ca.' : Date.MOD_ABOUT,
}
calendar_to_int = {
u'gregorianisch' : Date.CAL_GREGORIAN,
u'greg.' : Date.CAL_GREGORIAN,
u'julianisch' : Date.CAL_JULIAN,
u'jul.' : Date.CAL_JULIAN,
u'hebräisch' : Date.CAL_HEBREW,
u'hebr.' : Date.CAL_HEBREW,
u'islamisch' : Date.CAL_ISLAMIC,
u'isl.' : Date.CAL_ISLAMIC,
u'französisch republikanisch': Date.CAL_FRENCH,
u'franz.' : Date.CAL_FRENCH,
u'persisch' : Date.CAL_PERSIAN,
u'schwedisch' : Date.CAL_SWEDISH,
u's' : Date.CAL_SWEDISH,
'gregorianisch' : Date.CAL_GREGORIAN,
'greg.' : Date.CAL_GREGORIAN,
'julianisch' : Date.CAL_JULIAN,
'jul.' : Date.CAL_JULIAN,
'hebräisch' : Date.CAL_HEBREW,
'hebr.' : Date.CAL_HEBREW,
'islamisch' : Date.CAL_ISLAMIC,
'isl.' : Date.CAL_ISLAMIC,
'französisch republikanisch': Date.CAL_FRENCH,
'franz.' : Date.CAL_FRENCH,
'persisch' : Date.CAL_PERSIAN,
'schwedisch' : Date.CAL_SWEDISH,
's' : Date.CAL_SWEDISH,
}
quality_to_int = {
u'geschätzt' : Date.QUAL_ESTIMATED,
u'gesch.' : Date.QUAL_ESTIMATED,
u'errechnet' : Date.QUAL_CALCULATED,
u'berechnet' : Date.QUAL_CALCULATED,
u'ber.' : Date.QUAL_CALCULATED,
'geschätzt' : Date.QUAL_ESTIMATED,
'gesch.' : Date.QUAL_ESTIMATED,
'errechnet' : Date.QUAL_CALCULATED,
'berechnet' : Date.QUAL_CALCULATED,
'ber.' : Date.QUAL_CALCULATED,
}
bce = ["vor unserer Zeitrechnung", "vor unserer Zeit",
@ -198,22 +198,22 @@ class DateDisplayDE(DateDisplay):
German language date display class.
"""
long_months = ( u"", u"Januar", u"Februar", u"März", u"April", u"Mai",
u"Juni", u"Juli", u"August", u"September", u"Oktober",
u"November", u"Dezember" )
long_months = ( "", "Januar", "Februar", "März", "April", "Mai",
"Juni", "Juli", "August", "September", "Oktober",
"November", "Dezember" )
short_months = ( u"", u"Jan", u"Feb", u"Mär", u"Apr", u"Mai", u"Jun",
u"Jul", u"Aug", u"Sep", u"Okt", u"Nov", u"Dez" )
short_months = ( "", "Jan", "Feb", "Mär", "Apr", "Mai", "Jun",
"Jul", "Aug", "Sep", "Okt", "Nov", "Dez" )
calendar = (
"", u"julianisch", u"hebräisch",
u"französisch republikanisch", u"persisch", u"islamisch",
u"schwedisch"
"", "julianisch", "hebräisch",
"französisch republikanisch", "persisch", "islamisch",
"schwedisch"
)
_mod_str = ("", u"vor ", u"nach ", u"etwa ", "", "", "")
_mod_str = ("", "vor ", "nach ", "etwa ", "", "", "")
_qual_str = ("", u"geschätzt ", u"errechnet ")
_qual_str = ("", "geschätzt ", "errechnet ")
_bce_str = "%s v. u. Z."
@ -301,7 +301,7 @@ class DateDisplayDE(DateDisplay):
d1 = self.display_cal[cal](start)
d2 = self.display_cal[cal](date.get_stop_date())
scal = self.format_extras(cal, newyear)
return "%s%s %s %s %s%s" % (qual_str, u'von', d1, u'bis', d2, scal)
return "%s%s %s %s %s%s" % (qual_str, 'von', d1, 'bis', d2, scal)
elif mod == Date.MOD_RANGE:
d1 = self.display_cal[cal](start)
d2 = self.display_cal[cal](date.get_stop_date())

View File

@ -24,7 +24,7 @@
"""
Spanish-specific classes for parsing and displaying dates.
"""
from __future__ import unicode_literals
#-------------------------------------------------------------------------
#
# Python modules
@ -38,9 +38,9 @@ import re
#
#-------------------------------------------------------------------------
from ..lib.date import Date
from _dateparser import DateParser
from _datedisplay import DateDisplay
from _datehandler import register_datehandler
from ._dateparser import DateParser
from ._datedisplay import DateDisplay
from ._datehandler import register_datehandler
#-------------------------------------------------------------------------
#
@ -50,57 +50,57 @@ from _datehandler import register_datehandler
class DateParserES(DateParser):
modifier_to_int = {
u'antes de' : Date.MOD_BEFORE,
u'antes' : Date.MOD_BEFORE,
u'ant.' : Date.MOD_BEFORE,
u'ant' : Date.MOD_BEFORE,
u'después de' : Date.MOD_AFTER,
u'después' : Date.MOD_AFTER,
u'desp.' : Date.MOD_AFTER,
u'desp' : Date.MOD_AFTER,
u'aprox.' : Date.MOD_ABOUT,
u'aprox' : Date.MOD_ABOUT,
u'apr.' : Date.MOD_ABOUT,
u'apr' : Date.MOD_ABOUT,
u'circa' : Date.MOD_ABOUT,
u'ca.' : Date.MOD_ABOUT,
u'ca' : Date.MOD_ABOUT,
u'c.' : Date.MOD_ABOUT,
u'hacia' : Date.MOD_ABOUT,
'antes de' : Date.MOD_BEFORE,
'antes' : Date.MOD_BEFORE,
'ant.' : Date.MOD_BEFORE,
'ant' : Date.MOD_BEFORE,
'después de' : Date.MOD_AFTER,
'después' : Date.MOD_AFTER,
'desp.' : Date.MOD_AFTER,
'desp' : Date.MOD_AFTER,
'aprox.' : Date.MOD_ABOUT,
'aprox' : Date.MOD_ABOUT,
'apr.' : Date.MOD_ABOUT,
'apr' : Date.MOD_ABOUT,
'circa' : Date.MOD_ABOUT,
'ca.' : Date.MOD_ABOUT,
'ca' : Date.MOD_ABOUT,
'c.' : Date.MOD_ABOUT,
'hacia' : Date.MOD_ABOUT,
}
calendar_to_int = {
u'gregoriano' : Date.CAL_GREGORIAN,
u'g' : Date.CAL_GREGORIAN,
u'juliano' : Date.CAL_JULIAN,
u'j' : Date.CAL_JULIAN,
u'hebreo' : Date.CAL_HEBREW,
u'h' : Date.CAL_HEBREW,
u'islámico' : Date.CAL_ISLAMIC,
u'i' : Date.CAL_ISLAMIC,
u'revolucionario' : Date.CAL_FRENCH,
u'r' : Date.CAL_FRENCH,
u'persa' : Date.CAL_PERSIAN,
u'p' : Date.CAL_PERSIAN,
u'swedish' : Date.CAL_SWEDISH,
u's' : Date.CAL_SWEDISH,
'gregoriano' : Date.CAL_GREGORIAN,
'g' : Date.CAL_GREGORIAN,
'juliano' : Date.CAL_JULIAN,
'j' : Date.CAL_JULIAN,
'hebreo' : Date.CAL_HEBREW,
'h' : Date.CAL_HEBREW,
'islámico' : Date.CAL_ISLAMIC,
'i' : Date.CAL_ISLAMIC,
'revolucionario' : Date.CAL_FRENCH,
'r' : Date.CAL_FRENCH,
'persa' : Date.CAL_PERSIAN,
'p' : Date.CAL_PERSIAN,
'swedish' : Date.CAL_SWEDISH,
's' : Date.CAL_SWEDISH,
}
quality_to_int = {
u'estimado' : Date.QUAL_ESTIMATED,
u'est.' : Date.QUAL_ESTIMATED,
u'est' : Date.QUAL_ESTIMATED,
u'calc.' : Date.QUAL_CALCULATED,
u'calc' : Date.QUAL_CALCULATED,
u'calculado' : Date.QUAL_CALCULATED,
'estimado' : Date.QUAL_ESTIMATED,
'est.' : Date.QUAL_ESTIMATED,
'est' : Date.QUAL_ESTIMATED,
'calc.' : Date.QUAL_CALCULATED,
'calc' : Date.QUAL_CALCULATED,
'calculado' : Date.QUAL_CALCULATED,
}
def init_strings(self):
DateParser.init_strings(self)
_span_1 = [u'de']
_span_2 = [u'a']
_range_1 = [u'entre', u'ent\.', u'ent']
_range_2 = [u'y']
_span_1 = ['de']
_span_2 = ['a']
_range_1 = ['entre', 'ent\.', 'ent']
_range_2 = ['y']
self._span = re.compile("(%s)\s+(?P<start>.+)\s+(%s)\s+(?P<stop>.+)" %
('|'.join(_span_1), '|'.join(_span_2)),
re.IGNORECASE)
@ -118,21 +118,21 @@ class DateDisplayES(DateDisplay):
Spanish language date display class.
"""
# TODO: Translate these month strings:
long_months = ( u"", u"enero", u"febrero", u"marzo", u"abril", u"mayo",
u"junio", u"julio", u"agosto", u"septiembre", u"octubre",
u"noviembre", u"diciembre" )
long_months = ( "", "enero", "febrero", "marzo", "abril", "mayo",
"junio", "julio", "agosto", "septiembre", "octubre",
"noviembre", "diciembre" )
short_months = ( u"", u"enero", u"feb.", u"marzo", u"abr.", u"mayo",
u"jun.", u"jul.", u"agosto", u"set.", u"oct.", u"nov.",
u"dic" )
short_months = ( "", "enero", "feb.", "marzo", "abr.", "mayo",
"jun.", "jul.", "agosto", "set.", "oct.", "nov.",
"dic" )
calendar = (
"", u"Juliano", u"Hebreo",
u"Revolucionario", u"Persa", u"Islámico",
u"Swedish"
"", "Juliano", "Hebreo",
"Revolucionario", "Persa", "Islámico",
"Swedish"
)
_mod_str = ("", u"antes de ", u"después de ", u"hacia ", "", "", "")
_mod_str = ("", "antes de ", "después de ", "hacia ", "", "", "")
_qual_str = ("", "estimado ", "calculado ")
@ -161,12 +161,12 @@ class DateDisplayES(DateDisplay):
d1 = self.display_cal[cal](start)
d2 = self.display_cal[cal](date.get_stop_date())
scal = self.format_extras(cal, newyear)
return "%s%s %s %s %s%s" % (qual_str, u'de', d1, u'a', d2, scal)
return "%s%s %s %s %s%s" % (qual_str, 'de', d1, 'a', d2, scal)
elif mod == Date.MOD_RANGE:
d1 = self.display_cal[cal](start)
d2 = self.display_cal[cal](date.get_stop_date())
scal = self.format_extras(cal, newyear)
return "%s%s %s %s %s%s" % (qual_str, u'entre', d1, u'y', d2, scal)
return "%s%s %s %s %s%s" % (qual_str, 'entre', d1, 'y', d2, scal)
else:
text = self.display_cal[date.get_calendar()](start)
scal = self.format_extras(cal, newyear)

View File

@ -24,7 +24,7 @@
"""
Finnish-specific classes for parsing and displaying dates.
"""
from __future__ import unicode_literals
#-------------------------------------------------------------------------
#
# Python modules
@ -38,9 +38,9 @@ import re
#
#-------------------------------------------------------------------------
from ..lib.date import Date
from _dateparser import DateParser
from _datedisplay import DateDisplay
from _datehandler import register_datehandler
from ._dateparser import DateParser
from ._datedisplay import DateDisplay
from ._datehandler import register_datehandler
#-------------------------------------------------------------------------
#
@ -60,51 +60,51 @@ class DateParserFI(DateParser):
# examples:
# - ennen 1.1.2005
# - noin 1.1.2005
u'ennen' : Date.MOD_BEFORE,
u'e.' : Date.MOD_BEFORE,
u'noin' : Date.MOD_ABOUT,
u'n.' : Date.MOD_ABOUT,
'ennen' : Date.MOD_BEFORE,
'e.' : Date.MOD_BEFORE,
'noin' : Date.MOD_ABOUT,
'n.' : Date.MOD_ABOUT,
}
modifier_after_to_int = {
# examples:
# - 1.1.2005 jälkeen
u'jälkeen' : Date.MOD_AFTER,
u'j.' : Date.MOD_AFTER,
'jälkeen' : Date.MOD_AFTER,
'j.' : Date.MOD_AFTER,
}
bce = [u"ekr.", u"ekr"]
bce = ["ekr.", "ekr"]
calendar_to_int = {
u'gregoriaaninen' : Date.CAL_GREGORIAN,
u'greg.' : Date.CAL_GREGORIAN,
u'juliaaninen' : Date.CAL_JULIAN,
u'jul.' : Date.CAL_JULIAN,
u'heprealainen' : Date.CAL_HEBREW,
u'hepr.' : Date.CAL_HEBREW,
u'islamilainen' : Date.CAL_ISLAMIC,
u'isl.' : Date.CAL_ISLAMIC,
u'ranskan vallankumouksen aikainen': Date.CAL_FRENCH,
u'ranskan v.' : Date.CAL_FRENCH,
u'persialainen' : Date.CAL_PERSIAN,
u'pers.' : Date.CAL_PERSIAN,
u'svensk' : Date.CAL_SWEDISH,
u's' : Date.CAL_SWEDISH,
'gregoriaaninen' : Date.CAL_GREGORIAN,
'greg.' : Date.CAL_GREGORIAN,
'juliaaninen' : Date.CAL_JULIAN,
'jul.' : Date.CAL_JULIAN,
'heprealainen' : Date.CAL_HEBREW,
'hepr.' : Date.CAL_HEBREW,
'islamilainen' : Date.CAL_ISLAMIC,
'isl.' : Date.CAL_ISLAMIC,
'ranskan vallankumouksen aikainen': Date.CAL_FRENCH,
'ranskan v.' : Date.CAL_FRENCH,
'persialainen' : Date.CAL_PERSIAN,
'pers.' : Date.CAL_PERSIAN,
'svensk' : Date.CAL_SWEDISH,
's' : Date.CAL_SWEDISH,
}
quality_to_int = {
u'arviolta' : Date.QUAL_ESTIMATED,
u'arv.' : Date.QUAL_ESTIMATED,
u'laskettuna' : Date.QUAL_CALCULATED,
u'lask.' : Date.QUAL_CALCULATED,
'arviolta' : Date.QUAL_ESTIMATED,
'arv.' : Date.QUAL_ESTIMATED,
'laskettuna' : Date.QUAL_CALCULATED,
'lask.' : Date.QUAL_CALCULATED,
}
def init_strings(self):
DateParser.init_strings(self)
# date, whitespace
self._span = re.compile(u"(?P<start>.+)\s+(-)\s+(?P<stop>.+)",
self._span = re.compile("(?P<start>.+)\s+(-)\s+(?P<stop>.+)",
re.IGNORECASE)
self._range = re.compile(
u"(vuosien\s*)?(?P<start>.+)\s+ja\s+(?P<stop>.+)\s+välillä",
"(vuosien\s*)?(?P<start>.+)\s+ja\s+(?P<stop>.+)\s+välillä",
re.IGNORECASE)
#-------------------------------------------------------------------------
@ -116,26 +116,26 @@ class DateDisplayFI(DateDisplay):
"""
Finnish language date display class.
"""
long_months = (u"", u"Tammikuu", u"Helmikuu", u"Maaliskuu", u"Huhtikuu",
u"Toukokuu", u"Kesäkuu", u"Heinäkuu", u"Elokuu",
u"Syyskuu", u"Lokakuu", u"Marraskuu", u"Joulukuu")
long_months = ("", "Tammikuu", "Helmikuu", "Maaliskuu", "Huhtikuu",
"Toukokuu", "Kesäkuu", "Heinäkuu", "Elokuu",
"Syyskuu", "Lokakuu", "Marraskuu", "Joulukuu")
short_months = (u"", u"Tammi", u"Helmi", u"Maali", u"Huhti", u"Touko",
u"Kesäk", u"Heinä", u"Eloku", u"Syysk", u"Lokak", u"Marra",
u"Joulu")
short_months = ("", "Tammi", "Helmi", "Maali", "Huhti", "Touko",
"Kesäk", "Heinä", "Eloku", "Syysk", "Lokak", "Marra",
"Joulu")
calendar = ("",
u"juliaaninen",
u"heprealainen",
u"ranskan v.",
u"persialainen",
u"islamilainen",
u"svensk"
"juliaaninen",
"heprealainen",
"ranskan v.",
"persialainen",
"islamilainen",
"svensk"
)
_qual_str = (u"", u"arviolta", u"laskettuna")
_qual_str = ("", "arviolta", "laskettuna")
_bce_str = u"%s ekr."
_bce_str = "%s ekr."
formats = (
"VVVV-KK-PP (ISO)",
@ -155,7 +155,7 @@ class DateDisplayFI(DateDisplay):
if mod == Date.MOD_TEXTONLY:
return date.get_text()
if start == Date.EMPTY:
return u""
return ""
# select numerical date format
self.format = 1
@ -163,34 +163,34 @@ class DateDisplayFI(DateDisplay):
if mod == Date.MOD_SPAN:
d1 = self.display_cal[cal](start)
d2 = self.display_cal[cal](date.get_stop_date())
text = u"%s - %s" % (d1, d2)
text = "%s - %s" % (d1, d2)
elif mod == Date.MOD_RANGE:
stop = date.get_stop_date()
if start[0] == start[1] == 0 and stop[0] == 0 and stop[1] == 0:
d1 = self.display_cal[cal](start)
d2 = self.display_cal[cal](stop)
text = u"vuosien %s ja %s välillä" % (d1, d2)
text = "vuosien %s ja %s välillä" % (d1, d2)
else:
d1 = self.display_cal[cal](start)
d2 = self.display_cal[cal](stop)
text = u"%s ja %s välillä" % (d1, d2)
text = "%s ja %s välillä" % (d1, d2)
else:
text = self.display_cal[date.get_calendar()](start)
if mod == Date.MOD_AFTER:
text = text + u" jälkeen"
text = text + " jälkeen"
elif mod == Date.MOD_ABOUT:
text = u"noin " + text
text = "noin " + text
elif mod == Date.MOD_BEFORE:
text = u"ennen " + text
text = "ennen " + text
if qual:
# prepend quality
text = u"%s %s" % (self._qual_str[qual], text)
text = "%s %s" % (self._qual_str[qual], text)
if cal or newyear:
# append calendar type
scal = self.format_extras(cal, newyear)
text = u"%s %s" % (text, scal)
text = "%s %s" % (text, scal)
return text

View File

@ -32,7 +32,7 @@
"""
French-specific classes for parsing and displaying dates.
"""
from __future__ import unicode_literals
import re
#-------------------------------------------------------------------------
@ -42,10 +42,10 @@ import re
#-------------------------------------------------------------------------
from ..lib.date import Date
from _dateparser import DateParser
from _datedisplay import DateDisplay
from _datehandler import register_datehandler
import _grampslocale
from ._dateparser import DateParser
from ._datedisplay import DateDisplay
from ._datehandler import register_datehandler
from . import _grampslocale
#-------------------------------------------------------------------------
#
@ -62,132 +62,132 @@ class DateParserFR(DateParser):
# Custom short months not the same as long months
month_to_int[u"janv"] = 1
month_to_int[u"févr"] = 2
month_to_int[u"juil"] = 7
month_to_int[u"sept"] = 9
month_to_int[u"oct"] = 10
month_to_int[u"déc"] = 12
month_to_int["janv"] = 1
month_to_int["févr"] = 2
month_to_int["juil"] = 7
month_to_int["sept"] = 9
month_to_int["oct"] = 10
month_to_int["déc"] = 12
# Add common value
month_to_int[u"bluviose"] = 5
month_to_int[u"vendose"] = 6
month_to_int[u"7bre"] = 9
month_to_int[u"8bre"] = 10
month_to_int[u"9bre"] = 11
month_to_int[u"10bre"] = 12
month_to_int[u"xbre"] = 12
month_to_int["bluviose"] = 5
month_to_int["vendose"] = 6
month_to_int["7bre"] = 9
month_to_int["8bre"] = 10
month_to_int["9bre"] = 11
month_to_int["10bre"] = 12
month_to_int["xbre"] = 12
# Add common latin
month_to_int[u"januaris"] = 1
month_to_int[u"januarii"] = 1
month_to_int[u"januarius"] = 1
month_to_int[u"februaris"] = 2
month_to_int[u"februarii"] = 2
month_to_int[u"februarius"] = 2
month_to_int[u"martii"] = 3
month_to_int[u"martius"] = 3
month_to_int[u"aprilis"] = 4
month_to_int[u"maius"] = 5
month_to_int[u"maii"] = 5
month_to_int[u"junius"] = 6
month_to_int[u"junii"] = 6
month_to_int[u"julius"] = 7
month_to_int[u"julii"] = 7
month_to_int[u"augustus"] = 8
month_to_int[u"augusti"] = 8
month_to_int[u"septembris"] = 9
month_to_int[u"7bris"] = 9
month_to_int[u"september"] = 9
month_to_int[u"october"] = 10
month_to_int[u"octobris"] = 10
month_to_int[u"8bris"] = 10
month_to_int[u"novembris"] = 11
month_to_int[u"9bris"] = 11
month_to_int[u"november"] = 11
month_to_int[u"decembris"] = 12
month_to_int[u"10bris"] = 12
month_to_int[u"xbris"] = 12
month_to_int[u"december"] = 12
month_to_int["januaris"] = 1
month_to_int["januarii"] = 1
month_to_int["januarius"] = 1
month_to_int["februaris"] = 2
month_to_int["februarii"] = 2
month_to_int["februarius"] = 2
month_to_int["martii"] = 3
month_to_int["martius"] = 3
month_to_int["aprilis"] = 4
month_to_int["maius"] = 5
month_to_int["maii"] = 5
month_to_int["junius"] = 6
month_to_int["junii"] = 6
month_to_int["julius"] = 7
month_to_int["julii"] = 7
month_to_int["augustus"] = 8
month_to_int["augusti"] = 8
month_to_int["septembris"] = 9
month_to_int["7bris"] = 9
month_to_int["september"] = 9
month_to_int["october"] = 10
month_to_int["octobris"] = 10
month_to_int["8bris"] = 10
month_to_int["novembris"] = 11
month_to_int["9bris"] = 11
month_to_int["november"] = 11
month_to_int["decembris"] = 12
month_to_int["10bris"] = 12
month_to_int["xbris"] = 12
month_to_int["december"] = 12
#local and historical variants
# Add common on east france
month_to_int[u"janer"] = 1
month_to_int[u"jenner"] = 1
month_to_int[u"hartmonat"] = 1
month_to_int[u"hartung"] = 1
month_to_int[u"eismond"] = 1
month_to_int[u"hornung"] = 2
month_to_int[u"wintermonat"] = 2
month_to_int[u"taumond"] = 2
month_to_int[u"narrenmond"] = 2
month_to_int[u"lenzing"] = 3
month_to_int[u"ostermond"] = 4
month_to_int[u"wonnemond"] = 5
month_to_int[u"wiesenmonat"] = 5
month_to_int[u"brachet"] = 6
month_to_int[u"heuet"] = 7
month_to_int[u"ernting"] = 8
month_to_int[u"scheiding"] = 9
month_to_int[u"gilbhard"] = 10
month_to_int[u"nebelmonat"] = 11
month_to_int[u"nebelung"] = 11
month_to_int[u"julmond"] = 12
month_to_int["janer"] = 1
month_to_int["jenner"] = 1
month_to_int["hartmonat"] = 1
month_to_int["hartung"] = 1
month_to_int["eismond"] = 1
month_to_int["hornung"] = 2
month_to_int["wintermonat"] = 2
month_to_int["taumond"] = 2
month_to_int["narrenmond"] = 2
month_to_int["lenzing"] = 3
month_to_int["ostermond"] = 4
month_to_int["wonnemond"] = 5
month_to_int["wiesenmonat"] = 5
month_to_int["brachet"] = 6
month_to_int["heuet"] = 7
month_to_int["ernting"] = 8
month_to_int["scheiding"] = 9
month_to_int["gilbhard"] = 10
month_to_int["nebelmonat"] = 11
month_to_int["nebelung"] = 11
month_to_int["julmond"] = 12
modifier_to_int = {
u'avant': Date.MOD_BEFORE,
u'av.' : Date.MOD_BEFORE,
'avant': Date.MOD_BEFORE,
'av.' : Date.MOD_BEFORE,
#u'av' : Date.MOD_BEFORE, # Broke Hebrew "Av" month name
#u'<' : Date.MOD_BEFORE, # Worrying about XML/HTML parsing
u'après': Date.MOD_AFTER,
u'ap.' : Date.MOD_AFTER,
u'ap' : Date.MOD_AFTER,
'après': Date.MOD_AFTER,
'ap.' : Date.MOD_AFTER,
'ap' : Date.MOD_AFTER,
#u'>' : Date.MOD_AFTER, # Worrying about XML/HTML parsing
u'environ' : Date.MOD_ABOUT,
u'env.' : Date.MOD_ABOUT,
u'env' : Date.MOD_ABOUT,
u'circa' : Date.MOD_ABOUT,
u'ca.' : Date.MOD_ABOUT,
u'ca' : Date.MOD_ABOUT,
u'c.' : Date.MOD_ABOUT,
u'vers' : Date.MOD_ABOUT,
u'~' : Date.MOD_ABOUT,
'environ' : Date.MOD_ABOUT,
'env.' : Date.MOD_ABOUT,
'env' : Date.MOD_ABOUT,
'circa' : Date.MOD_ABOUT,
'ca.' : Date.MOD_ABOUT,
'ca' : Date.MOD_ABOUT,
'c.' : Date.MOD_ABOUT,
'vers' : Date.MOD_ABOUT,
'~' : Date.MOD_ABOUT,
}
calendar_to_int = {
u'grégorien': Date.CAL_GREGORIAN,
u'g' : Date.CAL_GREGORIAN,
u'julien': Date.CAL_JULIAN,
u'j' : Date.CAL_JULIAN,
u'hébreu': Date.CAL_HEBREW,
u'h' : Date.CAL_HEBREW,
u'islamique': Date.CAL_ISLAMIC,
u'i' : Date.CAL_ISLAMIC,
u'révolutionnaire': Date.CAL_FRENCH,
u'r' : Date.CAL_FRENCH,
u'perse': Date.CAL_PERSIAN,
u'p' : Date.CAL_PERSIAN,
u'suédois': Date.CAL_SWEDISH,
u's' : Date.CAL_SWEDISH,
'grégorien': Date.CAL_GREGORIAN,
'g' : Date.CAL_GREGORIAN,
'julien': Date.CAL_JULIAN,
'j' : Date.CAL_JULIAN,
'hébreu': Date.CAL_HEBREW,
'h' : Date.CAL_HEBREW,
'islamique': Date.CAL_ISLAMIC,
'i' : Date.CAL_ISLAMIC,
'révolutionnaire': Date.CAL_FRENCH,
'r' : Date.CAL_FRENCH,
'perse': Date.CAL_PERSIAN,
'p' : Date.CAL_PERSIAN,
'suédois': Date.CAL_SWEDISH,
's' : Date.CAL_SWEDISH,
}
quality_to_int = {
u'estimée': Date.QUAL_ESTIMATED,
u'est.' : Date.QUAL_ESTIMATED,
u'est' : Date.QUAL_ESTIMATED,
u'calculée': Date.QUAL_CALCULATED,
u'calc.' : Date.QUAL_CALCULATED,
u'calc' : Date.QUAL_CALCULATED,
u'comptée' : Date.QUAL_CALCULATED,
u'compt.' : Date.QUAL_CALCULATED,
u'compt' : Date.QUAL_CALCULATED,
'estimée': Date.QUAL_ESTIMATED,
'est.' : Date.QUAL_ESTIMATED,
'est' : Date.QUAL_ESTIMATED,
'calculée': Date.QUAL_CALCULATED,
'calc.' : Date.QUAL_CALCULATED,
'calc' : Date.QUAL_CALCULATED,
'comptée' : Date.QUAL_CALCULATED,
'compt.' : Date.QUAL_CALCULATED,
'compt' : Date.QUAL_CALCULATED,
}
bce = [u"avant le calendrier", u"avant notre ère", u"avant JC",
u"avant J.C"] + DateParser.bce
bce = ["avant le calendrier", "avant notre ère", "avant JC",
"avant J.C"] + DateParser.bce
def init_strings(self):
"""
@ -206,9 +206,9 @@ class DateParserFR(DateParser):
# avoid bug gregorian / french calendar conversion (+/-10 days)
self._numeric = re.compile("((\d+)[/\. ])?\s*((\d+)[/\.])?\s*(\d+)\s*$")
self._span = re.compile(u"(de)\s+(?P<start>.+)\s+(à)\s+(?P<stop>.+)",
self._span = re.compile("(de)\s+(?P<start>.+)\s+(à)\s+(?P<stop>.+)",
re.IGNORECASE)
self._range = re.compile(u"(entre|ent\.|ent)\s+(?P<start>.+)\s+(et)\s+(?P<stop>.+)",
self._range = re.compile("(entre|ent\.|ent)\s+(?P<start>.+)\s+(et)\s+(?P<stop>.+)",
re.IGNORECASE)
# This self._text are different from the base
@ -253,21 +253,21 @@ class DateDisplayFR(DateDisplay):
"""
French language date display class.
"""
long_months = ( u"", u"janvier", u"février", u"mars", u"avril", u"mai",
u"juin", u"juillet", u"août", u"septembre", u"octobre",
u"novembre", u"décembre" )
long_months = ( "", "janvier", "février", "mars", "avril", "mai",
"juin", "juillet", "août", "septembre", "octobre",
"novembre", "décembre" )
short_months = ( u"", u"janv", u"févr", u"mars", u"avril", u"mai", u"juin",
u"juil", u"août", u"sept", u"oct", u"nov", u"déc" )
short_months = ( "", "janv", "févr", "mars", "avril", "mai", "juin",
"juil", "août", "sept", "oct", "nov", "déc" )
calendar = ("", u"Julien", u"Hébreu", u"Révolutionnaire",
u"Perse", u"Islamique", u"Suédois")
calendar = ("", "Julien", "Hébreu", "Révolutionnaire",
"Perse", "Islamique", "Suédois")
_mod_str = ("", u"avant ", u"après ", u"vers ", "", "", "")
_mod_str = ("", "avant ", "après ", "vers ", "", "", "")
_qual_str = ("", u"estimée ", u"calculée ", "")
_qual_str = ("", "estimée ", "calculée ", "")
_bce_str = u"%s avant le calendrier"
_bce_str = "%s avant le calendrier"
# Replace the previous "Numérique" by a string which
# do have an explicit meaning: "System default (format)"
@ -428,13 +428,13 @@ class DateDisplayFR(DateDisplay):
date1 = self.display_cal[cal](start)
date2 = self.display_cal[cal](date.get_stop_date())
scal = self.format_extras(cal, newyear)
return "%s%s %s %s %s%s" % (qual_str, u'de', date1, u'à',
return "%s%s %s %s %s%s" % (qual_str, 'de', date1, 'à',
date2, scal)
elif mod == Date.MOD_RANGE:
date1 = self.display_cal[cal](start)
date2 = self.display_cal[cal](date.get_stop_date())
scal = self.format_extras(cal, newyear)
return "%s%s %s %s %s%s" % (qual_str, u'entre', date1, u'et',
return "%s%s %s %s %s%s" % (qual_str, 'entre', date1, 'et',
date2, scal)
else:
text = self.display_cal[date.get_calendar()](start)

View File

@ -26,7 +26,7 @@
"""
Croatian-specific classes for parsing and displaying dates.
"""
from __future__ import unicode_literals
#-------------------------------------------------------------------------
#
# Python modules
@ -40,9 +40,9 @@ import re
#
#-------------------------------------------------------------------------
from ..lib.date import Date
from _dateparser import DateParser
from _datedisplay import DateDisplay
from _datehandler import register_datehandler
from ._dateparser import DateParser
from ._datedisplay import DateDisplay
from ._datehandler import register_datehandler
#-------------------------------------------------------------------------
#
@ -55,125 +55,125 @@ class DateParserHR(DateParser):
"""
month_to_int = DateParser.month_to_int
month_to_int[u"siječanj"] = 1
month_to_int[u"siječnja"] = 1
month_to_int[u"sij"] = 1
month_to_int[u"januar"] = 1
month_to_int[u"januara"] = 1
month_to_int[u"i"] = 1
month_to_int["siječanj"] = 1
month_to_int["siječnja"] = 1
month_to_int["sij"] = 1
month_to_int["januar"] = 1
month_to_int["januara"] = 1
month_to_int["i"] = 1
month_to_int[u"veljača"] = 2
month_to_int[u"veljače"] = 2
month_to_int[u"velj"] = 2
month_to_int[u"februar"] = 2
month_to_int[u"februara"] = 2
month_to_int[u"ii"] = 2
month_to_int["veljača"] = 2
month_to_int["veljače"] = 2
month_to_int["velj"] = 2
month_to_int["februar"] = 2
month_to_int["februara"] = 2
month_to_int["ii"] = 2
month_to_int[u"ožujak"] = 3
month_to_int[u"ožujka"] = 3
month_to_int[u"ožu"] = 3
month_to_int[u"mart"] = 3
month_to_int[u"marta"] = 3
month_to_int[u"iii"] = 3
month_to_int["ožujak"] = 3
month_to_int["ožujka"] = 3
month_to_int["ožu"] = 3
month_to_int["mart"] = 3
month_to_int["marta"] = 3
month_to_int["iii"] = 3
month_to_int[u"travanj"] = 4
month_to_int[u"travnja"] = 4
month_to_int[u"tra"] = 4
month_to_int[u"april"] = 4
month_to_int[u"aprila"] = 4
month_to_int[u"iv"] = 4
month_to_int["travanj"] = 4
month_to_int["travnja"] = 4
month_to_int["tra"] = 4
month_to_int["april"] = 4
month_to_int["aprila"] = 4
month_to_int["iv"] = 4
month_to_int[u"svibanj"] = 5
month_to_int[u"svibnja"] = 5
month_to_int[u"svi"] = 5
month_to_int[u"maj"] = 5
month_to_int[u"maja"] = 5
month_to_int[u"v"] = 5
month_to_int["svibanj"] = 5
month_to_int["svibnja"] = 5
month_to_int["svi"] = 5
month_to_int["maj"] = 5
month_to_int["maja"] = 5
month_to_int["v"] = 5
month_to_int[u"lipanj"] = 6
month_to_int[u"lipnja"] = 6
month_to_int[u"lip"] = 6
month_to_int[u"jun"] = 6
month_to_int[u"juna"] = 6
month_to_int[u"vi"] = 6
month_to_int["lipanj"] = 6
month_to_int["lipnja"] = 6
month_to_int["lip"] = 6
month_to_int["jun"] = 6
month_to_int["juna"] = 6
month_to_int["vi"] = 6
month_to_int[u"srpanj"] = 7
month_to_int[u"srpnja"] = 7
month_to_int[u"srp"] = 7
month_to_int[u"juli"] = 7
month_to_int[u"jula"] = 7
month_to_int[u"vii"] = 7
month_to_int["srpanj"] = 7
month_to_int["srpnja"] = 7
month_to_int["srp"] = 7
month_to_int["juli"] = 7
month_to_int["jula"] = 7
month_to_int["vii"] = 7
month_to_int[u"kolovoz"] = 8
month_to_int[u"kolovoza"] = 8
month_to_int[u"kol"] = 8
month_to_int[u"august"] = 8
month_to_int[u"augusta"] = 8
month_to_int[u"viii"] = 8
month_to_int["kolovoz"] = 8
month_to_int["kolovoza"] = 8
month_to_int["kol"] = 8
month_to_int["august"] = 8
month_to_int["augusta"] = 8
month_to_int["viii"] = 8
month_to_int[u"rujan"] = 9
month_to_int[u"rujna"] = 9
month_to_int[u"ruj"] = 9
month_to_int[u"septembar"] = 9
month_to_int[u"septembra"] = 9
month_to_int[u"ix"] = 9
month_to_int[u"7ber"] = 9
month_to_int["rujan"] = 9
month_to_int["rujna"] = 9
month_to_int["ruj"] = 9
month_to_int["septembar"] = 9
month_to_int["septembra"] = 9
month_to_int["ix"] = 9
month_to_int["7ber"] = 9
month_to_int[u"listopad"] = 10
month_to_int[u"listopada"] = 10
month_to_int[u"lis"] = 10
month_to_int[u"oktobar"] = 10
month_to_int[u"oktobra"] = 10
month_to_int[u"x"] = 10
month_to_int[u"8ber"] = 10
month_to_int["listopad"] = 10
month_to_int["listopada"] = 10
month_to_int["lis"] = 10
month_to_int["oktobar"] = 10
month_to_int["oktobra"] = 10
month_to_int["x"] = 10
month_to_int["8ber"] = 10
month_to_int[u"studeni"] = 11
month_to_int[u"studenog"] = 11
month_to_int[u"stu"] = 11
month_to_int[u"novembar"] = 11
month_to_int[u"novembra"] = 11
month_to_int[u"xi"] = 11
month_to_int[u"9ber"] = 11
month_to_int["studeni"] = 11
month_to_int["studenog"] = 11
month_to_int["stu"] = 11
month_to_int["novembar"] = 11
month_to_int["novembra"] = 11
month_to_int["xi"] = 11
month_to_int["9ber"] = 11
month_to_int[u"prosinac"] = 12
month_to_int[u"prosinca"] = 12
month_to_int[u"pro"] = 12
month_to_int[u"decembar"] = 12
month_to_int[u"decembra"] = 12
month_to_int[u"xii"] = 12
month_to_int["prosinac"] = 12
month_to_int["prosinca"] = 12
month_to_int["pro"] = 12
month_to_int["decembar"] = 12
month_to_int["decembra"] = 12
month_to_int["xii"] = 12
modifier_to_int = {
u'prije' : Date.MOD_BEFORE,
u'pr. ' : Date.MOD_BEFORE,
u'poslije' : Date.MOD_AFTER,
u'po. ' : Date.MOD_AFTER,
u'okolo' : Date.MOD_ABOUT,
u'ok. ' : Date.MOD_ABOUT,
'prije' : Date.MOD_BEFORE,
'pr. ' : Date.MOD_BEFORE,
'poslije' : Date.MOD_AFTER,
'po. ' : Date.MOD_AFTER,
'okolo' : Date.MOD_ABOUT,
'ok. ' : Date.MOD_ABOUT,
}
calendar_to_int = {
u'gregorijanski' : Date.CAL_GREGORIAN,
u'greg.' : Date.CAL_GREGORIAN,
u'julijanski' : Date.CAL_JULIAN,
u'jul.' : Date.CAL_JULIAN,
u'hebrejski' : Date.CAL_HEBREW,
u'hebr.' : Date.CAL_HEBREW,
u'islamski' : Date.CAL_ISLAMIC,
u'isl.' : Date.CAL_ISLAMIC,
u'francuski republikanski': Date.CAL_FRENCH,
u'franc.' : Date.CAL_FRENCH,
u'perzijski' : Date.CAL_PERSIAN,
u'perz. ' : Date.CAL_PERSIAN,
u'švedski' : Date.CAL_SWEDISH,
u's' : Date.CAL_SWEDISH,
'gregorijanski' : Date.CAL_GREGORIAN,
'greg.' : Date.CAL_GREGORIAN,
'julijanski' : Date.CAL_JULIAN,
'jul.' : Date.CAL_JULIAN,
'hebrejski' : Date.CAL_HEBREW,
'hebr.' : Date.CAL_HEBREW,
'islamski' : Date.CAL_ISLAMIC,
'isl.' : Date.CAL_ISLAMIC,
'francuski republikanski': Date.CAL_FRENCH,
'franc.' : Date.CAL_FRENCH,
'perzijski' : Date.CAL_PERSIAN,
'perz. ' : Date.CAL_PERSIAN,
'švedski' : Date.CAL_SWEDISH,
's' : Date.CAL_SWEDISH,
}
quality_to_int = {
u'približno' : Date.QUAL_ESTIMATED,
u'prb.' : Date.QUAL_ESTIMATED,
u'izračunato' : Date.QUAL_CALCULATED,
u'izr.' : Date.QUAL_CALCULATED,
'približno' : Date.QUAL_ESTIMATED,
'prb.' : Date.QUAL_ESTIMATED,
'izračunato' : Date.QUAL_CALCULATED,
'izr.' : Date.QUAL_CALCULATED,
}
bce = ["prije nove ere", "prije Krista",
@ -194,7 +194,7 @@ class DateParserHR(DateParser):
self._span = re.compile("(od)\s+(?P<start>.+)\s+(do)\s+(?P<stop>.+)",
re.IGNORECASE)
self._range = re.compile(
u"(između)\s+(?P<start>.+)\s+(i)\s+(?P<stop>.+)",
"(između)\s+(?P<start>.+)\s+(i)\s+(?P<stop>.+)",
re.IGNORECASE)
self._jtext2 = re.compile('(\d+)?.?\s+?%s\s*((\d+)(/\d+)?)?'\
% self._jmon_str, re.IGNORECASE)
@ -208,30 +208,30 @@ class DateDisplayHR(DateDisplay):
"""
Croatian language date display class.
"""
long_months = ( u"",
u"siječnja",
u"veljače",
u"ožujka",
u"travnja",
u"svibnja",
u"lipnja",
u"srpnja",
u"kolovoza",
u"rujna",
u"listopada",
u"studenog",
u"prosinca"
long_months = ( "",
"siječnja",
"veljače",
"ožujka",
"travnja",
"svibnja",
"lipnja",
"srpnja",
"kolovoza",
"rujna",
"listopada",
"studenog",
"prosinca"
)
#currently unused
short_months = ( u"", u"sij", u"velj", u"ožu", u"tra", u"svi", u"lip",
u"srp", u"kol", u"ruj", u"lis", u"stu", u"pro"
short_months = ( "", "sij", "velj", "ožu", "tra", "svi", "lip",
"srp", "kol", "ruj", "lis", "stu", "pro"
)
calendar = (
"", u"julijanski", u"hebrejski",
u"francuski republikanski", u"perzijski", u"islamski",
u"swedish"
"", "julijanski", "hebrejski",
"francuski republikanski", "perzijski", "islamski",
"swedish"
)
_mod_str = ("", "prije ", "poslije ", "okolo ", "", "", "")
@ -295,17 +295,17 @@ class DateDisplayHR(DateDisplay):
# Day. MONTH year.
if date_val[0] == 0:
if date_val[1] == 0:
value = u"%s." % year
value = "%s." % year
else:
value = u"%s %s." % (self.long_months[date_val[1]], year)
value = "%s %s." % (self.long_months[date_val[1]], year)
else:
value = u"%d. %s %s." % (date_val[0],
value = "%d. %s %s." % (date_val[0],
self.long_months[date_val[1]], year)
else:
# Day RomanMon Year
if date_val[0] == 0:
if date_val[1] == 0:
value = u"%s." % year
value = "%s." % year
else:
value = "%s %s." % (self.roman_months[date_val[1]], year)
else:
@ -336,13 +336,13 @@ class DateDisplayHR(DateDisplay):
d_1 = self.display_cal[cal](start)
d_2 = self.display_cal[cal](date.get_stop_date())
scal = self.format_extras(cal, newyear)
return "%s%s %s %s %s%s" % (qual_str, u'od', d_1, u'do', d_2,
return "%s%s %s %s %s%s" % (qual_str, 'od', d_1, 'do', d_2,
scal)
elif mod == Date.MOD_RANGE:
d_1 = self.display_cal[cal](start)
d_2 = self.display_cal[cal](date.get_stop_date())
scal = self.format_extras(cal, newyear)
return "%s%s %s %s %s%s" % (qual_str, u'između', d_1, u'i', d_2,
return "%s%s %s %s %s%s" % (qual_str, 'između', d_1, 'i', d_2,
scal)
else:
text = self.display_cal[date.get_calendar()](start)

View File

@ -26,7 +26,7 @@
"""
Italian-specific classes for parsing and displaying dates.
"""
from __future__ import unicode_literals
#-------------------------------------------------------------------------
#
# Python modules
@ -40,9 +40,9 @@ import re
#
#-------------------------------------------------------------------------
from ..lib.date import Date
from _dateparser import DateParser
from _datedisplay import DateDisplay
from _datehandler import register_datehandler
from ._dateparser import DateParser
from ._datedisplay import DateDisplay
from ._datehandler import register_datehandler
#-------------------------------------------------------------------------
#
@ -52,52 +52,52 @@ from _datehandler import register_datehandler
class DateParserIT(DateParser):
modifier_to_int = {
u'prima del' : Date.MOD_BEFORE,
u'prima' : Date.MOD_BEFORE,
u'dopo del' : Date.MOD_AFTER,
u'dopo' : Date.MOD_AFTER,
u'approssimativamente' : Date.MOD_ABOUT,
u'apross.' : Date.MOD_ABOUT,
u'apross' : Date.MOD_ABOUT,
u'circa il' : Date.MOD_ABOUT,
u'circa' : Date.MOD_ABOUT,
u'ca.' : Date.MOD_ABOUT,
u'ca' : Date.MOD_ABOUT,
u'c.' : Date.MOD_ABOUT,
'prima del' : Date.MOD_BEFORE,
'prima' : Date.MOD_BEFORE,
'dopo del' : Date.MOD_AFTER,
'dopo' : Date.MOD_AFTER,
'approssimativamente' : Date.MOD_ABOUT,
'apross.' : Date.MOD_ABOUT,
'apross' : Date.MOD_ABOUT,
'circa il' : Date.MOD_ABOUT,
'circa' : Date.MOD_ABOUT,
'ca.' : Date.MOD_ABOUT,
'ca' : Date.MOD_ABOUT,
'c.' : Date.MOD_ABOUT,
}
calendar_to_int = {
u'gregoriano' : Date.CAL_GREGORIAN,
u'g' : Date.CAL_GREGORIAN,
u'giuliano' : Date.CAL_JULIAN,
u'j' : Date.CAL_JULIAN,
u'ebraico' : Date.CAL_HEBREW,
u'e' : Date.CAL_HEBREW,
u'islamico' : Date.CAL_ISLAMIC,
u'i' : Date.CAL_ISLAMIC,
u'rivoluzionario': Date.CAL_FRENCH,
u'r' : Date.CAL_FRENCH,
u'persiano' : Date.CAL_PERSIAN,
u'p' : Date.CAL_PERSIAN,
u'svedese' : Date.CAL_SWEDISH,
u's' : Date.CAL_SWEDISH,
'gregoriano' : Date.CAL_GREGORIAN,
'g' : Date.CAL_GREGORIAN,
'giuliano' : Date.CAL_JULIAN,
'j' : Date.CAL_JULIAN,
'ebraico' : Date.CAL_HEBREW,
'e' : Date.CAL_HEBREW,
'islamico' : Date.CAL_ISLAMIC,
'i' : Date.CAL_ISLAMIC,
'rivoluzionario': Date.CAL_FRENCH,
'r' : Date.CAL_FRENCH,
'persiano' : Date.CAL_PERSIAN,
'p' : Date.CAL_PERSIAN,
'svedese' : Date.CAL_SWEDISH,
's' : Date.CAL_SWEDISH,
}
quality_to_int = {
u'stimata' : Date.QUAL_ESTIMATED,
u'st.' : Date.QUAL_ESTIMATED,
u'st' : Date.QUAL_ESTIMATED,
u'calcolata' : Date.QUAL_CALCULATED,
u'calc.' : Date.QUAL_CALCULATED,
u'calc' : Date.QUAL_CALCULATED,
'stimata' : Date.QUAL_ESTIMATED,
'st.' : Date.QUAL_ESTIMATED,
'st' : Date.QUAL_ESTIMATED,
'calcolata' : Date.QUAL_CALCULATED,
'calc.' : Date.QUAL_CALCULATED,
'calc' : Date.QUAL_CALCULATED,
}
def init_strings(self):
DateParser.init_strings(self)
_span_1 = [u'dal', u'da']
_span_2 = [u'al', u'a']
_range_1 = [u'tra', u'fra']
_range_2 = [u'e']
_span_1 = ['dal', 'da']
_span_2 = ['al', 'a']
_range_1 = ['tra', 'fra']
_range_2 = ['e']
self._span = re.compile("(%s)\s+(?P<start>.+)\s+(%s)\s+(?P<stop>.+)" %
('|'.join(_span_1), '|'.join(_span_2)),
re.IGNORECASE)
@ -114,38 +114,38 @@ class DateDisplayIT(DateDisplay):
"""
Italian language date display class.
"""
long_months = ( u"", u"gennaio", u"febbraio", u"marzo", u"aprile",
u"maggio", u"giugno", u"luglio", u"agosto", u"settembre",
u"ottobre", u"novembre", u"dicembre" )
long_months = ( "", "gennaio", "febbraio", "marzo", "aprile",
"maggio", "giugno", "luglio", "agosto", "settembre",
"ottobre", "novembre", "dicembre" )
short_months = ( u"", u"gen", u"feb", u"mar", u"apr", u"mag", u"giu",
u"lug", u"ago", u"set", u"ott", u"nov", u"dic" )
short_months = ( "", "gen", "feb", "mar", "apr", "mag", "giu",
"lug", "ago", "set", "ott", "nov", "dic" )
calendar = (
"", u"Giuliano", u"Ebraico",
u"Rivoluzionario", u"Persiano", u"Islamico",
u"Svedese"
"", "Giuliano", "Ebraico",
"Rivoluzionario", "Persiano", "Islamico",
"Svedese"
)
_mod_str = ("", u"prima del ", u"dopo del ", u"circa il ", "", "", "")
_mod_str = ("", "prima del ", "dopo del ", "circa il ", "", "", "")
_qual_str = ("", "stimata ", "calcolata ")
french = (
u'',
u'vendemmiaio',
u'brumaio',
u'frimaio',
u'nevoso',
u'piovoso',
u'ventoso',
u'germile',
u'fiorile',
u'pratile',
u'messidoro',
u'termidoro',
u'fruttidoro',
u'extra',
'',
'vendemmiaio',
'brumaio',
'frimaio',
'nevoso',
'piovoso',
'ventoso',
'germile',
'fiorile',
'pratile',
'messidoro',
'termidoro',
'fruttidoro',
'extra',
)
formats = (
@ -173,12 +173,12 @@ class DateDisplayIT(DateDisplay):
d1 = self.display_cal[cal](start)
d2 = self.display_cal[cal](date.get_stop_date())
scal = self.format_extras(cal, newyear)
return "%s%s %s %s %s%s" % (qual_str, u'dal', d1, u'al', d2, scal)
return "%s%s %s %s %s%s" % (qual_str, 'dal', d1, 'al', d2, scal)
elif mod == Date.MOD_RANGE:
d1 = self.display_cal[cal](start)
d2 = self.display_cal[cal](date.get_stop_date())
scal = self.format_extras(cal, newyear)
return "%s%s %s %s %s%s" % (qual_str, u'tra', d1, u'e', d2, scal)
return "%s%s %s %s %s%s" % (qual_str, 'tra', d1, 'e', d2, scal)
else:
text = self.display_cal[date.get_calendar()](start)
scal = self.format_extras(cal, newyear)

View File

@ -24,7 +24,7 @@
"""
Lithuanian-specific classes for parsing and displaying dates.
"""
from __future__ import unicode_literals
#-------------------------------------------------------------------------
#
# Python modules
@ -38,9 +38,9 @@ import re
#
#-------------------------------------------------------------------------
from ..lib.date import Date
from _dateparser import DateParser
from _datedisplay import DateDisplay
from _datehandler import register_datehandler
from ._dateparser import DateParser
from ._datedisplay import DateDisplay
from ._datehandler import register_datehandler
#-------------------------------------------------------------------------
#
@ -57,85 +57,85 @@ class DateParserLT(DateParser):
# Custom months not the same as long months
month_to_int[u"sausis"] = 1
month_to_int[u"vasaris"] = 2
month_to_int[u"kovas"] = 3
month_to_int[u"balandis"] = 4
month_to_int[u"gegužė"] = 5
month_to_int[u"gegužis"] = 5
month_to_int[u"birželis"] = 6
month_to_int[u"liepa"] = 7
month_to_int[u"rugpjūtis"] = 8
month_to_int[u"rugsėjis"] = 9
month_to_int[u"spalis"] = 10
month_to_int[u"lapkritis"] = 11
month_to_int[u"gruodis"] = 12
month_to_int["sausis"] = 1
month_to_int["vasaris"] = 2
month_to_int["kovas"] = 3
month_to_int["balandis"] = 4
month_to_int["gegužė"] = 5
month_to_int["gegužis"] = 5
month_to_int["birželis"] = 6
month_to_int["liepa"] = 7
month_to_int["rugpjūtis"] = 8
month_to_int["rugsėjis"] = 9
month_to_int["spalis"] = 10
month_to_int["lapkritis"] = 11
month_to_int["gruodis"] = 12
# For not full months
month_to_int[u"saus"] = 1
month_to_int[u"vasa"] = 2
month_to_int[u"vasar"] = 2
month_to_int[u"bala"] = 4
month_to_int[u"balan"] = 4
month_to_int[u"baland"] = 4
month_to_int[u"gegu"] = 5
month_to_int[u"geguž"] = 5
month_to_int[u"birž"] = 6
month_to_int[u"birže"] = 6
month_to_int[u"biržel"] = 6
month_to_int[u"liep"] = 7
month_to_int[u"rugp"] = 8
month_to_int[u"rugpj"] = 8
month_to_int[u"rugpjū"] = 8
month_to_int[u"rugpjūt"] = 8
month_to_int[u"rugs"] = 9
month_to_int[u"rugsė"] = 9
month_to_int[u"rugsėj"] = 9
month_to_int[u"rugsėjis"] = 9
month_to_int[u"spal"] = 10
month_to_int[u"lapk"] = 11
month_to_int[u"lapkr"] = 11
month_to_int[u"lapkri"] = 11
month_to_int[u"lapkrit"] = 11
month_to_int[u"gru"] = 12
month_to_int[u"gruo"] = 12
month_to_int[u"gruod"] = 12
month_to_int["saus"] = 1
month_to_int["vasa"] = 2
month_to_int["vasar"] = 2
month_to_int["bala"] = 4
month_to_int["balan"] = 4
month_to_int["baland"] = 4
month_to_int["gegu"] = 5
month_to_int["geguž"] = 5
month_to_int["birž"] = 6
month_to_int["birže"] = 6
month_to_int["biržel"] = 6
month_to_int["liep"] = 7
month_to_int["rugp"] = 8
month_to_int["rugpj"] = 8
month_to_int["rugpjū"] = 8
month_to_int["rugpjūt"] = 8
month_to_int["rugs"] = 9
month_to_int["rugsė"] = 9
month_to_int["rugsėj"] = 9
month_to_int["rugsėjis"] = 9
month_to_int["spal"] = 10
month_to_int["lapk"] = 11
month_to_int["lapkr"] = 11
month_to_int["lapkri"] = 11
month_to_int["lapkrit"] = 11
month_to_int["gru"] = 12
month_to_int["gruo"] = 12
month_to_int["gruod"] = 12
modifier_to_int = {
u'prieš' : Date.MOD_BEFORE,
u'po' : Date.MOD_AFTER,
u'apie' : Date.MOD_ABOUT,
'prieš' : Date.MOD_BEFORE,
'po' : Date.MOD_AFTER,
'apie' : Date.MOD_ABOUT,
}
calendar_to_int = {
u'grigaliaus' : Date.CAL_GREGORIAN,
u'g' : Date.CAL_GREGORIAN,
u'julijaus' : Date.CAL_JULIAN,
u'j' : Date.CAL_JULIAN,
u'hebrajų' : Date.CAL_HEBREW,
u'h' : Date.CAL_HEBREW,
u'islamo' : Date.CAL_ISLAMIC,
u'i' : Date.CAL_ISLAMIC,
u'prancūzų respublikos': Date.CAL_FRENCH,
u'r' : Date.CAL_FRENCH,
u'persų' : Date.CAL_PERSIAN,
u'p' : Date.CAL_PERSIAN,
u'švedų' : Date.CAL_SWEDISH,
u's' : Date.CAL_SWEDISH,
'grigaliaus' : Date.CAL_GREGORIAN,
'g' : Date.CAL_GREGORIAN,
'julijaus' : Date.CAL_JULIAN,
'j' : Date.CAL_JULIAN,
'hebrajų' : Date.CAL_HEBREW,
'h' : Date.CAL_HEBREW,
'islamo' : Date.CAL_ISLAMIC,
'i' : Date.CAL_ISLAMIC,
'prancūzų respublikos': Date.CAL_FRENCH,
'r' : Date.CAL_FRENCH,
'persų' : Date.CAL_PERSIAN,
'p' : Date.CAL_PERSIAN,
'švedų' : Date.CAL_SWEDISH,
's' : Date.CAL_SWEDISH,
}
quality_to_int = {
u'apytikriai' : Date.QUAL_ESTIMATED,
u'apskaičiuota' : Date.QUAL_CALCULATED,
'apytikriai' : Date.QUAL_ESTIMATED,
'apskaičiuota' : Date.QUAL_CALCULATED,
}
def init_strings(self):
DateParser.init_strings(self)
_span_1 = [u'nuo']
_span_2 = [u'iki']
_range_1 = [u'tarp']
_range_2 = [u'ir']
_span_1 = ['nuo']
_span_2 = ['iki']
_range_1 = ['tarp']
_range_2 = ['ir']
self._span = re.compile(
"(%s)\s+(?P<start>.+)\s+(%s)\s+(?P<stop>.+)" %
('|'.join(_span_1), '|'.join(_span_2)),
@ -176,33 +176,33 @@ class DateDisplayLT(DateDisplay):
Lithuanian language date display class.
"""
long_months = ( u"", u"sausio", u"vasario", u"kovo", u"balandžio", u"gegužės",
u"birželio", u"liepos", u"rugpjūčio", u"rugsėjo", u"spalio",
u"lapkričio", u"gruodžio" )
long_months = ( "", "sausio", "vasario", "kovo", "balandžio", "gegužės",
"birželio", "liepos", "rugpjūčio", "rugsėjo", "spalio",
"lapkričio", "gruodžio" )
long_months_vardininkas = ( u"", u"sausis", u"vasaris", u"kovas", u"balandis", u"gegužė",
u"birželis", u"liepa", u"rugpjūtis", u"rugsėjis", u"spalis",
u"lapkritis", u"gruodis" )
long_months_vardininkas = ( "", "sausis", "vasaris", "kovas", "balandis", "gegužė",
"birželis", "liepa", "rugpjūtis", "rugsėjis", "spalis",
"lapkritis", "gruodis" )
short_months = ( u"", u"Sau", u"Vas", u"Kov", u"Bal", u"Geg", u"Bir",
u"Lie", u"Rgp", u"Rgs", u"Spa", u"Lap", u"Grd" )
short_months = ( "", "Sau", "Vas", "Kov", "Bal", "Geg", "Bir",
"Lie", "Rgp", "Rgs", "Spa", "Lap", "Grd" )
calendar = (
u"", u"julijaus",
u"hebrajų",
u"prancūzų respublikos",
u"persų",
u"islamo",
u"švedų"
"", "julijaus",
"hebrajų",
"prancūzų respublikos",
"persų",
"islamo",
"švedų"
)
_mod_str = (u"",
u"prieš ",
u"po ",
u"apie ",
u"", u"", u"")
_mod_str = ("",
"prieš ",
"po ",
"apie ",
"", "", "")
_qual_str = (u"", u"apytikriai ", u"apskaičiuota ")
_qual_str = ("", "apytikriai ", "apskaičiuota ")
formats = (
"mmmm-MM-DD (ISO)", "mmmm m. mėnesio diena d.", "Mėn diena, metai")
@ -267,13 +267,13 @@ class DateDisplayLT(DateDisplay):
d1 = self.display_cal[cal](start)
d2 = self.display_cal[cal](date.get_stop_date())
scal = self.format_extras(cal, newyear)
return "%s%s %s %s %s%s" % (qual_str, u'nuo', d1, u'iki',
return "%s%s %s %s %s%s" % (qual_str, 'nuo', d1, 'iki',
d2, scal)
elif mod == Date.MOD_RANGE:
d1 = self.display_cal[cal](start)
d2 = self.display_cal[cal](date.get_stop_date())
scal = self.format_extras(cal, newyear)
return "%s%s %s %s %s%s" % (qual_str, u'tarp', d1, u'ir',
return "%s%s %s %s %s%s" % (qual_str, 'tarp', d1, 'ir',
d2, scal)
else:
text = self.display_cal[date.get_calendar()](start)

View File

@ -24,7 +24,7 @@
"""
Norwegian-specific classes for parsing and displaying dates.
"""
from __future__ import unicode_literals
#-------------------------------------------------------------------------
#
# Python modules
@ -38,9 +38,9 @@ import re
#
#-------------------------------------------------------------------------
from ..lib.date import Date
from _dateparser import DateParser
from _datedisplay import DateDisplay
from _datehandler import register_datehandler
from ._dateparser import DateParser
from ._datedisplay import DateDisplay
from ._datehandler import register_datehandler
#-------------------------------------------------------------------------
#
@ -56,44 +56,44 @@ class DateParserNb(DateParser):
# modifiers before the date
modifier_to_int = {
u'før' : Date.MOD_BEFORE,
u'innen' : Date.MOD_BEFORE,
u'etter' : Date.MOD_AFTER,
u'omkring' : Date.MOD_ABOUT,
u'ca' : Date.MOD_ABOUT
'før' : Date.MOD_BEFORE,
'innen' : Date.MOD_BEFORE,
'etter' : Date.MOD_AFTER,
'omkring' : Date.MOD_ABOUT,
'ca' : Date.MOD_ABOUT
}
bce = ["f Kr"]
calendar_to_int = {
u'gregoriansk ' : Date.CAL_GREGORIAN,
u'g' : Date.CAL_GREGORIAN,
u'juliansk' : Date.CAL_JULIAN,
u'j' : Date.CAL_JULIAN,
u'hebraisk' : Date.CAL_HEBREW,
u'h' : Date.CAL_HEBREW,
u'islamisk' : Date.CAL_ISLAMIC,
u'muslimsk' : Date.CAL_ISLAMIC,
u'i' : Date.CAL_ISLAMIC,
u'fransk' : Date.CAL_FRENCH,
u'fransk republikansk' : Date.CAL_FRENCH,
u'f' : Date.CAL_FRENCH,
u'persisk' : Date.CAL_PERSIAN,
u'p' : Date.CAL_PERSIAN,
u'svensk' : Date.CAL_SWEDISH,
u's' : Date.CAL_SWEDISH,
'gregoriansk ' : Date.CAL_GREGORIAN,
'g' : Date.CAL_GREGORIAN,
'juliansk' : Date.CAL_JULIAN,
'j' : Date.CAL_JULIAN,
'hebraisk' : Date.CAL_HEBREW,
'h' : Date.CAL_HEBREW,
'islamisk' : Date.CAL_ISLAMIC,
'muslimsk' : Date.CAL_ISLAMIC,
'i' : Date.CAL_ISLAMIC,
'fransk' : Date.CAL_FRENCH,
'fransk republikansk' : Date.CAL_FRENCH,
'f' : Date.CAL_FRENCH,
'persisk' : Date.CAL_PERSIAN,
'p' : Date.CAL_PERSIAN,
'svensk' : Date.CAL_SWEDISH,
's' : Date.CAL_SWEDISH,
}
quality_to_int = {
u'estimert' : Date.QUAL_ESTIMATED,
u'beregnet' : Date.QUAL_CALCULATED,
'estimert' : Date.QUAL_ESTIMATED,
'beregnet' : Date.QUAL_CALCULATED,
}
def init_strings(self):
DateParser.init_strings(self)
self._span = re.compile(u"(fra)?\s*(?P<start>.+)\s*(til|--|)\s*(?P<stop>.+)",
self._span = re.compile("(fra)?\s*(?P<start>.+)\s*(til|--|)\s*(?P<stop>.+)",
re.IGNORECASE)
self._range = re.compile(u"(mellom)\s+(?P<start>.+)\s+og\s+(?P<stop>.+)",
self._range = re.compile("(mellom)\s+(?P<start>.+)\s+og\s+(?P<stop>.+)",
re.IGNORECASE)
#-------------------------------------------------------------------------
@ -106,20 +106,20 @@ class DateDisplayNb(DateDisplay):
Norwegian language date display class.
"""
long_months = ( u"", u"januar", u"februar", u"mars", u"april", u"mai",
u"juni", u"juli", u"august", u"september", u"oktober",
u"november", u"desember" )
long_months = ( "", "januar", "februar", "mars", "april", "mai",
"juni", "juli", "august", "september", "oktober",
"november", "desember" )
short_months = ( u"", u"jan", u"feb", u"mar", u"apr", u"mai", u"jun",
u"jul", u"aug", u"sep", u"okt", u"nov", u"des" )
short_months = ( "", "jan", "feb", "mar", "apr", "mai", "jun",
"jul", "aug", "sep", "okt", "nov", "des" )
formats = (
u"ÅÅÅÅ-MM-DD (ISO)",
u"Numerisk",
u"Måned dag, år",
u"Mån Dag År",
u"Dag måned år",
u"Dag Mån År",
"ÅÅÅÅ-MM-DD (ISO)",
"Numerisk",
"Måned dag, år",
"Mån Dag År",
"Dag måned år",
"Dag Mån År",
)
calendar = (
@ -132,9 +132,9 @@ class DateDisplayNb(DateDisplay):
"svensk"
)
_mod_str = ("", u"før ", u"etter ", u"ca ", "", "", "")
_mod_str = ("", "før ", "etter ", "ca ", "", "", "")
_qual_str = ("", u"beregnet ", u"beregnet ")
_qual_str = ("", "beregnet ", "beregnet ")
_bce_str = "%s f Kr"
@ -153,22 +153,22 @@ class DateDisplayNb(DateDisplay):
if mod == Date.MOD_TEXTONLY:
return date.get_text()
elif start == Date.EMPTY:
return u""
return ""
elif mod == Date.MOD_SPAN:
d1 = self.display_cal[cal](start)
d2 = self.display_cal[cal](date.get_stop_date())
scal = self.format_extras(cal, newyear)
return u"%sfra %s til %s%s" % (qual_str, d1, d2, scal)
return "%sfra %s til %s%s" % (qual_str, d1, d2, scal)
elif mod == Date.MOD_RANGE:
d1 = self.display_cal[cal](start)
d2 = self.display_cal[cal](date.get_stop_date())
scal = self.format_extras(cal, newyear)
return u"%smellom %s og %s%s" % (qual_str, d1, d2,
return "%smellom %s og %s%s" % (qual_str, d1, d2,
scal)
else:
text = self.display_cal[date.get_calendar()](start)
scal = self.format_extras(cal, newyear)
return u"%s%s%s%s" % (qual_str, self._mod_str[mod],
return "%s%s%s%s" % (qual_str, self._mod_str[mod],
text, scal)
#-------------------------------------------------------------------------

View File

@ -30,6 +30,7 @@
"""
Dutch-specific classes for parsing and displaying dates.
"""
from __future__ import unicode_literals
#-------------------------------------------------------------------------
#
@ -44,9 +45,9 @@ import re
#
#-------------------------------------------------------------------------
from ..lib.date import Date
from _dateparser import DateParser
from _datedisplay import DateDisplay
from _datehandler import register_datehandler
from ._dateparser import DateParser
from ._datedisplay import DateDisplay
from ._datehandler import register_datehandler
#-------------------------------------------------------------------------
#
@ -58,63 +59,63 @@ class DateParserNL(DateParser):
month_to_int = DateParser.month_to_int
# Always add dutch and flemish name variants
# no matter what the current locale is
month_to_int[u"januari"] = 1
month_to_int[u"jan"] = 1
month_to_int["januari"] = 1
month_to_int["jan"] = 1
# Add other common latin, local and historical variants
month_to_int[u"januaris"] = 1
month_to_int[u"feber"] = 2
month_to_int[u"februaris"] = 2
month_to_int[u"merz"] = 3
month_to_int["januaris"] = 1
month_to_int["feber"] = 2
month_to_int["februaris"] = 2
month_to_int["merz"] = 3
#make sure on all distro mrt and maa are accepted
month_to_int[u"maa"] = 3
month_to_int[u"mrt"] = 3
month_to_int[u"aprilis"] = 4
month_to_int[u"maius"] = 5
month_to_int[u"junius"] = 6
month_to_int[u"julius"] = 7
month_to_int[u"augst"] = 8
month_to_int[u"7ber"] = 9
month_to_int[u"7bris"] = 9
month_to_int[u"8ber"] = 10
month_to_int[u"8bris"] = 10
month_to_int[u"9ber"] = 11
month_to_int[u"9bris"] = 11
month_to_int[u"10ber"] = 12
month_to_int[u"10bris"] = 12
month_to_int[u"xber"] = 12
month_to_int[u"xbris"] = 12
month_to_int["maa"] = 3
month_to_int["mrt"] = 3
month_to_int["aprilis"] = 4
month_to_int["maius"] = 5
month_to_int["junius"] = 6
month_to_int["julius"] = 7
month_to_int["augst"] = 8
month_to_int["7ber"] = 9
month_to_int["7bris"] = 9
month_to_int["8ber"] = 10
month_to_int["8bris"] = 10
month_to_int["9ber"] = 11
month_to_int["9bris"] = 11
month_to_int["10ber"] = 12
month_to_int["10bris"] = 12
month_to_int["xber"] = 12
month_to_int["xbris"] = 12
modifier_to_int = {
u'voor' : Date.MOD_BEFORE,
u'na' : Date.MOD_AFTER,
u'tegen' : Date.MOD_ABOUT,
u'om' : Date.MOD_ABOUT,
u'rond' : Date.MOD_ABOUT,
u'circa' : Date.MOD_ABOUT,
u'ca.' : Date.MOD_ABOUT,
'voor' : Date.MOD_BEFORE,
'na' : Date.MOD_AFTER,
'tegen' : Date.MOD_ABOUT,
'om' : Date.MOD_ABOUT,
'rond' : Date.MOD_ABOUT,
'circa' : Date.MOD_ABOUT,
'ca.' : Date.MOD_ABOUT,
}
calendar_to_int = {
u'gregoriaans' : Date.CAL_GREGORIAN,
u'greg.' : Date.CAL_GREGORIAN,
u'juliaans' : Date.CAL_JULIAN,
u'jul.' : Date.CAL_JULIAN,
u'hebreeuws' : Date.CAL_HEBREW,
u'hebr.' : Date.CAL_HEBREW,
u'islamitisch' : Date.CAL_ISLAMIC,
u'isl.' : Date.CAL_ISLAMIC,
u'franse republiek': Date.CAL_FRENCH,
u'fran.' : Date.CAL_FRENCH,
u'persisch' : Date.CAL_PERSIAN,
u'zweeds' : Date.CAL_SWEDISH,
u'z' : Date.CAL_SWEDISH,
'gregoriaans' : Date.CAL_GREGORIAN,
'greg.' : Date.CAL_GREGORIAN,
'juliaans' : Date.CAL_JULIAN,
'jul.' : Date.CAL_JULIAN,
'hebreeuws' : Date.CAL_HEBREW,
'hebr.' : Date.CAL_HEBREW,
'islamitisch' : Date.CAL_ISLAMIC,
'isl.' : Date.CAL_ISLAMIC,
'franse republiek': Date.CAL_FRENCH,
'fran.' : Date.CAL_FRENCH,
'persisch' : Date.CAL_PERSIAN,
'zweeds' : Date.CAL_SWEDISH,
'z' : Date.CAL_SWEDISH,
}
quality_to_int = {
u'geschat' : Date.QUAL_ESTIMATED,
u'gesch.' : Date.QUAL_ESTIMATED,
u'berekend' : Date.QUAL_CALCULATED,
u'ber.' : Date.QUAL_CALCULATED,
'geschat' : Date.QUAL_ESTIMATED,
'gesch.' : Date.QUAL_ESTIMATED,
'berekend' : Date.QUAL_CALCULATED,
'ber.' : Date.QUAL_CALCULATED,
}
bce = ["voor onze tijdrekening", "voor Christus", "v. Chr."] + DateParser.bce
@ -142,21 +143,21 @@ class DateDisplayNL(DateDisplay):
Dutch language date display class.
"""
# TODO: Translate these month strings:
long_months = ( u"", u"januari", u"februari", u"maart", u"april", u"mei",
u"juni", u"juli", u"augustus", u"september", u"oktober",
u"november", u"december" )
long_months = ( "", "januari", "februari", "maart", "april", "mei",
"juni", "juli", "augustus", "september", "oktober",
"november", "december" )
short_months = ( u"", u"jan", u"feb", u"mrt", u"apr", u"mei", u"jun",
u"jul", u"aug", u"sep", u"okt", u"nov", u"dec" )
short_months = ( "", "jan", "feb", "mrt", "apr", "mei", "jun",
"jul", "aug", "sep", "okt", "nov", "dec" )
calendar = (
"", u"juliaans", u"hebreeuws",
u"franse republiek", u"persisch", u"islamitisch",
u"zweeds" )
"", "juliaans", "hebreeuws",
"franse republiek", "persisch", "islamitisch",
"zweeds" )
_mod_str = ("", u"voor ", u"na ", u"rond ", "", "", "")
_mod_str = ("", "voor ", "na ", "rond ", "", "", "")
_qual_str = ("", u"geschat ", u"berekend ")
_qual_str = ("", "geschat ", "berekend ")
_bce_str = "%s v. Chr."
@ -246,8 +247,8 @@ class DateDisplayNL(DateDisplay):
d1 = self.display_cal[cal](start)
d2 = self.display_cal[cal](date.get_stop_date())
scal = self.format_extras(cal, newyear)
return "%s%s %s %s %s%s" % (qual_str, u'van', d1,
u'tot', d2, scal)
return "%s%s %s %s %s%s" % (qual_str, 'van', d1,
'tot', d2, scal)
elif mod == Date.MOD_RANGE:
d1 = self.display_cal[cal](start)
d2 = self.display_cal[cal](date.get_stop_date())

View File

@ -27,7 +27,7 @@
"""
Polish-specific classes for parsing and displaying dates.
"""
from __future__ import unicode_literals
#-------------------------------------------------------------------------
#
# Python modules
@ -41,9 +41,9 @@ import re
#
#-------------------------------------------------------------------------
from ..lib.date import Date
from _dateparser import DateParser
from _datedisplay import DateDisplay
from _datehandler import register_datehandler
from ._dateparser import DateParser
from ._datedisplay import DateDisplay
from ._datehandler import register_datehandler
#-------------------------------------------------------------------------
#
@ -53,104 +53,104 @@ from _datehandler import register_datehandler
class DateParserPL(DateParser):
month_to_int = DateParser.month_to_int
month_to_int[u"styczeń"] = 1
month_to_int[u"sty"] = 1
month_to_int[u"I"] = 1
month_to_int[u"luty"] = 2
month_to_int[u"lut"] = 2
month_to_int[u"II"] = 2
month_to_int[u"marzec"] = 3
month_to_int[u"mar"] = 3
month_to_int[u"III"] = 3
month_to_int[u"kwiecień"] = 4
month_to_int[u"kwi"] = 4
month_to_int[u"IV"] = 4
month_to_int[u"maj"] = 5
month_to_int[u"V"] = 5
month_to_int[u"czerwiec"] = 6
month_to_int[u"cze"] = 6
month_to_int[u"VI"] = 6
month_to_int[u"lipiec"] = 7
month_to_int[u"lip"] = 7
month_to_int[u"VII"] = 7
month_to_int[u"sierpień"] = 8
month_to_int[u"sie"] = 8
month_to_int[u"VIII"] = 8
month_to_int[u"wrzesień"] = 9
month_to_int[u"wrz"] = 9
month_to_int[u"IX"] = 9
month_to_int[u"październik"] = 10
month_to_int[u"paź"] = 10
month_to_int[u"X"] = 10
month_to_int[u"listopad"] = 11
month_to_int[u"lis"] = 11
month_to_int[u"XI"] = 11
month_to_int[u"grudzień"] = 12
month_to_int[u"gru"] = 12
month_to_int[u"XII"] = 12
month_to_int["styczeń"] = 1
month_to_int["sty"] = 1
month_to_int["I"] = 1
month_to_int["luty"] = 2
month_to_int["lut"] = 2
month_to_int["II"] = 2
month_to_int["marzec"] = 3
month_to_int["mar"] = 3
month_to_int["III"] = 3
month_to_int["kwiecień"] = 4
month_to_int["kwi"] = 4
month_to_int["IV"] = 4
month_to_int["maj"] = 5
month_to_int["V"] = 5
month_to_int["czerwiec"] = 6
month_to_int["cze"] = 6
month_to_int["VI"] = 6
month_to_int["lipiec"] = 7
month_to_int["lip"] = 7
month_to_int["VII"] = 7
month_to_int["sierpień"] = 8
month_to_int["sie"] = 8
month_to_int["VIII"] = 8
month_to_int["wrzesień"] = 9
month_to_int["wrz"] = 9
month_to_int["IX"] = 9
month_to_int["październik"] = 10
month_to_int["paź"] = 10
month_to_int["X"] = 10
month_to_int["listopad"] = 11
month_to_int["lis"] = 11
month_to_int["XI"] = 11
month_to_int["grudzień"] = 12
month_to_int["gru"] = 12
month_to_int["XII"] = 12
# Alternative forms: declined nouns
month_to_int[u"stycznia"] = 1
month_to_int[u"lutego"] = 2
month_to_int[u"marca"] = 3
month_to_int[u"kwietnia"] = 4
month_to_int[u"maja"] = 5
month_to_int[u"czerwca"] = 6
month_to_int[u"lipca"] = 7
month_to_int[u"sierpnia"] = 8
month_to_int[u"września"] = 9
month_to_int[u"października"] = 10
month_to_int[u"listopada"] = 11
month_to_int[u"grudnia"] = 12
month_to_int["stycznia"] = 1
month_to_int["lutego"] = 2
month_to_int["marca"] = 3
month_to_int["kwietnia"] = 4
month_to_int["maja"] = 5
month_to_int["czerwca"] = 6
month_to_int["lipca"] = 7
month_to_int["sierpnia"] = 8
month_to_int["września"] = 9
month_to_int["października"] = 10
month_to_int["listopada"] = 11
month_to_int["grudnia"] = 12
# Alternative forms: nouns without polish accent letters
# (misspellings sometimes used in emails)
month_to_int[u"styczen"] = 1
month_to_int[u"kwiecien"] = 4
month_to_int[u"sierpien"] = 8
month_to_int[u"wrzesien"] = 9
month_to_int[u"pazdziernik"] = 10
month_to_int[u"grudzien"] = 12
month_to_int[u"wrzesnia"] = 9
month_to_int[u"pazdziernika"] = 10
month_to_int[u"paz"] = 10
month_to_int["styczen"] = 1
month_to_int["kwiecien"] = 4
month_to_int["sierpien"] = 8
month_to_int["wrzesien"] = 9
month_to_int["pazdziernik"] = 10
month_to_int["grudzien"] = 12
month_to_int["wrzesnia"] = 9
month_to_int["pazdziernika"] = 10
month_to_int["paz"] = 10
modifier_to_int = {
u'przed' : Date.MOD_BEFORE,
u'po' : Date.MOD_AFTER,
u'około' : Date.MOD_ABOUT,
u'ok.' : Date.MOD_ABOUT,
u'circa' : Date.MOD_ABOUT,
u'ca.' : Date.MOD_ABOUT,
'przed' : Date.MOD_BEFORE,
'po' : Date.MOD_AFTER,
'około' : Date.MOD_ABOUT,
'ok.' : Date.MOD_ABOUT,
'circa' : Date.MOD_ABOUT,
'ca.' : Date.MOD_ABOUT,
# Alternative forms: misspellings sometimes used in emails
u'okolo' : Date.MOD_ABOUT,
u'ok' : Date.MOD_ABOUT,
'okolo' : Date.MOD_ABOUT,
'ok' : Date.MOD_ABOUT,
}
calendar_to_int = {
u'gregoriański' : Date.CAL_GREGORIAN,
u'greg.' : Date.CAL_GREGORIAN,
u'juliański' : Date.CAL_JULIAN,
u'jul.' : Date.CAL_JULIAN,
u'hebrajski' : Date.CAL_HEBREW,
u'hebr.' : Date.CAL_HEBREW,
u'islamski' : Date.CAL_ISLAMIC,
u'isl.' : Date.CAL_ISLAMIC,
u'francuski republikański': Date.CAL_FRENCH,
u'franc.' : Date.CAL_FRENCH,
u'perski' : Date.CAL_PERSIAN,
u'szwedzki' : Date.CAL_SWEDISH,
u's' : Date.CAL_SWEDISH,
'gregoriański' : Date.CAL_GREGORIAN,
'greg.' : Date.CAL_GREGORIAN,
'juliański' : Date.CAL_JULIAN,
'jul.' : Date.CAL_JULIAN,
'hebrajski' : Date.CAL_HEBREW,
'hebr.' : Date.CAL_HEBREW,
'islamski' : Date.CAL_ISLAMIC,
'isl.' : Date.CAL_ISLAMIC,
'francuski republikański': Date.CAL_FRENCH,
'franc.' : Date.CAL_FRENCH,
'perski' : Date.CAL_PERSIAN,
'szwedzki' : Date.CAL_SWEDISH,
's' : Date.CAL_SWEDISH,
# Alternative forms: nouns without polish accent letters
# (misspellings sometimes used in emails)
u'gregorianski' : Date.CAL_GREGORIAN,
u'julianski' : Date.CAL_JULIAN,
u'francuski republikanski': Date.CAL_FRENCH,
'gregorianski' : Date.CAL_GREGORIAN,
'julianski' : Date.CAL_JULIAN,
'francuski republikanski': Date.CAL_FRENCH,
}
quality_to_int = {
u'szacowany' : Date.QUAL_ESTIMATED,
u'szac.' : Date.QUAL_ESTIMATED,
u'obliczony' : Date.QUAL_CALCULATED,
u'obl.' : Date.QUAL_CALCULATED,
'szacowany' : Date.QUAL_ESTIMATED,
'szac.' : Date.QUAL_ESTIMATED,
'obliczony' : Date.QUAL_CALCULATED,
'obl.' : Date.QUAL_CALCULATED,
}
bce = ["przed naszą erą", "przed Chrystusem",
@ -160,7 +160,7 @@ class DateParserPL(DateParser):
DateParser.init_strings(self)
self._span = re.compile("(od)\s+(?P<start>.+)\s+(do)\s+(?P<stop>.+)", re.IGNORECASE)
# Also handle a common mistakes
self._range = re.compile(u"((?:po)?mi(?:ę|e)dzy)\s+(?P<start>.+)\s+(a)\s+(?P<stop>.+)", re.IGNORECASE)
self._range = re.compile("((?:po)?mi(?:ę|e)dzy)\s+(?P<start>.+)\s+(a)\s+(?P<stop>.+)", re.IGNORECASE)
self._text2 = re.compile('(\d+)?.?\s+?%s\s*((\d+)(/\d+)?)?' % self._mon_str,
re.IGNORECASE)
self._jtext2 = re.compile('(\d+)?.?\s+?%s\s*((\d+)(/\d+)?)?' % self._jmon_str,
@ -176,22 +176,22 @@ class DateDisplayPL(DateDisplay):
Polish language date display class.
"""
long_months = ( u"", u"Styczeń", u"Luty", u"Marzec", u"Kwiecień", u"Maj",
u"Czerwiec", u"Lipiec", u"Sierpień", u"Wrzesień", u"Październik",
u"Listopad", u"Grudzień" )
long_months = ( "", "Styczeń", "Luty", "Marzec", "Kwiecień", "Maj",
"Czerwiec", "Lipiec", "Sierpień", "Wrzesień", "Październik",
"Listopad", "Grudzień" )
short_months = ( u"", u"Sty", u"Lut", u"Mar", u"Kwi", u"Maj", u"Cze",
u"Lip", u"Sie", u"Wrz", u"Paź", u"Lis", u"Gru" )
short_months = ( "", "Sty", "Lut", "Mar", "Kwi", "Maj", "Cze",
"Lip", "Sie", "Wrz", "Paź", "Lis", "Gru" )
calendar = (
"", u"juliański", u"hebrajski",
u"francuski republikański", u"perski", u"islamski",
u"swedish"
"", "juliański", "hebrajski",
"francuski republikański", "perski", "islamski",
"swedish"
)
_mod_str = ("", u"przed ", u"po ", u"ok. ", "", "", "")
_mod_str = ("", "przed ", "po ", "ok. ", "", "", "")
_qual_str = ("", u"szacowany ", u"obliczony ")
_qual_str = ("", "szacowany ", "obliczony ")
_bce_str = "%s p.n.e."
@ -294,13 +294,13 @@ class DateDisplayPL(DateDisplay):
d1 = self.display_cal[cal](start)
d2 = self.display_cal[cal](date.get_stop_date())
scal = self.format_extras(cal, newyear)
return "%s%s %s %s %s%s" % (qual_str, u'od', d1, u'do', d2,
return "%s%s %s %s %s%s" % (qual_str, 'od', d1, 'do', d2,
scal)
elif mod == Date.MOD_RANGE:
d1 = self.display_cal[cal](start)
d2 = self.display_cal[cal](date.get_stop_date())
scal = self.format_extras(cal, newyear)
return "%s%s %s %s %s%s" % (qual_str, u'między', d1, u'a', d2,
return "%s%s %s %s %s%s" % (qual_str, 'między', d1, 'a', d2,
scal)
else:
text = self.display_cal[date.get_calendar()](start)

View File

@ -26,7 +26,7 @@
"""
Portuguese-specific classes for parsing and displaying dates.
"""
from __future__ import unicode_literals
#-------------------------------------------------------------------------
#
# Python modules
@ -40,9 +40,9 @@ import re
#
#-------------------------------------------------------------------------
from ..lib.date import Date
from _dateparser import DateParser
from _datedisplay import DateDisplay
from _datehandler import register_datehandler
from ._dateparser import DateParser
from ._datedisplay import DateDisplay
from ._datehandler import register_datehandler
#-------------------------------------------------------------------------
#
@ -52,60 +52,60 @@ from _datehandler import register_datehandler
class DateParserPT(DateParser):
modifier_to_int = {
u'antes de' : Date.MOD_BEFORE,
u'antes' : Date.MOD_BEFORE,
u'ant.' : Date.MOD_BEFORE,
u'ant' : Date.MOD_BEFORE,
u'até' : Date.MOD_BEFORE,
u'depois de' : Date.MOD_AFTER,
u'depois' : Date.MOD_AFTER,
u'dep.' : Date.MOD_AFTER,
u'dep' : Date.MOD_AFTER,
u'aprox.' : Date.MOD_ABOUT,
u'aprox' : Date.MOD_ABOUT,
u'apr.' : Date.MOD_ABOUT,
u'apr' : Date.MOD_ABOUT,
u'cerca de' : Date.MOD_ABOUT,
u'ca.' : Date.MOD_ABOUT,
u'ca' : Date.MOD_ABOUT,
u'c.' : Date.MOD_ABOUT,
u'por volta de' : Date.MOD_ABOUT,
u'por volta' : Date.MOD_ABOUT,
u'pvd.' : Date.MOD_ABOUT,
'antes de' : Date.MOD_BEFORE,
'antes' : Date.MOD_BEFORE,
'ant.' : Date.MOD_BEFORE,
'ant' : Date.MOD_BEFORE,
'até' : Date.MOD_BEFORE,
'depois de' : Date.MOD_AFTER,
'depois' : Date.MOD_AFTER,
'dep.' : Date.MOD_AFTER,
'dep' : Date.MOD_AFTER,
'aprox.' : Date.MOD_ABOUT,
'aprox' : Date.MOD_ABOUT,
'apr.' : Date.MOD_ABOUT,
'apr' : Date.MOD_ABOUT,
'cerca de' : Date.MOD_ABOUT,
'ca.' : Date.MOD_ABOUT,
'ca' : Date.MOD_ABOUT,
'c.' : Date.MOD_ABOUT,
'por volta de' : Date.MOD_ABOUT,
'por volta' : Date.MOD_ABOUT,
'pvd.' : Date.MOD_ABOUT,
}
calendar_to_int = {
u'gregoriano' : Date.CAL_GREGORIAN,
u'g' : Date.CAL_GREGORIAN,
u'juliano' : Date.CAL_JULIAN,
u'j' : Date.CAL_JULIAN,
u'hebreu' : Date.CAL_HEBREW,
u'h' : Date.CAL_HEBREW,
u'islâmico' : Date.CAL_ISLAMIC,
u'i' : Date.CAL_ISLAMIC,
u'revolucionário' : Date.CAL_FRENCH,
u'r' : Date.CAL_FRENCH,
u'persa' : Date.CAL_PERSIAN,
u'p' : Date.CAL_PERSIAN,
u'swedish' : Date.CAL_SWEDISH,
u's' : Date.CAL_SWEDISH,
'gregoriano' : Date.CAL_GREGORIAN,
'g' : Date.CAL_GREGORIAN,
'juliano' : Date.CAL_JULIAN,
'j' : Date.CAL_JULIAN,
'hebreu' : Date.CAL_HEBREW,
'h' : Date.CAL_HEBREW,
'islâmico' : Date.CAL_ISLAMIC,
'i' : Date.CAL_ISLAMIC,
'revolucionário' : Date.CAL_FRENCH,
'r' : Date.CAL_FRENCH,
'persa' : Date.CAL_PERSIAN,
'p' : Date.CAL_PERSIAN,
'swedish' : Date.CAL_SWEDISH,
's' : Date.CAL_SWEDISH,
}
quality_to_int = {
u'estimado' : Date.QUAL_ESTIMATED,
u'est.' : Date.QUAL_ESTIMATED,
u'est' : Date.QUAL_ESTIMATED,
u'calc.' : Date.QUAL_CALCULATED,
u'calc' : Date.QUAL_CALCULATED,
u'calculado' : Date.QUAL_CALCULATED,
'estimado' : Date.QUAL_ESTIMATED,
'est.' : Date.QUAL_ESTIMATED,
'est' : Date.QUAL_ESTIMATED,
'calc.' : Date.QUAL_CALCULATED,
'calc' : Date.QUAL_CALCULATED,
'calculado' : Date.QUAL_CALCULATED,
}
def init_strings(self):
DateParser.init_strings(self)
_span_1 = [u'de']
_span_2 = [u'a']
_range_1 = [u'entre',u'ent\.',u'ent']
_range_2 = [u'e']
_span_1 = ['de']
_span_2 = ['a']
_range_1 = ['entre','ent\.','ent']
_range_2 = ['e']
self._span = re.compile("(%s)\s+(?P<start>.+)\s+(%s)\s+(?P<stop>.+)" %
('|'.join(_span_1),'|'.join(_span_2)),
re.IGNORECASE)
@ -122,20 +122,20 @@ class DateDisplayPT(DateDisplay):
"""
Portuguese language date display class.
"""
long_months = ( u"", u"Janeiro", u"Fevereiro", u"Março", u"Abril", u"Maio",
u"Junho", u"Julho", u"Agosto", u"Setembro", u"Outubro",
u"Novembro", u"Dezembro" )
long_months = ( "", "Janeiro", "Fevereiro", "Março", "Abril", "Maio",
"Junho", "Julho", "Agosto", "Setembro", "Outubro",
"Novembro", "Dezembro" )
short_months = ( u"", u"Jan", u"Fev", u"Mar", u"Abr", u"Mai", u"Jun",
u"Jul", u"Ago", u"Set", u"Out", u"Nov", u"Dez" )
short_months = ( "", "Jan", "Fev", "Mar", "Abr", "Mai", "Jun",
"Jul", "Ago", "Set", "Out", "Nov", "Dez" )
calendar = (
"", u"Juliano", u"Hebreu",
u"Revolucionário", u"Persa", u"Islâmico",
u"Sueco"
"", "Juliano", "Hebreu",
"Revolucionário", "Persa", "Islâmico",
"Sueco"
)
_mod_str = ("",u"antes de ",u"depois de ",u"por volta de ","","","")
_mod_str = ("","antes de ","depois de ","por volta de ","","","")
_qual_str = ("","estimado ","calculado ")
@ -164,12 +164,12 @@ class DateDisplayPT(DateDisplay):
d1 = self.display_cal[cal](start)
d2 = self.display_cal[cal](date.get_stop_date())
scal = self.format_extras(cal, newyear)
return "%s%s %s %s %s%s" % (qual_str, u'de', d1, u'a', d2, scal)
return "%s%s %s %s %s%s" % (qual_str, 'de', d1, 'a', d2, scal)
elif mod == Date.MOD_RANGE:
d1 = self.display_cal[cal](start)
d2 = self.display_cal[cal](date.get_stop_date())
scal = self.format_extras(cal, newyear)
return "%s%s %s %s %s%s" % (qual_str, u'entre', d1, u'e', d2, scal)
return "%s%s %s %s %s%s" % (qual_str, 'entre', d1, 'e', d2, scal)
else:
text = self.display_cal[date.get_calendar()](start)
scal = self.format_extras(cal, newyear)

View File

@ -24,7 +24,7 @@
"""
Russian-specific classes for parsing and displaying dates.
"""
from __future__ import unicode_literals
#-------------------------------------------------------------------------
#
# Python modules
@ -38,9 +38,9 @@ import re
#
#-------------------------------------------------------------------------
from ..lib.date import Date
from _dateparser import DateParser
from _datedisplay import DateDisplay
from _datehandler import register_datehandler
from ._dateparser import DateParser
from ._datedisplay import DateDisplay
from ._datehandler import register_datehandler
#-------------------------------------------------------------------------
#
@ -50,178 +50,178 @@ from _datehandler import register_datehandler
class DateParserRU(DateParser):
modifier_to_int = {
u'перед' : Date.MOD_BEFORE,
u'по' : Date.MOD_BEFORE,
u'после' : Date.MOD_AFTER,
u'п.' : Date.MOD_AFTER,
u'п' : Date.MOD_AFTER,
u'с' : Date.MOD_AFTER,
u'ок' : Date.MOD_ABOUT,
u'ок.' : Date.MOD_ABOUT,
u'около' : Date.MOD_ABOUT,
u'примерно' : Date.MOD_ABOUT,
u'прим' : Date.MOD_ABOUT,
u'прим.' : Date.MOD_ABOUT,
u'приблизительно' : Date.MOD_ABOUT,
u'приб.' : Date.MOD_ABOUT,
u'прибл.' : Date.MOD_ABOUT,
u'приб' : Date.MOD_ABOUT,
u'прибл' : Date.MOD_ABOUT,
'перед' : Date.MOD_BEFORE,
'по' : Date.MOD_BEFORE,
'после' : Date.MOD_AFTER,
'п.' : Date.MOD_AFTER,
'п' : Date.MOD_AFTER,
'с' : Date.MOD_AFTER,
'ок' : Date.MOD_ABOUT,
'ок.' : Date.MOD_ABOUT,
'около' : Date.MOD_ABOUT,
'примерно' : Date.MOD_ABOUT,
'прим' : Date.MOD_ABOUT,
'прим.' : Date.MOD_ABOUT,
'приблизительно' : Date.MOD_ABOUT,
'приб.' : Date.MOD_ABOUT,
'прибл.' : Date.MOD_ABOUT,
'приб' : Date.MOD_ABOUT,
'прибл' : Date.MOD_ABOUT,
}
calendar_to_int = {
u'григорианский' : Date.CAL_GREGORIAN,
u'г' : Date.CAL_GREGORIAN,
u'юлианский' : Date.CAL_JULIAN,
u'ю' : Date.CAL_JULIAN,
u'еврейский' : Date.CAL_HEBREW,
u'е' : Date.CAL_HEBREW,
u'исламский' : Date.CAL_ISLAMIC,
u'и' : Date.CAL_ISLAMIC,
u'республиканский': Date.CAL_FRENCH,
u'р' : Date.CAL_FRENCH,
u'персидский' : Date.CAL_PERSIAN,
u'п' : Date.CAL_PERSIAN,
u'swedish' : Date.CAL_SWEDISH,
u's' : Date.CAL_SWEDISH,
'григорианский' : Date.CAL_GREGORIAN,
'г' : Date.CAL_GREGORIAN,
'юлианский' : Date.CAL_JULIAN,
'ю' : Date.CAL_JULIAN,
'еврейский' : Date.CAL_HEBREW,
'е' : Date.CAL_HEBREW,
'исламский' : Date.CAL_ISLAMIC,
'и' : Date.CAL_ISLAMIC,
'республиканский': Date.CAL_FRENCH,
'р' : Date.CAL_FRENCH,
'персидский' : Date.CAL_PERSIAN,
'п' : Date.CAL_PERSIAN,
'swedish' : Date.CAL_SWEDISH,
's' : Date.CAL_SWEDISH,
}
quality_to_int = {
u'оценено' : Date.QUAL_ESTIMATED,
u'оцен.' : Date.QUAL_ESTIMATED,
u'оц.' : Date.QUAL_ESTIMATED,
u'оцен' : Date.QUAL_ESTIMATED,
u'оц' : Date.QUAL_ESTIMATED,
u'вычислено' : Date.QUAL_CALCULATED,
u'вычисл.' : Date.QUAL_CALCULATED,
u'выч.' : Date.QUAL_CALCULATED,
u'вычисл' : Date.QUAL_CALCULATED,
u'выч' : Date.QUAL_CALCULATED,
'оценено' : Date.QUAL_ESTIMATED,
'оцен.' : Date.QUAL_ESTIMATED,
'оц.' : Date.QUAL_ESTIMATED,
'оцен' : Date.QUAL_ESTIMATED,
'оц' : Date.QUAL_ESTIMATED,
'вычислено' : Date.QUAL_CALCULATED,
'вычисл.' : Date.QUAL_CALCULATED,
'выч.' : Date.QUAL_CALCULATED,
'вычисл' : Date.QUAL_CALCULATED,
'выч' : Date.QUAL_CALCULATED,
}
hebrew_to_int = {
u"тишрей":1,
u"тишрея":1,
u"хешван":2,
u"хешвана":2,
u"кислев":3,
u"кислева":3,
u"тевет":4,
u"тевета":4,
u"шеват":5,
u"шевата":5,
u"адар":6,
u"адара":6,
u"адара бет":7,
u"нисан":8,
u"нисана":8,
u"ниссан":8,
u"ниссана":8,
u"ияр":9,
u"ияра":9,
u"сиван":10,
u"сивана":10,
u"тамуз":11,
u"тамуза":11,
u"таммуз":11,
u"таммуза":11,
u"ав":12,
u"ава":12,
u"элул":13,
u"элула":13,
u"элуль":13,
u"элуля":13,
"тишрей":1,
"тишрея":1,
"хешван":2,
"хешвана":2,
"кислев":3,
"кислева":3,
"тевет":4,
"тевета":4,
"шеват":5,
"шевата":5,
"адар":6,
"адара":6,
"адара бет":7,
"нисан":8,
"нисана":8,
"ниссан":8,
"ниссана":8,
"ияр":9,
"ияра":9,
"сиван":10,
"сивана":10,
"тамуз":11,
"тамуза":11,
"таммуз":11,
"таммуза":11,
"ав":12,
"ава":12,
"элул":13,
"элула":13,
"элуль":13,
"элуля":13,
}
islamic_to_int = {
u"мухаррам":1,
u"мухаррама":1,
u"сафар":2,
u"сафара":2,
u"раби-аль-авваль":3,
u"раби-аль-авваля":3,
u"раби-ассани":4,
u"джумада-аль-уля":5,
u"джумада-аль-ахира":6,
u"раджаб":7,
u"раджаба":7,
u"шаабан":8,
u"шаабана":8,
u"рамадан":9,
u"рамадана":9,
u"шавваль":10,
u"шавваля":10,
u"зуль-каада":11,
u"зуль-хиджжа":12,
"мухаррам":1,
"мухаррама":1,
"сафар":2,
"сафара":2,
"раби-аль-авваль":3,
"раби-аль-авваля":3,
"раби-ассани":4,
"джумада-аль-уля":5,
"джумада-аль-ахира":6,
"раджаб":7,
"раджаба":7,
"шаабан":8,
"шаабана":8,
"рамадан":9,
"рамадана":9,
"шавваль":10,
"шавваля":10,
"зуль-каада":11,
"зуль-хиджжа":12,
}
persian_to_int = {
u"фарвардин":1,
u"фарвардина":1,
u"урдбихишт":2,
u"урдбихишта":2,
u"хурдад":3,
u"хурдада":3,
u"тир":4,
u"тира":4,
u"мурдад":5,
u"мурдада":5,
u"шахривар":6,
u"шахривара":6,
u"михр":7,
u"михра":7,
u"абан":8,
u"абана":8,
u"азар":9,
u"азара":9,
u"дай":10,
u"дая":10,
u"бахман":11,
u"бахмана":11,
u"исфаидармуз":12,
u"исфаидармуза":12,
"фарвардин":1,
"фарвардина":1,
"урдбихишт":2,
"урдбихишта":2,
"хурдад":3,
"хурдада":3,
"тир":4,
"тира":4,
"мурдад":5,
"мурдада":5,
"шахривар":6,
"шахривара":6,
"михр":7,
"михра":7,
"абан":8,
"абана":8,
"азар":9,
"азара":9,
"дай":10,
"дая":10,
"бахман":11,
"бахмана":11,
"исфаидармуз":12,
"исфаидармуза":12,
}
french_to_int = {
u"вандемьер":1,
u"вандемьера":1,
u"брюмер":2,
u"брюмера":2,
u"фример":3,
u"фримера":3,
u"нивоз":4,
u"нивоза":4,
u"плювиоз":5,
u"плювиоза":5,
u"вантоз":6,
u"вантоза":6,
u"жерминаль":7,
u"жерминаля":7,
u"флореаль":8,
u"флореаля":8,
u"прериаль":9,
u"прериаля":9,
u"мессидор":10,
u"мессидора":10,
u"термидор":11,
u"термидора":11,
u"фрюктидор":12,
u"фрюктидора":12,
u"доп.":13,
u"дополн.":13,
u"дополнит.":13,
"вандемьер":1,
"вандемьера":1,
"брюмер":2,
"брюмера":2,
"фример":3,
"фримера":3,
"нивоз":4,
"нивоза":4,
"плювиоз":5,
"плювиоза":5,
"вантоз":6,
"вантоза":6,
"жерминаль":7,
"жерминаля":7,
"флореаль":8,
"флореаля":8,
"прериаль":9,
"прериаля":9,
"мессидор":10,
"мессидора":10,
"термидор":11,
"термидора":11,
"фрюктидор":12,
"фрюктидора":12,
"доп.":13,
"дополн.":13,
"дополнит.":13,
}
bce = [
u'до нашей эры', u'до н. э.', u'до н.э.',
u'до н э', u'до нэ'] + DateParser.bce
'до нашей эры', 'до н. э.', 'до н.э.',
'до н э', 'до нэ'] + DateParser.bce
def init_strings(self):
DateParser.init_strings(self)
_span_1 = [u'с', u'от']
_span_2 = [u'по']
_range_1 = [u'между', u'меж\.', u'меж']
_range_2 = [u'и']
_span_1 = ['с', 'от']
_span_2 = ['по']
_range_1 = ['между', 'меж\.', 'меж']
_range_2 = ['и']
self._span = re.compile("(%s)\s+(?P<start>.+)\s+(%s)\s+(?P<stop>.+)" %
('|'.join(_span_1), '|'.join(_span_2)),
re.IGNORECASE)
@ -238,99 +238,99 @@ class DateDisplayRU(DateDisplay):
"""
Russian language date display class.
"""
long_months = ( u"", u"января", u"февраля", u"марта", u"апреля", u"мая",
u"июня", u"июля", u"августа", u"сентября", u"октября",
u"ноября", u"декабря" )
long_months = ( "", "января", "февраля", "марта", "апреля", "мая",
"июня", "июля", "августа", "сентября", "октября",
"ноября", "декабря" )
short_months = ( u"", u"янв", u"фев", u"мар", u"апр", u"мая", u"июн",
u"июл", u"авг", u"сен", u"окт", u"ноя", u"дек" )
short_months = ( "", "янв", "фев", "мар", "апр", "мая", "июн",
"июл", "авг", "сен", "окт", "ноя", "дек" )
calendar = (
u"",
u"юлианский",
u"еврейский",
u"республиканский",
u"персидский",
u"исламский",
u"шведский"
"",
"юлианский",
"еврейский",
"республиканский",
"персидский",
"исламский",
"шведский"
)
_mod_str = (
u"",
u"перед ",
u"после ",
u"около ",
u"", u"", u"")
"",
"перед ",
"после ",
"около ",
"", "", "")
_qual_str = (u"", u"оцен ", u"вычисл ")
_qual_str = ("", "оцен ", "вычисл ")
_bce_str = u"%s до н.э."
_bce_str = "%s до н.э."
formats = (
"ГГГГ-ММ-ДД (ISO)", "Численный", "Месяц День, Год",
"МЕС ДД, ГГГГ", "День Месяц, Год", "ДД МЕС, ГГГГ"
)
hebrew = ( u"",
u"тишрея",
u"хешвана",
u"кислева",
u"тевета",
u"шевата",
u"адара",
u"адара бет",
u"нисана",
u"ияра",
u"сивана",
u"таммуза",
u"ава",
u"элула",
hebrew = ( "",
"тишрея",
"хешвана",
"кислева",
"тевета",
"шевата",
"адара",
"адара бет",
"нисана",
"ияра",
"сивана",
"таммуза",
"ава",
"элула",
)
islamic = ( u"",
u"мухаррама",
u"сафара",
u"раби-аль-авваля",
u"раби-ассани",
u"джумада-аль-уля",
u"джумада-аль-ахира",
u"раджаба",
u"шаабана",
u"рамадана",
u"шавваля",
u"зуль-каада",
u"зуль-хиджжа",
islamic = ( "",
"мухаррама",
"сафара",
"раби-аль-авваля",
"раби-ассани",
"джумада-аль-уля",
"джумада-аль-ахира",
"раджаба",
"шаабана",
"рамадана",
"шавваля",
"зуль-каада",
"зуль-хиджжа",
)
persian = ( u"",
u"фарвардина",
u"урдбихишта",
u"хурдада",
u"тира",
u"мурдада",
u"шахривара",
u"михра",
u"абана",
u"азара",
u"дая",
u"бахмана",
u"исфаидармуза",
persian = ( "",
"фарвардина",
"урдбихишта",
"хурдада",
"тира",
"мурдада",
"шахривара",
"михра",
"абана",
"азара",
"дая",
"бахмана",
"исфаидармуза",
)
french = ( u"",
u"вандемьера",
u"брюмера",
u"фримера",
u"нивоза",
u"плювиоза",
u"вантоза",
u"жерминаля",
u"флореаля",
u"прериаля",
u"мессидора",
u"термидора",
u"фрюктидора",
u"дополнит."
french = ( "",
"вандемьера",
"брюмера",
"фримера",
"нивоза",
"плювиоза",
"вантоза",
"жерминаля",
"флореаля",
"прериаля",
"мессидора",
"термидора",
"фрюктидора",
"дополнит."
)
def display(self, date):
@ -353,13 +353,13 @@ class DateDisplayRU(DateDisplay):
d1 = self.display_cal[cal](start)
d2 = self.display_cal[cal](date.get_stop_date())
scal = self.format_extras(cal, newyear)
return "%sс %s %s %s%s" % (qual_str, d1, u'по', d2,
return "%sс %s %s %s%s" % (qual_str, d1, 'по', d2,
scal)
elif mod == Date.MOD_RANGE:
d1 = self.display_cal[cal](start)
d2 = self.display_cal[cal](date.get_stop_date())
scal = self.format_extras(cal, newyear)
return "%s%s %s %s %s%s" % (qual_str, u'между', d1, u'и',
return "%s%s %s %s %s%s" % (qual_str, 'между', d1, 'и',
d2, scal)
else:
text = self.display_cal[date.get_calendar()](start)

View File

@ -24,7 +24,7 @@
"""
Slovak-specific classes for parsing and displaying dates.
"""
from __future__ import unicode_literals
#-------------------------------------------------------------------------
#
# Python modules
@ -38,9 +38,9 @@ import re
#
#-------------------------------------------------------------------------
from ..lib.date import Date
from _dateparser import DateParser
from _datedisplay import DateDisplay
from _datehandler import register_datehandler
from ._dateparser import DateParser
from ._datedisplay import DateDisplay
from ._datehandler import register_datehandler
#-------------------------------------------------------------------------
#
@ -50,44 +50,44 @@ from _datehandler import register_datehandler
class DateParserSK(DateParser):
modifier_to_int = {
u'pred' : Date.MOD_BEFORE,
u'do' : Date.MOD_BEFORE,
u'po' : Date.MOD_AFTER,
u'asi' : Date.MOD_ABOUT,
u'okolo' : Date.MOD_ABOUT,
u'pribl.' : Date.MOD_ABOUT,
'pred' : Date.MOD_BEFORE,
'do' : Date.MOD_BEFORE,
'po' : Date.MOD_AFTER,
'asi' : Date.MOD_ABOUT,
'okolo' : Date.MOD_ABOUT,
'pribl.' : Date.MOD_ABOUT,
}
calendar_to_int = {
u'gregoriánsky' : Date.CAL_GREGORIAN,
u'g' : Date.CAL_GREGORIAN,
u'juliánský' : Date.CAL_JULIAN,
u'j' : Date.CAL_JULIAN,
u'hebrejský' : Date.CAL_HEBREW,
u'h' : Date.CAL_HEBREW,
u'islamský' : Date.CAL_ISLAMIC,
u'i' : Date.CAL_ISLAMIC,
u'republikánsky' : Date.CAL_FRENCH,
u'r' : Date.CAL_FRENCH,
u'perzský' : Date.CAL_PERSIAN,
u'p' : Date.CAL_PERSIAN,
u'swedish' : Date.CAL_SWEDISH,
u's' : Date.CAL_SWEDISH,
'gregoriánsky' : Date.CAL_GREGORIAN,
'g' : Date.CAL_GREGORIAN,
'juliánský' : Date.CAL_JULIAN,
'j' : Date.CAL_JULIAN,
'hebrejský' : Date.CAL_HEBREW,
'h' : Date.CAL_HEBREW,
'islamský' : Date.CAL_ISLAMIC,
'i' : Date.CAL_ISLAMIC,
'republikánsky' : Date.CAL_FRENCH,
'r' : Date.CAL_FRENCH,
'perzský' : Date.CAL_PERSIAN,
'p' : Date.CAL_PERSIAN,
'swedish' : Date.CAL_SWEDISH,
's' : Date.CAL_SWEDISH,
}
quality_to_int = {
u'odhadovaný' : Date.QUAL_ESTIMATED,
u'odh.' : Date.QUAL_ESTIMATED,
u'vypočítaný' : Date.QUAL_CALCULATED,
u'vyp.' : Date.QUAL_CALCULATED,
'odhadovaný' : Date.QUAL_ESTIMATED,
'odh.' : Date.QUAL_ESTIMATED,
'vypočítaný' : Date.QUAL_CALCULATED,
'vyp.' : Date.QUAL_CALCULATED,
}
def init_strings(self):
DateParser.init_strings(self)
_span_1 = [u'od']
_span_2 = [u'do']
_range_1 = [u'medzi']
_range_2 = [u'a']
_span_1 = ['od']
_span_2 = ['do']
_range_1 = ['medzi']
_range_2 = ['a']
self._span = re.compile("(%s)\s+(?P<start>.+)\s+(%s)\s+(?P<stop>.+)" %
('|'.join(_span_1), '|'.join(_span_2)),
re.IGNORECASE)
@ -104,20 +104,20 @@ class DateDisplaySK(DateDisplay):
"""
Slovak language date display class.
"""
long_months = ( u"", u"január", u"február", u"marec", u"apríl", u"máj",
u"jún", u"júl", u"august", u"september", u"október",
u"november", u"december" )
long_months = ( "", "január", "február", "marec", "apríl", "máj",
"jún", "júl", "august", "september", "október",
"november", "december" )
short_months = ( u"", u"jan", u"feb", u"mar", u"apr", u"máj", u"jún",
u"júl", u"aug", u"sep", u"okt", u"nov", u"dec" )
short_months = ( "", "jan", "feb", "mar", "apr", "máj", "jún",
"júl", "aug", "sep", "okt", "nov", "dec" )
calendar = (
"", u"juliánský", u"hebrejský",
u"republikánsky", u"perzský", u"islamský",
u"swedish"
"", "juliánský", "hebrejský",
"republikánsky", "perzský", "islamský",
"swedish"
)
_mod_str = ("", u"pred ", u"po ", u"okolo ", "", "", "")
_mod_str = ("", "pred ", "po ", "okolo ", "", "", "")
_qual_str = ("", "odh. ", "vyp. ")
@ -146,14 +146,14 @@ class DateDisplaySK(DateDisplay):
d1 = self.display_cal[cal](start)
d2 = self.display_cal[cal](date.get_stop_date())
scal = self.format_extras(cal, newyear)
return "%s%s %s %s %s%s" % (qual_str, u'od', d1,
u'do', d2, scal)
return "%s%s %s %s %s%s" % (qual_str, 'od', d1,
'do', d2, scal)
elif mod == Date.MOD_RANGE:
d1 = self.display_cal[cal](start)
d2 = self.display_cal[cal](date.get_stop_date())
scal = self.format_extras(cal, newyear)
return "%s%s %s %s %s%s" % (qual_str, u'medzi',
d1, u'a', d2, scal)
return "%s%s %s %s %s%s" % (qual_str, 'medzi',
d1, 'a', d2, scal)
else:
text = self.display_cal[date.get_calendar()](start)
scal = self.format_extras(cal, newyear)

View File

@ -26,7 +26,7 @@
"""
Slovenian-specific classes for parsing and displaying dates.
"""
from __future__ import unicode_literals
#-------------------------------------------------------------------------
#
# Python modules
@ -40,9 +40,9 @@ import re
#
#-------------------------------------------------------------------------
from ..lib.date import Date
from _dateparser import DateParser
from _datedisplay import DateDisplay
from _datehandler import register_datehandler
from ._dateparser import DateParser
from ._datedisplay import DateDisplay
from ._datehandler import register_datehandler
#-------------------------------------------------------------------------
#
@ -55,114 +55,114 @@ class DateParserSL(DateParser):
"""
month_to_int = DateParser.month_to_int
month_to_int[u"januar"] = 1
month_to_int[u"januarja"] = 1
month_to_int[u"januarjem"] = 1
month_to_int[u"jan"] = 1
month_to_int[u"i"] = 1
month_to_int["januar"] = 1
month_to_int["januarja"] = 1
month_to_int["januarjem"] = 1
month_to_int["jan"] = 1
month_to_int["i"] = 1
month_to_int[u"februar"] = 2
month_to_int[u"februarjem"] = 2
month_to_int[u"februarja"] = 2
month_to_int[u"feb"] = 2
month_to_int[u"ii"] = 2
month_to_int["februar"] = 2
month_to_int["februarjem"] = 2
month_to_int["februarja"] = 2
month_to_int["feb"] = 2
month_to_int["ii"] = 2
month_to_int[u"mar"] = 3
month_to_int[u"marcem"] = 3
month_to_int[u"marec"] = 3
month_to_int[u"marca"] = 3
month_to_int[u"iii"] = 3
month_to_int["mar"] = 3
month_to_int["marcem"] = 3
month_to_int["marec"] = 3
month_to_int["marca"] = 3
month_to_int["iii"] = 3
month_to_int[u"apr"] = 4
month_to_int[u"april"] = 4
month_to_int[u"aprilom"] = 4
month_to_int[u"aprila"] = 4
month_to_int[u"iv"] = 4
month_to_int["apr"] = 4
month_to_int["april"] = 4
month_to_int["aprilom"] = 4
month_to_int["aprila"] = 4
month_to_int["iv"] = 4
month_to_int[u"maj"] = 5
month_to_int[u"maja"] = 5
month_to_int[u"majem"] = 5
month_to_int[u"v"] = 5
month_to_int["maj"] = 5
month_to_int["maja"] = 5
month_to_int["majem"] = 5
month_to_int["v"] = 5
month_to_int[u"jun"] = 6
month_to_int[u"junij"] = 6
month_to_int[u"junijem"] = 6
month_to_int[u"junija"] = 6
month_to_int[u"vi"] = 6
month_to_int["jun"] = 6
month_to_int["junij"] = 6
month_to_int["junijem"] = 6
month_to_int["junija"] = 6
month_to_int["vi"] = 6
month_to_int[u"jul"] = 7
month_to_int[u"julij"] = 7
month_to_int[u"julijem"] = 7
month_to_int[u"julija"] = 7
month_to_int[u"vii"] = 7
month_to_int["jul"] = 7
month_to_int["julij"] = 7
month_to_int["julijem"] = 7
month_to_int["julija"] = 7
month_to_int["vii"] = 7
month_to_int[u"avg"] = 8
month_to_int[u"avgust"] = 8
month_to_int[u"avgustom"] = 8
month_to_int[u"avgusta"] = 8
month_to_int[u"viii"] = 8
month_to_int["avg"] = 8
month_to_int["avgust"] = 8
month_to_int["avgustom"] = 8
month_to_int["avgusta"] = 8
month_to_int["viii"] = 8
month_to_int[u"sep"] = 9
month_to_int[u"sept"] = 9
month_to_int[u"september"] = 9
month_to_int[u"septembrom"] = 9
month_to_int[u"septembra"] = 9
month_to_int[u"ix"] = 9
month_to_int["sep"] = 9
month_to_int["sept"] = 9
month_to_int["september"] = 9
month_to_int["septembrom"] = 9
month_to_int["septembra"] = 9
month_to_int["ix"] = 9
month_to_int[u"okt"] = 10
month_to_int[u"oktober"] = 10
month_to_int[u"oktobrom"] = 10
month_to_int[u"oktobra"] = 10
month_to_int[u"x"] = 10
month_to_int["okt"] = 10
month_to_int["oktober"] = 10
month_to_int["oktobrom"] = 10
month_to_int["oktobra"] = 10
month_to_int["x"] = 10
month_to_int[u"nov"] = 11
month_to_int[u"november"] = 11
month_to_int[u"novembrom"] = 11
month_to_int[u"novembra"] = 11
month_to_int[u"xi"] = 11
month_to_int["nov"] = 11
month_to_int["november"] = 11
month_to_int["novembrom"] = 11
month_to_int["novembra"] = 11
month_to_int["xi"] = 11
month_to_int[u"dec"] = 12
month_to_int[u"december"] = 12
month_to_int[u"decembrom"] = 12
month_to_int[u"decembra"] = 12
month_to_int[u"xii"] = 12
month_to_int["dec"] = 12
month_to_int["december"] = 12
month_to_int["decembrom"] = 12
month_to_int["decembra"] = 12
month_to_int["xii"] = 12
modifier_to_int = {
u'pred' : Date.MOD_BEFORE,
u'pr.' : Date.MOD_BEFORE,
u'po' : Date.MOD_AFTER,
u'okoli' : Date.MOD_ABOUT,
u'okrog' : Date.MOD_ABOUT,
u'okr.' : Date.MOD_ABOUT,
u'ok.' : Date.MOD_ABOUT,
u'cca.' : Date.MOD_ABOUT,
u'cca' : Date.MOD_ABOUT,
u'circa' : Date.MOD_ABOUT,
u'ca.' : Date.MOD_ABOUT,
'pred' : Date.MOD_BEFORE,
'pr.' : Date.MOD_BEFORE,
'po' : Date.MOD_AFTER,
'okoli' : Date.MOD_ABOUT,
'okrog' : Date.MOD_ABOUT,
'okr.' : Date.MOD_ABOUT,
'ok.' : Date.MOD_ABOUT,
'cca.' : Date.MOD_ABOUT,
'cca' : Date.MOD_ABOUT,
'circa' : Date.MOD_ABOUT,
'ca.' : Date.MOD_ABOUT,
}
calendar_to_int = {
u'gregorijanski' : Date.CAL_GREGORIAN,
u'greg.' : Date.CAL_GREGORIAN,
u'julijanski' : Date.CAL_JULIAN,
u'jul.' : Date.CAL_JULIAN,
u'hebrejski' : Date.CAL_HEBREW,
u'hebr.' : Date.CAL_HEBREW,
u'islamski' : Date.CAL_ISLAMIC,
u'isl.' : Date.CAL_ISLAMIC,
u'francoski republikanski': Date.CAL_FRENCH,
u'franc.' : Date.CAL_FRENCH,
u'perzijski' : Date.CAL_PERSIAN,
u'perz. ' : Date.CAL_PERSIAN,
u'švedski' : Date.CAL_SWEDISH,
u'šved.' : Date.CAL_SWEDISH,
'gregorijanski' : Date.CAL_GREGORIAN,
'greg.' : Date.CAL_GREGORIAN,
'julijanski' : Date.CAL_JULIAN,
'jul.' : Date.CAL_JULIAN,
'hebrejski' : Date.CAL_HEBREW,
'hebr.' : Date.CAL_HEBREW,
'islamski' : Date.CAL_ISLAMIC,
'isl.' : Date.CAL_ISLAMIC,
'francoski republikanski': Date.CAL_FRENCH,
'franc.' : Date.CAL_FRENCH,
'perzijski' : Date.CAL_PERSIAN,
'perz. ' : Date.CAL_PERSIAN,
'švedski' : Date.CAL_SWEDISH,
'šved.' : Date.CAL_SWEDISH,
}
quality_to_int = {
u'približno' : Date.QUAL_ESTIMATED,
u'pribl.' : Date.QUAL_ESTIMATED,
u'izračunano' : Date.QUAL_CALCULATED,
u'izrač.' : Date.QUAL_CALCULATED,
'približno' : Date.QUAL_ESTIMATED,
'pribl.' : Date.QUAL_ESTIMATED,
'izračunano' : Date.QUAL_CALCULATED,
'izrač.' : Date.QUAL_CALCULATED,
}
bce = ["pred našim štetjem", "pred Kristusom",
@ -182,7 +182,7 @@ class DateParserSL(DateParser):
self._span = re.compile("od\s+(?P<start>.+)\s+do\s+(?P<stop>.+)",
re.IGNORECASE)
self._range = re.compile(
u"med\s+(?P<start>.+)\s+in\s+(?P<stop>.+)",
"med\s+(?P<start>.+)\s+in\s+(?P<stop>.+)",
re.IGNORECASE)
self._jtext2 = re.compile('(\d+)?.?\s+?%s\s*((\d+)(/\d+)?)?'\
% self._jmon_str, re.IGNORECASE)
@ -196,19 +196,19 @@ class DateDisplaySL(DateDisplay):
"""
Slovenian language date display class.
"""
long_months = ( u"", u"januarja", u"februarja", u"marca",u"aprila",
u"maja", u"junija", u"julija", u"avgusta", u"septembra",
u"oktobra", u"novembra", u"decembra"
long_months = ( "", "januarja", "februarja", "marca","aprila",
"maja", "junija", "julija", "avgusta", "septembra",
"oktobra", "novembra", "decembra"
)
short_months = ( u"", u"jan", u"feb", u"mar", u"apr", u"maj", u"jun",
u"jul", u"avg", u"sep", u"okt", u"nov", u"dec"
short_months = ( "", "jan", "feb", "mar", "apr", "maj", "jun",
"jul", "avg", "sep", "okt", "nov", "dec"
)
calendar = (
"", u"julijanski", u"hebrejski",
u"francoski republikanski", u"perzijski", u"islamski",
u"švedski"
"", "julijanski", "hebrejski",
"francoski republikanski", "perzijski", "islamski",
"švedski"
)
_mod_str = ("", "pred ", "po ", "okrog ", "", "", "")
@ -283,21 +283,21 @@ class DateDisplaySL(DateDisplay):
if mod == Date.MOD_TEXTONLY:
return date.get_text()
elif start == Date.EMPTY:
return u""
return ""
elif mod == Date.MOD_SPAN:
d_1 = self.display_cal[cal](start)
d_2 = self.display_cal[cal](date.get_stop_date())
scal = self.format_extras(cal, newyear)
return u"%sod %s do %s%s" % (qual_str, d_1, d_2, scal)
return "%sod %s do %s%s" % (qual_str, d_1, d_2, scal)
elif mod == Date.MOD_RANGE:
d_1 = self.display_cal[cal](start)
d_2 = self.display_cal[cal](date.get_stop_date())
scal = self.format_extras(cal, newyear)
date_string = u"%smed %s in %s%s" % (qual_str, d_1, d_2, scal)
date_string = date_string.replace(u"a ",u"em ") #to correct declination
date_string = date_string.replace(u"lem ",u"lom ")
date_string = date_string.replace(u"rem ",u"rom ")
date_string = date_string.replace(u"tem ",u"tom ")
date_string = "%smed %s in %s%s" % (qual_str, d_1, d_2, scal)
date_string = date_string.replace("a ","em ") #to correct declination
date_string = date_string.replace("lem ","lom ")
date_string = date_string.replace("rem ","rom ")
date_string = date_string.replace("tem ","tom ")
return date_string
else:
text = self.display_cal[date.get_calendar()](start)

View File

@ -27,7 +27,7 @@
"""
Serbian-specific classes for parsing and displaying dates.
"""
from __future__ import unicode_literals
#-------------------------------------------------------------------------
#
# Python modules
@ -41,9 +41,9 @@ import re
#
#-------------------------------------------------------------------------
from ..lib.date import Date
from _dateparser import DateParser
from _datedisplay import DateDisplay
from _datehandler import register_datehandler
from ._dateparser import DateParser
from ._datedisplay import DateDisplay
from ._datehandler import register_datehandler
#-------------------------------------------------------------------------
#
@ -56,153 +56,153 @@ class DateParserSR(DateParser):
"""
month_to_int = DateParser.month_to_int
month_to_int[u"januar"] = 1
month_to_int[u"januara"] = 1
month_to_int[u"jan"] = 1
month_to_int[u"јан"] = 1
month_to_int[u"јануара"] = 1
month_to_int[u"јануар"] = 1
month_to_int[u"i"] = 1
month_to_int["januar"] = 1
month_to_int["januara"] = 1
month_to_int["jan"] = 1
month_to_int["јан"] = 1
month_to_int["јануара"] = 1
month_to_int["јануар"] = 1
month_to_int["i"] = 1
month_to_int[u"februar"] = 2
month_to_int[u"februara"] = 2
month_to_int[u"feb"] = 2
month_to_int[u"феб"] = 2
month_to_int[u"фебруар"] = 2
month_to_int[u"фебруара"] = 2
month_to_int[u"ii"] = 2
month_to_int["februar"] = 2
month_to_int["februara"] = 2
month_to_int["feb"] = 2
month_to_int["феб"] = 2
month_to_int["фебруар"] = 2
month_to_int["фебруара"] = 2
month_to_int["ii"] = 2
month_to_int[u"mart"] = 3
month_to_int[u"marta"] = 3
month_to_int[u"mar"] = 3
month_to_int[u"мар"] = 3
month_to_int[u"март"] = 3
month_to_int[u"марта"] = 3
month_to_int[u"iii"] = 3
month_to_int["mart"] = 3
month_to_int["marta"] = 3
month_to_int["mar"] = 3
month_to_int["мар"] = 3
month_to_int["март"] = 3
month_to_int["марта"] = 3
month_to_int["iii"] = 3
month_to_int[u"april"] = 4
month_to_int[u"aprila"] = 4
month_to_int[u"apr"] = 4
month_to_int[u"апр"] = 4
month_to_int[u"април"] = 4
month_to_int[u"априла"] = 4
month_to_int[u"iv"] = 4
month_to_int["april"] = 4
month_to_int["aprila"] = 4
month_to_int["apr"] = 4
month_to_int["апр"] = 4
month_to_int["април"] = 4
month_to_int["априла"] = 4
month_to_int["iv"] = 4
month_to_int[u"maj"] = 5
month_to_int[u"maja"] = 5
month_to_int[u"мај"] = 5
month_to_int[u"маја"] = 5
month_to_int[u"v"] = 5
month_to_int["maj"] = 5
month_to_int["maja"] = 5
month_to_int["мај"] = 5
month_to_int["маја"] = 5
month_to_int["v"] = 5
month_to_int[u"jun"] = 6
month_to_int[u"juna"] = 6
month_to_int[u"јун"] = 6
month_to_int[u"јуна"] = 6
month_to_int[u"vi"] = 6
month_to_int["jun"] = 6
month_to_int["juna"] = 6
month_to_int["јун"] = 6
month_to_int["јуна"] = 6
month_to_int["vi"] = 6
month_to_int[u"jul"] = 7
month_to_int[u"jula"] = 7
month_to_int[u"јул"] = 7
month_to_int[u"јула"] = 7
month_to_int[u"vii"] = 7
month_to_int["jul"] = 7
month_to_int["jula"] = 7
month_to_int["јул"] = 7
month_to_int["јула"] = 7
month_to_int["vii"] = 7
month_to_int[u"avgust"] = 8
month_to_int[u"avgusta"] = 8
month_to_int[u"avg"] = 8
month_to_int[u"авг"] = 8
month_to_int[u"август"] = 8
month_to_int[u"августа"] = 8
month_to_int[u"viii"] = 8
month_to_int["avgust"] = 8
month_to_int["avgusta"] = 8
month_to_int["avg"] = 8
month_to_int["авг"] = 8
month_to_int["август"] = 8
month_to_int["августа"] = 8
month_to_int["viii"] = 8
month_to_int[u"septembar"] = 9
month_to_int[u"septembra"] = 9
month_to_int[u"sep"] = 9
month_to_int[u"сеп"] = 9
month_to_int[u"септембар"] = 9
month_to_int[u"септембра"] = 9
month_to_int[u"ix"] = 9
month_to_int["septembar"] = 9
month_to_int["septembra"] = 9
month_to_int["sep"] = 9
month_to_int["сеп"] = 9
month_to_int["септембар"] = 9
month_to_int["септембра"] = 9
month_to_int["ix"] = 9
month_to_int[u"oktobar"] = 10
month_to_int[u"oktobra"] = 10
month_to_int[u"okt"] = 10
month_to_int[u"окт"] = 10
month_to_int[u"октобар"] = 10
month_to_int[u"октобра"] = 10
month_to_int[u"x"] = 10
month_to_int["oktobar"] = 10
month_to_int["oktobra"] = 10
month_to_int["okt"] = 10
month_to_int["окт"] = 10
month_to_int["октобар"] = 10
month_to_int["октобра"] = 10
month_to_int["x"] = 10
month_to_int[u"novembar"] = 11
month_to_int[u"novembra"] = 11
month_to_int[u"nov"] = 11
month_to_int[u"нов"] = 11
month_to_int[u"новембар"] = 11
month_to_int[u"новембра"] = 11
month_to_int[u"xi"] = 11
month_to_int["novembar"] = 11
month_to_int["novembra"] = 11
month_to_int["nov"] = 11
month_to_int["нов"] = 11
month_to_int["новембар"] = 11
month_to_int["новембра"] = 11
month_to_int["xi"] = 11
month_to_int[u"decembar"] = 12
month_to_int[u"decembra"] = 12
month_to_int[u"dec"] = 12
month_to_int[u"дец"] = 12
month_to_int[u"децембар"] = 12
month_to_int[u"децембра"] = 12
month_to_int[u"xii"] = 12
month_to_int["decembar"] = 12
month_to_int["decembra"] = 12
month_to_int["dec"] = 12
month_to_int["дец"] = 12
month_to_int["децембар"] = 12
month_to_int["децембра"] = 12
month_to_int["xii"] = 12
modifier_to_int = {
u'pre' : Date.MOD_BEFORE,
u'posle' : Date.MOD_AFTER,
u'oko' : Date.MOD_ABOUT,
u'cca' : Date.MOD_ABOUT,
'pre' : Date.MOD_BEFORE,
'posle' : Date.MOD_AFTER,
'oko' : Date.MOD_ABOUT,
'cca' : Date.MOD_ABOUT,
u'пре' : Date.MOD_BEFORE,
u'после' : Date.MOD_AFTER,
u'око' : Date.MOD_ABOUT,
'пре' : Date.MOD_BEFORE,
'после' : Date.MOD_AFTER,
'око' : Date.MOD_ABOUT,
}
calendar_to_int = {
u'gregorijanski' : Date.CAL_GREGORIAN,
u'greg.' : Date.CAL_GREGORIAN,
u'julijanski' : Date.CAL_JULIAN,
u'jul.' : Date.CAL_JULIAN,
u'hebrejski' : Date.CAL_HEBREW,
u'hebr.' : Date.CAL_HEBREW,
u'islamski' : Date.CAL_ISLAMIC,
u'isl.' : Date.CAL_ISLAMIC,
u'francuski republikanski': Date.CAL_FRENCH,
u'franc.' : Date.CAL_FRENCH,
u'persijski' : Date.CAL_PERSIAN,
u'pers. ' : Date.CAL_PERSIAN,
u'švedski' : Date.CAL_SWEDISH,
u'šv.' : Date.CAL_SWEDISH,
'gregorijanski' : Date.CAL_GREGORIAN,
'greg.' : Date.CAL_GREGORIAN,
'julijanski' : Date.CAL_JULIAN,
'jul.' : Date.CAL_JULIAN,
'hebrejski' : Date.CAL_HEBREW,
'hebr.' : Date.CAL_HEBREW,
'islamski' : Date.CAL_ISLAMIC,
'isl.' : Date.CAL_ISLAMIC,
'francuski republikanski': Date.CAL_FRENCH,
'franc.' : Date.CAL_FRENCH,
'persijski' : Date.CAL_PERSIAN,
'pers. ' : Date.CAL_PERSIAN,
'švedski' : Date.CAL_SWEDISH,
'šv.' : Date.CAL_SWEDISH,
u'грегоријански' : Date.CAL_GREGORIAN,
u'грег.' : Date.CAL_GREGORIAN,
u'јулијански' : Date.CAL_JULIAN,
u'јул.' : Date.CAL_JULIAN,
u'хебрејски' : Date.CAL_HEBREW,
u'хебр.' : Date.CAL_HEBREW,
u'исламски' : Date.CAL_ISLAMIC,
u'исл.' : Date.CAL_ISLAMIC,
u'француски републикански': Date.CAL_FRENCH,
u'франц.' : Date.CAL_FRENCH,
u'персијски' : Date.CAL_PERSIAN,
u'перс. ' : Date.CAL_PERSIAN,
u'шведски' : Date.CAL_SWEDISH,
u'шв' : Date.CAL_SWEDISH,
'грегоријански' : Date.CAL_GREGORIAN,
'грег.' : Date.CAL_GREGORIAN,
'јулијански' : Date.CAL_JULIAN,
'јул.' : Date.CAL_JULIAN,
'хебрејски' : Date.CAL_HEBREW,
'хебр.' : Date.CAL_HEBREW,
'исламски' : Date.CAL_ISLAMIC,
'исл.' : Date.CAL_ISLAMIC,
'француски републикански': Date.CAL_FRENCH,
'франц.' : Date.CAL_FRENCH,
'персијски' : Date.CAL_PERSIAN,
'перс. ' : Date.CAL_PERSIAN,
'шведски' : Date.CAL_SWEDISH,
'шв' : Date.CAL_SWEDISH,
}
quality_to_int = {
u'procenjeno' : Date.QUAL_ESTIMATED,
u'pro.' : Date.QUAL_ESTIMATED,
u'izračunato' : Date.QUAL_CALCULATED,
u'izr.' : Date.QUAL_CALCULATED,
'procenjeno' : Date.QUAL_ESTIMATED,
'pro.' : Date.QUAL_ESTIMATED,
'izračunato' : Date.QUAL_CALCULATED,
'izr.' : Date.QUAL_CALCULATED,
u'процењено' : Date.QUAL_ESTIMATED,
u'про.' : Date.QUAL_ESTIMATED,
u'израчунато' : Date.QUAL_CALCULATED,
u'изр.' : Date.QUAL_CALCULATED,
'процењено' : Date.QUAL_ESTIMATED,
'про.' : Date.QUAL_ESTIMATED,
'израчунато' : Date.QUAL_CALCULATED,
'изр.' : Date.QUAL_CALCULATED,
}
bce = [u"пре нове ере", u"пре Христа", u"п.н.е."
u"pre nove ere", u"pre Hrista", u"p.n.e."] + DateParser.bce
bce = ["пре нове ере", "пре Христа", "п.н.е."
"pre nove ere", "pre Hrista", "p.n.e."] + DateParser.bce
def init_strings(self):
"""
@ -216,10 +216,10 @@ class DateParserSR(DateParser):
# match Day.Month.Year.
self._numeric = re.compile("((\d+)[/\. ])?\s*((\d+)[/\.])?\s*(\d+)\.?$")
_span1 = [u'od', u'од']
_span2 = [u'do', u'до']
_range1 = [u'između', u'између']
_range2 = [u'i', u'и']
_span1 = ['od', 'од']
_span2 = ['do', 'до']
_range1 = ['između', 'између']
_range2 = ['i', 'и']
self._span = re.compile("(%s)\s+(?P<start>.+)\s+(%s)\s+(?P<stop>.+)" %
('|'.join(_span1),'|'.join(_span2)),
re.IGNORECASE)
@ -237,14 +237,14 @@ class DateDisplaySR_latin(DateDisplay):
Serbian (latin) date display class
"""
long_months = ("",
u"januara", u"februara", u"marta", u"aprila",
u"maja", u"juna", u"jula", u"avgusta",
u"septembra", u"oktobra", u"novembra", u"decembra"
"januara", "februara", "marta", "aprila",
"maja", "juna", "jula", "avgusta",
"septembra", "oktobra", "novembra", "decembra"
)
short_months = ("",
u"jan", u"feb", u"mar", u"apr", u"maj", u"jun",
u"jul", u"avg", u"sep", u"okt", u"nov", u"dec"
"jan", "feb", "mar", "apr", "maj", "jun",
"jul", "avg", "sep", "okt", "nov", "dec"
)
roman_months = (
@ -253,9 +253,9 @@ class DateDisplaySR_latin(DateDisplay):
)
calendar = (
"", u"julijanski", u"hebrejski",
u"francuski republikanski", u"persijski", u"islamski",
u"švedski"
"", "julijanski", "hebrejski",
"francuski republikanski", "persijski", "islamski",
"švedski"
)
_mod_str = ("", "pre ", "posle ", "oko ", "", "", "")
@ -297,27 +297,27 @@ class DateDisplaySR_latin(DateDisplay):
# Day. MON Year.
if date_val[0] == 0:
if date_val[1] == 0:
value = u"%s." % year
value = "%s." % year
else:
value = u"%s %s." % (self.short_months[date_val[1]], year)
value = "%s %s." % (self.short_months[date_val[1]], year)
else:
value = u"%d. %s %s." % (date_val[0],
value = "%d. %s %s." % (date_val[0],
self.short_months[date_val[1]], year)
elif self.format == 3:
# Day. MONTH Year.
if date_val[0] == 0:
if date_val[1] == 0:
value = u"%s." % year
value = "%s." % year
else:
value = u"%s %s." % (self.long_months[date_val[1]], year)
value = "%s %s." % (self.long_months[date_val[1]], year)
else:
value = u"%d. %s %s." % (date_val[0],
value = "%d. %s %s." % (date_val[0],
self.long_months[date_val[1]], year)
else:
# Day RomanMon Year
if date_val[0] == 0:
if date_val[1] == 0:
value = u"%s." % year
value = "%s." % year
else:
value = "%s %s." % (self.roman_months[date_val[1]], year)
else:
@ -348,13 +348,13 @@ class DateDisplaySR_latin(DateDisplay):
d_1 = self.display_cal[cal](start)
d_2 = self.display_cal[cal](date.get_stop_date())
scal = self.format_extras(cal, newyear)
return "%s%s %s %s %s%s" % (qual_str, u'od', d_1, u'do', d_2,
return "%s%s %s %s %s%s" % (qual_str, 'od', d_1, 'do', d_2,
scal)
elif mod == Date.MOD_RANGE:
d_1 = self.display_cal[cal](start)
d_2 = self.display_cal[cal](date.get_stop_date())
scal = self.format_extras(cal, newyear)
return "%s%s %s %s %s%s" % (qual_str, u'između', d_1, u'i', d_2,
return "%s%s %s %s %s%s" % (qual_str, 'između', d_1, 'i', d_2,
scal)
else:
text = self.display_cal[date.get_calendar()](start)

View File

@ -24,7 +24,7 @@
"""
Swedish-specific classes for parsing and displaying dates.
"""
from __future__ import unicode_literals
#-------------------------------------------------------------------------
#
# Python modules
@ -38,9 +38,9 @@ import re
#
#-------------------------------------------------------------------------
from ..lib.date import Date
from _dateparser import DateParser
from _datedisplay import DateDisplay
from _datehandler import register_datehandler
from ._dateparser import DateParser
from ._datedisplay import DateDisplay
from ._datehandler import register_datehandler
#-------------------------------------------------------------------------
#
@ -56,50 +56,50 @@ class DateParserSv(DateParser):
# modifiers before the date
modifier_to_int = {
u'före' : Date.MOD_BEFORE,
u'innan' : Date.MOD_BEFORE,
u'efter' : Date.MOD_AFTER,
u'omkring' : Date.MOD_ABOUT,
u'ca' : Date.MOD_ABOUT,
u'c:a' : Date.MOD_ABOUT
'före' : Date.MOD_BEFORE,
'innan' : Date.MOD_BEFORE,
'efter' : Date.MOD_AFTER,
'omkring' : Date.MOD_ABOUT,
'ca' : Date.MOD_ABOUT,
'c:a' : Date.MOD_ABOUT
}
bce = [u"f Kr"]
bce = ["f Kr"]
calendar_to_int = {
u'gregoriansk ' : Date.CAL_GREGORIAN,
u'g' : Date.CAL_GREGORIAN,
u'juliansk' : Date.CAL_JULIAN,
u'j' : Date.CAL_JULIAN,
u'hebreisk' : Date.CAL_HEBREW,
u'h' : Date.CAL_HEBREW,
u'islamisk' : Date.CAL_ISLAMIC,
u'muslimsk' : Date.CAL_ISLAMIC,
u'i' : Date.CAL_ISLAMIC,
u'fransk' : Date.CAL_FRENCH,
u'fransk republikansk' : Date.CAL_FRENCH,
u'f' : Date.CAL_FRENCH,
u'persisk' : Date.CAL_PERSIAN,
u'p' : Date.CAL_PERSIAN,
u'svensk' : Date.CAL_SWEDISH,
u's' : Date.CAL_SWEDISH,
'gregoriansk ' : Date.CAL_GREGORIAN,
'g' : Date.CAL_GREGORIAN,
'juliansk' : Date.CAL_JULIAN,
'j' : Date.CAL_JULIAN,
'hebreisk' : Date.CAL_HEBREW,
'h' : Date.CAL_HEBREW,
'islamisk' : Date.CAL_ISLAMIC,
'muslimsk' : Date.CAL_ISLAMIC,
'i' : Date.CAL_ISLAMIC,
'fransk' : Date.CAL_FRENCH,
'fransk republikansk' : Date.CAL_FRENCH,
'f' : Date.CAL_FRENCH,
'persisk' : Date.CAL_PERSIAN,
'p' : Date.CAL_PERSIAN,
'svensk' : Date.CAL_SWEDISH,
's' : Date.CAL_SWEDISH,
}
quality_to_int = {
u'uppskattat' : Date.QUAL_ESTIMATED,
u'uppskattad' : Date.QUAL_ESTIMATED,
u'bedömt' : Date.QUAL_ESTIMATED,
u'bedömd' : Date.QUAL_ESTIMATED,
u'beräknat' : Date.QUAL_CALCULATED,
u'beräknad' : Date.QUAL_CALCULATED,
'uppskattat' : Date.QUAL_ESTIMATED,
'uppskattad' : Date.QUAL_ESTIMATED,
'bedömt' : Date.QUAL_ESTIMATED,
'bedömd' : Date.QUAL_ESTIMATED,
'beräknat' : Date.QUAL_CALCULATED,
'beräknad' : Date.QUAL_CALCULATED,
}
def init_strings(self):
""" Define, in Swedish, span and range regular expressions"""
DateParser.init_strings(self)
self._span = re.compile(u"(från)?\s*(?P<start>.+)\s*(till|--|)\s*(?P<stop>.+)",
self._span = re.compile("(från)?\s*(?P<start>.+)\s*(till|--|)\s*(?P<stop>.+)",
re.IGNORECASE)
self._range = re.compile(u"(mellan)\s+(?P<start>.+)\s+och\s+(?P<stop>.+)",
self._range = re.compile("(mellan)\s+(?P<start>.+)\s+och\s+(?P<stop>.+)",
re.IGNORECASE)
#-------------------------------------------------------------------------
@ -111,37 +111,37 @@ class DateDisplaySv(DateDisplay):
"""
Swedish language date display class.
"""
long_months = ( u"", u"januari", u"februari", u"mars", u"april", u"maj",
u"juni", u"juli", u"augusti", u"september", u"oktober",
u"november", u"december" )
long_months = ( "", "januari", "februari", "mars", "april", "maj",
"juni", "juli", "augusti", "september", "oktober",
"november", "december" )
short_months = ( u"", u"jan", u"feb", u"mar", u"apr", u"maj", u"jun",
u"jul", u"aug", u"sep", u"okt", u"nov", u"dec" )
short_months = ( "", "jan", "feb", "mar", "apr", "maj", "jun",
"jul", "aug", "sep", "okt", "nov", "dec" )
formats = (
u"ÅÅÅÅ-MM-DD (ISO)",
u"År/mån/dag",
u"Månad dag, år",
u"MÅN DAG ÅR",
u"Dag månad år",
u"DAG MÅN ÅR",
"ÅÅÅÅ-MM-DD (ISO)",
"År/mån/dag",
"Månad dag, år",
"MÅN DAG ÅR",
"Dag månad år",
"DAG MÅN ÅR",
)
calendar = (
u"",
u"juliansk",
u"hebreisk",
u"fransk republikansk",
u"persisk",
u"islamisk",
u"svensk"
"",
"juliansk",
"hebreisk",
"fransk republikansk",
"persisk",
"islamisk",
"svensk"
)
_mod_str = (u"", u"före ", u"efter ", u"c:a ", u"", u"", u"")
_mod_str = ("", "före ", "efter ", "c:a ", "", "", "")
_qual_str = (u"", u"uppskattat ", u"beräknat ")
_qual_str = ("", "uppskattat ", "beräknat ")
_bce_str = u"%s f Kr"
_bce_str = "%s f Kr"
def display(self, date):
"""
@ -158,22 +158,22 @@ class DateDisplaySv(DateDisplay):
if mod == Date.MOD_TEXTONLY:
return date.get_text()
elif start == Date.EMPTY:
return u""
return ""
elif mod == Date.MOD_SPAN:
d1 = self.display_cal[cal](start)
d2 = self.display_cal[cal](date.get_stop_date())
scal = self.format_extras(cal, newyear)
return u"%sfrån %s till %s%s" % (qual_str, d1, d2, scal)
return "%sfrån %s till %s%s" % (qual_str, d1, d2, scal)
elif mod == Date.MOD_RANGE:
d1 = self.display_cal[cal](start)
d2 = self.display_cal[cal](date.get_stop_date())
scal = self.format_extras(cal, newyear)
return u"%smellan %s och %s%s" % (qual_str, d1, d2,
return "%smellan %s och %s%s" % (qual_str, d1, d2,
scal)
else:
text = self.display_cal[date.get_calendar()](start)
scal = self.format_extras(cal, newyear)
return u"%s%s%s%s" % (qual_str, self._mod_str[mod],
return "%s%s%s%s" % (qual_str, self._mod_str[mod],
text, scal)
#-------------------------------------------------------------------------

View File

@ -30,7 +30,7 @@
"""
Chinese-specific classes for parsing and displaying dates.
"""
from __future__ import unicode_literals
import re
#-------------------------------------------------------------------------
@ -40,9 +40,9 @@ import re
#-------------------------------------------------------------------------
from ..lib.date import Date
from _dateparser import DateParser
from _datedisplay import DateDisplay
from _datehandler import register_datehandler
from ._dateparser import DateParser
from ._datedisplay import DateDisplay
from ._datehandler import register_datehandler
#-------------------------------------------------------------------------
#
@ -58,43 +58,43 @@ class DateParserZH(DateParser):
# translate english strings into chinese
modifier_to_int = {
u'before' : Date.MOD_BEFORE, u'bef' : Date.MOD_BEFORE,
u'bef.' : Date.MOD_BEFORE, u'after' : Date.MOD_AFTER,
u'aft' : Date.MOD_AFTER, u'aft.' : Date.MOD_AFTER,
u'about' : Date.MOD_ABOUT, u'abt.' : Date.MOD_ABOUT,
u'abt' : Date.MOD_ABOUT, u'circa' : Date.MOD_ABOUT,
u'c.' : Date.MOD_ABOUT, u'around' : Date.MOD_ABOUT,
'before' : Date.MOD_BEFORE, 'bef' : Date.MOD_BEFORE,
'bef.' : Date.MOD_BEFORE, 'after' : Date.MOD_AFTER,
'aft' : Date.MOD_AFTER, 'aft.' : Date.MOD_AFTER,
'about' : Date.MOD_ABOUT, 'abt.' : Date.MOD_ABOUT,
'abt' : Date.MOD_ABOUT, 'circa' : Date.MOD_ABOUT,
'c.' : Date.MOD_ABOUT, 'around' : Date.MOD_ABOUT,
}
month_to_int = DateParser.month_to_int
month_to_int[u""] = 1
month_to_int[u""] = 1
month_to_int[u"zhēngyuè"] = 1
month_to_int[u""] = 2
month_to_int[u"èryuè"] = 2
month_to_int[u""] = 3
month_to_int[u"sānyuè"] = 3
month_to_int[u""] = 4
month_to_int[u"sìyuè"] = 4
month_to_int[u""] = 5
month_to_int[u"wǔyuè"] = 5
month_to_int[u""] = 6
month_to_int[u"liùyuè"] = 6
month_to_int[u""] = 7
month_to_int[u"qīyuè"] = 7
month_to_int[u""] = 8
month_to_int[u"bāyuè"] = 8
month_to_int[u""] = 9
month_to_int[u"jiǔyuè"] = 9
month_to_int[u""] = 10
month_to_int[u"shíyuè"] = 10
month_to_int[u"十一"] = 11
month_to_int[u"shíyīyuè"] = 11
month_to_int[u"十二"] = 12
month_to_int[u"shí'èryuè"] = 12
month_to_int[u"假閏"] = 13
month_to_int[u"jiǎ rùn yùe"] = 13
month_to_int[""] = 1
month_to_int[""] = 1
month_to_int["zhēngyuè"] = 1
month_to_int[""] = 2
month_to_int["èryuè"] = 2
month_to_int[""] = 3
month_to_int["sānyuè"] = 3
month_to_int[""] = 4
month_to_int["sìyuè"] = 4
month_to_int[""] = 5
month_to_int["wǔyuè"] = 5
month_to_int[""] = 6
month_to_int["liùyuè"] = 6
month_to_int[""] = 7
month_to_int["qīyuè"] = 7
month_to_int[""] = 8
month_to_int["bāyuè"] = 8
month_to_int[""] = 9
month_to_int["jiǔyuè"] = 9
month_to_int[""] = 10
month_to_int["shíyuè"] = 10
month_to_int["十一"] = 11
month_to_int["shíyīyuè"] = 11
month_to_int["十二"] = 12
month_to_int["shí'èryuè"] = 12
month_to_int["假閏"] = 13
month_to_int["jiǎ rùn yùe"] = 13
# translate english strings into chinese
@ -119,17 +119,17 @@ class DateParserZH(DateParser):
# translate english strings into chinese
quality_to_int = {
u'estimated' : Date.QUAL_ESTIMATED,
u'est.' : Date.QUAL_ESTIMATED,
u'est' : Date.QUAL_ESTIMATED,
u'calc.' : Date.QUAL_CALCULATED,
u'calc' : Date.QUAL_CALCULATED,
u'calculated' : Date.QUAL_CALCULATED,
'estimated' : Date.QUAL_ESTIMATED,
'est.' : Date.QUAL_ESTIMATED,
'est' : Date.QUAL_ESTIMATED,
'calc.' : Date.QUAL_CALCULATED,
'calc' : Date.QUAL_CALCULATED,
'calculated' : Date.QUAL_CALCULATED,
}
# translate english strings into chinese
bce = [u"before calendar", u"negative year"] + DateParser.bce
bce = ["before calendar", "negative year"] + DateParser.bce
def init_strings(self):
"""
@ -149,9 +149,9 @@ class DateParserZH(DateParser):
# See DateParser class; translate english strings (from/to, between/and) into chinese
# do not translate <start> and <stop>
self._span = re.compile(u"(from)\s+(?P<start>.+)\s+to\s+(?P<stop>.+)",
self._span = re.compile("(from)\s+(?P<start>.+)\s+to\s+(?P<stop>.+)",
re.IGNORECASE)
self._range = re.compile(u"(bet|bet.|between)\s+(?P<start>.+)\s+and\s+(?P<stop>.+)",
self._range = re.compile("(bet|bet.|between)\s+(?P<start>.+)\s+and\s+(?P<stop>.+)",
re.IGNORECASE)
#def _parse_lunisolar(self, date_val=text):
@ -171,21 +171,21 @@ class DateDisplayZH(DateDisplay):
# translate english strings into chinese
long_months = ( u"", u"January", u"February", u"March", u"April", u"May",
u"June", u"July", u"August", u"September", u"October",
u"November", u"December" )
long_months = ( "", "January", "February", "March", "April", "May",
"June", "July", "August", "September", "October",
"November", "December" )
short_months = ( u"", u"Jan", u"Feb", u"Mar", u"Apr", u"May", u"Jun",
u"Jul", u"Aug", u"Sep", u"Oct", u"Nov", u"Dec" )
short_months = ( "", "Jan", "Feb", "Mar", "Apr", "May", "Jun",
"Jul", "Aug", "Sep", "Oct", "Nov", "Dec" )
calendar = (
"", u"Julian", u"Hebrew", u"French Republican",
u"Persian", u"Islamic", u"Swedish"
"", "Julian", "Hebrew", "French Republican",
"Persian", "Islamic", "Swedish"
)
_mod_str = ("", u"before ", u"after ", u"around ", "", "", "")
_mod_str = ("", "before ", "after ", "around ", "", "", "")
_qual_str = ("", u"estimated ", u"calculated ", "")
_qual_str = ("", "estimated ", "calculated ", "")
_bce_str = "%s B.C.E."
@ -212,14 +212,14 @@ class DateDisplayZH(DateDisplay):
date2 = self.display_cal[cal](date.get_stop_date())
scal = self.format_extras(cal, newyear)
# translate english strings into chinese
return "%s%s %s %s %s%s" % (qual_str, u'from', date1, u'to',
return "%s%s %s %s %s%s" % (qual_str, 'from', date1, 'to',
date2, scal)
elif mod == Date.MOD_RANGE:
date1 = self.display_cal[cal](start)
date2 = self.display_cal[cal](date.get_stop_date())
scal = self.format_extras(cal, newyear)
# translate english strings into chinese
return "%s%s %s %s %s%s" % (qual_str, u'between', date1, u'and',
return "%s%s %s %s %s%s" % (qual_str, 'between', date1, 'and',
date2, scal)
else:
text = self.display_cal[date.get_calendar()](start)

View File

@ -24,6 +24,7 @@
U.S English date display class. Should serve as the base class for all
localized tasks.
"""
from __future__ import unicode_literals
#-------------------------------------------------------------------------
#
@ -39,7 +40,7 @@ log = logging.getLogger(".DateDisplay")
#
#-------------------------------------------------------------------------
from ..lib.date import Date
import _grampslocale
from . import _grampslocale
#-------------------------------------------------------------------------
#
@ -50,12 +51,12 @@ class DateDisplay(object):
"""
Base date display class.
"""
long_months = ( u"", u"January", u"February", u"March", u"April", u"May",
u"June", u"July", u"August", u"September", u"October",
u"November", u"December" )
long_months = ( "", "January", "February", "March", "April", "May",
"June", "July", "August", "September", "October",
"November", "December" )
short_months = ( u"", u"Jan", u"Feb", u"Mar", u"Apr", u"May", u"Jun",
u"Jul", u"Aug", u"Sep", u"Oct", u"Nov", u"Dec" )
short_months = ( "", "Jan", "Feb", "Mar", "Apr", "May", "Jun",
"Jul", "Aug", "Sep", "Oct", "Nov", "Dec" )
_tformat = _grampslocale.tformat
@ -66,20 +67,20 @@ class DateDisplay(object):
)
french = (
u'',
u"Vendémiaire",
u'Brumaire',
u'Frimaire',
u"Nivôse",
u"Pluviôse",
u"Ventôse",
u'Germinal',
u"Floréal",
u'Prairial',
u'Messidor',
u'Thermidor',
u'Fructidor',
u'Extra',
'',
"Vendémiaire",
'Brumaire',
'Frimaire',
"Nivôse",
"Pluviôse",
"Ventôse",
'Germinal',
"Floréal",
'Prairial',
'Messidor',
'Thermidor',
'Fructidor',
'Extra',
)
persian = (
@ -284,9 +285,9 @@ class DateDisplay(object):
if date_val[1] == 0:
value = year
else:
value = u"%s %d" % (month_list[date_val[1]], year)
value = "%s %d" % (month_list[date_val[1]], year)
else:
value = u"%s %d, %s" % (month_list[date_val[1]], date_val[0],
value = "%s %d, %s" % (month_list[date_val[1]], date_val[0],
year)
if date_val[2] < 0:
return self._bce_str % value
@ -302,9 +303,9 @@ class DateDisplay(object):
if date_val[1] == 0:
value = year
else:
value = u"%s %d" % (self.french[date_val[1]], year)
value = "%s %d" % (self.french[date_val[1]], year)
else:
value = u"%d %s %s" % (date_val[0], self.french[date_val[1]],
value = "%d %s %s" % (date_val[0], self.french[date_val[1]],
year)
if date_val[2] < 0:
return self._bce_str % value

View File

@ -23,6 +23,7 @@
"""
Class handling language-specific selection for date parser and displayer.
"""
from __future__ import unicode_literals
#-------------------------------------------------------------------------
#
@ -45,9 +46,9 @@ log = logging.getLogger(".gen.datehandler")
# GRAMPS modules
#
#-------------------------------------------------------------------------
from _dateparser import DateParser
from _datedisplay import DateDisplay, DateDisplayEn
from ..constfunc import win
from ._dateparser import DateParser
from ._datedisplay import DateDisplay, DateDisplayEn
from ..constfunc import win, cuni
#-------------------------------------------------------------------------
#
@ -73,6 +74,9 @@ if LANG:
else:
LANG_SHORT = "C"
LANG = cuni(LANG)
LANG_SHORT = cuni(LANG_SHORT)
LANG_TO_PARSER = {
'C' : DateParser,
'en' : DateParser,

View File

@ -32,6 +32,8 @@ English.
# Python modules
#
#-------------------------------------------------------------------------
from __future__ import print_function, unicode_literals
import re
import calendar
@ -49,7 +51,7 @@ log = logging.getLogger(".DateParser")
#
#-------------------------------------------------------------------------
from ..lib.date import Date, DateError
import _grampslocale
from . import _grampslocale
#-------------------------------------------------------------------------
#
@ -156,35 +158,35 @@ class DateParser(object):
modifier_after_to_int = {}
hebrew_to_int = {
u"tishri" : 1, u"heshvan" : 2, u"kislev" : 3,
u"tevet" : 4, u"shevat" : 5, u"adari" : 6,
u"adarii" : 7, u"nisan" : 8, u"iyyar" : 9,
u"sivan" : 10, u"tammuz" : 11, u"av" : 12,
u"elul" : 13,
"tishri" : 1, "heshvan" : 2, "kislev" : 3,
"tevet" : 4, "shevat" : 5, "adari" : 6,
"adarii" : 7, "nisan" : 8, "iyyar" : 9,
"sivan" : 10, "tammuz" : 11, "av" : 12,
"elul" : 13,
#alternative spelling
u"cheshvan": 2, u"adar sheni": 7, u"iyar" : 9,
"cheshvan": 2, "adar sheni": 7, "iyar" : 9,
#GEDCOM months
u"tsh" : 1, u"csh": 5, u"ksl": 3, u"tvt": 4, u"shv": 5, u"adr": 6,
u"ads" : 7, u"nsn": 8, u"iyr": 9, u"svn":10, u"tmz":11, u"aav":12,
u"ell":13,
"tsh" : 1, "csh": 5, "ksl": 3, "tvt": 4, "shv": 5, "adr": 6,
"ads" : 7, "nsn": 8, "iyr": 9, "svn":10, "tmz":11, "aav":12,
"ell":13,
}
french_to_int = {
u'vendémiaire' : 1, u'brumaire' : 2,
u'frimaire' : 3, u'nivôse': 4,
u'pluviôse' : 5, u'ventôse' : 6,
u'germinal' : 7, u'floréal' : 8,
u'prairial' : 9, u'messidor' : 10,
u'thermidor' : 11, u'fructidor' : 12,
u'extra' : 13,
'vendémiaire' : 1, 'brumaire' : 2,
'frimaire' : 3, 'nivôse': 4,
'pluviôse' : 5, 'ventôse' : 6,
'germinal' : 7, 'floréal' : 8,
'prairial' : 9, 'messidor' : 10,
'thermidor' : 11, 'fructidor' : 12,
'extra' : 13,
#GEDCOM months
u'vend' : 1, u'brum' : 2,
u'frim' : 3, u'nivo' : 4,
u'pluv' : 5, u'vent' : 6,
u'germ' : 7, u'flor' : 8,
u'prai' : 9, u'mess' : 10,
u'ther' : 11, u'fruc' : 12,
u'comp' : 13,
'vend' : 1, 'brum' : 2,
'frim' : 3, 'nivo' : 4,
'pluv' : 5, 'vent' : 6,
'germ' : 7, 'flor' : 8,
'prai' : 9, 'mess' : 10,
'ther' : 11, 'fruc' : 12,
'comp' : 13,
}
islamic_to_int = {
@ -289,7 +291,7 @@ class DateParser(object):
sorted so that longest keys match first. Any '.' characters
are quoted.
"""
keys.sort(lambda x, y: cmp(len(y), len(x)))
keys.sort(key=lambda x: len(x), reverse=True)
return '(' + '|'.join([key.replace('.', '\.') for key in keys]) + ')'
def init_strings(self):
@ -303,23 +305,23 @@ class DateParser(object):
can be coded after DateParser.init_strings(self) call, that way they
override stuff from this method. See DateParserRU() as an example.
"""
self._rfc_mon_str = '(' + '|'.join(self._rfc_mons_to_int.keys()) + ')'
self._rfc_mon_str = '(' + '|'.join(list(self._rfc_mons_to_int.keys())) + ')'
self._rfc_day_str = '(' + '|'.join(self._rfc_days) + ')'
self._bce_str = self.re_longest_first(self.bce)
self._qual_str = self.re_longest_first(self.quality_to_int.keys())
self._mod_str = self.re_longest_first(self.modifier_to_int.keys())
self._qual_str = self.re_longest_first(list(self.quality_to_int.keys()))
self._mod_str = self.re_longest_first(list(self.modifier_to_int.keys()))
self._mod_after_str = self.re_longest_first(
self.modifier_after_to_int.keys())
list(self.modifier_after_to_int.keys()))
self._mon_str = self.re_longest_first(self.month_to_int.keys())
self._jmon_str = self.re_longest_first(self.hebrew_to_int.keys())
self._fmon_str = self.re_longest_first(self.french_to_int.keys())
self._pmon_str = self.re_longest_first(self.persian_to_int.keys())
self._imon_str = self.re_longest_first(self.islamic_to_int.keys())
self._smon_str = self.re_longest_first(self.swedish_to_int.keys())
self._cal_str = self.re_longest_first(self.calendar_to_int.keys())
self._ny_str = self.re_longest_first(self.newyear_to_int.keys())
self._mon_str = self.re_longest_first(list(self.month_to_int.keys()))
self._jmon_str = self.re_longest_first(list(self.hebrew_to_int.keys()))
self._fmon_str = self.re_longest_first(list(self.french_to_int.keys()))
self._pmon_str = self.re_longest_first(list(self.persian_to_int.keys()))
self._imon_str = self.re_longest_first(list(self.islamic_to_int.keys()))
self._smon_str = self.re_longest_first(list(self.swedish_to_int.keys()))
self._cal_str = self.re_longest_first(list(self.calendar_to_int.keys()))
self._ny_str = self.re_longest_first(list(self.newyear_to_int.keys()))
# bce, calendar type and quality may be either at the end or at
# the beginning of the given date string, therefore they will
@ -687,7 +689,7 @@ class DateParser(object):
try:
text = match.group(1) + match.group(3)
except:
print "ERROR MATCH:", match.groups()
print("ERROR MATCH:", match.groups())
bc = True
return (text, bc)

View File

@ -22,7 +22,8 @@
# $Id$
import locale
from ..constfunc import mac, win
import sys
from ..constfunc import mac, win, conv_to_unicode
"""
Some OS environments do not support the locale.nl_langinfo() method
@ -39,62 +40,62 @@ try:
codeset = locale.nl_langinfo(locale.CODESET)
month_to_int = {
unicode(locale.nl_langinfo(locale.MON_1),codeset).lower() : 1,
unicode(locale.nl_langinfo(locale.ABMON_1),codeset).lower() : 1,
unicode(locale.nl_langinfo(locale.MON_2),codeset).lower() : 2,
unicode(locale.nl_langinfo(locale.ABMON_2),codeset).lower() : 2,
unicode(locale.nl_langinfo(locale.MON_3),codeset).lower() : 3,
unicode(locale.nl_langinfo(locale.ABMON_3),codeset).lower() : 3,
unicode(locale.nl_langinfo(locale.MON_4),codeset).lower() : 4,
unicode(locale.nl_langinfo(locale.ABMON_4),codeset).lower() : 4,
unicode(locale.nl_langinfo(locale.MON_5),codeset).lower() : 5,
unicode(locale.nl_langinfo(locale.ABMON_5),codeset).lower() : 5,
unicode(locale.nl_langinfo(locale.MON_6),codeset).lower() : 6,
unicode(locale.nl_langinfo(locale.ABMON_6),codeset).lower() : 6,
unicode(locale.nl_langinfo(locale.MON_7),codeset).lower() : 7,
unicode(locale.nl_langinfo(locale.ABMON_7),codeset).lower() : 7,
unicode(locale.nl_langinfo(locale.MON_8),codeset).lower() : 8,
unicode(locale.nl_langinfo(locale.ABMON_8),codeset).lower() : 8,
unicode(locale.nl_langinfo(locale.MON_9),codeset).lower() : 9,
unicode(locale.nl_langinfo(locale.ABMON_9),codeset).lower() : 9,
unicode(locale.nl_langinfo(locale.MON_10),codeset).lower() : 10,
unicode(locale.nl_langinfo(locale.ABMON_10),codeset).lower(): 10,
unicode(locale.nl_langinfo(locale.MON_11),codeset).lower() : 11,
unicode(locale.nl_langinfo(locale.ABMON_11),codeset).lower(): 11,
unicode(locale.nl_langinfo(locale.MON_12),codeset).lower() : 12,
unicode(locale.nl_langinfo(locale.ABMON_12),codeset).lower(): 12,
conv_to_unicode(locale.nl_langinfo(locale.MON_1),codeset).lower() : 1,
conv_to_unicode(locale.nl_langinfo(locale.ABMON_1),codeset).lower() : 1,
conv_to_unicode(locale.nl_langinfo(locale.MON_2),codeset).lower() : 2,
conv_to_unicode(locale.nl_langinfo(locale.ABMON_2),codeset).lower() : 2,
conv_to_unicode(locale.nl_langinfo(locale.MON_3),codeset).lower() : 3,
conv_to_unicode(locale.nl_langinfo(locale.ABMON_3),codeset).lower() : 3,
conv_to_unicode(locale.nl_langinfo(locale.MON_4),codeset).lower() : 4,
conv_to_unicode(locale.nl_langinfo(locale.ABMON_4),codeset).lower() : 4,
conv_to_unicode(locale.nl_langinfo(locale.MON_5),codeset).lower() : 5,
conv_to_unicode(locale.nl_langinfo(locale.ABMON_5),codeset).lower() : 5,
conv_to_unicode(locale.nl_langinfo(locale.MON_6),codeset).lower() : 6,
conv_to_unicode(locale.nl_langinfo(locale.ABMON_6),codeset).lower() : 6,
conv_to_unicode(locale.nl_langinfo(locale.MON_7),codeset).lower() : 7,
conv_to_unicode(locale.nl_langinfo(locale.ABMON_7),codeset).lower() : 7,
conv_to_unicode(locale.nl_langinfo(locale.MON_8),codeset).lower() : 8,
conv_to_unicode(locale.nl_langinfo(locale.ABMON_8),codeset).lower() : 8,
conv_to_unicode(locale.nl_langinfo(locale.MON_9),codeset).lower() : 9,
conv_to_unicode(locale.nl_langinfo(locale.ABMON_9),codeset).lower() : 9,
conv_to_unicode(locale.nl_langinfo(locale.MON_10),codeset).lower() : 10,
conv_to_unicode(locale.nl_langinfo(locale.ABMON_10),codeset).lower(): 10,
conv_to_unicode(locale.nl_langinfo(locale.MON_11),codeset).lower() : 11,
conv_to_unicode(locale.nl_langinfo(locale.ABMON_11),codeset).lower(): 11,
conv_to_unicode(locale.nl_langinfo(locale.MON_12),codeset).lower() : 12,
conv_to_unicode(locale.nl_langinfo(locale.ABMON_12),codeset).lower(): 12,
}
long_months = (
"",
unicode(locale.nl_langinfo(locale.MON_1),codeset),
unicode(locale.nl_langinfo(locale.MON_2),codeset),
unicode(locale.nl_langinfo(locale.MON_3),codeset),
unicode(locale.nl_langinfo(locale.MON_4),codeset),
unicode(locale.nl_langinfo(locale.MON_5),codeset),
unicode(locale.nl_langinfo(locale.MON_6),codeset),
unicode(locale.nl_langinfo(locale.MON_7),codeset),
unicode(locale.nl_langinfo(locale.MON_8),codeset),
unicode(locale.nl_langinfo(locale.MON_9),codeset),
unicode(locale.nl_langinfo(locale.MON_10),codeset),
unicode(locale.nl_langinfo(locale.MON_11),codeset),
unicode(locale.nl_langinfo(locale.MON_12),codeset),
conv_to_unicode(locale.nl_langinfo(locale.MON_1),codeset),
conv_to_unicode(locale.nl_langinfo(locale.MON_2),codeset),
conv_to_unicode(locale.nl_langinfo(locale.MON_3),codeset),
conv_to_unicode(locale.nl_langinfo(locale.MON_4),codeset),
conv_to_unicode(locale.nl_langinfo(locale.MON_5),codeset),
conv_to_unicode(locale.nl_langinfo(locale.MON_6),codeset),
conv_to_unicode(locale.nl_langinfo(locale.MON_7),codeset),
conv_to_unicode(locale.nl_langinfo(locale.MON_8),codeset),
conv_to_unicode(locale.nl_langinfo(locale.MON_9),codeset),
conv_to_unicode(locale.nl_langinfo(locale.MON_10),codeset),
conv_to_unicode(locale.nl_langinfo(locale.MON_11),codeset),
conv_to_unicode(locale.nl_langinfo(locale.MON_12),codeset),
)
short_months = (
"",
unicode(locale.nl_langinfo(locale.ABMON_1),codeset),
unicode(locale.nl_langinfo(locale.ABMON_2),codeset),
unicode(locale.nl_langinfo(locale.ABMON_3),codeset),
unicode(locale.nl_langinfo(locale.ABMON_4),codeset),
unicode(locale.nl_langinfo(locale.ABMON_5),codeset),
unicode(locale.nl_langinfo(locale.ABMON_6),codeset),
unicode(locale.nl_langinfo(locale.ABMON_7),codeset),
unicode(locale.nl_langinfo(locale.ABMON_8),codeset),
unicode(locale.nl_langinfo(locale.ABMON_9),codeset),
unicode(locale.nl_langinfo(locale.ABMON_10),codeset),
unicode(locale.nl_langinfo(locale.ABMON_11),codeset),
unicode(locale.nl_langinfo(locale.ABMON_12),codeset),
conv_to_unicode(locale.nl_langinfo(locale.ABMON_1),codeset),
conv_to_unicode(locale.nl_langinfo(locale.ABMON_2),codeset),
conv_to_unicode(locale.nl_langinfo(locale.ABMON_3),codeset),
conv_to_unicode(locale.nl_langinfo(locale.ABMON_4),codeset),
conv_to_unicode(locale.nl_langinfo(locale.ABMON_5),codeset),
conv_to_unicode(locale.nl_langinfo(locale.ABMON_6),codeset),
conv_to_unicode(locale.nl_langinfo(locale.ABMON_7),codeset),
conv_to_unicode(locale.nl_langinfo(locale.ABMON_8),codeset),
conv_to_unicode(locale.nl_langinfo(locale.ABMON_9),codeset),
conv_to_unicode(locale.nl_langinfo(locale.ABMON_10),codeset),
conv_to_unicode(locale.nl_langinfo(locale.ABMON_11),codeset),
conv_to_unicode(locale.nl_langinfo(locale.ABMON_12),codeset),
)
# Gramps day number: Sunday => 1, Monday => 2, etc
@ -105,24 +106,24 @@ try:
# see http://docs.python.org/library/locale.html
long_days = (
"",
unicode(locale.nl_langinfo(locale.DAY_1),codeset), # Sunday
unicode(locale.nl_langinfo(locale.DAY_2),codeset), # Monday
unicode(locale.nl_langinfo(locale.DAY_3),codeset), # Tuesday
unicode(locale.nl_langinfo(locale.DAY_4),codeset), # Wednesday
unicode(locale.nl_langinfo(locale.DAY_5),codeset), # Thursday
unicode(locale.nl_langinfo(locale.DAY_6),codeset), # Friday
unicode(locale.nl_langinfo(locale.DAY_7),codeset), # Saturday
conv_to_unicode(locale.nl_langinfo(locale.DAY_1),codeset), # Sunday
conv_to_unicode(locale.nl_langinfo(locale.DAY_2),codeset), # Monday
conv_to_unicode(locale.nl_langinfo(locale.DAY_3),codeset), # Tuesday
conv_to_unicode(locale.nl_langinfo(locale.DAY_4),codeset), # Wednesday
conv_to_unicode(locale.nl_langinfo(locale.DAY_5),codeset), # Thursday
conv_to_unicode(locale.nl_langinfo(locale.DAY_6),codeset), # Friday
conv_to_unicode(locale.nl_langinfo(locale.DAY_7),codeset), # Saturday
)
short_days = (
"",
unicode(locale.nl_langinfo(locale.ABDAY_1),codeset), # Sunday
unicode(locale.nl_langinfo(locale.ABDAY_2),codeset), # Monday
unicode(locale.nl_langinfo(locale.ABDAY_3),codeset), # Tuesday
unicode(locale.nl_langinfo(locale.ABDAY_4),codeset), # Wednesday
unicode(locale.nl_langinfo(locale.ABDAY_5),codeset), # Thursday
unicode(locale.nl_langinfo(locale.ABDAY_6),codeset), # Friday
unicode(locale.nl_langinfo(locale.ABDAY_7),codeset), # Saturday
conv_to_unicode(locale.nl_langinfo(locale.ABDAY_1),codeset), # Sunday
conv_to_unicode(locale.nl_langinfo(locale.ABDAY_2),codeset), # Monday
conv_to_unicode(locale.nl_langinfo(locale.ABDAY_3),codeset), # Tuesday
conv_to_unicode(locale.nl_langinfo(locale.ABDAY_4),codeset), # Wednesday
conv_to_unicode(locale.nl_langinfo(locale.ABDAY_5),codeset), # Thursday
conv_to_unicode(locale.nl_langinfo(locale.ABDAY_6),codeset), # Friday
conv_to_unicode(locale.nl_langinfo(locale.ABDAY_7),codeset), # Saturday
)
tformat = locale.nl_langinfo(locale.D_FMT).replace('%y','%Y')
@ -139,62 +140,62 @@ except:
codeset = locale.getpreferredencoding()
month_to_int = {
unicode(time.strftime('%B',(0,1,1,1,1,1,1,1,1)),codeset).lower() : 1,
unicode(time.strftime('%b',(0,1,1,1,1,1,1,1,1)),codeset).lower() : 1,
unicode(time.strftime('%B',(0,2,1,1,1,1,1,1,1)),codeset).lower() : 2,
unicode(time.strftime('%b',(0,2,1,1,1,1,1,1,1)),codeset).lower() : 2,
unicode(time.strftime('%B',(0,3,1,1,1,1,1,1,1)),codeset).lower() : 3,
unicode(time.strftime('%b',(0,3,1,1,1,1,1,1,1)),codeset).lower() : 3,
unicode(time.strftime('%B',(0,4,1,1,1,1,1,1,1)),codeset).lower() : 4,
unicode(time.strftime('%b',(0,4,1,1,1,1,1,1,1)),codeset).lower() : 4,
unicode(time.strftime('%B',(0,5,1,1,1,1,1,1,1)),codeset).lower() : 5,
unicode(time.strftime('%b',(0,5,1,1,1,1,1,1,1)),codeset).lower() : 5,
unicode(time.strftime('%B',(0,6,1,1,1,1,1,1,1)),codeset).lower() : 6,
unicode(time.strftime('%b',(0,6,1,1,1,1,1,1,1)),codeset).lower() : 6,
unicode(time.strftime('%B',(0,7,1,1,1,1,1,1,1)),codeset).lower() : 7,
unicode(time.strftime('%b',(0,7,1,1,1,1,1,1,1)),codeset).lower() : 7,
unicode(time.strftime('%B',(0,8,1,1,1,1,1,1,1)),codeset).lower() : 8,
unicode(time.strftime('%b',(0,8,1,1,1,1,1,1,1)),codeset).lower() : 8,
unicode(time.strftime('%B',(0,9,1,1,1,1,1,1,1)),codeset).lower() : 9,
unicode(time.strftime('%b',(0,9,1,1,1,1,1,1,1)),codeset).lower() : 9,
unicode(time.strftime('%B',(0,10,1,1,1,1,1,1,1)),codeset).lower() : 10,
unicode(time.strftime('%b',(0,10,1,1,1,1,1,1,1)),codeset).lower() : 10,
unicode(time.strftime('%B',(0,11,1,1,1,1,1,1,1)),codeset).lower() : 11,
unicode(time.strftime('%b',(0,11,1,1,1,1,1,1,1)),codeset).lower() : 11,
unicode(time.strftime('%B',(0,12,1,1,1,1,1,1,1)),codeset).lower() : 12,
unicode(time.strftime('%b',(0,12,1,1,1,1,1,1,1)),codeset).lower() : 12,
conv_to_unicode(time.strftime('%B',(0,1,1,1,1,1,1,1,1)),codeset).lower() : 1,
conv_to_unicode(time.strftime('%b',(0,1,1,1,1,1,1,1,1)),codeset).lower() : 1,
conv_to_unicode(time.strftime('%B',(0,2,1,1,1,1,1,1,1)),codeset).lower() : 2,
conv_to_unicode(time.strftime('%b',(0,2,1,1,1,1,1,1,1)),codeset).lower() : 2,
conv_to_unicode(time.strftime('%B',(0,3,1,1,1,1,1,1,1)),codeset).lower() : 3,
conv_to_unicode(time.strftime('%b',(0,3,1,1,1,1,1,1,1)),codeset).lower() : 3,
conv_to_unicode(time.strftime('%B',(0,4,1,1,1,1,1,1,1)),codeset).lower() : 4,
conv_to_unicode(time.strftime('%b',(0,4,1,1,1,1,1,1,1)),codeset).lower() : 4,
conv_to_unicode(time.strftime('%B',(0,5,1,1,1,1,1,1,1)),codeset).lower() : 5,
conv_to_unicode(time.strftime('%b',(0,5,1,1,1,1,1,1,1)),codeset).lower() : 5,
conv_to_unicode(time.strftime('%B',(0,6,1,1,1,1,1,1,1)),codeset).lower() : 6,
conv_to_unicode(time.strftime('%b',(0,6,1,1,1,1,1,1,1)),codeset).lower() : 6,
conv_to_unicode(time.strftime('%B',(0,7,1,1,1,1,1,1,1)),codeset).lower() : 7,
conv_to_unicode(time.strftime('%b',(0,7,1,1,1,1,1,1,1)),codeset).lower() : 7,
conv_to_unicode(time.strftime('%B',(0,8,1,1,1,1,1,1,1)),codeset).lower() : 8,
conv_to_unicode(time.strftime('%b',(0,8,1,1,1,1,1,1,1)),codeset).lower() : 8,
conv_to_unicode(time.strftime('%B',(0,9,1,1,1,1,1,1,1)),codeset).lower() : 9,
conv_to_unicode(time.strftime('%b',(0,9,1,1,1,1,1,1,1)),codeset).lower() : 9,
conv_to_unicode(time.strftime('%B',(0,10,1,1,1,1,1,1,1)),codeset).lower() : 10,
conv_to_unicode(time.strftime('%b',(0,10,1,1,1,1,1,1,1)),codeset).lower() : 10,
conv_to_unicode(time.strftime('%B',(0,11,1,1,1,1,1,1,1)),codeset).lower() : 11,
conv_to_unicode(time.strftime('%b',(0,11,1,1,1,1,1,1,1)),codeset).lower() : 11,
conv_to_unicode(time.strftime('%B',(0,12,1,1,1,1,1,1,1)),codeset).lower() : 12,
conv_to_unicode(time.strftime('%b',(0,12,1,1,1,1,1,1,1)),codeset).lower() : 12,
}
long_months = (
"",
unicode(time.strftime('%B',(0,1,1,1,1,1,1,1,1)),codeset),
unicode(time.strftime('%B',(0,2,1,1,1,1,1,1,1)),codeset),
unicode(time.strftime('%B',(0,3,1,1,1,1,1,1,1)),codeset),
unicode(time.strftime('%B',(0,4,1,1,1,1,1,1,1)),codeset),
unicode(time.strftime('%B',(0,5,1,1,1,1,1,1,1)),codeset),
unicode(time.strftime('%B',(0,6,1,1,1,1,1,1,1)),codeset),
unicode(time.strftime('%B',(0,7,1,1,1,1,1,1,1)),codeset),
unicode(time.strftime('%B',(0,8,1,1,1,1,1,1,1)),codeset),
unicode(time.strftime('%B',(0,9,1,1,1,1,1,1,1)),codeset),
unicode(time.strftime('%B',(0,10,1,1,1,1,1,1,1)),codeset),
unicode(time.strftime('%B',(0,11,1,1,1,1,1,1,1)),codeset),
unicode(time.strftime('%B',(0,12,1,1,1,1,1,1,1)),codeset),
conv_to_unicode(time.strftime('%B',(0,1,1,1,1,1,1,1,1)),codeset),
conv_to_unicode(time.strftime('%B',(0,2,1,1,1,1,1,1,1)),codeset),
conv_to_unicode(time.strftime('%B',(0,3,1,1,1,1,1,1,1)),codeset),
conv_to_unicode(time.strftime('%B',(0,4,1,1,1,1,1,1,1)),codeset),
conv_to_unicode(time.strftime('%B',(0,5,1,1,1,1,1,1,1)),codeset),
conv_to_unicode(time.strftime('%B',(0,6,1,1,1,1,1,1,1)),codeset),
conv_to_unicode(time.strftime('%B',(0,7,1,1,1,1,1,1,1)),codeset),
conv_to_unicode(time.strftime('%B',(0,8,1,1,1,1,1,1,1)),codeset),
conv_to_unicode(time.strftime('%B',(0,9,1,1,1,1,1,1,1)),codeset),
conv_to_unicode(time.strftime('%B',(0,10,1,1,1,1,1,1,1)),codeset),
conv_to_unicode(time.strftime('%B',(0,11,1,1,1,1,1,1,1)),codeset),
conv_to_unicode(time.strftime('%B',(0,12,1,1,1,1,1,1,1)),codeset),
)
short_months = (
"",
unicode(time.strftime('%b',(0,1,1,1,1,1,1,1,1)),codeset),
unicode(time.strftime('%b',(0,2,1,1,1,1,1,1,1)),codeset),
unicode(time.strftime('%b',(0,3,1,1,1,1,1,1,1)),codeset),
unicode(time.strftime('%b',(0,4,1,1,1,1,1,1,1)),codeset),
unicode(time.strftime('%b',(0,5,1,1,1,1,1,1,1)),codeset),
unicode(time.strftime('%b',(0,6,1,1,1,1,1,1,1)),codeset),
unicode(time.strftime('%b',(0,7,1,1,1,1,1,1,1)),codeset),
unicode(time.strftime('%b',(0,8,1,1,1,1,1,1,1)),codeset),
unicode(time.strftime('%b',(0,9,1,1,1,1,1,1,1)),codeset),
unicode(time.strftime('%b',(0,10,1,1,1,1,1,1,1)),codeset),
unicode(time.strftime('%b',(0,11,1,1,1,1,1,1,1)),codeset),
unicode(time.strftime('%b',(0,12,1,1,1,1,1,1,1)),codeset),
conv_to_unicode(time.strftime('%b',(0,1,1,1,1,1,1,1,1)),codeset),
conv_to_unicode(time.strftime('%b',(0,2,1,1,1,1,1,1,1)),codeset),
conv_to_unicode(time.strftime('%b',(0,3,1,1,1,1,1,1,1)),codeset),
conv_to_unicode(time.strftime('%b',(0,4,1,1,1,1,1,1,1)),codeset),
conv_to_unicode(time.strftime('%b',(0,5,1,1,1,1,1,1,1)),codeset),
conv_to_unicode(time.strftime('%b',(0,6,1,1,1,1,1,1,1)),codeset),
conv_to_unicode(time.strftime('%b',(0,7,1,1,1,1,1,1,1)),codeset),
conv_to_unicode(time.strftime('%b',(0,8,1,1,1,1,1,1,1)),codeset),
conv_to_unicode(time.strftime('%b',(0,9,1,1,1,1,1,1,1)),codeset),
conv_to_unicode(time.strftime('%b',(0,10,1,1,1,1,1,1,1)),codeset),
conv_to_unicode(time.strftime('%b',(0,11,1,1,1,1,1,1,1)),codeset),
conv_to_unicode(time.strftime('%b',(0,12,1,1,1,1,1,1,1)),codeset),
)
# Gramps day number: Sunday => 1, Monday => 2, etc
@ -208,24 +209,24 @@ except:
# just a dummy.
long_days = (
"",
unicode(time.strftime('%A',(0,1,1,1,1,1,6,1,1)),codeset), # Sunday
unicode(time.strftime('%A',(0,1,1,1,1,1,0,1,1)),codeset), # Monday
unicode(time.strftime('%A',(0,1,1,1,1,1,1,1,1)),codeset), # Tuesday
unicode(time.strftime('%A',(0,1,1,1,1,1,2,1,1)),codeset), # Wednesday
unicode(time.strftime('%A',(0,1,1,1,1,1,3,1,1)),codeset), # Thursday
unicode(time.strftime('%A',(0,1,1,1,1,1,4,1,1)),codeset), # Friday
unicode(time.strftime('%A',(0,1,1,1,1,1,5,1,1)),codeset), # Saturday
conv_to_unicode(time.strftime('%A',(0,1,1,1,1,1,6,1,1)),codeset), # Sunday
conv_to_unicode(time.strftime('%A',(0,1,1,1,1,1,0,1,1)),codeset), # Monday
conv_to_unicode(time.strftime('%A',(0,1,1,1,1,1,1,1,1)),codeset), # Tuesday
conv_to_unicode(time.strftime('%A',(0,1,1,1,1,1,2,1,1)),codeset), # Wednesday
conv_to_unicode(time.strftime('%A',(0,1,1,1,1,1,3,1,1)),codeset), # Thursday
conv_to_unicode(time.strftime('%A',(0,1,1,1,1,1,4,1,1)),codeset), # Friday
conv_to_unicode(time.strftime('%A',(0,1,1,1,1,1,5,1,1)),codeset), # Saturday
)
short_days = (
"",
unicode(time.strftime('%a',(0,1,1,1,1,1,6,1,1)),codeset), # Sunday
unicode(time.strftime('%a',(0,1,1,1,1,1,0,1,1)),codeset), # Monday
unicode(time.strftime('%a',(0,1,1,1,1,1,1,1,1)),codeset), # Tuesday
unicode(time.strftime('%a',(0,1,1,1,1,1,2,1,1)),codeset), # Wednesday
unicode(time.strftime('%a',(0,1,1,1,1,1,3,1,1)),codeset), # Thursday
unicode(time.strftime('%a',(0,1,1,1,1,1,4,1,1)),codeset), # Friday
unicode(time.strftime('%a',(0,1,1,1,1,1,5,1,1)),codeset), # Saturday
conv_to_unicode(time.strftime('%a',(0,1,1,1,1,1,6,1,1)),codeset), # Sunday
conv_to_unicode(time.strftime('%a',(0,1,1,1,1,1,0,1,1)),codeset), # Monday
conv_to_unicode(time.strftime('%a',(0,1,1,1,1,1,1,1,1)),codeset), # Tuesday
conv_to_unicode(time.strftime('%a',(0,1,1,1,1,1,2,1,1)),codeset), # Wednesday
conv_to_unicode(time.strftime('%a',(0,1,1,1,1,1,3,1,1)),codeset), # Thursday
conv_to_unicode(time.strftime('%a',(0,1,1,1,1,1,4,1,1)),codeset), # Friday
conv_to_unicode(time.strftime('%a',(0,1,1,1,1,1,5,1,1)),codeset), # Saturday
)
# depending on the locale, the value returned for 20th Feb 2009 could be
@ -251,5 +252,5 @@ except:
try:
tformat = time2fmt_map[timestr]
except KeyError, e:
except KeyError as e:
tformat = '%d/%m/%Y' #default value

View File

@ -72,13 +72,13 @@
More details can be found in the manual's U{Using database API<http://www.gramps-project.org/wiki/index.php?title=Using_database_API>}.
"""
from base import *
from dbconst import *
from cursor import *
from read import *
from bsddbtxn import *
from txn import *
from undoredo import *
from exceptions import *
from write import *
from backup import backup, restore
from .base import *
from .dbconst import *
from .cursor import *
from .read import *
from .bsddbtxn import *
from .txn import *
from .undoredo import *
from .exceptions import *
from .write import *
from .backup import backup, restore

View File

@ -55,15 +55,19 @@ db.
#
#-------------------------------------------------------------------------
import os
import sys
if sys.version_info[0] < 3:
import cPickle as pickle
else:
import pickle
#------------------------------------------------------------------------
#
# Gramps libs
#
#------------------------------------------------------------------------
from exceptions import DbException
from write import FAMILY_TBL, PLACES_TBL, SOURCES_TBL, MEDIA_TBL, \
from .exceptions import DbException
from .write import FAMILY_TBL, PLACES_TBL, SOURCES_TBL, MEDIA_TBL, \
EVENTS_TBL, PERSON_TBL, REPO_TBL, NOTE_TBL, TAG_TBL, META, CITATIONS_TBL
#------------------------------------------------------------------------
@ -87,7 +91,7 @@ def backup(database):
"""
try:
__do_export(database)
except (OSError, IOError), msg:
except (OSError, IOError) as msg:
raise DbException(str(msg))
def __mk_backup_name(database, base):
@ -129,7 +133,7 @@ def __do_export(database):
data = cursor.first()
while data:
pickle.dump(data, backup_table, 2)
data = cursor.next()
data = next(cursor)
cursor.close()
backup_table.close()
except (IOError,OSError):
@ -155,7 +159,7 @@ def restore(database):
"""
try:
__do_restore(database)
except (OSError, IOError), msg:
except (OSError, IOError) as msg:
raise DbException(str(msg))
def __do_restore(database):

View File

@ -41,8 +41,8 @@ from ..ggettext import gettext as _
#-------------------------------------------------------------------------
from ..lib.childreftype import ChildRefType
from ..lib.childref import ChildRef
from txn import DbTxn
from exceptions import DbTransactionCancel
from .txn import DbTxn
from .exceptions import DbTransactionCancel
class DbReadBase(object):
"""

View File

@ -29,7 +29,7 @@ BSDDBTxn class: Wrapper for BSDDB transaction-oriented methods
# BSDDBTxn
#
#-------------------------------------------------------------------------
from __future__ import with_statement
from __future__ import print_function, with_statement
class BSDDBTxn(object):
"""
@ -187,25 +187,26 @@ class BSDDBTxn(object):
# test code
if __name__ == "__main__":
print "1"
print("1")
from ..config import config
if config.get('preferences.use-bsddb3'):
import sys
if config.get('preferences.use-bsddb3') or sys.version_info[0] >= 3:
from bsddb3 import db, dbshelve
else:
from bsddb import db, dbshelve
print "2"
print("2")
x = db.DBEnv()
print "3"
print("3")
x.open('/tmp', db.DB_CREATE | db.DB_PRIVATE |\
db.DB_INIT_MPOOL | db.DB_INIT_LOCK |\
db.DB_INIT_LOG | db.DB_INIT_TXN | db.DB_THREAD)
print "4"
print("4")
d = dbshelve.DBShelf(x)
print "5"
print("5")
#from tran import BSDDBTxn as T
print "6"
print("6")
T = BSDDBTxn
with T(x) as tx:
print "stat", tx.stat()
print "id", tx.id()
print("stat", tx.stat())
print("id", tx.id())
tx.checkpoint()

View File

@ -26,10 +26,14 @@
# Standard python modules
#
#-------------------------------------------------------------------------
import sys
if sys.version_info[0] < 3:
from cPickle import dumps, loads
else:
from pickle import dumps, loads
from ..config import config
if config.get('preferences.use-bsddb3'):
if config.get('preferences.use-bsddb3') or sys.version_info[0] >= 3:
from bsddb3 import db
else:
from bsddb import db

View File

@ -30,6 +30,7 @@ Declare constants used by database modules
# standard python modules
#
#-------------------------------------------------------------------------
import sys
#-------------------------------------------------------------------------
#
@ -60,14 +61,14 @@ DBLOGNAME = ".Db" # Name of logger
DBMODE_R = "r" # Read-only access
DBMODE_W = "w" # Full Read/Write access
DBPAGE = 16384 # Size of the pages used to hold items in the database
DBMODE = 0666 # Unix mode for database creation
DBMODE = 0o666 # Unix mode for database creation
DBCACHE = 0x4000000 # Size of the shared memory buffer pool
DBLOCKS = 100000 # Maximum number of locks supported
DBOBJECTS = 100000 # Maximum number of simultaneously locked objects
DBUNDO = 1000 # Maximum size of undo buffer
from ..config import config
if config.get('preferences.use-bsddb3'):
if config.get('preferences.use-bsddb3') or sys.version_info[0] >= 3:
from bsddb3.db import DB_CREATE, DB_AUTO_COMMIT, DB_DUP, DB_DUPSORT, DB_RDONLY
else:
from bsddb.db import DB_CREATE, DB_AUTO_COMMIT, DB_DUP, DB_DUPSORT, DB_RDONLY

View File

@ -26,7 +26,11 @@
# Gramps Modules
#
#------------------------------------------------------------------------
import cPickle
import sys
if sys.version_info[0] < 3:
import cPickle as pickle
else:
import pickle
import base64
import time
import re
@ -52,6 +56,7 @@ from ..lib.place import Place
from ..lib.repo import Repository
from ..lib.note import Note
from ..lib.tag import Tag
from ..constfunc import STRTYPE
class Cursor(object):
"""
@ -264,7 +269,7 @@ class DictionaryDb(DbWriteBase, DbReadBase):
@staticmethod
def _validated_id_prefix(val, default):
if isinstance(val, basestring) and val:
if isinstance(val, STRTYPE) and val:
try:
str_ = val % 1
except TypeError: # missing conversion specifier

View File

@ -25,21 +25,27 @@
"""
Read classes for the GRAMPS databases.
"""
from __future__ import with_statement
#-------------------------------------------------------------------------
#
# libraries
#
#-------------------------------------------------------------------------
import cPickle
from __future__ import print_function, with_statement
import sys
if sys.version_info[0] < 3:
import cPickle as pickle
else:
import pickle
import time
import random
import locale
import os
from sys import maxint
from sys import maxsize
from ..config import config
if config.get('preferences.use-bsddb3'):
if config.get('preferences.use-bsddb3') or sys.version_info[0] >= 3:
from bsddb3 import db
else:
from bsddb import db
@ -67,12 +73,13 @@ from ..lib.genderstats import GenderStats
from ..lib.researcher import Researcher
from ..lib.nameorigintype import NameOriginType
from dbconst import *
from .dbconst import *
from ..utils.callback import Callback
from ..utils.cast import conv_dbstr_to_unicode
from . import (BsddbBaseCursor, DbReadBase)
from ..utils.id import create_id
from ..errors import DbError
from ..constfunc import UNITYPE, STRTYPE, cuni
LOG = logging.getLogger(DBLOGNAME)
LOG = logging.getLogger(".citation")
@ -81,7 +88,7 @@ LOG = logging.getLogger(".citation")
# constants
#
#-------------------------------------------------------------------------
from dbconst import *
from .dbconst import *
_SIGBASE = ('person', 'family', 'source', 'citation',
'event', 'media', 'place', 'repository',
@ -113,10 +120,10 @@ def __index_surname(surn_list):
pa/matronymic not as they change for every generation!
"""
if surn_list:
surn = u" ".join([x[0] for x in surn_list if not (x[3][0] in [
surn = " ".join([x[0] for x in surn_list if not (x[3][0] in [
NameOriginType.PATRONYMIC, NameOriginType.MATRONYMIC]) ])
else:
surn = u""
surn = ""
return surn.encode('utf-8')
@ -426,7 +433,7 @@ class DbBsddbRead(DbReadBase, Callback):
def get_table_names(self):
"""Return a list of valid table names."""
return self._tables.keys()
return list(self._tables.keys())
def get_table_metadata(self, table_name):
"""Return the metadata for a valid table name."""
@ -437,7 +444,7 @@ class DbBsddbRead(DbReadBase, Callback):
def get_cursor(self, table, *args, **kwargs):
try:
return DbReadCursor(table, self.txn)
except DBERRS, msg:
except DBERRS as msg:
self.__log_error()
raise DbError(msg)
@ -741,12 +748,12 @@ class DbBsddbRead(DbReadBase, Callback):
if self.readonly:
tuple_data = prim_tbl.get(data, txn=self.txn)
else:
tuple_data = cPickle.loads(data)
tuple_data = pickle.loads(data)
obj.unserialize(tuple_data)
return obj
else:
return None
except DBERRS, msg:
except DBERRS as msg:
self.__log_error()
raise DbError(msg)
@ -845,7 +852,8 @@ class DbBsddbRead(DbReadBase, Callback):
Return the default grouping name for a surname.
Return type is a unicode object
"""
if isinstance(surname, unicode):
if isinstance(surname, UNITYPE):
ssurname = surname.encode('utf-8')
return conv_dbstr_to_unicode(self.name_group.get(ssurname, ssurname))
else:
@ -855,7 +863,7 @@ class DbBsddbRead(DbReadBase, Callback):
"""
Return the defined names that have been assigned to a default grouping.
"""
return map(conv_dbstr_to_unicode, self.name_group.keys())
return list(map(conv_dbstr_to_unicode, list(self.name_group.keys())))
def has_name_group_key(self, name):
"""
@ -863,10 +871,10 @@ class DbBsddbRead(DbReadBase, Callback):
"""
# The use of has_key seems allright because there is no write lock
# on the name_group table when this is called.
if isinstance(name, unicode):
return self.name_group.has_key(name.encode('utf-8'))
if isinstance(name, UNITYPE):
return name.encode('utf-8') in self.name_group
else:
return self.name_group.has_key(name)
return name in self.name_group
def get_number_of_records(self, table):
if not self.db_is_open:
@ -1124,7 +1132,7 @@ class DbBsddbRead(DbReadBase, Callback):
}
table = key2table[obj_key]
return table.keys()
return list(table.keys())
def has_gramps_id(self, obj_key, gramps_id):
key2table = {
@ -1153,7 +1161,7 @@ class DbBsddbRead(DbReadBase, Callback):
@staticmethod
def _validated_id_prefix(val, default):
if isinstance(val, basestring) and val:
if isinstance(val, STRTYPE) and val:
try:
str_ = val % 1
except TypeError: # missing conversion specifier
@ -1499,7 +1507,7 @@ class DbBsddbRead(DbReadBase, Callback):
"""
try:
return table.get(str(handle), txn=self.txn)
except DBERRS, msg:
except DBERRS as msg:
self.__log_error()
raise DbError(msg)
@ -1539,7 +1547,7 @@ class DbBsddbRead(DbReadBase, Callback):
"""
try:
return table.get(str(handle), txn=self.txn) is not None
except DBERRS, msg:
except DBERRS as msg:
self.__log_error()
raise DbError(msg)
@ -1615,21 +1623,21 @@ class DbBsddbRead(DbReadBase, Callback):
return locale.strxfrm(self.place_map.get(str(place))[2])
def __sortbysource(self, first, second):
source1 = unicode(self.source_map[str(first)][2])
source2 = unicode(self.source_map[str(second)][2])
source1 = cuni(self.source_map[str(first)][2])
source2 = cuni(self.source_map[str(second)][2])
return locale.strcoll(source1, source2)
def __sortbysource_key(self, key):
source = unicode(self.source_map[str(key)][2])
source = cuni(self.source_map[str(key)][2])
return locale.strxfrm(source)
def __sortbycitation(self, first, second):
citation1 = unicode(self.citation_map[str(first)][3])
citation2 = unicode(self.citation_map[str(second)][3])
citation1 = cuni(self.citation_map[str(first)][3])
citation2 = cuni(self.citation_map[str(second)][3])
return locale.strcoll(citation1, citation2)
def __sortbycitation_key(self, key):
citation = unicode(self.citation_map[str(key)][3])
citation = cuni(self.citation_map[str(key)][3])
return locale.strxfrm(citation)
def __sortbymedia(self, first, second):
@ -1731,13 +1739,13 @@ class DbBsddbRead(DbReadBase, Callback):
# Find which tables to iterate over
if (include_classes is None):
the_tables = primary_tables.keys()
the_tables = list(primary_tables.keys())
else:
the_tables = include_classes
# Now we use the functions and classes defined above to loop through
# each of the existing primary object tables
for primary_table_name, funcs in the_tables.iteritems():
for primary_table_name, funcs in the_tables.items():
with funcs['cursor_func']() as cursor:
# Grab the real object class here so that the lookup does
@ -1782,7 +1790,7 @@ class DbBsddbRead(DbReadBase, Callback):
name_file = open(filepath, "r")
name = name_file.read()
name_file.close()
except (OSError, IOError), msg:
except (OSError, IOError) as msg:
self.__log_error()
name = None
return name

View File

@ -21,6 +21,8 @@
# gen/db/test/db_test.py
# $Id$
from __future__ import print_function
from ..db import (DbReadBase, DbWriteBase,
DbBsddbRead, DbBsddb)
from ...proxy.proxybase import ProxyDbBase
@ -238,24 +240,24 @@ class DbTest(object):
self.db = db
def _verify_readonly(self):
print "Verifying readonly", self.db.__class__.__name__
print("Verifying readonly", self.db.__class__.__name__)
for method in self.READ_METHODS:
assert hasattr(self.db, method), \
("readonly should have a '%s' method" % method)
for method in self.WRITE_METHODS:
assert not hasattr(self.db, method), \
("readonly should NOT have a '%s' method" % method)
print "passed!"
print("passed!")
def _verify_readwrite(self):
print "Verifying readwrite", self.db.__class__.__name__
print("Verifying readwrite", self.db.__class__.__name__)
for method in self.READ_METHODS:
assert hasattr(self.db, method), \
("readwrite should have a '%s' method" % method)
for method in self.WRITE_METHODS:
assert hasattr(self.db, method), \
("readwrite should have a '%s' method" % method)
print "passed!"
print("passed!")
db1 = DbTest(DbReadBase())
db1._verify_readonly()

View File

@ -30,8 +30,13 @@ database.
# Standard python modules
#
#-------------------------------------------------------------------------
from __future__ import with_statement
from __future__ import print_function, with_statement
import sys
if sys.version_info[0] < 3:
import cPickle as pickle
else:
import pickle
import logging
from collections import defaultdict
@ -41,7 +46,7 @@ from collections import defaultdict
# Gramps modules
#
#-------------------------------------------------------------------------
from dbconst import (DBLOGNAME, TXNADD, TXNUPD, TXNDEL)
from .dbconst import (DBLOGNAME, TXNADD, TXNUPD, TXNDEL)
_LOG = logging.getLogger(DBLOGNAME)
@ -115,7 +120,7 @@ class DbTxn(defaultdict):
self.commitdb = grampsdb.get_undodb()
self.db = grampsdb
self.batch = batch
for key, value in kwargs.iteritems():
for key, value in kwargs.items():
setattr(self, key, value)
self.first = None
self.last = None
@ -164,9 +169,9 @@ class DbTxn(defaultdict):
if self.first is None or self.last is None:
return []
if not reverse:
return xrange(self.first, self.last+1)
return range(self.first, self.last+1)
else:
return xrange(self.last, self.first-1, -1)
return range(self.last, self.first-1, -1)
def get_record(self, recno):
"""
@ -238,15 +243,15 @@ def testtxn():
grampsdb.person_map.delete('1')
trans.add(0, TXNDEL, '1', None, None)
print trans
print trans.get_description()
print trans.set_description("new text")
print trans.get_description()
print(trans)
print(trans.get_description())
print(trans.set_description("new text"))
print(trans.get_description())
for i in trans.get_recnos():
print trans.get_record(i)
print list(trans.get_recnos())
print list(trans.get_recnos(reverse=True))
print grampsdb.person_map
print(trans.get_record(i))
print(list(trans.get_recnos()))
print(list(trans.get_recnos(reverse=True)))
print(grampsdb.person_map)
if __name__ == '__main__':
testtxn()

View File

@ -31,13 +31,18 @@ undos and redos.
# Standard python modules
#
#-------------------------------------------------------------------------
from __future__ import with_statement
from __future__ import print_function, with_statement
import time, os
import sys
if sys.version_info[0] < 3:
import cPickle as pickle
else:
import pickle
from collections import deque
from ..config import config
if config.get('preferences.use-bsddb3'):
if config.get('preferences.use-bsddb3') or sys.version_info[0] >= 3:
from bsddb3 import db
else:
from bsddb import db
@ -48,7 +53,7 @@ from ..ggettext import gettext as _
# Gramps modules
#
#-------------------------------------------------------------------------
from dbconst import *
from .dbconst import *
from . import BSDDBTxn
from ..errors import DbError
@ -207,7 +212,7 @@ class DbUndo(object):
self.db.txn = None
return status
except DBERRS, msg:
except DBERRS as msg:
self.db._log_error()
raise DbError(msg)
@ -300,7 +305,7 @@ class DbUndo(object):
else:
db_map.put(handle, data, txn=self.txn)
except DBERRS, msg:
except DBERRS as msg:
self.db._log_error()
raise DbError(msg)
@ -321,7 +326,7 @@ class DbUndo(object):
db_map.put(handle, data, txn=self.txn)
emit(signal, ([handle],))
except DBERRS, msg:
except DBERRS as msg:
self.db._log_error()
raise DbError(msg)
@ -454,7 +459,7 @@ class DbUndoBSDDB(DbUndo):
data = cursor.first()
while data:
yield data
data = cursor.next()
data = next(cursor)
def testundo():
class T:
@ -477,32 +482,32 @@ def testundo():
self.repository_map = {}
self.reference_map = {}
print "list tests"
print("list tests")
undo = DbUndoList(D())
print undo.append('foo')
print undo.append('bar')
print undo[0]
print(undo.append('foo'))
print(undo.append('bar'))
print(undo[0])
undo[0] = 'foobar'
print undo[0]
print "len", len(undo)
print "iter"
print(undo[0])
print("len", len(undo))
print("iter")
for data in undo:
print data
print
print "bsddb tests"
print(data)
print()
print("bsddb tests")
undo = DbUndoBSDDB(D(), '/tmp/testundo')
undo.open()
print undo.append('foo')
print undo.append('fo2')
print undo.append('fo3')
print undo[1]
print(undo.append('foo'))
print(undo.append('fo2'))
print(undo.append('fo3'))
print(undo[1])
undo[1] = 'bar'
print undo[1]
print(undo[1])
for data in undo:
print data
print "len", len(undo)
print(data)
print("len", len(undo))
print "test commit"
print("test commit")
undo.commit(T(), msg="test commit")
undo.close()

View File

@ -21,8 +21,9 @@
# $Id$
from __future__ import with_statement
from __future__ import with_statement, unicode_literals
import sys
from ..lib.markertype import MarkerType
from ..lib.tag import Tag
import time
@ -30,19 +31,20 @@ import logging
LOG = logging.getLogger(".citation")
from ..ggettext import gettext as _
from ..constfunc import cuni
"""
methods to upgrade a database from version 13 to current version
"""
from ..config import config
if config.get('preferences.use-bsddb3'):
if config.get('preferences.use-bsddb3') or sys.version_info[0] >= 3:
from bsddb3 import db
else:
from bsddb import db
from . import BSDDBTxn
from ..lib.nameorigintype import NameOriginType
from write import _mkname, SURNAMES
from dbconst import (PERSON_KEY, FAMILY_KEY, EVENT_KEY,
from .write import _mkname, SURNAMES
from .dbconst import (PERSON_KEY, FAMILY_KEY, EVENT_KEY,
MEDIA_KEY, PLACE_KEY, REPOSITORY_KEY)
from gramps.gui.dialog import (InfoDialog)
@ -146,10 +148,10 @@ def gramps_upgrade_16(self):
self.update()
LOG.debug("%d persons upgraded with %d citations in %d seconds. " %
(len(self.person_map.keys()),
(len(list(self.person_map.keys())),
self.cmap_index - start_num_citations,
time.time() - start_time))
data_upgradeobject[key2data[PERSON_KEY]] = (len(self.person_map.keys()),
data_upgradeobject[key2data[PERSON_KEY]] = (len(list(self.person_map.keys())),
self.cmap_index - start_num_citations,
time.time() - start_time)
@ -182,7 +184,7 @@ def gramps_upgrade_16(self):
LOG.debug("Media upgrade %d citations upgraded in %d seconds" %
(self.cmap_index - start_num_citations,
int(time.time() - start_time)))
data_upgradeobject[key2data[MEDIA_KEY]] = (len(self.media_map.keys()),
data_upgradeobject[key2data[MEDIA_KEY]] = (len(list(self.media_map.keys())),
self.cmap_index - start_num_citations,
time.time() - start_time)
@ -193,7 +195,7 @@ def gramps_upgrade_16(self):
start_time = time.time()
for place_handle in self.place_map.keys():
place = self.place_map[place_handle]
(handle, gramps_id, title, long, lat,
(handle, gramps_id, title, int, lat,
main_loc, alt_loc, urls, media_list, source_list, note_list,
change, private) = place
if source_list:
@ -206,7 +208,7 @@ def gramps_upgrade_16(self):
self, media_list)
if source_list or media_list:
new_place = (handle, gramps_id, title,
long, lat, main_loc, alt_loc, urls,
int, lat, main_loc, alt_loc, urls,
media_list, new_citation_list, note_list,
change, private)
with BSDDBTxn(self.env, self.place_map) as txn:
@ -214,10 +216,10 @@ def gramps_upgrade_16(self):
self.update()
LOG.debug("%d places upgraded with %d citations in %d seconds. " %
(len(self.place_map.keys()),
(len(list(self.place_map.keys())),
self.cmap_index - start_num_citations,
time.time() - start_time))
data_upgradeobject[key2data[PLACE_KEY]] = (len(self.place_map.keys()),
data_upgradeobject[key2data[PLACE_KEY]] = (len(list(self.place_map.keys())),
self.cmap_index - start_num_citations,
time.time() - start_time)
@ -262,10 +264,10 @@ def gramps_upgrade_16(self):
self.update()
LOG.debug("%d familys upgraded with %d citations in %d seconds. " %
(len(self.family_map.keys()),
(len(list(self.family_map.keys())),
self.cmap_index - start_num_citations,
time.time() - start_time))
data_upgradeobject[key2data[FAMILY_KEY]] = (len(self.family_map.keys()),
data_upgradeobject[key2data[FAMILY_KEY]] = (len(list(self.family_map.keys())),
self.cmap_index - start_num_citations,
time.time() - start_time)
# ---------------------------------
@ -307,10 +309,10 @@ def gramps_upgrade_16(self):
LOG.debug("%d events upgraded with %d citations in %d seconds. "
"Backlinks took %d seconds" %
(len(self.event_map.keys()),
(len(list(self.event_map.keys())),
self.cmap_index - start_num_citations,
int(upgrade_time), int(backlink_time)))
data_upgradeobject[key2data[EVENT_KEY]] = (len(self.event_map.keys()),
data_upgradeobject[key2data[EVENT_KEY]] = (len(list(self.event_map.keys())),
self.cmap_index - start_num_citations,
time.time() - start_time)
@ -334,10 +336,10 @@ def gramps_upgrade_16(self):
self.update()
LOG.debug("%d repositorys upgraded with %d citations in %d seconds. " %
(len(self.repository_map.keys()),
(len(list(self.repository_map.keys())),
self.cmap_index - start_num_citations,
time.time() - start_time))
data_upgradeobject[key2data[REPOSITORY_KEY]] = (len(self.repository_map.keys()),
data_upgradeobject[key2data[REPOSITORY_KEY]] = (len(list(self.repository_map.keys())),
self.cmap_index - start_num_citations,
time.time() - start_time)
# ---------------------------------
@ -592,9 +594,9 @@ def gramps_upgrade_15(self):
tags = [tag_handle]
else:
tags = []
address_list = map(convert_address, address_list)
address_list = list(map(convert_address, address_list))
new_primary_name = convert_name_15(primary_name)
new_alternate_names = map(convert_name_15, alternate_names)
new_alternate_names = list(map(convert_name_15, alternate_names))
new_person = (junk_handle, # 0
gramps_id, # 1
gender, # 2
@ -698,7 +700,7 @@ def gramps_upgrade_15(self):
new_place = list(place)
if new_place[5] is not None:
new_place[5] = convert_location(new_place[5])
new_place[6] = map(convert_location, new_place[6])
new_place[6] = list(map(convert_location, new_place[6]))
new_place = new_place[:12] + new_place[13:]
new_place = tuple(new_place)
with BSDDBTxn(self.env, self.place_map) as txn:
@ -726,7 +728,7 @@ def gramps_upgrade_15(self):
repository = self.repository_map[handle]
new_repository = list(repository)
new_repository = new_repository[:8] + new_repository[9:]
new_repository[5] = map(convert_address, new_repository[5])
new_repository[5] = list(map(convert_address, new_repository[5]))
new_repository = tuple(new_repository)
with BSDDBTxn(self.env, self.repository_map) as txn:
txn.put(str(handle), new_repository)
@ -740,7 +742,7 @@ def convert_marker(self, marker_field):
"""Convert a marker into a tag."""
marker = MarkerType()
marker.unserialize(marker_field)
tag_name = unicode(marker)
tag_name = cuni(marker)
if tag_name != '':
if tag_name not in self.tags:
@ -759,7 +761,7 @@ def convert_marker(self, marker_field):
def convert_locbase(loc):
"""Convert location base to include an empty locality field."""
return tuple([loc[0], u''] + list(loc[1:]))
return tuple([loc[0], ''] + list(loc[1:]))
def convert_location(loc):
"""Convert a location into the new format."""
@ -775,26 +777,26 @@ def convert_name_15(name):
name_type, prefix, patronymic,
group_as, sort_as, display_as, call) = name
connector = u""
origintype = (NameOriginType.NONE, u"")
patorigintype = (NameOriginType.PATRONYMIC, u"")
connector = ""
origintype = (NameOriginType.NONE, "")
patorigintype = (NameOriginType.PATRONYMIC, "")
if patronymic.strip() == u"":
if patronymic.strip() == "":
#no patronymic, create a single surname
surname_list = [(surname, prefix, True, origintype, connector)]
else:
#a patronymic, if no surname or equal as patronymic, a single surname
if (surname.strip() == u"") or (surname == patronymic and prefix == u""):
if (surname.strip() == "") or (surname == patronymic and prefix == ""):
surname_list = [(patronymic, prefix, True, patorigintype, connector)]
else:
#two surnames, first patronymic, then surname which is primary
surname_list = [(patronymic, u"", False, patorigintype, u""),
surname_list = [(patronymic, "", False, patorigintype, ""),
(surname, prefix, True, origintype, connector)]
#return new value, add two empty strings for nick and family nick
return (privacy, source_list, note_list, date,
first_name, surname_list, suffix, title, name_type,
group_as, sort_as, display_as, call, u"", u"")
group_as, sort_as, display_as, call, "", "")
def gramps_upgrade_14(self):
"""Upgrade database from version 13 to 14."""
@ -1002,12 +1004,12 @@ def gramps_upgrade_14(self):
# ---------------------------------
for place_handle in self.place_map.keys():
place = self.place_map[place_handle]
(handle, gramps_id, title, long, lat,
(handle, gramps_id, title, int, lat,
main_loc, alt_loc, urls, media_list, source_list, note_list,
change, marker, private) = place
new_media_list = new_media_list_14(media_list)
new_source_list = new_source_list_14(source_list)
new_place = (handle, gramps_id, title, long, lat,
new_place = (handle, gramps_id, title, int, lat,
main_loc, alt_loc, urls, new_media_list,
new_source_list, note_list, change, marker, private)

View File

@ -32,19 +32,23 @@ This is used since GRAMPS version 3.0
# Standard python modules
#
#-------------------------------------------------------------------------
from __future__ import with_statement
from __future__ import print_function, with_statement
import sys
if sys.version_info[0] < 3:
import cPickle as pickle
else:
import pickle
import os
import time
import locale
import bisect
from functools import wraps
import logging
from sys import maxint
from sys import maxsize
from ..ggettext import gettext as _
from ..config import config
if config.get('preferences.use-bsddb3'):
if config.get('preferences.use-bsddb3') or sys.version_info[0] >= 3:
from bsddb3 import dbshelve, db
else:
from bsddb import dbshelve, db
@ -71,12 +75,12 @@ from . import (DbBsddbRead, DbWriteBase, BSDDBTxn,
DbTxn, BsddbBaseCursor, BsddbDowngradeError, DbVersionError,
DbEnvironmentError, DbUpgradeRequiredError, find_surname,
find_surname_name, DbUndoBSDDB as DbUndo)
from dbconst import *
from .dbconst import *
from ..utils.callback import Callback
from ..utils.cast import (conv_unicode_tosrtkey, conv_dbstr_to_unicode)
from ..updatecallback import UpdateCallback
from ..errors import DbError
from ..constfunc import win
from ..constfunc import win, conv_to_unicode
_LOG = logging.getLogger(DBLOGNAME)
LOG = logging.getLogger(".citation")
@ -231,7 +235,10 @@ class DbBsddb(DbBsddbRead, DbWriteBase, UpdateCallback):
__signals__['home-person-changed'] = None
# 4. Signal for change in person group name, parameters are
if sys.version_info[0] < 3:
__signals__['person-groupname-rebuild'] = (unicode, unicode)
else:
__signals__['person-groupname-rebuild'] = (str, str)
def __init__(self):
"""Create a new GrampsDB."""
@ -255,7 +262,7 @@ class DbBsddb(DbBsddbRead, DbWriteBase, UpdateCallback):
def try_(self, *args, **kwargs):
try:
return func(self, *args, **kwargs)
except DBERRS, msg:
except DBERRS as msg:
self.__log_error()
raise DbError(msg)
return try_
@ -475,7 +482,7 @@ class DbBsddb(DbBsddbRead, DbWriteBase, UpdateCallback):
try:
self.env.open(env_name, env_flags)
except Exception, msg:
except Exception as msg:
_LOG.warning("Error opening db environment: " + str(msg))
try:
self.__close_early()
@ -1434,7 +1441,7 @@ class DbBsddb(DbBsddbRead, DbWriteBase, UpdateCallback):
if group is not None:
txn.put(sname, group)
if group == None:
grouppar = u''
grouppar = ''
else:
grouppar = group
self.emit('person-groupname-rebuild', (name, grouppar))
@ -1460,7 +1467,7 @@ class DbBsddb(DbBsddbRead, DbWriteBase, UpdateCallback):
"""
if batch_transaction:
return
name = unicode(find_surname_name(person.handle,
name = conv_to_unicode(find_surname_name(person.handle,
person.get_primary_name().serialize()), 'utf-8')
i = bisect.bisect(self.surname_list, name)
if 0 < i <= len(self.surname_list):
@ -1480,11 +1487,18 @@ class DbBsddb(DbBsddbRead, DbWriteBase, UpdateCallback):
"""
name = find_surname_name(person.handle,
person.get_primary_name().serialize())
if sys.version_info[0] < 3:
if isinstance(name, unicode):
uname = name
name = str(name)
else:
uname = unicode(name, 'utf-8')
else:
if isinstance(name, str):
uname = name
name = str(name)
else:
uname = str(name)
try:
cursor = self.surnames.cursor(txn=self.txn)
cursor_position = cursor.set(name)
@ -1493,7 +1507,7 @@ class DbBsddb(DbBsddbRead, DbWriteBase, UpdateCallback):
i = bisect.bisect(self.surname_list, uname)
if 0 <= i-1 < len(self.surname_list):
del self.surname_list[i-1]
except db.DBError, err:
except db.DBError as err:
if str(err) == "(0, 'DB object has been closed')":
pass # A batch transaction closes the surnames db table.
else:
@ -1820,7 +1834,7 @@ class DbBsddb(DbBsddbRead, DbWriteBase, UpdateCallback):
self.env.log_flush()
if not transaction.batch:
emit = self.__emit
for obj_type, obj_name in KEY_TO_NAME_MAP.iteritems():
for obj_type, obj_name in KEY_TO_NAME_MAP.items():
emit(transaction, obj_type, TXNADD, obj_name, '-add')
emit(transaction, obj_type, TXNUPD, obj_name, '-update')
emit(transaction, obj_type, TXNDEL, obj_name, '-delete')
@ -1867,7 +1881,7 @@ class DbBsddb(DbBsddbRead, DbWriteBase, UpdateCallback):
# "while Gtk.events_pending(): Gtk.main_iteration() loop"
# (typically used in a progress bar), so emit rebuild signals
# to correct that.
object_types = set([x[0] for x in transaction.keys()])
object_types = set([x[0] for x in list(transaction.keys())])
for object_type in object_types:
if object_type == REFERENCE_KEY:
continue
@ -1928,7 +1942,7 @@ class DbBsddb(DbBsddbRead, DbWriteBase, UpdateCallback):
t = time.time()
import upgrade
from . import upgrade
if version < 14:
upgrade.gramps_upgrade_14(self)
if version < 15:
@ -2074,13 +2088,14 @@ if __name__ == "__main__":
db_name = f.read()
if db_name == 'Small Example':
break
print "loading", db_path
print("loading", db_path)
d.load(db_path, lambda x: x)
print d.get_default_person()
print(d.get_default_person())
out = ''
with d.get_person_cursor() as c:
for key, data in c:
person = Person(data)
print key, person.get_primary_name().get_name(),
out += key + person.get_primary_name().get_name()
print d.surnames.keys()
print(out, list(d.surnames.keys()))

View File

@ -25,10 +25,10 @@
Provide the database state class
"""
from db import DbBsddbRead
from proxy.proxybase import ProxyDbBase
from utils.callback import Callback
from config import config
from .db import DbBsddbRead
from .proxy.proxybase import ProxyDbBase
from .utils.callback import Callback
from .config import config
class DbState(Callback):
"""

View File

@ -61,6 +61,7 @@ import re
# GRAMPS modules
#
#-------------------------------------------------------------------------
from ..constfunc import cuni, conv_to_unicode
from ..lib.name import Name
from ..lib.nameorigintype import NameOriginType
@ -744,7 +745,7 @@ class NameDisplay(object):
s = func(first, [surn.serialize() for surn in surname_list],
suffix, title, call, nick, famnick)
except (ValueError, TypeError,):
raise NameDisplayError, "Incomplete format string"
raise NameDisplayError("Incomplete format string")
return s
@ -761,7 +762,7 @@ class NameDisplay(object):
return sur.get_surname()
def sort_string(self, name):
return u"%-25s%-30s%s" % (self.primary_surname(name),
return cuni("%-25s%-30s%s") % (self.primary_surname(name),
name.first_name, name.suffix)
def sorted(self, person):
@ -940,7 +941,7 @@ class NameDisplay(object):
format_str[0] == format_str[-1] == '"'):
pass
else:
d_keys = [(code, _tuple[2]) for code, _tuple in d.iteritems()]
d_keys = [(code, _tuple[2]) for code, _tuple in d.items()]
d_keys.sort(_make_cmp) # reverse on length and by ikeyword
for (code, ikeyword) in d_keys:
exp, keyword, ikeyword = d[code]
@ -956,17 +957,17 @@ class NameDisplay(object):
format_str[0] == format_str[-1] == '"'):
pass
else:
d_keys = [(code, _tuple[1]) for code, _tuple in d.iteritems()]
d_keys = [(code, _tuple[1]) for code, _tuple in d.items()]
d_keys.sort(_make_cmp) # reverse sort on length and by keyword
# if in double quotes, just use % codes
for (code, keyword) in d_keys:
exp, keyword, ikeyword = d[code]
keyword = unicode(keyword, "utf8")
keyword = conv_to_unicode(keyword, "utf8")
format_str = format_str.replace(keyword, "%"+ code)
format_str = format_str.replace(keyword.title(), "%"+ code)
format_str = format_str.replace(keyword.upper(), "%"+ code.upper())
# Get lower and upper versions of codes:
codes = d.keys() + [c.upper() for c in d]
codes = list(d.keys()) + [c.upper() for c in d]
# Next, list out the matching patterns:
# If it starts with "!" however, treat the punctuation verbatim:
if len(format_str) > 0 and format_str[0] == "!":

View File

@ -28,10 +28,10 @@ Package providing filtering framework for GRAMPS.
CustomFilters = None
from ..const import CUSTOM_FILTERS
from _filterlist import FilterList
from _genericfilter import GenericFilter, GenericFilterFactory
from _paramfilter import ParamFilter
from _searchfilter import SearchFilter, ExactSearchFilter
from ._filterlist import FilterList
from ._genericfilter import GenericFilter, GenericFilterFactory
from ._paramfilter import ParamFilter
from ._searchfilter import SearchFilter, ExactSearchFilter
#def reload_system_filters():
#global SystemFilters

View File

@ -25,17 +25,21 @@
# Standard Python modules
#
#-------------------------------------------------------------------------
from __future__ import print_function
from xml.sax import make_parser, SAXParseException
import os
import sys
import collections
#-------------------------------------------------------------------------
#
# GRAMPS modules
#
#-------------------------------------------------------------------------
from _filterparser import FilterParser
from ._filterparser import FilterParser
from ..plug import BasePluginManager
from ..constfunc import STRTYPE
PLUGMAN = BasePluginManager.get_instance()
#-------------------------------------------------------------------------
@ -77,7 +81,7 @@ class FilterList(object):
plugin_filters = []
try:
for plug in plugins:
if callable(plug):
if isinstance(plug, collections.Callable):
plug = plug(namespace)
if plug:
if isinstance(plug, (list, tuple)):
@ -92,7 +96,7 @@ class FilterList(object):
return filters
def add(self, namespace, filt):
assert(isinstance(namespace, basestring))
assert(isinstance(namespace, STRTYPE))
if namespace not in self.filter_namespaces:
self.filter_namespaces[namespace] = []
@ -109,7 +113,7 @@ class FilterList(object):
except (IOError, OSError):
pass
except SAXParseException:
print "Parser error"
print("Parser error")
def fix(self, line):
l = line.strip()
@ -137,7 +141,7 @@ class FilterList(object):
for rule in the_filter.get_rules():
f.write(' <rule class="%s">\n'
% rule.__class__.__name__)
for value in rule.values():
for value in list(rule.values()):
f.write(' <arg value="%s"/>\n' % self.fix(value))
f.write(' </rule>\n')
f.write(' </filter>\n')

View File

@ -25,6 +25,8 @@
# Standard Python modules
#
#-------------------------------------------------------------------------
from __future__ import print_function, unicode_literals
from xml.sax import handler
from ..ggettext import gettext as _
@ -33,8 +35,8 @@ from ..ggettext import gettext as _
# Gramps modules
#
#-------------------------------------------------------------------------
from _genericfilter import GenericFilterFactory
import rules
from ._genericfilter import GenericFilterFactory
from . import rules
#-------------------------------------------------------------------------
#
@ -58,14 +60,14 @@ class FilterParser(handler.ContentHandler):
def startElement(self, tag, attrs):
if tag == "object":
if attrs.has_key('type'):
if 'type' in attrs:
self.namespace = attrs['type']
else:
self.namespace = "generic"
elif tag == "filter":
self.f = GenericFilterFactory(self.namespace)()
self.f.set_name(attrs['name'])
if attrs.has_key('function'):
if 'function' in attrs:
try:
if int(attrs['function']):
op = 'or'
@ -74,9 +76,9 @@ class FilterParser(handler.ContentHandler):
except ValueError:
op = attrs['function']
self.f.set_logical_op(op)
if attrs.has_key('invert'):
if 'invert' in attrs:
self.f.set_invert(attrs['invert'])
if attrs.has_key('comment'):
if 'comment' in attrs:
self.f.set_comment(attrs['comment'])
self.gfilter_list.add(self.namespace, self.f)
elif tag == "rule":
@ -86,18 +88,18 @@ class FilterParser(handler.ContentHandler):
else:
try:
# First try to use fully qualified name
exec 'self.r = %s' % save_name
exec('self.r = %s' % save_name)
except (ImportError, NameError, AttributeError ):
# Now try to use name from rules.namespace
mc_match = save_name.split('.')
last_name = mc_match[-1]
try:
exec 'self.r = rules.%s.%s' % (
self.namespace.lower(), last_name)
exec('self.r = rules.%s.%s' % (
self.namespace.lower(), last_name))
except (ImportError, NameError, AttributeError ):
print "ERROR: Filter rule '%s' in "\
print("ERROR: Filter rule '%s' in "\
"filter '%s' not found!"\
% (save_name, self.f.get_name())
% (save_name, self.f.get_name()))
self.r = None
return
self.a = []
@ -109,24 +111,24 @@ class FilterParser(handler.ContentHandler):
if len(self.r.labels) != len(self.a):
self.__upgrade()
if len(self.r.labels) < len(self.a):
print _("WARNING: Too many arguments in filter '%s'!\n"\
print(_("WARNING: Too many arguments in filter '%s'!\n"\
"Trying to load with subset of arguments.") %\
self.f.get_name()
self.f.get_name())
nargs = len(self.r.labels)
rule = self.r(self.a[0:nargs])
self.f.add_rule(rule)
else:
if len(self.r.labels) > len(self.a):
print _("WARNING: Too few arguments in filter '%s'!\n" \
print(_("WARNING: Too few arguments in filter '%s'!\n" \
" Trying to load anyway in the hope this "\
"will be upgraded.") %\
self.f.get_name()
self.f.get_name())
try:
rule = self.r(self.a)
except AssertionError, msg:
print msg
print _("ERROR: filter %s could not be correctly loaded. "
"Edit the filter!") % self.f.get_name()
except AssertionError as msg:
print(msg)
print(_("ERROR: filter %s could not be correctly loaded. "
"Edit the filter!") % self.f.get_name())
return
self.f.add_rule(rule)
@ -140,13 +142,13 @@ class FilterParser(handler.ContentHandler):
"""
# HasPlace rule has extra locality field in v3.3
if self.r == rules.place.HasPlace and len(self.a) == 8:
self.a = self.a[0:2] + [u''] + self.a[4:8] + [self.a[3]] + \
self.a = self.a[0:2] + [''] + self.a[4:8] + [self.a[3]] + \
[self.a[2]]
# HasNameOf rule has new fields for surnames in v3.3
if self.r == rules.person.HasNameOf and len(self.a) == 7:
self.a = self.a[0:2] + [self.a[3]] + [self.a[2]] + [self.a[6]] + \
[u''] + [self.a[4]] + [u'', u''] + [self.a[5]] + \
[u'', u'0']
[''] + [self.a[4]] + ['', ''] + [self.a[5]] + \
['', '0']
#-------------------------------------------------------------------------
#

View File

@ -29,7 +29,7 @@ Package providing filtering framework for GRAMPS.
# GRAMPS modules
#
#-------------------------------------------------------------------------
from _genericfilter import GenericFilter
from ._genericfilter import GenericFilter
from ..errors import FilterError
#-------------------------------------------------------------------------
@ -60,8 +60,8 @@ class ParamFilter(GenericFilter):
rule.set_list(new_list)
for rule in self.flist:
if rule.nrprepare > 0:
raise FilterError, 'Custom filters can not twice be used' \
' in a parameter filter'
raise FilterError('Custom filters can not twice be used' \
' in a parameter filter')
rule.requestprepare(db)
result = GenericFilter.apply(self, db, id_list)
for rule in self.flist:

View File

@ -69,26 +69,26 @@ _Everything Match every object in the database
# Need to expose this to be available for filter plugins:
# the plugins should say: from .. import Rule
from _rule import Rule
from ._rule import Rule
from _everything import Everything
from _hasgrampsid import HasGrampsId
from _isprivate import IsPrivate
from _ispublic import IsPublic
from _hastextmatchingsubstringof import HasTextMatchingSubstringOf
from _hastextmatchingregexpof import HasTextMatchingRegexpOf
from _matchesfilterbase import MatchesFilterBase
from _matcheseventfilterbase import MatchesEventFilterBase
from _matchessourceconfidencebase import MatchesSourceConfidenceBase
from _matchessourcefilterbase import MatchesSourceFilterBase
from _changedsincebase import ChangedSinceBase
from ._everything import Everything
from ._hasgrampsid import HasGrampsId
from ._isprivate import IsPrivate
from ._ispublic import IsPublic
from ._hastextmatchingsubstringof import HasTextMatchingSubstringOf
from ._hastextmatchingregexpof import HasTextMatchingRegexpOf
from ._matchesfilterbase import MatchesFilterBase
from ._matcheseventfilterbase import MatchesEventFilterBase
from ._matchessourceconfidencebase import MatchesSourceConfidenceBase
from ._matchessourcefilterbase import MatchesSourceFilterBase
from ._changedsincebase import ChangedSinceBase
#object filters
import person
import family
import event
import source
import citation
import place
import media
import repository
import note
from . import person
from . import family
from . import event
from . import source
from . import citation
from . import place
from . import media
from . import repository
from . import note

View File

@ -41,6 +41,8 @@ import re
import logging
LOG = logging.getLogger(".")
from ...constfunc import conv_to_unicode_direct
#-------------------------------------------------------------------------
#
# Rule
@ -79,10 +81,11 @@ class Rule(object):
if self.nrprepare == 0:
if self.use_regex:
self.regex = [None]*len(self.labels)
for i in xrange(len(self.labels)):
for i in range(len(self.labels)):
if self.list[i]:
try:
self.regex[i] = re.compile(unicode(self.list[i]),
self.regex[i] = re.compile(
conv_to_unicode_direct(self.list[i]),
re.I|re.U|re.L)
except re.error:
self.regex[i] = re.compile('')
@ -137,7 +140,7 @@ class Rule(object):
def display_values(self):
"""Return the labels and values of this rule."""
l_v = ( '%s="%s"' % (_(self.labels[ix]), self.list[ix])
for ix in xrange(len(self.list)) if self.list[ix] )
for ix in range(len(self.list)) if self.list[ix] )
return ';'.join(l_v)
@ -149,7 +152,7 @@ class Rule(object):
"""
# make str_var unicode so that search for ü works
# see issue 3188
str_var = unicode(str_var)
str_var = conv_to_unicode_direct(str_var)
if self.list[param_index] and \
(str_var.upper().find(self.list[param_index].upper()) == -1):
return False
@ -162,7 +165,7 @@ class Rule(object):
matches filter element indicated by param_index using a regular
expression search.
"""
str_var = unicode(str_var)
str_var = conv_to_unicode_direct(str_var)
if (self.list[param_index] and self.regex[param_index].search(str_var)
is None):
return False

View File

@ -26,22 +26,22 @@
Package providing filter rules for GRAMPS.
"""
from _hascitation import HasCitation
from _allcitations import AllCitations
from _changedsince import ChangedSince
from _citationprivate import CitationPrivate
from _hasgallery import HasGallery
from _hasidof import HasIdOf
from _hasnote import HasNote
from _hasnotematchingsubstringof import HasNoteMatchingSubstringOf
from _hasnoteregexp import HasNoteRegexp
from _hasreferencecountof import HasReferenceCountOf
from _hassource import HasSource
from _matchesfilter import MatchesFilter
from _matchespagesubstringof import MatchesPageSubstringOf
from _matchesrepositoryfilter import MatchesRepositoryFilter
from _matchessourcefilter import MatchesSourceFilter
from _regexpidof import RegExpIdOf
from ._hascitation import HasCitation
from ._allcitations import AllCitations
from ._changedsince import ChangedSince
from ._citationprivate import CitationPrivate
from ._hasgallery import HasGallery
from ._hasidof import HasIdOf
from ._hasnote import HasNote
from ._hasnotematchingsubstringof import HasNoteMatchingSubstringOf
from ._hasnoteregexp import HasNoteRegexp
from ._hasreferencecountof import HasReferenceCountOf
from ._hassource import HasSource
from ._matchesfilter import MatchesFilter
from ._matchespagesubstringof import MatchesPageSubstringOf
from ._matchesrepositoryfilter import MatchesRepositoryFilter
from ._matchessourcefilter import MatchesSourceFilter
from ._regexpidof import RegExpIdOf
editor_rule_list = [
HasCitation,

View File

@ -28,25 +28,25 @@ Package providing filter rules for GRAMPS.
from .._haseventbase import HasEventBase as HasEvent
from _hastype import HasType
from _allevents import AllEvents
from _hasgallery import HasGallery
from _hasidof import HasIdOf
from _regexpidof import RegExpIdOf
from _hascitation import HasCitation
from _hasnote import HasNote
from _hasnoteregexp import HasNoteRegexp
from _hasnotematchingsubstringof import HasNoteMatchingSubstringOf
from _hasreferencecountof import HasReferenceCountOf
from _hassourcecount import HasSourceCount
from _eventprivate import EventPrivate
from _matchesfilter import MatchesFilter
from _matchespersonfilter import MatchesPersonFilter
from _matchessourceconfidence import MatchesSourceConfidence
from _matchessourcefilter import MatchesSourceFilter
from _hasattribute import HasAttribute
from _hasdata import HasData
from _changedsince import ChangedSince
from ._hastype import HasType
from ._allevents import AllEvents
from ._hasgallery import HasGallery
from ._hasidof import HasIdOf
from ._regexpidof import RegExpIdOf
from ._hascitation import HasCitation
from ._hasnote import HasNote
from ._hasnoteregexp import HasNoteRegexp
from ._hasnotematchingsubstringof import HasNoteMatchingSubstringOf
from ._hasreferencecountof import HasReferenceCountOf
from ._hassourcecount import HasSourceCount
from ._eventprivate import EventPrivate
from ._matchesfilter import MatchesFilter
from ._matchespersonfilter import MatchesPersonFilter
from ._matchessourceconfidence import MatchesSourceConfidence
from ._matchessourcefilter import MatchesSourceFilter
from ._hasattribute import HasAttribute
from ._hasdata import HasData
from ._changedsince import ChangedSince
editor_rule_list = [
AllEvents,

View File

@ -26,40 +26,40 @@
Package providing filter rules for GRAMPS.
"""
from _searchfathername import SearchFatherName
from _searchmothername import SearchMotherName
from _searchchildname import SearchChildName
from _regexpfathername import RegExpFatherName
from _regexpmothername import RegExpMotherName
from _regexpchildname import RegExpChildName
from ._searchfathername import SearchFatherName
from ._searchmothername import SearchMotherName
from ._searchchildname import SearchChildName
from ._regexpfathername import RegExpFatherName
from ._regexpmothername import RegExpMotherName
from ._regexpchildname import RegExpChildName
from _hasreltype import HasRelType
from _allfamilies import AllFamilies
from _hasgallery import HasGallery
from _hasidof import HasIdOf
from _haslds import HasLDS
from _regexpidof import RegExpIdOf
from _hasnote import HasNote
from _hasnoteregexp import HasNoteRegexp
from _hasnotematchingsubstringof import HasNoteMatchingSubstringOf
from _hassourcecount import HasSourceCount
from _hassourceof import HasSourceOf
from _hasreferencecountof import HasReferenceCountOf
from _hascitation import HasCitation
from _familyprivate import FamilyPrivate
from _hasattribute import HasAttribute
from _hasevent import HasEvent
from _isbookmarked import IsBookmarked
from _matchesfilter import MatchesFilter
from _matchessourceconfidence import MatchesSourceConfidence
from _fatherhasnameof import FatherHasNameOf
from _fatherhasidof import FatherHasIdOf
from _motherhasnameof import MotherHasNameOf
from _motherhasidof import MotherHasIdOf
from _childhasnameof import ChildHasNameOf
from _childhasidof import ChildHasIdOf
from _changedsince import ChangedSince
from _hastag import HasTag
from ._hasreltype import HasRelType
from ._allfamilies import AllFamilies
from ._hasgallery import HasGallery
from ._hasidof import HasIdOf
from ._haslds import HasLDS
from ._regexpidof import RegExpIdOf
from ._hasnote import HasNote
from ._hasnoteregexp import HasNoteRegexp
from ._hasnotematchingsubstringof import HasNoteMatchingSubstringOf
from ._hassourcecount import HasSourceCount
from ._hassourceof import HasSourceOf
from ._hasreferencecountof import HasReferenceCountOf
from ._hascitation import HasCitation
from ._familyprivate import FamilyPrivate
from ._hasattribute import HasAttribute
from ._hasevent import HasEvent
from ._isbookmarked import IsBookmarked
from ._matchesfilter import MatchesFilter
from ._matchessourceconfidence import MatchesSourceConfidence
from ._fatherhasnameof import FatherHasNameOf
from ._fatherhasidof import FatherHasIdOf
from ._motherhasnameof import MotherHasNameOf
from ._motherhasidof import MotherHasIdOf
from ._childhasnameof import ChildHasNameOf
from ._childhasidof import ChildHasIdOf
from ._changedsince import ChangedSince
from ._hastag import HasTag
editor_rule_list = [
AllFamilies,

View File

@ -33,7 +33,7 @@ from ....ggettext import gettext as _
#
#-------------------------------------------------------------------------
from .. import HasGrampsId
from _memberbase import child_base
from ._memberbase import child_base
#-------------------------------------------------------------------------
#

View File

@ -33,7 +33,7 @@ from ....ggettext import gettext as _
#
#-------------------------------------------------------------------------
from ..person import HasNameOf
from _memberbase import child_base
from ._memberbase import child_base
#-------------------------------------------------------------------------
#

View File

@ -33,7 +33,7 @@ from ....ggettext import gettext as _
#
#-------------------------------------------------------------------------
from .. import HasGrampsId
from _memberbase import father_base
from ._memberbase import father_base
#-------------------------------------------------------------------------
#

View File

@ -33,7 +33,7 @@ from ....ggettext import gettext as _
#
#-------------------------------------------------------------------------
from ..person import HasNameOf
from _memberbase import father_base
from ._memberbase import father_base
#-------------------------------------------------------------------------
#

View File

@ -33,7 +33,7 @@ from ....ggettext import gettext as _
#
#-------------------------------------------------------------------------
from .. import HasGrampsId
from _memberbase import mother_base
from ._memberbase import mother_base
#-------------------------------------------------------------------------
#

View File

@ -33,7 +33,7 @@ from ....ggettext import gettext as _
#
#-------------------------------------------------------------------------
from ..person import HasNameOf
from _memberbase import mother_base
from ._memberbase import mother_base
#-------------------------------------------------------------------------
#

View File

@ -33,7 +33,7 @@ from ....ggettext import gettext as _
#
#-------------------------------------------------------------------------
from ..person import RegExpName
from _memberbase import child_base
from ._memberbase import child_base
#-------------------------------------------------------------------------
#

View File

@ -33,7 +33,7 @@ from ....ggettext import gettext as _
#
#-------------------------------------------------------------------------
from ..person import RegExpName
from _memberbase import father_base
from ._memberbase import father_base
#-------------------------------------------------------------------------
#

View File

@ -33,7 +33,7 @@ from ....ggettext import gettext as _
#
#-------------------------------------------------------------------------
from ..person import RegExpName
from _memberbase import mother_base
from ._memberbase import mother_base
#-------------------------------------------------------------------------
#

View File

@ -33,7 +33,7 @@ from ....ggettext import gettext as _
#
#-------------------------------------------------------------------------
from ..person import SearchName
from _memberbase import child_base
from ._memberbase import child_base
#-------------------------------------------------------------------------
#

View File

@ -33,7 +33,7 @@ from ....ggettext import gettext as _
#
#-------------------------------------------------------------------------
from ..person import SearchName
from _memberbase import father_base
from ._memberbase import father_base
#-------------------------------------------------------------------------
#

View File

@ -33,7 +33,7 @@ from ....ggettext import gettext as _
#
#-------------------------------------------------------------------------
from ..person import SearchName
from _memberbase import mother_base
from ._memberbase import mother_base
#-------------------------------------------------------------------------
#

View File

@ -24,22 +24,22 @@
Package providing filter rules for GRAMPS.
"""
from _allmedia import AllMedia
from _hasidof import HasIdOf
from _regexpidof import RegExpIdOf
from _hascitation import HasCitation
from _hasnoteregexp import HasNoteRegexp
from _hasnotematchingsubstringof import HasNoteMatchingSubstringOf
from _hasreferencecountof import HasReferenceCountOf
from _hassourcecount import HasSourceCount
from _hassourceof import HasSourceOf
from _mediaprivate import MediaPrivate
from _matchesfilter import MatchesFilter
from _matchessourceconfidence import MatchesSourceConfidence
from _hasmedia import HasMedia
from _hasattribute import HasAttribute
from _changedsince import ChangedSince
from _hastag import HasTag
from ._allmedia import AllMedia
from ._hasidof import HasIdOf
from ._regexpidof import RegExpIdOf
from ._hascitation import HasCitation
from ._hasnoteregexp import HasNoteRegexp
from ._hasnotematchingsubstringof import HasNoteMatchingSubstringOf
from ._hasreferencecountof import HasReferenceCountOf
from ._hassourcecount import HasSourceCount
from ._hassourceof import HasSourceOf
from ._mediaprivate import MediaPrivate
from ._matchesfilter import MatchesFilter
from ._matchessourceconfidence import MatchesSourceConfidence
from ._hasmedia import HasMedia
from ._hasattribute import HasAttribute
from ._changedsince import ChangedSince
from ._hastag import HasTag
editor_rule_list = [
AllMedia,

View File

@ -25,17 +25,17 @@
Package providing filter rules for GRAMPS.
"""
from _allnotes import AllNotes
from _hasidof import HasIdOf
from _regexpidof import RegExpIdOf
from _matchesregexpof import MatchesRegexpOf
from _matchessubstringof import MatchesSubstringOf
from _hasreferencecountof import HasReferenceCountOf
from _noteprivate import NotePrivate
from _matchesfilter import MatchesFilter
from _hasnote import HasNote
from _changedsince import ChangedSince
from _hastag import HasTag
from ._allnotes import AllNotes
from ._hasidof import HasIdOf
from ._regexpidof import RegExpIdOf
from ._matchesregexpof import MatchesRegexpOf
from ._matchessubstringof import MatchesSubstringOf
from ._hasreferencecountof import HasReferenceCountOf
from ._noteprivate import NotePrivate
from ._matchesfilter import MatchesFilter
from ._hasnote import HasNote
from ._changedsince import ChangedSince
from ._hastag import HasTag
editor_rule_list = [
AllNotes,

View File

@ -27,90 +27,90 @@
Package providing filter rules for GRAMPS.
"""
from _disconnected import Disconnected
from _everyone import Everyone
from _familywithincompleteevent import FamilyWithIncompleteEvent
from _hasaddress import HasAddress
from _hasalternatename import HasAlternateName
from _hasassociation import HasAssociation
from _hasattribute import HasAttribute
from _hasbirth import HasBirth
from _hascitation import HasCitation
from _hascommonancestorwith import HasCommonAncestorWith
from _hascommonancestorwithfiltermatch import HasCommonAncestorWithFilterMatch
from _hasdeath import HasDeath
from _hasevent import HasEvent
from _hasfamilyattribute import HasFamilyAttribute
from _hasfamilyevent import HasFamilyEvent
from _hasgallery import HavePhotos
from _hasidof import HasIdOf
from _haslds import HasLDS
from _hasnameof import HasNameOf
from _hasnameorigintype import HasNameOriginType
from _hasnametype import HasNameType
from _hasnickname import HasNickname
from _hasnote import HasNote
from _hasnotematchingsubstringof import HasNoteMatchingSubstringOf
from _hasnoteregexp import HasNoteRegexp
from _hasrelationship import HasRelationship
from _hassourcecount import HasSourceCount
from _hassourceof import HasSourceOf
from _hastag import HasTag
from _hastextmatchingregexpof import HasTextMatchingRegexpOf
from _hastextmatchingsubstringof import HasTextMatchingSubstringOf
from _hasunknowngender import HasUnknownGender
from _havealtfamilies import HaveAltFamilies
from _havechildren import HaveChildren
from _incompletenames import IncompleteNames
from _isancestorof import IsAncestorOf
from _isancestoroffiltermatch import IsAncestorOfFilterMatch
from _isbookmarked import IsBookmarked
from _ischildoffiltermatch import IsChildOfFilterMatch
from _isdefaultperson import IsDefaultPerson
from _isdescendantfamilyof import IsDescendantFamilyOf
from _isdescendantfamilyoffiltermatch import IsDescendantFamilyOfFilterMatch
from _isdescendantof import IsDescendantOf
from _isdescendantoffiltermatch import IsDescendantOfFilterMatch
from _isduplicatedancestorof import IsDuplicatedAncestorOf
from _isfemale import IsFemale
from _islessthannthgenerationancestorof import \
from ._disconnected import Disconnected
from ._everyone import Everyone
from ._familywithincompleteevent import FamilyWithIncompleteEvent
from ._hasaddress import HasAddress
from ._hasalternatename import HasAlternateName
from ._hasassociation import HasAssociation
from ._hasattribute import HasAttribute
from ._hasbirth import HasBirth
from ._hascitation import HasCitation
from ._hascommonancestorwith import HasCommonAncestorWith
from ._hascommonancestorwithfiltermatch import HasCommonAncestorWithFilterMatch
from ._hasdeath import HasDeath
from ._hasevent import HasEvent
from ._hasfamilyattribute import HasFamilyAttribute
from ._hasfamilyevent import HasFamilyEvent
from ._hasgallery import HavePhotos
from ._hasidof import HasIdOf
from ._haslds import HasLDS
from ._hasnameof import HasNameOf
from ._hasnameorigintype import HasNameOriginType
from ._hasnametype import HasNameType
from ._hasnickname import HasNickname
from ._hasnote import HasNote
from ._hasnotematchingsubstringof import HasNoteMatchingSubstringOf
from ._hasnoteregexp import HasNoteRegexp
from ._hasrelationship import HasRelationship
from ._hassourcecount import HasSourceCount
from ._hassourceof import HasSourceOf
from ._hastag import HasTag
from ._hastextmatchingregexpof import HasTextMatchingRegexpOf
from ._hastextmatchingsubstringof import HasTextMatchingSubstringOf
from ._hasunknowngender import HasUnknownGender
from ._havealtfamilies import HaveAltFamilies
from ._havechildren import HaveChildren
from ._incompletenames import IncompleteNames
from ._isancestorof import IsAncestorOf
from ._isancestoroffiltermatch import IsAncestorOfFilterMatch
from ._isbookmarked import IsBookmarked
from ._ischildoffiltermatch import IsChildOfFilterMatch
from ._isdefaultperson import IsDefaultPerson
from ._isdescendantfamilyof import IsDescendantFamilyOf
from ._isdescendantfamilyoffiltermatch import IsDescendantFamilyOfFilterMatch
from ._isdescendantof import IsDescendantOf
from ._isdescendantoffiltermatch import IsDescendantOfFilterMatch
from ._isduplicatedancestorof import IsDuplicatedAncestorOf
from ._isfemale import IsFemale
from ._islessthannthgenerationancestorof import \
IsLessThanNthGenerationAncestorOf
from _islessthannthgenerationancestorofbookmarked import \
from ._islessthannthgenerationancestorofbookmarked import \
IsLessThanNthGenerationAncestorOfBookmarked
from _islessthannthgenerationancestorofdefaultperson import \
from ._islessthannthgenerationancestorofdefaultperson import \
IsLessThanNthGenerationAncestorOfDefaultPerson
from _islessthannthgenerationdescendantof import \
from ._islessthannthgenerationdescendantof import \
IsLessThanNthGenerationDescendantOf
from _ismale import IsMale
from _ismorethannthgenerationancestorof import \
from ._ismale import IsMale
from ._ismorethannthgenerationancestorof import \
IsMoreThanNthGenerationAncestorOf
from _ismorethannthgenerationdescendantof import \
from ._ismorethannthgenerationdescendantof import \
IsMoreThanNthGenerationDescendantOf
from _isparentoffiltermatch import IsParentOfFilterMatch
from _issiblingoffiltermatch import IsSiblingOfFilterMatch
from _isspouseoffiltermatch import IsSpouseOfFilterMatch
from _iswitness import IsWitness
from _matchesfilter import MatchesFilter
from _matcheseventfilter import MatchesEventFilter
from _matchessourceconfidence import MatchesSourceConfidence
from _missingparent import MissingParent
from _multiplemarriages import MultipleMarriages
from _nevermarried import NeverMarried
from _nobirthdate import NoBirthdate
from _nodeathdate import NoDeathdate
from _peopleprivate import PeoplePrivate
from _peoplepublic import PeoplePublic
from _personwithincompleteevent import PersonWithIncompleteEvent
from _probablyalive import ProbablyAlive
from _relationshippathbetween import RelationshipPathBetween
from _deeprelationshippathbetween import DeepRelationshipPathBetween
from _relationshippathbetweenbookmarks import RelationshipPathBetweenBookmarks
from _searchname import SearchName
from _regexpname import RegExpName
from _matchidof import MatchIdOf
from _regexpidof import RegExpIdOf
from _changedsince import ChangedSince
from _isrelatedwith import IsRelatedWith
from ._isparentoffiltermatch import IsParentOfFilterMatch
from ._issiblingoffiltermatch import IsSiblingOfFilterMatch
from ._isspouseoffiltermatch import IsSpouseOfFilterMatch
from ._iswitness import IsWitness
from ._matchesfilter import MatchesFilter
from ._matcheseventfilter import MatchesEventFilter
from ._matchessourceconfidence import MatchesSourceConfidence
from ._missingparent import MissingParent
from ._multiplemarriages import MultipleMarriages
from ._nevermarried import NeverMarried
from ._nobirthdate import NoBirthdate
from ._nodeathdate import NoDeathdate
from ._peopleprivate import PeoplePrivate
from ._peoplepublic import PeoplePublic
from ._personwithincompleteevent import PersonWithIncompleteEvent
from ._probablyalive import ProbablyAlive
from ._relationshippathbetween import RelationshipPathBetween
from ._deeprelationshippathbetween import DeepRelationshipPathBetween
from ._relationshippathbetweenbookmarks import RelationshipPathBetweenBookmarks
from ._searchname import SearchName
from ._regexpname import RegExpName
from ._matchidof import MatchIdOf
from ._regexpidof import RegExpIdOf
from ._changedsince import ChangedSince
from ._isrelatedwith import IsRelatedWith
#-------------------------------------------------------------------------
#

View File

@ -145,7 +145,7 @@ class DeepRelationshipPathBetween(Rule):
progress = None
self.__matches = set()
map(self.__matches.update, paths)
list(map(self.__matches.update, paths))
def reset(self):
self.__matches = set()

View File

@ -33,8 +33,8 @@ from ....ggettext import gettext as _
#
#-------------------------------------------------------------------------
from ....utils.db import for_each_ancestor
from _hascommonancestorwith import HasCommonAncestorWith
from _matchesfilter import MatchesFilter
from ._hascommonancestorwith import HasCommonAncestorWith
from ._matchesfilter import MatchesFilter
#-------------------------------------------------------------------------
#

View File

@ -31,7 +31,7 @@
# GRAMPS modules
#
#-------------------------------------------------------------------------
from _hastextmatchingsubstringof import HasTextMatchingSubstringOf
from ._hastextmatchingsubstringof import HasTextMatchingSubstringOf
#-------------------------------------------------------------------------
# "HasTextMatchingRegexOf"

View File

@ -32,8 +32,8 @@ from ....ggettext import gettext as _
# GRAMPS modules
#
#-------------------------------------------------------------------------
from _isancestorof import IsAncestorOf
from _matchesfilter import MatchesFilter
from ._isancestorof import IsAncestorOf
from ._matchesfilter import MatchesFilter
#-------------------------------------------------------------------------
#

View File

@ -33,7 +33,7 @@ from ....ggettext import gettext as _
#
#-------------------------------------------------------------------------
from .. import Rule
from _matchesfilter import MatchesFilter
from ._matchesfilter import MatchesFilter
#-------------------------------------------------------------------------
#

View File

@ -32,8 +32,8 @@ from ....ggettext import gettext as _
# GRAMPS modules
#
#-------------------------------------------------------------------------
from _isdescendantfamilyof import IsDescendantFamilyOf
from _matchesfilter import MatchesFilter
from ._isdescendantfamilyof import IsDescendantFamilyOf
from ._matchesfilter import MatchesFilter
#-------------------------------------------------------------------------
#

View File

@ -32,8 +32,8 @@ from ....ggettext import gettext as _
# GRAMPS modules
#
#-------------------------------------------------------------------------
from _isdescendantof import IsDescendantOf
from _matchesfilter import MatchesFilter
from ._isdescendantof import IsDescendantOf
from ._matchesfilter import MatchesFilter
#-------------------------------------------------------------------------
#

View File

@ -33,7 +33,7 @@ from ....ggettext import gettext as _
#
#-------------------------------------------------------------------------
from .. import Rule
from _matchesfilter import MatchesFilter
from ._matchesfilter import MatchesFilter
#-------------------------------------------------------------------------
#

View File

@ -33,7 +33,7 @@ from ....ggettext import gettext as _
#
#-------------------------------------------------------------------------
from .. import Rule
from _matchesfilter import MatchesFilter
from ._matchesfilter import MatchesFilter
#-------------------------------------------------------------------------
#

View File

@ -33,7 +33,7 @@ from ....ggettext import gettext as _
#
#-------------------------------------------------------------------------
from .. import Rule
from _matchesfilter import MatchesFilter
from ._matchesfilter import MatchesFilter
#-------------------------------------------------------------------------
#

View File

@ -35,6 +35,7 @@ from ....ggettext import gettext as _
from ....utils.alive import probably_alive
from .. import Rule
from ....datehandler import parser
from ....constfunc import conv_to_unicode_direct
#-------------------------------------------------------------------------
# "People probably alive"
@ -49,7 +50,7 @@ class ProbablyAlive(Rule):
def prepare(self,db):
try:
self.current_date = parser.parse(unicode(self.list[0]))
self.current_date = parser.parse(conv_to_unicode_direct(self.list[0]))
except:
self.current_date = None

View File

@ -25,25 +25,25 @@
Package providing filter rules for GRAMPS.
"""
from _allplaces import AllPlaces
from _hascitation import HasCitation
from _hasgallery import HasGallery
from _hasidof import HasIdOf
from _regexpidof import RegExpIdOf
from _hasnote import HasNote
from _hasnoteregexp import HasNoteRegexp
from _hasnotematchingsubstringof import HasNoteMatchingSubstringOf
from _hasreferencecountof import HasReferenceCountOf
from _hassourcecount import HasSourceCount
from _hassourceof import HasSourceOf
from _placeprivate import PlacePrivate
from _matchesfilter import MatchesFilter
from _hasplace import HasPlace
from _hasnolatorlon import HasNoLatOrLon
from _inlatlonneighborhood import InLatLonNeighborhood
from _matcheseventfilter import MatchesEventFilter
from _matchessourceconfidence import MatchesSourceConfidence
from _changedsince import ChangedSince
from ._allplaces import AllPlaces
from ._hascitation import HasCitation
from ._hasgallery import HasGallery
from ._hasidof import HasIdOf
from ._regexpidof import RegExpIdOf
from ._hasnote import HasNote
from ._hasnoteregexp import HasNoteRegexp
from ._hasnotematchingsubstringof import HasNoteMatchingSubstringOf
from ._hasreferencecountof import HasReferenceCountOf
from ._hassourcecount import HasSourceCount
from ._hassourceof import HasSourceOf
from ._placeprivate import PlacePrivate
from ._matchesfilter import MatchesFilter
from ._hasplace import HasPlace
from ._hasnolatorlon import HasNoLatOrLon
from ._inlatlonneighborhood import InLatLonNeighborhood
from ._matcheseventfilter import MatchesEventFilter
from ._matchessourceconfidence import MatchesSourceConfidence
from ._changedsince import ChangedSince
editor_rule_list = [
AllPlaces,

View File

@ -24,17 +24,17 @@
Package providing filter rules for GRAMPS.
"""
from _allrepos import AllRepos
from _hasidof import HasIdOf
from _regexpidof import RegExpIdOf
from _hasnoteregexp import HasNoteRegexp
from _hasnotematchingsubstringof import HasNoteMatchingSubstringOf
from _hasreferencecountof import HasReferenceCountOf
from _repoprivate import RepoPrivate
from _matchesfilter import MatchesFilter
from _hasrepo import HasRepo
from _changedsince import ChangedSince
from _matchesnamesubstringof import MatchesNameSubstringOf
from ._allrepos import AllRepos
from ._hasidof import HasIdOf
from ._regexpidof import RegExpIdOf
from ._hasnoteregexp import HasNoteRegexp
from ._hasnotematchingsubstringof import HasNoteMatchingSubstringOf
from ._hasreferencecountof import HasReferenceCountOf
from ._repoprivate import RepoPrivate
from ._matchesfilter import MatchesFilter
from ._hasrepo import HasRepo
from ._changedsince import ChangedSince
from ._matchesnamesubstringof import MatchesNameSubstringOf
editor_rule_list = [
AllRepos,

View File

@ -28,21 +28,21 @@ Package providing filter rules for GRAMPS.
from .._hassourcebase import HasSourceBase as HasSource
from _allsources import AllSources
from _hasgallery import HasGallery
from _hasidof import HasIdOf
from _regexpidof import RegExpIdOf
from _hasnote import HasNote
from _hasnoteregexp import HasNoteRegexp
from _hasnotematchingsubstringof import HasNoteMatchingSubstringOf
from _hasreferencecountof import HasReferenceCountOf
from _sourceprivate import SourcePrivate
from _matchesfilter import MatchesFilter
from _changedsince import ChangedSince
from _hasrepository import HasRepository
from _matchestitlesubstringof import MatchesTitleSubstringOf
from _hasrepositorycallnumberref import HasRepositoryCallNumberRef
from _matchesrepositoryfilter import MatchesRepositoryFilter
from ._allsources import AllSources
from ._hasgallery import HasGallery
from ._hasidof import HasIdOf
from ._regexpidof import RegExpIdOf
from ._hasnote import HasNote
from ._hasnoteregexp import HasNoteRegexp
from ._hasnotematchingsubstringof import HasNoteMatchingSubstringOf
from ._hasreferencecountof import HasReferenceCountOf
from ._sourceprivate import SourcePrivate
from ._matchesfilter import MatchesFilter
from ._changedsince import ChangedSince
from ._hasrepository import HasRepository
from ._matchestitlesubstringof import MatchesTitleSubstringOf
from ._hasrepositorycallnumberref import HasRepositoryCallNumberRef
from ._matchesrepositoryfilter import MatchesRepositoryFilter
editor_rule_list = [
AllSources,

View File

@ -32,6 +32,11 @@ This module ("Gramps Gettext") is an extension to the Python gettext module.
#------------------------------------------------------------------------
import gettext as pgettext
import sys
if sys.version_info[0] < 3:
cuni = unicode
else:
cuni = str
def gettext(msgid):
"""
@ -45,7 +50,7 @@ def gettext(msgid):
# and that's not what we want.
if len(msgid.strip()) == 0:
return msgid
return unicode(pgettext.gettext(msgid))
return cuni(pgettext.gettext(msgid))
def ngettext(singular, plural, n):
"""
@ -63,7 +68,7 @@ def ngettext(singular, plural, n):
:returns: Translation or the original.
:rtype: unicode
"""
return unicode(pgettext.ngettext(singular, plural, n))
return cuni(pgettext.ngettext(singular, plural, n))
def sgettext(msgid, sep='|'):
"""
@ -86,4 +91,4 @@ def sgettext(msgid, sep='|'):
if msgval == msgid:
sep_idx = msgid.rfind(sep)
msgval = msgid[sep_idx+1:]
return unicode(msgval)
return cuni(msgval)

View File

@ -24,59 +24,59 @@
"""The core library of GRAMPS objects
"""
# Dates
from date import Date, DateError, Span
from .date import Date, DateError, Span
# Secondary objects
from secondaryobj import SecondaryObject
from address import Address
from location import Location
from attribute import Attribute
from eventref import EventRef
from ldsord import LdsOrd
from mediaref import MediaRef
from name import Name
from reporef import RepoRef
from surname import Surname
from url import Url
from witness import Witness
from childref import ChildRef
from .secondaryobj import SecondaryObject
from .address import Address
from .location import Location
from .attribute import Attribute
from .eventref import EventRef
from .ldsord import LdsOrd
from .mediaref import MediaRef
from .name import Name
from .reporef import RepoRef
from .surname import Surname
from .url import Url
from .witness import Witness
from .childref import ChildRef
# Primary objects
from primaryobj import PrimaryObject
from person import Person
from personref import PersonRef
from family import Family
from event import Event
from place import Place
from src import Source
from mediaobj import MediaObject
from repo import Repository
from note import Note
from citation import Citation
from .primaryobj import PrimaryObject
from .person import Person
from .personref import PersonRef
from .family import Family
from .event import Event
from .place import Place
from .src import Source
from .mediaobj import MediaObject
from .repo import Repository
from .note import Note
from .citation import Citation
# Table objects
from tag import Tag
from .tag import Tag
# These are actually metadata
from genderstats import GenderStats
from researcher import Researcher
from .genderstats import GenderStats
from .researcher import Researcher
# Type classes
from grampstype import GrampsType
from nametype import NameType
from attrtype import AttributeType
from urltype import UrlType
from childreftype import ChildRefType
from repotype import RepositoryType
from eventtype import EventType
from familyreltype import FamilyRelType
from srcmediatype import SourceMediaType
from eventroletype import EventRoleType
from markertype import MarkerType
from nameorigintype import NameOriginType
from notetype import NoteType
from styledtexttagtype import StyledTextTagType
from .grampstype import GrampsType
from .nametype import NameType
from .attrtype import AttributeType
from .urltype import UrlType
from .childreftype import ChildRefType
from .repotype import RepositoryType
from .eventtype import EventType
from .familyreltype import FamilyRelType
from .srcmediatype import SourceMediaType
from .eventroletype import EventRoleType
from .markertype import MarkerType
from .nameorigintype import NameOriginType
from .notetype import NoteType
from .styledtexttagtype import StyledTextTagType
# Text
from styledtexttag import StyledTextTag
from styledtext import StyledText
from .styledtexttag import StyledTextTag
from .styledtext import StyledText

View File

@ -31,13 +31,13 @@ Address class for GRAMPS.
# GRAMPS modules
#
#-------------------------------------------------------------------------
from secondaryobj import SecondaryObject
from privacybase import PrivacyBase
from citationbase import CitationBase
from notebase import NoteBase
from datebase import DateBase
from locationbase import LocationBase
from const import IDENTICAL, EQUAL, DIFFERENT
from .secondaryobj import SecondaryObject
from .privacybase import PrivacyBase
from .citationbase import CitationBase
from .notebase import NoteBase
from .datebase import DateBase
from .locationbase import LocationBase
from .const import IDENTICAL, EQUAL, DIFFERENT
#-------------------------------------------------------------------------
#

View File

@ -30,8 +30,8 @@ AddressBase class for GRAMPS.
# GRAMPS modules
#
#-------------------------------------------------------------------------
from address import Address
from const import IDENTICAL, EQUAL
from .address import Address
from .const import IDENTICAL, EQUAL
#-------------------------------------------------------------------------
#
@ -53,7 +53,7 @@ class AddressBase(object):
:param source: Object used to initialize the new object
:type source: AddressBase
"""
self.address_list = map(Address, source.address_list) if source else []
self.address_list = list(map(Address, source.address_list)) if source else []
def serialize(self):
"""

View File

@ -30,8 +30,9 @@ AttributeBase class for GRAMPS.
# GRAMPS modules
#
#-------------------------------------------------------------------------
from attribute import Attribute
from const import IDENTICAL, EQUAL
from .attribute import Attribute
from .const import IDENTICAL, EQUAL
from ..constfunc import STRTYPE
#-------------------------------------------------------------------------
#
@ -100,7 +101,7 @@ class AttributeBase(object):
:param attribute: :class:`~gen.lib.attribute.Attribute` instance to add.
:type attribute: :class:`~gen.lib.attribute.Attribute`
"""
assert not isinstance(attribute, unicode)
assert not isinstance(attribute, STRTYPE)
self.attribute_list.append(attribute)
def remove_attribute(self, attribute):

View File

@ -31,12 +31,12 @@ Attribute class for GRAMPS.
# GRAMPS modules
#
#-------------------------------------------------------------------------
from secondaryobj import SecondaryObject
from privacybase import PrivacyBase
from citationbase import CitationBase
from notebase import NoteBase
from attrtype import AttributeType
from const import IDENTICAL, EQUAL, DIFFERENT
from .secondaryobj import SecondaryObject
from .privacybase import PrivacyBase
from .citationbase import CitationBase
from .notebase import NoteBase
from .attrtype import AttributeType
from .const import IDENTICAL, EQUAL, DIFFERENT
#-------------------------------------------------------------------------
#

View File

@ -35,7 +35,7 @@ from ..ggettext import gettext as _
# GRAMPS modules
#
#-------------------------------------------------------------------------
from grampstype import GrampsType
from .grampstype import GrampsType
class AttributeType(GrampsType):

View File

@ -31,6 +31,13 @@ Base Object class for GRAMPS
#-------------------------------------------------------------------------
import re
#-------------------------------------------------------------------------
#
# GRAMPS modules
#
#-------------------------------------------------------------------------
from ..constfunc import cuni
#-------------------------------------------------------------------------
#
# Base Object
@ -96,7 +103,7 @@ class BaseObject(object):
for item in self.get_text_data_list():
# Some items are strings, which will fail in item.upper(), and some items are unicode.
# Convert all items to unicode and the item.upper().find(patern_upper) will work OK.
item = unicode(item)
item = cuni(item)
if not item:
continue
if case_sensitive:

View File

@ -30,13 +30,13 @@ Child Reference class for GRAMPS.
# GRAMPS modules
#
#-------------------------------------------------------------------------
from secondaryobj import SecondaryObject
from privacybase import PrivacyBase
from citationbase import CitationBase
from notebase import NoteBase
from refbase import RefBase
from childreftype import ChildRefType
from const import IDENTICAL, EQUAL, DIFFERENT
from .secondaryobj import SecondaryObject
from .privacybase import PrivacyBase
from .citationbase import CitationBase
from .notebase import NoteBase
from .refbase import RefBase
from .childreftype import ChildRefType
from .const import IDENTICAL, EQUAL, DIFFERENT
#-------------------------------------------------------------------------
#

View File

@ -35,7 +35,7 @@ from ..ggettext import gettext as _
# GRAMPS modules
#
#-------------------------------------------------------------------------
from grampstype import GrampsType
from .grampstype import GrampsType
class ChildRefType(GrampsType):
"""

View File

@ -39,10 +39,11 @@ LOG = logging.getLogger(".citation")
# GRAMPS modules
#
#-------------------------------------------------------------------------
from primaryobj import PrimaryObject
from mediabase import MediaBase
from notebase import NoteBase
from datebase import DateBase
from .primaryobj import PrimaryObject
from .mediabase import MediaBase
from .notebase import NoteBase
from .datebase import DateBase
from ..constfunc import cuni
#-------------------------------------------------------------------------
#
@ -82,7 +83,7 @@ class Citation(MediaBase, NoteBase, PrimaryObject, DateBase):
return (self.handle, # 0
self.gramps_id, # 1
DateBase.serialize(self, no_text_date),# 2
unicode(self.page), # 3
cuni(self.page), # 3
self.confidence, # 4
self.source_handle, # 5
NoteBase.serialize(self), # 6
@ -114,7 +115,7 @@ class Citation(MediaBase, NoteBase, PrimaryObject, DateBase):
return {"handle": self.handle, # 0
"gramps_id": self.gramps_id, # 1
"date": DateBase.to_struct(self), # 2
"page": unicode(self.page), # 3
"page": cuni(self.page), # 3
"confidence": self.confidence, # 4
"source_handle": self.source_handle, # 5
"note_list": NoteBase.to_struct(self), # 6
@ -203,7 +204,7 @@ class Citation(MediaBase, NoteBase, PrimaryObject, DateBase):
:rtype: list
"""
return [self.page,
self.gramps_id] + self.datamap.keys() + self.datamap.values()
self.gramps_id] + list(self.datamap.keys()) + list(self.datamap.values())
def get_text_data_child_list(self):
"""

View File

@ -246,7 +246,7 @@ class CitationBase(object):
if new_handle in self.citation_list:
new_ref = new_handle
n_replace = refs_list.count(old_handle)
for ix_replace in xrange(n_replace):
for ix_replace in range(n_replace):
idx = refs_list.index(old_handle)
if new_ref:
self.citation_list.pop(idx)

View File

@ -28,6 +28,7 @@
# Python modules
#
#------------------------------------------------------------------------
from __future__ import unicode_literals
from ..ggettext import sgettext as _
from ..ggettext import ngettext
@ -51,7 +52,7 @@ log = logging.getLogger(".Date")
# Gramps modules
#
#------------------------------------------------------------------------
from calendar import (gregorian_sdn, julian_sdn, hebrew_sdn,
from .calendar import (gregorian_sdn, julian_sdn, hebrew_sdn,
french_sdn, persian_sdn, islamic_sdn, swedish_sdn,
gregorian_ymd, julian_ymd, hebrew_ymd,
french_ymd, persian_ymd, islamic_ymd,
@ -595,7 +596,7 @@ class Date(object):
elif len(source) == 3:
pass # source is ok
else:
raise AttributeError, "invalid args to Date: %s" % source
raise AttributeError("invalid args to Date: %s" % source)
self.format = None
#### ok, process either date or tuple
if isinstance(source, tuple):
@ -603,7 +604,7 @@ class Date(object):
self.modifier = Date.MOD_NONE
self.quality = Date.QUAL_NONE
self.dateval = Date.EMPTY
self.text = u""
self.text = ""
self.sortval = 0
self.newyear = 0
self.set_yr_mon_day(*source)
@ -620,7 +621,7 @@ class Date(object):
self.modifier = Date.MOD_NONE
self.quality = Date.QUAL_NONE
self.dateval = Date.EMPTY
self.text = u""
self.text = ""
self.sortval = 0
self.newyear = Date.NEWYEAR_JAN1
@ -629,7 +630,7 @@ class Date(object):
Convert to a series of tuples for data storage.
"""
if no_text_date:
text = u''
text = ''
else:
text = self.text
@ -719,7 +720,7 @@ class Date(object):
elif isinstance(other, (tuple, list)):
return self.copy_offset_ymd(*other)
else:
raise AttributeError, "unknown date add type: %s " % type(other)
raise AttributeError("unknown date add type: %s " % type(other))
def __radd__(self, other):
"""
@ -738,7 +739,7 @@ class Date(object):
elif isinstance(other, type(self)): # Date1 - Date2 -> tuple
return Span(self, other)
else:
raise AttributeError, "unknown date sub type: %s " % type(other)
raise AttributeError("unknown date sub type: %s " % type(other))
# Can't use this (as is) as this breaks comparing dates to None
#def __eq__(self, other):
@ -926,7 +927,7 @@ class Date(object):
# If all > all
return self_start > other_stop
else:
raise AttributeError, ("invalid match comparison operator: '%s'" %
raise AttributeError("invalid match comparison operator: '%s'" %
comparison)
def __str__(self):

Some files were not shown because too many files have changed in this diff Show More