Templates are a full TableObject and stored in the database. Template attributes are CUSTOM attributes.

svn: r22843
This commit is contained in:
Tim G L Lyons 2013-08-10 15:25:56 +00:00
parent c4ecfaafe9
commit 06de73c8f4
15 changed files with 589 additions and 783 deletions

View File

@ -46,7 +46,7 @@ __all__ = (
('PERSON_KEY', 'FAMILY_KEY', 'SOURCE_KEY', 'CITATION_KEY',
'EVENT_KEY', 'MEDIA_KEY', 'PLACE_KEY', 'REPOSITORY_KEY',
'NOTE_KEY', 'REFERENCE_KEY', 'TAG_KEY'
'NOTE_KEY', 'REFERENCE_KEY', 'TAG_KEY', 'TEMPLATE_KEY'
) +
('TXNADD', 'TXNUPD', 'TXNDEL')
@ -87,5 +87,6 @@ REFERENCE_KEY = 7
NOTE_KEY = 8
TAG_KEY = 9
CITATION_KEY = 10
TEMPLATE_KEY = 11
TXNADD, TXNUPD, TXNDEL = 0, 1, 2

View File

@ -3,7 +3,7 @@
#
# Copyright (C) 2000-2007 Donald N. Allingham
# Copyright (C) 2010 Nick Hall
# Copyright (C) 2011 Tim G L Lyons
# Copyright (C) 2011-2013 Tim G L Lyons
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
@ -69,6 +69,7 @@ from ..lib.place import Place
from ..lib.repo import Repository
from ..lib.note import Note
from ..lib.tag import Tag
from ..lib.srctemplate import SrcTemplate
from ..lib.genderstats import GenderStats
from ..lib.researcher import Researcher
from ..lib.nameorigintype import NameOriginType
@ -93,7 +94,7 @@ from .dbconst import *
_SIGBASE = ('person', 'family', 'source', 'citation',
'event', 'media', 'place', 'repository',
'reference', 'note', 'tag')
'reference', 'note', 'tag', 'srctemplate')
DBERRS = (db.DBRunRecoveryError, db.DBAccessError,
db.DBPageNotFoundError, db.DBInvalidArgError)
@ -339,6 +340,14 @@ class DbBsddbRead(DbReadBase, Callback):
"cursor_func": self.get_tag_cursor,
"handles_func": self.get_tag_handles,
},
'SrcTemplate':
{
"handle_func": self.get_template_from_handle,
"gramps_id_func": None,
"class_func": SrcTemplate,
"cursor_func": self.get_template_cursor,
"handles_func": self.get_template_handles,
},
}
self.set_person_id_prefix('I%04d')
@ -394,6 +403,7 @@ class DbBsddbRead(DbReadBase, Callback):
self.nid_trans = {}
self.eid_trans = {}
self.tag_trans = {}
self.template_trans = {}
self.env = None
self.person_map = {}
self.family_map = {}
@ -404,6 +414,7 @@ class DbBsddbRead(DbReadBase, Callback):
self.note_map = {}
self.media_map = {}
self.event_map = {}
self.template_map = {}
self.metadata = {}
self.name_group = {}
self.undo_callback = None
@ -497,6 +508,9 @@ class DbBsddbRead(DbReadBase, Callback):
def get_tag_cursor(self, *args, **kwargs):
return self.get_cursor(self.tag_map, *args, **kwargs)
def get_template_cursor(self, *args, **kwargs):
return self.get_cursor(self.template_map, *args, **kwargs)
def close(self):
"""
Close the specified database.
@ -545,6 +559,7 @@ class DbBsddbRead(DbReadBase, Callback):
self.emit('repository-rebuild')
self.emit('note-rebuild')
self.emit('tag-rebuild')
self.emit('template-rebuild')
def __find_next_gramps_id(self, prefix, map_index, trans):
"""
@ -760,6 +775,14 @@ class DbBsddbRead(DbReadBase, Callback):
"""
return self.get_from_handle(handle, Tag, self.tag_map)
def get_template_from_handle(self, handle):
"""
Find a Tag in the database from the passed handle.
If no such Tag exists, None is returned.
"""
return self.get_from_handle(handle, SrcTemplate, self.template_map)
def __get_obj_from_gramps_id(self, val, tbl, class_, prim_tbl):
if isinstance(tbl, dict):
return None ## trying to get object too early
@ -968,6 +991,12 @@ class DbBsddbRead(DbReadBase, Callback):
"""
return self.get_number_of_records(self.tag_map)
def get_number_of_templates(self):
"""
Return the number of tags currently in the database.
"""
return self.get_number_of_records(self.template_map)
def all_handles(self, table):
""" return all the keys of a database table
CAREFUL: For speed the keys are directly returned, so on python3
@ -1137,6 +1166,24 @@ class DbBsddbRead(DbReadBase, Callback):
return handle_list
return []
def get_template_handles(self, sort_handles=False):
"""
Return a list of database handles, one handle for each Tag in
the database.
If sort_handles is True, the list is sorted by Tag name.
CAREFUL: For speed the keys are directly returned, so on python3
bytestrings are returned! Use constfunc.py handle2internal
on this result!
"""
if self.db_is_open:
handle_list = self.all_handles(self.template_map)
if sort_handles:
handle_list.sort(key=self.__sortbytemplate_key)
return handle_list
return []
def _f(curs_):
"""
Closure that returns an iterator over handles in the database.
@ -1159,6 +1206,7 @@ class DbBsddbRead(DbReadBase, Callback):
iter_repository_handles = _f(get_repository_cursor)
iter_note_handles = _f(get_note_cursor)
iter_tag_handles = _f(get_tag_cursor)
iter_template_handles = _f(get_template_cursor)
del _f
def _f(curs_, obj_):
@ -1185,6 +1233,7 @@ class DbBsddbRead(DbReadBase, Callback):
iter_repositories = _f(get_repository_cursor, Repository)
iter_notes = _f(get_note_cursor, Note)
iter_tags = _f(get_tag_cursor, Tag)
iter_templates = _f(get_template_cursor, SrcTemplate)
del _f
def get_gramps_ids(self, obj_key):
@ -1463,6 +1512,12 @@ class DbBsddbRead(DbReadBase, Callback):
return self.metadata.get(b'default')
return None
def get_GEDCOM_template_handle(self):
"""Return the handle of the GEDCOM template of the database."""
if self.metadata is not None:
return self.metadata.get(b'gedcom_template')
return None
def get_save_path(self):
"""Return the save path of the file, or "" if one does not exist."""
return self.path
@ -1627,6 +1682,9 @@ class DbBsddbRead(DbReadBase, Callback):
def get_raw_tag_data(self, handle):
return self.__get_raw_data(self.tag_map, handle)
def get_raw_template_data(self, handle):
return self.__get_raw_data(self.template_map, handle)
def __has_handle(self, table, handle):
"""
Helper function for has_<object>_handle methods
@ -1699,6 +1757,12 @@ class DbBsddbRead(DbReadBase, Callback):
"""
return self.__has_handle(self.tag_map, handle)
def has_template_handle(self, handle):
"""
Return True if the handle exists in the current Tag database.
"""
return self.__has_handle(self.template_map, handle)
def __sortbyperson_key(self, handle):
if isinstance(handle, UNITYPE):
handle = handle.encode('utf-8')
@ -1778,6 +1842,12 @@ class DbBsddbRead(DbReadBase, Callback):
tag = self.tag_map[key][1]
return glocale.sort_key(tag)
def __sortbytemplate_key(self, key):
if isinstance(key, UNITYPE):
key = key.encode('utf-8')
template = self.template_map[key][1]
return glocale.sort_key(template)
def set_mediapath(self, path):
"""Set the default media path for database, path should be utf-8."""
if (self.metadata is not None) and (not self.readonly):
@ -1855,6 +1925,10 @@ class DbBsddbRead(DbReadBase, Callback):
'cursor_func': self.get_tag_cursor,
'class_func': Tag,
},
'Template': {
'cursor_func': self.get_template_cursor,
'class_func': SrcTemplate,
},
}
# Find which tables to iterate over

View File

@ -3,7 +3,7 @@
#
# Copyright (C) 2000-2008 Donald N. Allingham
# Copyright (C) 2010 Nick Hall
# Copyright (C) 2011 Tim G L Lyons
# Copyright (C) 2011-2013 Tim G L Lyons
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
@ -66,6 +66,7 @@ from ..lib.repo import Repository
from ..lib.mediaobj import MediaObject
from ..lib.note import Note
from ..lib.tag import Tag
from ..lib.srctemplate import SrcTemplate
from ..lib.genderstats import GenderStats
from ..lib.researcher import Researcher
@ -98,6 +99,7 @@ NIDTRANS = "note_id"
SIDTRANS = "source_id"
CIDTRANS = "citation_id"
TAGTRANS = "tag_name"
TEMPLATETRANS = "template_name"
SURNAMES = "surnames"
NAME_GROUP = "name_group"
META = "meta_data"
@ -112,6 +114,7 @@ PERSON_TBL = "person"
REPO_TBL = "repo"
NOTE_TBL = "note"
TAG_TBL = "tag"
TEMPLATE_TBL = "template"
REF_MAP = "reference_map"
REF_PRI = "primary_map"
@ -135,7 +138,9 @@ CLASS_TO_KEY_MAP = {Person.__name__: PERSON_KEY,
Place.__name__: PLACE_KEY,
Repository.__name__:REPOSITORY_KEY,
Note.__name__: NOTE_KEY,
Tag.__name__: TAG_KEY}
Tag.__name__: TAG_KEY,
SrcTemplate.__name__: TEMPLATE_KEY,
}
KEY_TO_CLASS_MAP = {PERSON_KEY: Person.__name__,
FAMILY_KEY: Family.__name__,
@ -146,7 +151,9 @@ KEY_TO_CLASS_MAP = {PERSON_KEY: Person.__name__,
PLACE_KEY: Place.__name__,
REPOSITORY_KEY: Repository.__name__,
NOTE_KEY: Note.__name__,
TAG_KEY: Tag.__name__}
TAG_KEY: Tag.__name__,
TEMPLATE_KEY: SrcTemplate.__name__,
}
KEY_TO_NAME_MAP = {PERSON_KEY: 'person',
FAMILY_KEY: 'family',
@ -158,7 +165,9 @@ KEY_TO_NAME_MAP = {PERSON_KEY: 'person',
REPOSITORY_KEY: 'repository',
#REFERENCE_KEY: 'reference',
NOTE_KEY: 'note',
TAG_KEY: 'tag'}
TAG_KEY: 'tag',
TEMPLATE_KEY: 'template',
}
#-------------------------------------------------------------------------
#
# Helper functions
@ -237,7 +246,8 @@ class DbBsddb(DbBsddbRead, DbWriteBase, UpdateCallback):
__signals__ = dict((obj+'-'+op, signal)
for obj in
['person', 'family', 'event', 'place',
'source', 'citation', 'media', 'note', 'repository', 'tag']
'source', 'citation', 'media', 'note', 'repository', 'tag',
'template']
for op, signal in zip(
['add', 'update', 'delete', 'rebuild'],
[(list,), (list,), (list,), None]
@ -380,6 +390,17 @@ class DbBsddb(DbBsddbRead, DbWriteBase, UpdateCallback):
txn.put(b'default', handle)
self.emit('home-person-changed')
@catch_db_error
def set_GEDCOM_template_handle(self, handle):
"""Set the handle of the GEDCOM template to the passed instance."""
#we store a byte string!
if isinstance(handle, UNITYPE):
handle = handle.encode('utf-8')
if not self.readonly:
# Start transaction
with BSDDBTxn(self.env, self.metadata) as txn:
txn.put(b'gedcom_template', handle)
@catch_db_error
def get_default_person(self):
"""Return the default Person of the database."""
@ -555,7 +576,7 @@ class DbBsddb(DbBsddbRead, DbWriteBase, UpdateCallback):
# See if we lack write access to any files in the directory
for base in [FAMILY_TBL, PLACES_TBL, SOURCES_TBL, CITATIONS_TBL,
MEDIA_TBL, EVENTS_TBL, PERSON_TBL, REPO_TBL,
NOTE_TBL, REF_MAP, META]:
NOTE_TBL, TEMPLATE_TBL, REF_MAP, META]:
path = os.path.join(name, base + DBEXT)
if os.path.isfile(path) and not os.access(path, os.W_OK):
return True
@ -679,6 +700,7 @@ class DbBsddb(DbBsddbRead, DbWriteBase, UpdateCallback):
("repository_map", REPO_TBL, db.DB_HASH),
("note_map", NOTE_TBL, db.DB_HASH),
("tag_map", TAG_TBL, db.DB_HASH),
("template_map", TEMPLATE_TBL, db.DB_HASH),
("reference_map", REF_MAP, db.DB_BTREE),
]
@ -747,6 +769,12 @@ class DbBsddb(DbBsddbRead, DbWriteBase, UpdateCallback):
self.__open_undodb()
self.db_is_open = True
if gstats is None:
# FIXME gstat is used as a proxy to say whether the database is new
# or not, This is not a very clean approach
from gramps.plugins.srctemplates.importcsv import load_srctemplates_data
load_srctemplates_data(self)
if callback:
callback(87)
@ -861,6 +889,7 @@ class DbBsddb(DbBsddbRead, DbWriteBase, UpdateCallback):
("rid_trans", RIDTRANS, db.DB_HASH, 0),
("nid_trans", NIDTRANS, db.DB_HASH, 0),
("tag_trans", TAGTRANS, db.DB_HASH, 0),
("template_trans", TEMPLATETRANS, db.DB_HASH, 0),
("reference_map_primary_map", REF_PRI, db.DB_BTREE, 0),
("reference_map_referenced_map", REF_REF, db.DB_BTREE, db.DB_DUPSORT),
]
@ -884,6 +913,7 @@ class DbBsddb(DbBsddbRead, DbWriteBase, UpdateCallback):
(self.repository_map, self.rid_trans, find_idmap),
(self.note_map, self.nid_trans, find_idmap),
(self.tag_map, self.tag_trans, find_idmap),
(self.template_map, self.template_trans, find_idmap),
(self.reference_map, self.reference_map_primary_map,
find_primary_handle),
(self.reference_map, self.reference_map_referenced_map,
@ -925,6 +955,7 @@ class DbBsddb(DbBsddbRead, DbWriteBase, UpdateCallback):
( self.nid_trans, NIDTRANS ),
( self.cid_trans, CIDTRANS ),
( self.tag_trans, TAGTRANS ),
( self.template_trans, TEMPLATETRANS ),
( self.reference_map_primary_map, REF_PRI),
( self.reference_map_referenced_map, REF_REF),
]
@ -1197,6 +1228,7 @@ class DbBsddb(DbBsddbRead, DbWriteBase, UpdateCallback):
(self.get_repository_cursor, Repository),
(self.get_note_cursor, Note),
(self.get_tag_cursor, Tag),
(self.get_template_cursor, SrcTemplate),
)
# Now we use the functions and classes defined above
@ -1304,6 +1336,7 @@ class DbBsddb(DbBsddbRead, DbWriteBase, UpdateCallback):
self.cid_trans.close()
self.pid_trans.close()
self.tag_trans.close()
self.template_trans.close()
self.reference_map_primary_map.close()
self.reference_map_referenced_map.close()
self.reference_map.close()
@ -1321,6 +1354,7 @@ class DbBsddb(DbBsddbRead, DbWriteBase, UpdateCallback):
self.media_map.close()
self.event_map.close()
self.tag_map.close()
self.template_map.close()
self.env.close()
self.__close_undodb()
@ -1334,6 +1368,7 @@ class DbBsddb(DbBsddbRead, DbWriteBase, UpdateCallback):
self.media_map = None
self.event_map = None
self.tag_map = None
self.template_map = None
self.surnames = None
self.env = None
self.metadata = None
@ -1352,6 +1387,7 @@ class DbBsddb(DbBsddbRead, DbWriteBase, UpdateCallback):
self.media_map = None
self.event_map = None
self.tag_map = None
self.template_map = None
self.reference_map_primary_map = None
self.reference_map_referenced_map = None
self.reference_map = None
@ -1503,6 +1539,13 @@ class DbBsddb(DbBsddbRead, DbWriteBase, UpdateCallback):
"""
return self.__add_object(obj, transaction, None, self.commit_tag)
def add_template(self, obj, transaction):
"""
Add a Template to the database, assigning a handle if it has not already
been defined.
"""
return self.__add_object(obj, transaction, None, self.commit_template)
def __do_remove(self, handle, transaction, data_map, key):
if self.readonly or not handle:
return
@ -1617,6 +1660,14 @@ class DbBsddb(DbBsddbRead, DbWriteBase, UpdateCallback):
self.__do_remove(handle, transaction, self.tag_map,
TAG_KEY)
def remove_template(self, handle, transaction):
"""
Remove the Template specified by the database handle from the
database, preserving the change in the passed transaction.
"""
self.__do_remove(handle, transaction, self.template_map,
TEMPLATE_KEY)
@catch_db_error
def set_name_group_mapping(self, name, group):
if not self.readonly:
@ -1945,6 +1996,14 @@ class DbBsddb(DbBsddbRead, DbWriteBase, UpdateCallback):
self.commit_base(tag, self.tag_map, TAG_KEY,
transaction, change_time)
def commit_template(self, tag, transaction, change_time=None):
"""
Commit the specified Template to the database, storing the changes as part
of the transaction.
"""
self.commit_base(tag, self.template_map, TEMPLATE_KEY,
transaction, change_time)
def get_from_handle(self, handle, class_type, data_map):
if isinstance(handle, UNITYPE):
handle = handle.encode('utf-8')

View File

@ -55,12 +55,9 @@ from .repo import Repository
from .note import Note
from .citation import Citation
# Logical objects
from .srctemplate import SrcTemplate
from .srctemplatelist import SrcTemplateList
# Table objects
from .tag import Tag
from .srctemplate import SrcTemplate
# These are actually metadata
from .genderstats import GenderStats

View File

@ -46,7 +46,6 @@ from .datebase import DateBase
from .tagbase import TagBase
from .srcattrbase import SrcAttributeBase
from .srctemplate import SrcTemplate
from .srctemplatelist import SrcTemplateList
from ..constfunc import cuni, deprecated
from .handle import Handle
@ -329,20 +328,3 @@ class Citation(MediaBase, NoteBase, SrcAttributeBase, PrimaryObject, DateBase):
reference information
"""
return self.get_name()
def get_gedcom_page(self, templatekey):
"""
Return the descriptive page part as used in GEDCOM
page depends on the source template. The logic is:
1. obtain template, if no key given, name of citation is used
2. create page from the 'full' reference
:returns: Returns the descriptive page part of the citation
:rtype: str
"""
attrlist = self.get_attribute_list()
if templatekey:
stemp = SrcTemplateList().get_template_from_name(templatekey)
return stemp.page_gedcom(attrlist)
else:
return self.get_name()

View File

@ -58,7 +58,7 @@ class Source(MediaBase, NoteBase, SrcAttributeBase, PrimaryObject):
NoteBase.__init__(self)
SrcAttributeBase.__init__(self)
self.name = ""
self.template = 'GEDCOM'
self.template = None
self.abbrev = ""
self.reporef_list = []
@ -69,7 +69,7 @@ class Source(MediaBase, NoteBase, SrcAttributeBase, PrimaryObject):
return (self.handle, # 0
self.gramps_id, # 1
cuni(self.name), # 2
cuni(self.template), # 3
self.template, # 3
NoteBase.serialize(self), # 4
MediaBase.serialize(self), # 5
cuni(self.abbrev), # 6
@ -428,52 +428,15 @@ class Source(MediaBase, NoteBase, SrcAttributeBase, PrimaryObject):
@deprecated
def get_title(self):
return self.get_gedcom_title()
return "title not available"
# return self.get_gedcom_title()
@deprecated
def get_author(self):
return self.get_gedcom_author()
return "author not available"
# return self.get_gedcom_author()
@deprecated
def get_publication_info(self):
return self.get_gedcom_publication_info()
def get_gedcom_title(self):
"""
Return the descriptive title of the source
Title depends on the source template. The logic is:
1. obtain template
2. create title from the 'full' reference
3. if no template, it defaults to GEDCOM, so TITLE will be used
:returns: Returns the descriptive title of the source
:rtype: str
"""
attrlist = self.get_attribute_list()
stemp = SrcTemplateList().get_template_from_name(self.get_template())
return stemp.title_gedcom(attrlist)
def get_gedcom_author(self):
"""Return the author of the Source.
Author depends on the source template. The logic is:
1. obtain template
2. create author from the 'full' reference
3. if no template, it defaults to GEDCOM, so AUTHOR will be used
"""
attrlist = self.get_attribute_list()
stemp = SrcTemplateList().get_template_from_name(self.get_template())
return stemp.author_gedcom(attrlist)
def get_gedcom_publication_info(self):
"""Return the publication information of the Source.
PubInfo depends on the source template. The logic is:
1. obtain template
2. create pubinfo from the 'full' reference
3. if no template, it defaults to GEDCOM, so PUB_INFO will be used
"""
attrlist = self.get_attribute_list()
stemp = SrcTemplateList().get_template_from_name(self.get_template())
return stemp.pubinfo_gedcom(attrlist)
return "pubinfo not available"
# return self.get_gedcom_publication_info()

View File

@ -3,6 +3,7 @@
# Gramps - a GTK+/GNOME based genealogy program
#
# Copyright (C) 2013 Benny Malengier
# Copyright (C) 2013 Tim G L Lyons
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
@ -88,560 +89,124 @@ class SrcAttributeType(GrampsType):
# PREDEFINED TYPES
UNKNOWN = -1
CUSTOM = 0
# GEDCOM support
EVEN_REC = 2
EVEN_CITED = 3
EVEN_ROLE = 4
GEN_BY = 5
# Special fields which double existing database
# 1. repository fields
REPOSITORY = 10
REPOSITORY_ADDRESS = 11
REPOSITORY_SHORT_VERSION = 12
REPOSITORY_CALL_NUMBER = 13
# 2. existing class attributes
DATE = 14
_DATAMAP = [
(UNKNOWN , _("Unknown"), "Unknown"),
(CUSTOM , _("Custom"), "Custom"),
# GEDCOM support
(EVEN_REC , _("Events Recorded in Source"), "Events Recorded in Source"), # GEDCOM EVENTS_RECORDED
(EVEN_CITED , _("Event Type Used for Citation"), "Event Type Used for Citation"), # GEDCOM EVENT_TYPE_CITED_FROM
(EVEN_ROLE , _("Role in Event Cited from"), "Role in Event Cited from"), # GEDCOM ROLE_IN_EVENT
(GEN_BY , _("Generated by"), "Generated by"), # Generated sources on import
(REPOSITORY, _("Repository"), "Repository"),
(REPOSITORY_ADDRESS, _("Repository address"), "Repository address"),
(REPOSITORY_SHORT_VERSION, _("Repository (Short)"), "Repository (Short)"),
(REPOSITORY_CALL_NUMBER, _("Repository call number"), "Repository call number"),
(DATE, _("Date"), "Date"),
# possible fields for evidence styles need to be added next
]
#following fields are generated with evidencefieldgenerator.py
#the index starts at 100!
ACT = 226
ACT_SHORT_VERSION = 227
ADDRESS = 155
AFFILIATION = 160
AUTHOR = 100
AUTHOR_LOCATION = 170
AUTHOR_SHORT_VERSION = 107
BOOK = 203
BOOK_SHORT_VERSION = 204
CASE = 198
CASE_SHORT_VERSION = 200
CEMETERY = 176
CEMETERY_SHORT_VERSION = 178
CHAPTER = 228
CHAPTER_PAGES = 217
COLLECTION = 104
COLLECTION_SHORT_VERSION = 109
COLUMN = 235
COLUMN_SHORT_VERSION = 236
COMPILER = 163
COMPILER_SHORT_VERSION = 194
CREATION_DATE = 103
CREATION_DATE_SHORT_VERSION = 141
CREATOR = 190
CREATOR_SHORT_VERSION = 213
CREDIT_LINE = 116
DATE_ACCESSED = 114
DATE_RANGE = 133
DATE_SHORT_VERSION = 156
DESCRIPTION = 139
DISTRICT = 188
DISTRICT_SHORT_VERSION = 189
DIVISION = 182
DIVISION_SHORT_VERSION = 186
EDITION = 221
EDITOR = 216
EDITOR_SHORT_VERSION = 218
FILE = 129
FILE_DATE = 206
FILE_DATE_SHORT_VERSION = 207
FILE_LOCATION = 166
FILE_NO = 128
FILE_NO_SHORT_VERSION = 199
FILE_SHORT_VERSION = 152
FILE_UNIT = 143
FILE_UNIT_SHORT_VERSION = 179
FILM_ID = 191
FILM_PUBLICATION_PLACE = 223
FILM_PUBLISHER = 224
FILM_TYPE = 147
FORMAT = 159
FRAME = 205
GROUP = 167
GROUP_SHORT_VERSION = 174
HOUSEHOLD = 183
HOUSEHOLD_SHORT_VERSION = 187
ID = 127
ID_SHORT_VERSION = 131
INSTITUTION = 173
INSTITUTION_SHORT_VERSION = 175
INTERVIEWER = 158
ISSUE_DATE = 231
ISSUE_DATE_SHORT_VERSION = 238
ISSUE_RANGE = 234
ITEM_OF_INTEREST = 119
ITEM_OF_INTEREST_SHORT_VERSION = 150
JURISDICTION = 180
JURISDICTION_SHORT_VERSION = 184
LOCATION = 157
LOCATION_SHORT_VERSION = 195
NUMBER = 105
NUMBER_6TOTAL9 = 144
NUMBER_SHORT_VERSION = 120
ORIGINAL_REPOSITORY = 145
ORIGINAL_REPOSITORY_LOCATION = 146
ORIGINAL_YEAR = 220
PAGE = 115
PAGE_RANGE = 232
PAGE_SHORT_VERSION = 118
PART = 225
PLACE_CREATED = 154
POSITION = 177
POSITION_SHORT_VERSION = 233
POSTING_DATE = 237
PROFESSIONAL_CREDENTIALS = 142
PROVENANCE = 164
PUBLICATION_FORMAT = 209
PUBLICATION_PLACE = 134
PUBLICATION_TITLE = 208
PUBLICATION_TITLE_SHORT_VERSION = 214
PUBLICATION_YEAR = 136
PUBLICATION_YEAR_SHORT_VERSION = 197
PUBLISHER = 135
PUB_INFO = 239
RECIPIENT = 126
RECIPIENT_SHORT_VERSION = 130
RELATIONSHIP = 165
REPORT_DATE = 162
REPORT_DATE_SHORT_VERSION = 171
RESEARCH_COMMENT = 106
RESEARCH_COMMENT_SHORT_VERSION = 137
RESEARCH_PROJECT = 161
ROLL = 151
ROLL_SHORT_VERSION = 196
SCHEDULE = 181
SCHEDULE_SHORT_VERSION = 185
SECTION = 148
SECTION_SHORT_VERSION = 149
SERIES = 122
SERIES_NO = 121
SERIES_NO_SHORT_VERSION = 124
SERIES_SHORT_VERSION = 132
SESSION = 229
SESSION_SHORT_VERSION = 230
SHEET_NO = 192
SHEET_NO_SHORT_VERSION = 193
SUBJECT = 138
SUBJECT_SHORT_VERSION = 140
SUBSERIES = 168
SUBSERIES_SHORT_VERSION = 169
SUBTITLE = 215
TERM = 201
TERM_SHORT_VERSION = 202
TIMESTAMP = 210
TIMESTAMP_SHORT_VERSION = 211
TITLE = 101
TITLE_SHORT_VERSION = 108
TRANSLATION = 222
TYPE = 102
TYPE_SHORT_VERSION = 153
URL_6DIGITAL_LOCATION9 = 112
VOLUME = 123
VOLUME_INFO = 219
VOLUME_SHORT_VERSION = 125
WEBSITE = 111
WEBSITE_CREATOR_OR_OWNER = 110
WEBSITE_SHORT_VERSION = 117
YEAR = 113
YEAR_ACCESSED = 172
YEAR_SHORT_VERSION = 212
]
# All the SrcAttributeTypes are specified as CUSTOM attributes. This is to
# allow users complete control over the attributes that are present so they
# need only have exactly those attributes that they want. Other attributes
# are only defined in source/citation templates.
# N.B. The attribute values are specified as strings, rather than the
# integers that would be normal for normal pre-defined attributes
# Some attributes are used internally in core Gramps and so are defined
# here.
# The following attributes are used in GEDCOM import and upgrade of
# databases from Gramps versions prior to 4.1 (including xml import). If no
# GEDCOM files are imported, they don't need to be defined.
TITLE = "Title"
AUTHOR = "Author"
PUB_INFO = "Pub_info"
PAGE = "Page"
# The following are used in GEDCOM import and export
EVEN_CITED = "Event Type Used for Citation" # GEDCOM EVENT_TYPE_CITED_FROM
EVEN_ROLE = "Role in Event Cited from" # GEDCOM ROLE_IN_EVENT
# The following is used in GEDCOM import only
GEN_BY = "Generated by" # Generated sources on import
# The following probably should be used in GEDCOM import and export, but
# don't appear there yet
EVEN_REC = "Events Recorded in Source" # GEDCOM EVENTS_RECORDED
# The following are special cased in template processing
REPOSITORY = "Repository"
REPOSITORY_ADDRESS = "Repository address"
REPOSITORY_SHORT_VERSION = "Repository (Short)"
REPOSITORY_CALL_NUMBER = "Repository call number"
DATE = "Date"
# All the special case attributes need to be specified as translatable
# strings so they can be picked up during extraction of translatable strings
if False:
_("Title")
_("Author")
_("Pub_info")
_("Page")
_("Event Type Used for Citation")
_("Role in Event Cited from")
_("Generated by")
_("Events Recorded in Source")
_("Repository")
_("Repository address")
_("Repository (Short)")
_("Repository call number")
_("Date")
_CUSTOM = CUSTOM
_DEFAULT = TITLE
# _DEFAULT = TITLE
_DATAMAPIGNORE = [
AUTHOR_SHORT_VERSION,
TITLE_SHORT_VERSION,
COLLECTION_SHORT_VERSION,
WEBSITE_SHORT_VERSION,
PAGE_SHORT_VERSION,
NUMBER_SHORT_VERSION,
SERIES_NO_SHORT_VERSION,
VOLUME_SHORT_VERSION,
RECIPIENT_SHORT_VERSION,
ID_SHORT_VERSION,
SERIES_SHORT_VERSION,
RESEARCH_COMMENT_SHORT_VERSION,
SUBJECT_SHORT_VERSION,
CREATION_DATE_SHORT_VERSION,
SECTION_SHORT_VERSION,
ITEM_OF_INTEREST_SHORT_VERSION,
FILE_SHORT_VERSION,
TYPE_SHORT_VERSION,
DATE_SHORT_VERSION,
SUBSERIES_SHORT_VERSION,
REPORT_DATE_SHORT_VERSION,
GROUP_SHORT_VERSION,
INSTITUTION_SHORT_VERSION,
CEMETERY_SHORT_VERSION,
FILE_UNIT_SHORT_VERSION,
JURISDICTION_SHORT_VERSION,
SCHEDULE_SHORT_VERSION,
DIVISION_SHORT_VERSION,
HOUSEHOLD_SHORT_VERSION,
DISTRICT_SHORT_VERSION,
SHEET_NO_SHORT_VERSION,
COMPILER_SHORT_VERSION,
LOCATION_SHORT_VERSION,
ROLL_SHORT_VERSION,
PUBLICATION_YEAR_SHORT_VERSION,
FILE_NO_SHORT_VERSION,
CASE_SHORT_VERSION,
TERM_SHORT_VERSION,
BOOK_SHORT_VERSION,
FILE_DATE_SHORT_VERSION,
TIMESTAMP_SHORT_VERSION,
YEAR_SHORT_VERSION,
CREATOR_SHORT_VERSION,
PUBLICATION_TITLE_SHORT_VERSION,
EDITOR_SHORT_VERSION,
ACT_SHORT_VERSION,
SESSION_SHORT_VERSION,
POSITION_SHORT_VERSION,
COLUMN_SHORT_VERSION,
ISSUE_DATE_SHORT_VERSION,
"Act (Short)",
"Author (Short)",
"Book (Short)",
"Case (Short)",
"Cemetery (Short)",
"Collection (Short)",
"Column (Short)",
"Compiler (Short)",
"Creation date (Short)",
"Creator (Short)",
"Date (Short)",
"District (Short)",
"Division (Short)",
"Editor (Short)",
"File date (Short)",
"File no. (Short)",
"File (Short)",
"File unit (Short)",
"Group (Short)",
"Household (Short)",
"Id (Short)",
"Institution (Short)",
"Issue date (Short)",
"Item of interest (Short)",
"Jurisdiction (Short)",
"Location (Short)",
"Number (Short)",
"Page (Short)",
"Position (Short)",
"Publication title (Short)",
"Publication year (Short)",
"Recipient (Short)",
"Report date (Short)",
"Research comment (Short)",
"Roll (Short)",
"Schedule (Short)",
"Section (Short)",
"Series no. (Short)",
"Series (Short)",
"Session (Short)",
"Sheet no. (Short)",
"Subject (Short)",
"Subseries (Short)",
"Term (Short)",
"Timestamp (Short)",
"Title (Short)",
"Type (Short)",
"Volume (Short)",
"Website (Short)",
"Year (Short)",
]
_DATAMAP += [
(ACT, _("Act"), "Act"),
(ACT_SHORT_VERSION, _("Act (Short)"), "Act (Short)"),
(ADDRESS, _("Address"), "Address"),
(AFFILIATION, _("Affiliation"), "Affiliation"),
(AUTHOR, _("Author"), "Author"),
(AUTHOR_LOCATION, _("Author location"), "Author location"),
(AUTHOR_SHORT_VERSION, _("Author (Short)"), "Author (Short)"),
(BOOK, _("Book"), "Book"),
(BOOK_SHORT_VERSION, _("Book (Short)"), "Book (Short)"),
(CASE, _("Case"), "Case"),
(CASE_SHORT_VERSION, _("Case (Short)"), "Case (Short)"),
(CEMETERY, _("Cemetery"), "Cemetery"),
(CEMETERY_SHORT_VERSION, _("Cemetery (Short)"), "Cemetery (Short)"),
(CHAPTER, _("Chapter"), "Chapter"),
(CHAPTER_PAGES, _("Chapter pages"), "Chapter pages"),
(COLLECTION, _("Collection"), "Collection"),
(COLLECTION_SHORT_VERSION, _("Collection (Short)"), "Collection (Short)"),
(COLUMN, _("Column"), "Column"),
(COLUMN_SHORT_VERSION, _("Column (Short)"), "Column (Short)"),
(COMPILER, _("Compiler"), "Compiler"),
(COMPILER_SHORT_VERSION, _("Compiler (Short)"), "Compiler (Short)"),
(CREATION_DATE, _("Creation date"), "Creation date"),
(CREATION_DATE_SHORT_VERSION, _("Creation date (Short)"), "Creation date (Short)"),
(CREATOR, _("Creator"), "Creator"),
(CREATOR_SHORT_VERSION, _("Creator (Short)"), "Creator (Short)"),
(CREDIT_LINE, _("Credit line"), "Credit line"),
(DATE_ACCESSED, _("Date accessed"), "Date accessed"),
(DATE_RANGE, _("Date range"), "Date range"),
(DATE_SHORT_VERSION, _("Date (Short)"), "Date (Short)"),
(DESCRIPTION, _("Description"), "Description"),
(DISTRICT, _("District"), "District"),
(DISTRICT_SHORT_VERSION, _("District (Short)"), "District (Short)"),
(DIVISION, _("Division"), "Division"),
(DIVISION_SHORT_VERSION, _("Division (Short)"), "Division (Short)"),
(EDITION, _("Edition"), "Edition"),
(EDITOR, _("Editor"), "Editor"),
(EDITOR_SHORT_VERSION, _("Editor (Short)"), "Editor (Short)"),
(FILE, _("File"), "File"),
(FILE_DATE, _("File date"), "File date"),
(FILE_DATE_SHORT_VERSION, _("File date (Short)"), "File date (Short)"),
(FILE_LOCATION, _("File location"), "File location"),
(FILE_NO, _("File no."), "File no."),
(FILE_NO_SHORT_VERSION, _("File no. (Short)"), "File no. (Short)"),
(FILE_SHORT_VERSION, _("File (Short)"), "File (Short)"),
(FILE_UNIT, _("File unit"), "File unit"),
(FILE_UNIT_SHORT_VERSION, _("File unit (Short)"), "File unit (Short)"),
(FILM_ID, _("Film id"), "Film id"),
(FILM_PUBLICATION_PLACE, _("Film publication place"), "Film publication place"),
(FILM_PUBLISHER, _("Film publisher"), "Film publisher"),
(FILM_TYPE, _("Film type"), "Film type"),
(FORMAT, _("Format"), "Format"),
(FRAME, _("Frame"), "Frame"),
(GROUP, _("Group"), "Group"),
(GROUP_SHORT_VERSION, _("Group (Short)"), "Group (Short)"),
(HOUSEHOLD, _("Household"), "Household"),
(HOUSEHOLD_SHORT_VERSION, _("Household (Short)"), "Household (Short)"),
(ID, _("Id"), "Id"),
(ID_SHORT_VERSION, _("Id (Short)"), "Id (Short)"),
(INSTITUTION, _("Institution"), "Institution"),
(INSTITUTION_SHORT_VERSION, _("Institution (Short)"), "Institution (Short)"),
(INTERVIEWER, _("Interviewer"), "Interviewer"),
(ISSUE_DATE, _("Issue date"), "Issue date"),
(ISSUE_DATE_SHORT_VERSION, _("Issue date (Short)"), "Issue date (Short)"),
(ISSUE_RANGE, _("Issue range"), "Issue range"),
(ITEM_OF_INTEREST, _("Item of interest"), "Item of interest"),
(ITEM_OF_INTEREST_SHORT_VERSION, _("Item of interest (Short)"), "Item of interest (Short)"),
(JURISDICTION, _("Jurisdiction"), "Jurisdiction"),
(JURISDICTION_SHORT_VERSION, _("Jurisdiction (Short)"), "Jurisdiction (Short)"),
(LOCATION, _("Location"), "Location"),
(LOCATION_SHORT_VERSION, _("Location (Short)"), "Location (Short)"),
(NUMBER, _("Number"), "Number"),
(NUMBER_6TOTAL9, _("Number (total)"), "Number (total)"),
(NUMBER_SHORT_VERSION, _("Number (Short)"), "Number (Short)"),
(ORIGINAL_REPOSITORY, _("Original repository"), "Original repository"),
(ORIGINAL_REPOSITORY_LOCATION, _("Original repository location"), "Original repository location"),
(ORIGINAL_YEAR, _("Original year"), "Original year"),
(PAGE, _("Page"), "Page"),
(PAGE_RANGE, _("Page range"), "Page range"),
(PAGE_SHORT_VERSION, _("Page (Short)"), "Page (Short)"),
(PART, _("Part"), "Part"),
(PLACE_CREATED, _("Place created"), "Place created"),
(POSITION, _("Position"), "Position"),
(POSITION_SHORT_VERSION, _("Position (Short)"), "Position (Short)"),
(POSTING_DATE, _("Posting date"), "Posting date"),
(PROFESSIONAL_CREDENTIALS, _("Professional credentials"), "Professional credentials"),
(PROVENANCE, _("Provenance"), "Provenance"),
(PUBLICATION_FORMAT, _("Publication format"), "Publication format"),
(PUBLICATION_PLACE, _("Publication place"), "Publication place"),
(PUBLICATION_TITLE, _("Publication title"), "Publication title"),
(PUBLICATION_TITLE_SHORT_VERSION, _("Publication title (Short)"), "Publication title (Short)"),
(PUBLICATION_YEAR, _("Publication year"), "Publication year"),
(PUBLICATION_YEAR_SHORT_VERSION, _("Publication year (Short)"), "Publication year (Short)"),
(PUBLISHER, _("Publisher"), "Publisher"),
(PUB_INFO, _("Pub_info"), "Pub_info"),
(RECIPIENT, _("Recipient"), "Recipient"),
(RECIPIENT_SHORT_VERSION, _("Recipient (Short)"), "Recipient (Short)"),
(RELATIONSHIP, _("Relationship"), "Relationship"),
(REPORT_DATE, _("Report date"), "Report date"),
(REPORT_DATE_SHORT_VERSION, _("Report date (Short)"), "Report date (Short)"),
(RESEARCH_COMMENT, _("Research comment"), "Research comment"),
(RESEARCH_COMMENT_SHORT_VERSION, _("Research comment (Short)"), "Research comment (Short)"),
(RESEARCH_PROJECT, _("Research project"), "Research project"),
(ROLL, _("Roll"), "Roll"),
(ROLL_SHORT_VERSION, _("Roll (Short)"), "Roll (Short)"),
(SCHEDULE, _("Schedule"), "Schedule"),
(SCHEDULE_SHORT_VERSION, _("Schedule (Short)"), "Schedule (Short)"),
(SECTION, _("Section"), "Section"),
(SECTION_SHORT_VERSION, _("Section (Short)"), "Section (Short)"),
(SERIES, _("Series"), "Series"),
(SERIES_NO, _("Series no."), "Series no."),
(SERIES_NO_SHORT_VERSION, _("Series no. (Short)"), "Series no. (Short)"),
(SERIES_SHORT_VERSION, _("Series (Short)"), "Series (Short)"),
(SESSION, _("Session"), "Session"),
(SESSION_SHORT_VERSION, _("Session (Short)"), "Session (Short)"),
(SHEET_NO, _("Sheet no."), "Sheet no."),
(SHEET_NO_SHORT_VERSION, _("Sheet no. (Short)"), "Sheet no. (Short)"),
(SUBJECT, _("Subject"), "Subject"),
(SUBJECT_SHORT_VERSION, _("Subject (Short)"), "Subject (Short)"),
(SUBSERIES, _("Subseries"), "Subseries"),
(SUBSERIES_SHORT_VERSION, _("Subseries (Short)"), "Subseries (Short)"),
(SUBTITLE, _("Subtitle"), "Subtitle"),
(TERM, _("Term"), "Term"),
(TERM_SHORT_VERSION, _("Term (Short)"), "Term (Short)"),
(TIMESTAMP, _("Timestamp"), "Timestamp"),
(TIMESTAMP_SHORT_VERSION, _("Timestamp (Short)"), "Timestamp (Short)"),
(TITLE, _("Title"), "Title"),
(TITLE_SHORT_VERSION, _("Title (Short)"), "Title (Short)"),
(TRANSLATION, _("Translation"), "Translation"),
(TYPE, _("Type"), "Type"),
(TYPE_SHORT_VERSION, _("Type (Short)"), "Type (Short)"),
(URL_6DIGITAL_LOCATION9, _("Url (digital location)"), "Url (digital location)"),
(VOLUME, _("Volume"), "Volume"),
(VOLUME_INFO, _("Volume info"), "Volume info"),
(VOLUME_SHORT_VERSION, _("Volume (Short)"), "Volume (Short)"),
(WEBSITE, _("Website"), "Website"),
(WEBSITE_CREATOR_OR_OWNER, _("Website creator/owner"), "Website creator/owner"),
(WEBSITE_SHORT_VERSION, _("Website (Short)"), "Website (Short)"),
(YEAR, _("Year"), "Year"),
(YEAR_ACCESSED, _("Year accessed"), "Year accessed"),
(YEAR_SHORT_VERSION, _("Year (Short)"), "Year (Short)"),
]
_DEFAULT_HINTS = {
ACT: _("Public Law 12-98"),
ADDRESS: _("Broadway Avenue, New York"),
AFFILIATION: _("Agent of Gramps Software"),
AUTHOR: _("Doe, D.P. & Cameron, E."),
AUTHOR_LOCATION: _("Chicago"),
BOOK: _("The big example Gramps manual"),
CASE: _("B. Malengier versus N. Hall"),
CEMETERY: _("Greenwich Cemetery Office"),
CHAPTER: _("The first office of T. Rooseveld"),
CHAPTER_PAGES: _("24-55"),
COLLECTION: _("Bruges Lace Collection"),
COLUMN: _("col. 3"),
COMPILER: _("T. Da Silva"),
CREATION_DATE: _("13 Aug 1965"),
CREATOR: _("P. Picasso"),
CREDIT_LINE: _("Based on unnamed document lost in fire"),
DATE: _("17 Sep 1745"),
DATE_ACCESSED: _("18 Jun 2013"),
DATE_RANGE: _("2003-6"),
DESCRIPTION: _("The lace has inscriptions with names of nobility"),
DISTRICT: _("Enumeration district (ED) 14"),
DIVISION: _("Peterburg Post Office, or Portland, ward 4"),
EDITION: _("Second Edition"),
EDITOR: _("Hoover, J.E."),
FILE: _("Membership application J. Rapinat"),
FILE_DATE: _("15 Jan 1870"),
FILE_LOCATION: _("Accession 7, Box 3"),
FILE_NO: _("1243-EB-98"),
FILE_UNIT: _("Letters to George Washington"),
FILM_ID: _("T345"),
FILM_PUBLICATION_PLACE: _("Kansas City"),
FILM_PUBLISHER: _("NY Genealogy Association"),
FILM_TYPE: _("FHL microfilm"),
FORMAT: _("Digital Images, or Database, or Cards, ..."),
FRAME: _("frames 387-432"),
GROUP: _("Miami Patent Office"),
HOUSEHOLD: _("dwelling 345, family 654"),
ID: _("I50-68, or 1910 U.S. census, or ..."),
INSTITUTION: _("Sorbonne University"),
INTERVIEWER: _("Materley, B."),
ISSUE_DATE: _("Jun 2004"),
ISSUE_RANGE: _("145-394, scattered issues"),
ITEM_OF_INTEREST: _("entry for G. Galileo, or Doe Household, or A. Einstein Grave ..."),
JURISDICTION: _("Jackson County, Alabama"),
LOCATION: _("Istanbul"),
NUMBER: _("2, or Record Group 34, or ..."),
NUMBER_6TOTAL9: _("5"),
ORIGINAL_REPOSITORY: _("National Archives"),
ORIGINAL_REPOSITORY_LOCATION: _("Washington, D.C."),
ORIGINAL_YEAR: _("1966"),
PAGE: _("5; or 4,6-8, ..."),
PAGE_RANGE: _("1-13"),
PART: _("Part 3"),
PLACE_CREATED: _("London"),
POSITION: _("written in the left margin, or second row, 3th line"),
POSTING_DATE: _("5 Jul 1799"),
PROFESSIONAL_CREDENTIALS: _("Prof.; or Dr. ..."),
PROVENANCE: _("add provenance of the material"),
PUBLICATION_FORMAT: _("CD-ROM or eprint or ..."),
PUBLICATION_PLACE: _("Berlin"),
PUBLICATION_TITLE: _("Title of Blog, Newsletter, DVD, ..."),
PUBLICATION_YEAR: _("2014"),
PUBLISHER: _("Springer"),
PUB_INFO: _("Springer, Berlin, 2014"),
RECIPIENT: _("J. Ralls"),
RELATIONSHIP: _("Paul's uncle and brother of Erik"),
REPORT_DATE: _("3 May 1999"),
RESEARCH_COMMENT: _("Descriptive detail or provenance or research analysis conclusion, ..."),
RESEARCH_PROJECT: _("Tahiti Natives"),
ROLL: _("176, or rolls 145-160"),
SCHEDULE: _("population schedule or slave schedule or ..."),
SECTION: _("1890 section or ER patients or ..."),
SERIES: _("Carnival County Records"),
SERIES_NO: _("series 34-38"),
SESSION: _("2nd session"),
SHEET_NO: _("sheet 13-C"),
SUBJECT: _("D. Copernicus and close family"),
SUBTITLE: _("Subtitle of article or magazine ..."),
TERM: _("June Term 1934 or 13th Congress or Reagan Office or ..."),
TIMESTAMP: _("min. 34-36"),
TITLE: _("Diary Title, Message Title, Bible Name, Article Title, ..."),
TRANSLATION: _("A translated version, typically of the title"),
TYPE: _("Letter"),
URL_6DIGITAL_LOCATION9: _("http://gramps-project.org/blog"),
VOLUME: _("4"),
VOLUME_INFO: _("5 volumes"),
WEBSITE: _("gramps-project.org"),
WEBSITE_CREATOR_OR_OWNER: _("Family Historians Inc"),
YEAR: _("1888"),
YEAR_ACCESSED: _("2013"),
}
_DEFAULT_TOOLTIPS = {
ACT: _("A statute or law name passed by a legislature"),
ADDRESS: _("Store address information. Set Private if needed! Give information from lowest to highest level separated by comma's"),
AFFILIATION: _("A relevant affiliation that might influence data in the source"),
AUTHOR: _("Give names in following form: 'FirstAuthorSurname, Given Names & SecondAuthorSurname, Given Names'. Like this Gramps can parse the name and shorten as needed."),
AUTHOR_LOCATION: _("City where author resides or wrote."),
BOOK: _("Title of the Book"),
CASE: _("Dispute between opposing parties in a court of law."),
CEMETERY: _("Name of cemetery or cemetery office with sources."),
CHAPTER_PAGES: _("The pages in the chapter."),
COMPILER: _("The name of the person who compiled the source."),
CREATOR: _("The name of the creator of the artifact."),
CREDIT_LINE: _("Acknowledgement of writers and contributors"),
DATE_RANGE: _("The range of years which are present in the source."),
DESCRIPTION: _("Some important detail of the source."),
DISTRICT: _("District as handled by Census"),
DIVISION: _("The subdivision of a larger group that is handled in the source."),
EDITOR: _("The Editor of a multi-author book."),
FILE: _("The title of a specific file in a source."),
FILE_DATE: _("Date of submitting the document to a clerk or court."),
FILE_LOCATION: _("Accession method to the file"),
FILE_NO: _("Number to indicate a file"),
FILE_UNIT: _("A grouping unit for a number of files in a source."),
FILM_ID: _("ID of a Microfilm."),
FILM_TYPE: _("The type of the microfilm."),
FORMAT: _("The format of the source."),
FRAME: _("What frames in the source are relevant."),
GROUP: _("A larger grouping to which the source belongs."),
HOUSEHOLD: _("Household of interest on a census."),
ID: _("ID to identify the source or citation part"),
INSTITUTION: _("Institution that issued the source."),
ISSUE_DATE: _("Date the source was issued."),
ISSUE_RANGE: _("A range of magazine, journal, ... issues covered in the source"),
ITEM_OF_INTEREST: _("Specific part, item, or person of interest in the source"),
JURISDICTION: _("Area with a set of laws under the control of a system of courts or government entity. Enter this from lowest to highest relevant jurisdiction, separated by comma's."),
LOCATION: _("City that is relevant."),
NUMBER: _("A number."),
NUMBER_6TOTAL9: _("The maximum of entities available."),
ORIGINAL_REPOSITORY: _("Name of the repository where the original is stored."),
ORIGINAL_REPOSITORY_LOCATION: _("Address or only city of the repository where the original is stored."),
ORIGINAL_YEAR: _("Year the original source was published/created"),
PAGE: _("The page or page(s) relevant for the citation"),
PAGE_RANGE: _("The range of the pages in the source. The page given for a citation must be in this range."),
POSITION: _("Where in or on the source the citation piece can be found."),
PROVENANCE: _("Where the material originated from."),
PUB_INFO: _("Publication Information, such as city and year of publication, name of publisher, ..."),
RECIPIENT: _("The person to who the letter is addressed."),
RELATIONSHIP: _("The relationship of the author to the person of interest that is the subject."),
REPORT_DATE: _("Date the report was written/submitted."),
RESEARCH_COMMENT: _("Descriptive detail or provenance or research analysis conclusion, ..."),
RESEARCH_PROJECT: _("The genealogical or scientific research project."),
ROLL: _("The Microfilm role."),
SCHEDULE: _("The census schedule (the type of census table) used, eg population schedule or slave schedule. or ..."),
SECTION: _("The section or subgroup under which filed, eg 'Diplomatic correspondance, 1798-1810'"),
SESSION: _("The number of the meeting or series of connected meetings devoted by a legislature to a single order of business, program, agenda, or announced purpose."),
SHEET_NO: _("Number of a census sheet."),
TERM: _("Reference to the time a person/group/parliament is in office or session."),
TIMESTAMP: _("Indication of the time in audio or video where the relevant fragment can be found."),
TRANSLATION: _("A translated version, typically of the title"),
URL_6DIGITAL_LOCATION9: _("Detailed internet address of the content"),
VOLUME_INFO: _("Information about the volumes, eg the amount of volumes."),
WEBSITE: _("The main internet address."),
WEBSITE_CREATOR_OR_OWNER: _("Organization or person behind a website."),
}
def __init__(self, value=None):
GrampsType.__init__(self, value)
def short_version(self, sattrtype):
"""
Method that returns the type which is the short version type of the given type
"""
sattrt = SrcAttributeType(sattrtype)
if sattrt.xml_str().lower().endswith(' (short)'):
return sattrtype
return SrcAttributeType(sattrt.xml_str() +' (Short)')
@staticmethod
def get_default_hint(sattrtype):
index = int(SrcAttributeType(sattrtype))
return SrcAttributeType._DEFAULT_HINTS.get(index) or ""
@staticmethod
def get_default_tooltip(sattrtype):
index = int(SrcAttributeType(sattrtype))
return SrcAttributeType._DEFAULT_TOOLTIPS.get(index) or ""
def get_ignore_list(self, exception=None):
"""
Return a list of the types to ignore and not include in default lists.

View File

@ -202,6 +202,26 @@ class SrcTemplate(TableObject):
"mapdict" : self.mapdict,
}
def unserialize(self, data):
"""
Convert the data held in a tuple created by the serialize method
back into the data in a SrcTemplate object.
:param data: tuple containing the persistent data associated the
SrcTemplate object
:type data: tuple
"""
(self.handle,
self.name,
self.descr,
template_element_list,
self.mapdict,
) = data
self.template_element_list = [TemplateElement().unserialize(te)
for te in template_element_list]
return self
def get_name(self):
return self.name
@ -307,15 +327,16 @@ class SrcTemplate(TableObject):
self.input_dict[short_name] == ("[" + short_name + "]")):
self.input_dict[short_name] = self.input_dict[name]
if self.date_citation:
if self.date_citation and (not self.date_citation.is_empty()):
#we store the date of the citation in attrmap
name = SrcAttributeType(SrcAttributeType.DATE).xml_str().upper().replace(' ', '_')
self.input_dict[name] = str(self.date_citation)
name = SrcAttributeType.DATE.upper().replace(' ', '_')
txt = str(self.date_citation)
self.input_dict[name] = txt
short_name = name + "_(SHORT)"
if self.input_dict.get(short_name) is None or \
(self.input_dict.get(short_name) and \
self.input_dict[short_name] == ("[" + short_name + "]")):
self.input_dict[short_name] = self.input_dict[name]
self.input_dict[short_name] = txt
# FIXME: REPOSITORY, REPOSITORY_ADDRESS and REPOSITORY_CALL_NUMBER all
# need to be added to the self.input_dict. See srctemplatetab.py

View File

@ -78,36 +78,39 @@ class SrcTemplateList(STL):
"""
# __metaclass__ = Singleton
def __init__(self):
self.template_list = {}
self.clear()
def clear(self):
self.template_list = {}
self.GEDCOM_handle = None
self.UNKNOWN_handle = None
def add_template(self, handle, template):
self.template_list[handle] = template
def get_template_from_name(self, name):
# N.B. names can be ambiguous; it is better to use the handles which are
# guaranteed o be unique. This method returns the first matching
# template it finds.
# Match processing in old set_template_key()
gedtempl = None
if name == 'UNKNOWN':
name = 'GEDCOM'
for template in list(self.template_list.values()):
if template.get_name() == name:
return template
if template.get_name() == 'GEDCOM':
gedtempl = template
# Return the GEDCOM template if one was found
return gedtempl
# def get_template_from_handle(self, handle):
# if handle in self.template_list:
# return self.template_list[handle]
# else:
# return self.template_list[self.get_UNKNOWN_handle()]
def get_template_from_handle(self, handle):
return self.template_list[handle]
def get_template_list(self):
return self.template_list
def template_defined(self, name):
if self.get_template_from_name(name) is None:
return False
else:
return True
# def get_template_list(self):
# return self.template_list
#
# def template_defined(self, handle):
# if self.get_template_from_handle(handle) is None:
# return False
# else:
# return True
#
# def set_GEDCOM_handle(self, handle):
# self.GEDCOM_handle = handle
#
# def get_GEDCOM_handle(self):
# return self.GEDCOM_handle
#
# def set_UNKNOWN_handle(self, handle):
# self.UNKNOWN_handle = handle
#
# def get_UNKNOWN_handle(self):
# return self.UNKNOWN_handle

View File

@ -52,7 +52,7 @@ LOG = logging.getLogger('.template')
#-------------------------------------------------------------------------
from gramps.gen.lib.srcattrtype import (SrcAttributeType, REF_TYPE_F,
REF_TYPE_S, REF_TYPE_L, EMPTY)
from gramps.gen.lib import SrcAttribute, SrcTemplate, SrcTemplateList
from gramps.gen.lib import SrcAttribute, SrcTemplate
from gramps.gen.plug.report.utils import get_address_ref_str
from ...autocomp import StandardCustomSelector
from ...widgets.srctemplatetreeview import SrcTemplateTreeView
@ -92,6 +92,7 @@ class SrcTemplateTab(GrampsTab):
self.glade = glade
self.callback_src_changed = callback_src_changed
self.readonly = dbstate.db.readonly
self.db = dbstate.db
self.autoset_title = False
@ -133,7 +134,7 @@ class SrcTemplateTab(GrampsTab):
:param scrolled: GtkScrolledWindow to which to add treeview with templates
"""
templ = self.src.get_template()
self.temp_tv = SrcTemplateTreeView(templ,
self.temp_tv = SrcTemplateTreeView(templ, self.db,
sel_callback=self.on_template_selected)
scrolled.add(self.temp_tv)
@ -147,7 +148,7 @@ class SrcTemplateTab(GrampsTab):
If title of the source is what we would set with autotitle, we set
the checkbox to true. Otherwise to False
"""
srctemp = SrcTemplateList().get_template_from_name(self.src.get_template())
srctemp = self.db.get_template_from_handle(self.src.get_template())
srctemp.set_attr_list(self.src.get_attribute_list())
title = srctemp.title_gedcom()
if self.src.get_title() == title:
@ -207,19 +208,17 @@ class TemplateFields(object):
self.btns = []
self.monentry = []
def reset_template_fields(self, key):
def reset_template_fields(self, handle):
"""
Method that constructs the actual fields where user can enter data.
Template must be the index of the template.
handle is the handle of the template.
"""
show_default_cite_fields = False #we don't do this for now
#obtain the template of the key
if SrcTemplateList().template_defined(key):
#a predefined template,
template = SrcTemplateList().get_template_from_name(key).get_structure()
telist = SrcTemplateList().get_template_from_name(key).get_template_element_list()
if handle:
template = self.db.get_template_from_handle(handle)
telist = template.get_template_element_list()
else:
LOG.warn("template not defined %s" % key)
LOG.warn("template not defined %s" % handle)
return
# first remove old fields
@ -309,18 +308,15 @@ class TemplateFields(object):
Add an entryfield to the grid of fields at row row, to edit the given
srcattrtype value. Use alt_label if given to indicate the field
(otherwise the srcattrtype string description is used)
Note srcattrtype should actually be the integer key of the type!
Note srcattrtype should actually be the English name of the type!
"""
self.gridfields.insert_row(row)
field = srcattrtype
if isinstance(field, STRTYPE):
raise NotImplementedError("type must be the integer key")
#setup label
if alt_label:
label = alt_label
label = _(alt_label)
else:
srcattr = SrcAttributeType(field)
label = str(srcattr)
label = _(srcattrtype)
lbl = Gtk.Label(_("%s:") % label)
lbl.set_halign(Gtk.Align.START)
self.gridfields.attach(lbl, 0, row-1, 1, 1)
@ -329,7 +325,8 @@ class TemplateFields(object):
SrcAttributeType.REPOSITORY_ADDRESS,
SrcAttributeType.REPOSITORY_CALL_NUMBER]:
self._add_repo_entry(srcattrtype, row)
elif self.cite and srcattrtype == SrcAttributeType.DATE:
elif self.cite and \
srcattrtype == SrcAttributeType.DATE:
#the DATE on level citation is not an attribute but stored
#as date in the citation
self._add_cite_date(row)
@ -345,19 +342,19 @@ class TemplateFields(object):
inpt.set_halign(Gtk.Align.FILL)
inpt.set_hexpand(True)
if tooltip:
inpt.set_tooltip_text(tooltip)
inpt.set_tooltip_text(_(tooltip))
self.gridfields.attach(inpt, 1, row-1, 1, 1)
self.inpts.append(inpt)
if self.cite:
MonitoredEntryIndicator(inpt, self.set_cite_field, self.get_cite_field,
hint or "",
_(hint or ""),
read_only=self.db.readonly,
parameter=srcattrtype)
parameter=_(srcattrtype))
else:
MonitoredEntryIndicator(inpt, self.set_src_field, self.get_src_field,
hint or "",
_(hint or ""),
read_only=self.db.readonly,
parameter=srcattrtype)
parameter=_(srcattrtype))
def _add_cite_date(self, row):
"""
@ -437,12 +434,12 @@ class TemplateFields(object):
def __get_field(self, srcattrtype, obj):
"""
Obtain srcattribute with type srcattrtype, where srcattrtype is an
integer key!
Obtain srcattribute with type srcattrtype, where srcattrtype is the
English name of the attribute!
"""
val = ''
for attr in obj.attribute_list:
if int(attr.get_type()) == srcattrtype:
if attr.get_type() == srcattrtype:
val = attr.get_value()
break
return val
@ -459,13 +456,13 @@ class TemplateFields(object):
def __set_field(self, value, srcattrtype, obj):
"""
Set attribute of source of type srcattrtype (which is integer!) to
value. If not present, create attribute. If value == '', remove
Set attribute of source of type srcattrtype (which is the English name)
to value. If not present, create attribute. If value == '', remove
"""
value = value.strip()
foundattr = None
for attr in obj.attribute_list:
if int(attr.get_type()) == srcattrtype:
if attr.get_type() == srcattrtype:
attr.set_value(value)
foundattr = attr
break

View File

@ -44,7 +44,7 @@ from gi.repository import Gtk, Gdk
# gramps modules
#
#-------------------------------------------------------------------------
from gramps.gen.lib import NoteType, Source, SrcTemplate, Citation, SrcTemplateList
from gramps.gen.lib import NoteType, Source, SrcTemplate, Citation
from gramps.gen.db import DbTxn
from gramps.gen.utils.file import media_path_full
from ..thumbnails import get_thumbnail_image
@ -68,7 +68,6 @@ from ..glade import Glade
#
#-------------------------------------------------------------------------
FIRST = True
class EditSource(EditPrimary):
def __init__(self, dbstate, uistate, track, source, citation=None,
@ -83,12 +82,7 @@ class EditSource(EditPrimary):
must handle this (corresponds to closing the editor with
nothing made!)
"""
# FIXME: Is there a cleaner place to initially load the template data?
global FIRST
if FIRST:
from gramps.plugins.srctemplates.importcsv import load_srctemplates_data
load_srctemplates_data()
FIRST = False
self.db = dbstate.db
self.srctemp = None
self.citation = citation
self.template_tab = None
@ -106,6 +100,8 @@ class EditSource(EditPrimary):
if citation.get_reference_handle() and \
not (citation.get_reference_handle() == source.handle):
raise Exception('Citation must be a Citation of the Source edited')
if source.get_template() is None:
source.set_template(dbstate.db.get_GEDCOM_template_handle())
else:
#no citation given.
self.citation_loaded = False
@ -354,13 +350,10 @@ class EditSource(EditPrimary):
"""
Reaction to update on attributes
"""
#we only construct once the template to use to format information
if self.srctemp is None:
self.srctemp = SrcTemplateList().get_template_from_name(self.obj.get_template())
if self.srctemp is None or \
self.obj.get_template() != self.srctemp.get_name():
self.srctemp = self.db.get_template_from_handle(self.obj.get_template())
#if source template changed, reinit template
if self.obj.get_template() != self.srctemp.get_name():
self.srctemp = SrcTemplateList().get_template_from_name(self.obj.get_template())
#set new attrlist in template
if self.citation_loaded:
citeattr = self.citation.get_attribute_list()
@ -373,12 +366,8 @@ class EditSource(EditPrimary):
#set fields with the template
self.refL.set_markup(self.srctemp.reference_L())
if self.citation_loaded:
self.refF.set_markup(self.srctemp.reference_F())
self.refS.set_markup(self.srctemp.reference_S())
else:
self.refF.set_markup(_("<no citation loaded>"))
self.refS.set_markup(_("<no citation loaded>"))
self.refF.set_markup(self.srctemp.reference_F())
self.refS.set_markup(self.srctemp.reference_S())
self.author.set_markup(self.srctemp.author_gedcom())
self.pubinfo.set_markup(self.srctemp.pubinfo_gedcom())
if self.template_tab and self.template_tab.autoset_title:

View File

@ -45,7 +45,7 @@ from gi.repository import Gtk
# Gramps classes
#
#-------------------------------------------------------------------------
from gramps.gen.lib import SrcTemplate, SrcTemplateList
from gramps.gen.lib import SrcTemplate
#-------------------------------------------------------------------------
#
@ -57,13 +57,14 @@ class SrcTemplateTreeView(Gtk.TreeView):
'''
TreeView for SrcTemplate templates, to allow fast selection
'''
def __init__(self, default_key, sel_callback):
def __init__(self, default_key, db, sel_callback):
"""
Set up the treeview to select template.
TreeView is initialized to default_key
On setting a selection, sel_callback is called
"""
Gtk.TreeView.__init__(self)
self.db = db
self.sel_callback = sel_callback
self.default_key = default_key
self.build_model()
@ -82,10 +83,10 @@ class SrcTemplateTreeView(Gtk.TreeView):
self.Key2Path = {}
# store (key, src_type)
self.model = Gtk.TreeStore(str, str)
tlist = SrcTemplateList()
alltexts = sorted((tlist.get_template_from_handle(handle).get_descr(),
tlist.get_template_from_handle(handle).get_name())
for handle in tlist.get_template_list() )
tlist = self.db.get_template_handles()
alltexts = sorted((self.db.get_template_from_handle(handle).get_descr(),
handle)
for handle in tlist )
parentiter = None
parentiterlev1 = None
prevstrval = ['', '']

View File

@ -908,16 +908,20 @@ class GedcomWriter(UpdateCallback):
for (source_id, handle) in sorted_list:
source = self.dbase.get_source_from_handle(handle)
if source is None: continue
templatehandle = source.get_template()
if templatehandle is None: continue
template = self.dbase.get_template_from-handle(templatehandle)
self._writeln(0, '@%s@' % source_id, 'SOUR')
stitle = source.get_gedcom_title()
attrlist = source.get_attribute_list()
stitle = template.title_gedcom(attrlist)
if stitle:
self._writeln(1, 'TITL', stitle)
sauth = source.get_gedcom_author()
sauth = template.author_gedcom(attrlist)
if sauth:
self._writeln(1, "AUTH", sauth)
spubi = source.get_gedcom_publication_info()
spubi = template.pubinfo_gedcom(attrlist)
if spubi:
self._writeln(1, "PUBL", spubi)
@ -1270,7 +1274,12 @@ class GedcomWriter(UpdateCallback):
# Reference to the source
self._writeln(level, "SOUR", "@%s@" % src.get_gramps_id())
gedcom_page = citation.get_gedcom_page(src.get_template())
templatehandle = src.get_template()
if templatehandle:
template = self.dbase.get_template_from_handle(templatehandle)
gedcom_page = template.page_gedcom(citation.get_attribute_list())
else:
gedcom_page = citation.get_name()
if gedcom_page != "":
# PAGE <WHERE_WITHIN_SOURCE> can not have CONC lines.
# WHERE_WITHIN_SOURCE:= {Size=1:248}

View File

@ -6304,13 +6304,17 @@ class GedcomParser(UpdateCallback):
@param state: The current state
@type state: CurrentState
"""
if state.source.get_gedcom_title() == "":
title = line.data.replace('\n', ' ')
sattr = SrcAttribute()
sattr.set_type(SrcAttributeType.TITLE)
sattr.set_value(title)
src.add_attribute(sattr)
state.source.set_name(title)
templatehandle = state.source.get_template()
if templatehandle:
template = self.dbase.get_template_from_handle(templatehandle)
title = template.title_gedcom(state.source.get_attribute_list())
if title == "":
title = line.data.replace('\n', ' ')
sattr = SrcAttribute()
sattr.set_type(SrcAttributeType.TITLE)
sattr.set_value(title)
state.source.add_attribute(sattr)
state.source.set_name(title)
#----------------------------------------------------------------------
#

View File

@ -44,11 +44,11 @@ import sys
# GRAMPS modules
#
#-------------------------------------------------------------------------
from gramps.gen.db import DbTxn
from gramps.gen.utils.id import create_id
from gramps.gen.lib.srcattrtype import *
from gramps.gen.lib.date import Date
from gramps.gen.lib.srctemplate import SrcTemplate, TemplateElement
from gramps.gen.lib.srctemplatelist import SrcTemplateList
#------------------------------------------------------------------------
#
@ -82,12 +82,109 @@ UNKNOWN = 'UNKNOWN'
DESCR = -10
def load_srctemplates_data():
# This contains the default hints and tooltips
DEFAULTS = {
"Act" : ("Public Law 12-98" , "A statute or law name passed by a legislature"),
"Address" : ("Broadway Avenue, New York" , "Store address information. Set Private if needed! Give information from lowest to highest level separated by comma's"),
"Affiliation" : ("Agent of Gramps Software" , "A relevant affiliation that might influence data in the source"),
"Author" : ("Doe, D.P. & Cameron, E." , "Give names in following form:'FirstAuthorSurname, Given Names & SecondAuthorSurname, Given Names'. Like this Gramps can parse the name and shorten as needed."),
"Author location" : ("Chicago" , "City where author resides or wrote."),
"Book" : ("The big example Gramps manual" , "Title of the Book"),
"Case" : ("B. Malengier versus N. Hall" , "Dispute between opposing parties in a court of law."),
"Cemetery" : ("Greenwich Cemetery Office" , "Name of cemetery or cemetery office with sources."),
"Chapter" : ("The first office of T. Rooseveld" , None),
"Chapter pages" : ("24-55" , "The pages in the chapter."),
"Collection" : ("Bruges Lace Collection" , "The name of the person who compiled the source."),
"Column" : ("col. 3" , "The name of the creator of the artifact."),
"Compiler" : ("T. Da Silva" , None),
"Creation date" : ("13 Aug 1965" , None),
"Creator" : ("P. Picasso" , None),
"Credit line" : ("Based on unnamed document lost in fire" , "Acknowledgement of writers and contributors"),
"Date" : ("17 Sep 1745" , "The range of years which are present in the source."),
"Date accessed" : ("18 Jun 2013" , "Some important detail of the source."),
"Date range" : ("2003-6" , None),
"Description" : ("The lace has inscriptions with names of nobility" , None),
"District" : ("Enumeration district (ED) 14" , "District as handled by Census"),
"Division" : ("Peterburg Post Office, or Portland, ward 4" , "The subdivision of a larger group that is handled in the source."),
"Edition" : ("Second Edition" , None),
"Editor" : ("Hoover, J.E." , "The Editor of a multi-author book."),
"File" : ("Membership application J. Rapinat" , "The title of a specific file in a source."),
"File date" : ("15 Jan 1870" , "Date of submitting the document to a clerk or court."),
"File location" : ("Accession 7, Box 3" , "Accession method to the file"),
"File no." : ("1243-EB-98" , "Number to indicate a file"),
"File unit" : ("Letters to George Washington" , "A grouping unit for a number of files in a source."),
"Film id" : ("T345" , "ID of a Microfilm."),
"Film publication place" : ("Kansas City" , None),
"Film publisher" : ("NY Genealogy Association" , None),
"Film type" : ("FHL microfilm" , "The type of the microfilm."),
"Format" : ("Digital Images, or Database, or Cards, ..." , "The format of the source."),
"Frame" : ("frames 387-432" , "What frames in the source are relevant."),
"Group" : ("Miami Patent Office" , "A larger grouping to which the source belongs."),
"Household" : ("dwelling 345, family 654" , "Household of interest on a census."),
"Id" : ("I50-68, or 1910 U.S. census, or ..." , "ID to identify the source or citation part"),
"Institution" : ("Sorbonne University" , "Institution that issued the source."),
"Interviewer" : ("Materley, B." , None),
"Issue date" : ("Jun 2004" , "Date the source was issued."),
"Issue range" : ("145-394, scattered issues" , "A range of magazine, journal, ... issues covered in the source"),
"Item of interest" : ("entry for G. Galileo, or Doe Household, or A. Einstein Grave ..." , "Specific part, item, or person of interest in the source"),
"Jurisdiction" : ("Jackson County, Alabama" , "Area with a set of laws under the control of a system of courts or government entity. Enter this from lowest to highest relevant jurisdiction, separated by comma's."),
"Location" : ("Istanbul" , "City that is relevant."),
"Number" : ("2, or Record Group 34, or ..." , "A number."),
"Number (total)" : ("5" , "The maximum of entities available."),
"Original repository" : ("National Archives" , "Name of the repository where the original is stored."),
"Original repository location" : ("Washington, D.C." , "Address or only city of the repository where the original is stored."),
"Original year" : ("1966" , "Year the original source was published/created"),
"Page" : ("5; or 4,6-8, ..." , "The page or page(s) relevant for the citation"),
"Page range" : ("1-13" , "The range of the pages in the source. The page given for a citation must be in this range."),
"Part" : ("Part 3" , None),
"Place created" : ("London" , None),
"Position" : ("written in the left margin, or second row, 3th line" , "Where in or on the source the citation piece can be found."),
"Posting date" : ("5 Jul 1799" , None),
"Professional credentials" : ("Prof.; or Dr. ..." , None),
"Provenance" : ("add provenance of the material" , "Where the material originated from."),
"Publication format" : ("CD-ROM or eprint or ..." , None),
"Publication place" : ("Berlin" , None),
"Publication title" : ("Title of Blog, Newsletter, DVD, ..." , None),
"Publication year" : ("2014" , None),
"Publisher" : ("Springer" , None),
"Pub_info" : ("Springer, Berlin, 2014" , "Publication Information, such as city and year of publication, name of publisher, ..."),
"Recipient" : ("J. Ralls" , "The person to who the letter is addressed."),
"Relationship" : ("Paul's uncle and brother of Erik" , "The relationship of the author to the person of interest that is the subject."),
"Report date" : ("3 May 1999" , "Date the report was written/submitted."),
"Research comment" : ("Descriptive detail or provenance or research analysis conclusion, ..." , "Descriptive detail or provenance or research analysis conclusion, ..."),
"Research project" : ("Tahiti Natives" , "The genealogical or scientific research project."),
"Roll" : ("176, or rolls 145-160" , "The Microfilm role."),
"Schedule" : ("population schedule or slave schedule or ..." , "The census schedule (the type of census table) used, eg population schedule or slave schedule. or ..."),
"Section" : ("1890 section or ER patients or ..." , "The section or subgroup under which filed, eg 'Diplomatic correspondance, 1798-1810'"),
"Series" : ("Carnival County Records" , None),
"Series no." : ("series 34-38" , None),
"Session" : ("2nd session" , "The number of the meeting or series of connected meetings devoted by a legislature to a single order of business, program, agenda, or announced purpose."),
"Sheet no." : ("sheet 13-C" , "Number of a census sheet."),
"Subject" : ("D. Copernicus and close family" , None),
"Subseries" : (None , None),
"Subtitle" : ("Subtitle of article or magazine ..." , None),
"Term" : ("June Term 1934 or 13th Congress or Reagan Office or ..." , "Reference to the time a person/group/parliament is in office or session."),
"Timestamp" : ("min. 34-36" , "Indication of the time in audio or video where the relevant fragment can be found."),
"Title" : ("Diary Title, Message Title, Bible Name, Article Title, ..." , None),
"Translation" : ("A translated version, typically of the title" , "A translated version, typically of the title"),
"Type" : ("Letter" , None),
"Url (digital location)" : ("http//gramps-project.org/blog" , "Detailed internet address of the content"),
"Volume" : ("4" , None),
"Volume info" : ("5 volumes" , "Information about the volumes, eg the amount of volumes."),
"Website" : ("gramps-project.org" , "The main internet address."),
"Website creator/owner" : ("Family Historians Inc" , "Organization or person behind a website."),
"Year" : ("1888" , None),
"Year accessed" : ("2013" , None),
}
def load_srctemplates_data(db):
"""
Loads the srctemplates defined, and returns a dict with template data
"""
LOG.debug("**** load_srctemplate_data. Starting")
load_srctemplate_gedcom()
load_srctemplate_gedcom(db)
LOG.debug("**** load_srctemplate_data. GEDCOM and UNKNOWN loaded")
@ -102,45 +199,63 @@ def load_srctemplates_data():
LOG.debug("**** load_srctemplate_data. Loading csv from %s" % csvfilename)
if sys.version_info[0] <3:
with open(csvfilename, 'rb') as csvfile:
load_srctemplate_csv(csvfile)
load_srctemplate_csv(csvfile, db)
else:
with open(csvfilename, 'r') as csvfile:
load_srctemplate_csv(csvfile)
load_srctemplate_csv(csvfile, db)
LOG.debug("**** load_srctemplate_data. csv data loaded")
def load_srctemplate_gedcom():
for handle in db.get_template_handles():
LOG.debug("handle %s" % handle)
template = db.get_template_from_handle(handle)
LOG.debug("source_type: %s; handle %s" % (template.get_name(), template.get_handle()))
for te in template.get_template_element_list():
LOG.debug(" name: %s; display: %s; hint: %s; tooltip: %s; citation %s; "
"short %s; short_alg %s" %
(te.get_name(),
te.get_display(), te.get_hint(),
te.get_tooltip(), te.get_citation(),
te.get_short(), te.get_short_alg()
))
for target in template.get_map_dict():
LOG.debug("Type %s; target %s; map %s" %
(template.get_name(), target, template.get_map_element(target)))
LOG.debug("**** load_srctemplate_data. finished")
def load_srctemplate_gedcom(db):
"""
Loads the GEDCOM and UNKNOWN templates which are always pre-defined
"""
global DEFAULTS
TEMPLATES = {
'GEDCOM': {
REF_TYPE_L: [
('', SrcAttributeType.AUTHOR, _(''), '.', EMPTY, False, False, EMPTY, GED_AUTHOR,
('', "Author", '', '.', EMPTY, False, False, EMPTY, GED_AUTHOR,
None, None),
('', SrcAttributeType.TITLE, _(''), '.', STYLE_QUOTE, False, False, EMPTY, GED_TITLE,
('', "Title", '', '.', STYLE_QUOTE, False, False, EMPTY, GED_TITLE,
None, None),
('', SrcAttributeType.PUB_INFO, _(''), '', EMPTY, False, False, EMPTY, GED_PUBINF,
('', "Pub_info", '', '', EMPTY, False, False, EMPTY, GED_PUBINF,
None, None),
],
REF_TYPE_F: [
('', SrcAttributeType.AUTHOR, _(''), ',', EMPTY, False, False, EMPTY, EMPTY,
('', "Author", '', ',', EMPTY, False, False, EMPTY, EMPTY,
None, None),
('', SrcAttributeType.TITLE, _(''), ',', STYLE_QUOTE, False, False, EMPTY, EMPTY,
('', "Title", '', ',', STYLE_QUOTE, False, False, EMPTY, EMPTY,
None, None),
('', SrcAttributeType.PUB_INFO, _(''), '.', EMPTY, False, False, EMPTY, EMPTY,
('', "Pub_info", '', '.', EMPTY, False, False, EMPTY, EMPTY,
None, None),
('', SrcAttributeType.DATE, _(''), ' -', EMPTY, False, False, EMPTY, EMPTY,
('', "Date", '', ' -', EMPTY, False, False, EMPTY, EMPTY,
None, None),
('', SrcAttributeType.PAGE, _('Page(s)'), '.', EMPTY, False, False, EMPTY, EMPTY,
('', "Page", 'Page(s)', '.', EMPTY, False, False, EMPTY, EMPTY,
None, None),
],
REF_TYPE_S: [
('', SrcAttributeType.AUTHOR, _(''), ',', EMPTY, False, False, EMPTY, EMPTY,
('', "Author", '', ',', EMPTY, False, False, EMPTY, EMPTY,
None, None),
('', SrcAttributeType.DATE, _(''), ' -', EMPTY, False, False, EMPTY, EMPTY,
('', "Date", '', ' -', EMPTY, False, False, EMPTY, EMPTY,
None, None),
('', SrcAttributeType.PAGE, _('Page(s)'), '.', EMPTY, False, False, EMPTY, EMPTY,
('', "Page", 'Page(s)', '.', EMPTY, False, False, EMPTY, EMPTY,
None, None),
],
DESCR: '%(first)s - %(sec)s - %(third)s' % { 'first': _('Basic'), 'sec': _('GEDCOM Style'), 'third': _('')},
@ -161,8 +276,6 @@ def load_srctemplate_gedcom():
template.set_descr('%(first)s - %(sec)s - %(third)s' % { 'first': _('Basic'), 'sec': _('GEDCOM Style'), 'third': _('')})
handle = create_id()
template.set_handle(handle)
tlist = SrcTemplateList()
tlist.add_template(handle, template)
for (cite_type, slist) in list(TEMPLATES['GEDCOM'].items()):
if cite_type != DESCR:
@ -191,39 +304,49 @@ def load_srctemplate_gedcom():
tooltip = struct[10]
te.set_name(field_type)
te.set_display(field_label)
te.set_hint(hint or SrcAttributeType.get_default_hint(field_type))
te.set_tooltip(tooltip or SrcAttributeType.get_default_tooltip(field_type))
if DEFAULTS.get(field_type):
te.set_hint(hint or (DEFAULTS[field_type][0] or ""))
te.set_tooltip(tooltip or (DEFAULTS[field_type][1] or ""))
else:
te.set_hint("")
te.set_tooltip("")
if cite_type == REF_TYPE_S:
te.set_short(True)
te.set_name(int(SrcAttributeType().short_version(te.get_name())))
if field_type == SrcAttributeType.PAGE or \
field_type == SrcAttributeType.DATE:
if field_type.lower().endswith(' (short)'):
te.set_name(field_type)
else:
te.set_name(field_type + ' (Short)')
if field_type == "Page" or \
field_type == "Date":
te.set_citation(True)
template.add_structure_element(cite_type, [(ldel, field_type,
field_label, rdel, style, private, optional,
shorteralg, gedcommap, hint, tooltip)])
template.set_map_element("GEDCOM_A", "AUTHOR")
template.set_map_element("GEDCOM_T", "TITLE")
template.set_map_element("GEDCOM_P", "PUB_INFO")
template.set_map_element("GEDCOM_D", "DATE")
template.set_map_element("GEDCOM_PAGE", "PAGE")
template.set_map_element("GEDCOM_A", "%(AUTHOR)s")
template.set_map_element("GEDCOM_T", "%(TITLE)s")
template.set_map_element("GEDCOM_P", "%(PUB_INFO)s")
template.set_map_element("GEDCOM_D", "%(DATE)s")
template.set_map_element("GEDCOM_PAGE", "%(PAGE)s")
template.set_map_element("EE_L", "%(AUTHOR)s. %(TITLE)s. %(PUB_INFO)s")
template.set_map_element("EE_F", "%(AUTHOR)s, %(TITLE)s, %(PUB_INFO)s. %(DATE)s - %(PAGE)s")
template.set_map_element("EE_S", "%(AUTHOR_(SHORT))s, %(DATE_(SHORT))s - %(PAGE_(SHORT))s.")
for handle in SrcTemplateList().get_template_list():
template = SrcTemplateList().get_template_from_handle(handle)
LOG.debug("source_type: %s" % template.get_name())
for te in template.get_template_element_list():
LOG.debug(" name: %s; display: %s; hint: %s; tooltip: %s; citation %s; "
"short %s; short_alg %s" %
(SrcAttributeType(te.get_name()).xml_str(),
te.get_display(), te.get_hint(),
te.get_tooltip(), te.get_citation(),
te.get_short(), te.get_short_alg()
))
msg = _("Add template (%s)") % template.get_name()
with DbTxn(msg, db) as trans:
db.commit_template(template, trans)
db.set_GEDCOM_template_handle(template.get_handle())
# for handle in db.get_template_handles():
# template = db.get_template_from_handle(handle)
# LOG.debug("source_type: %s; handle %s" % (template.get_name(), template.get_handle()))
# for te in template.get_template_element_list():
# LOG.debug(" name: %s; display: %s; hint: %s; tooltip: %s; citation %s; "
# "short %s; short_alg %s" %
# (te.get_name(),
# te.get_display(), te.get_hint(),
# te.get_tooltip(), te.get_citation(),
# te.get_short(), te.get_short_alg()
# ))
# Now load the UNKNOWN template
template = SrcTemplate()
@ -231,13 +354,14 @@ def load_srctemplate_gedcom():
template.set_descr(_("Unrecognized Template. Download it's definition."))
handle = create_id()
template.set_handle(handle)
tlist = SrcTemplateList()
tlist.add_template(handle, template)
msg = _("Add template (%s)") % template.get_name()
with DbTxn(msg, db) as trans:
db.commit_template(template, trans)
for cite_type in (REF_TYPE_F, REF_TYPE_L, REF_TYPE_S):
template.add_structure_element(cite_type, [])
def load_srctemplate_csv(csvfile):
def load_srctemplate_csv(csvfile, db):
"""
Loads a template csvfile, and returns a dict with template data
Note: csvfile could be a list containing strings!
@ -246,7 +370,6 @@ def load_srctemplate_csv(csvfile):
TYPE2CITEMAP = {}
TYPE2TEMPLATEMAP = {}
TYPE2FIELDS = collections.defaultdict(lambda: collections.defaultdict(list))
tlist = SrcTemplateList()
CITE_TYPES = {'F': REF_TYPE_F, 'L': REF_TYPE_L, 'S': REF_TYPE_S}
GEDCOMFIELDS = {'A': GED_AUTHOR, 'T': GED_TITLE,
'P': GED_PUBINF, 'D': GED_DATE}
@ -294,8 +417,6 @@ def load_srctemplate_csv(csvfile):
handle = create_id()
template.set_handle(handle)
TYPE2TEMPLATEMAP[source_type] = template
tlist = SrcTemplateList()
tlist.add_template(handle, template)
# TYPE2CITEMAP[source_type] = {REF_TYPE_L: [], REF_TYPE_F: [],
# REF_TYPE_S: [], DESCR: source_descr}
@ -317,13 +438,13 @@ def load_srctemplate_csv(csvfile):
# .replace(',', '').replace('.', '').replace(':', '')\
# .replace('-', '_')
#we need to force English SrcAttributeType
ifield_type = SrcAttributeType()
ifield_type.set_from_xml_str(field_type)
ifield_type = int(SrcAttributeType(ifield_type))
if ifield_type == SrcAttributeType.CUSTOM:
raise NotImplementedError("field must be a known SrcAttributeType, is " + str(SrcAttributeType(field_type)))
field_type = ifield_type
# #we need to force English SrcAttributeType
# ifield_type = SrcAttributeType()
# ifield_type.set_from_xml_str(field_type)
# ifield_type = int(SrcAttributeType(ifield_type))
# if ifield_type == SrcAttributeType.CUSTOM:
# raise NotImplementedError("field must be a known SrcAttributeType, is " + str(SrcAttributeType(field_type)))
# field_type = ifield_type
#field_descr = field.replace('[', '').replace(']','').lower().capitalize()
field_label = row[LABELCOL].strip()
#field_label = field_label.replace("'", "\\'")
@ -364,7 +485,6 @@ def load_srctemplate_csv(csvfile):
te.set_short_alg(shorteralg)
if cite_type == REF_TYPE_S:
te = TemplateElement()
# field_type = int(SrcAttributeType().short_version(field_type))
te.set_name(field_type)
te.set_short_alg(shorteralg)
te.set_short(True)
@ -375,18 +495,21 @@ def load_srctemplate_csv(csvfile):
template.add_template_element(te)
TYPE2FIELDS[source_type][cite_type].append(field_type)
template.add_structure_element(cite_type, [(row[LDELCOL], field_type,
_(field_label), row[RDELCOL], style, private, optional,
shorteralg, gedcommap, _(hint), _(tooltip))])
field_label, row[RDELCOL], style, private, optional,
shorteralg, gedcommap, hint, tooltip)])
# Setup the mapping. A typical mapping would look like:
# ('EE_Full' : '%(COMPILER)s, "%(TITLE)s", %(TYPE)s, %(WEBSITE CREATOR/OWNER)s, <i>%(WEBSITE)s</i>, (%(URL (DIGITAL LOCATION))s: accessed %(DATE ACCESSED)s), %(ITEM OF INTEREST)s; %(CREDIT LINE)s.')
target = "EE_" + cite_type_text
if te.get_short():
txt = int(SrcAttributeType().short_version(field_type))
if field_type.lower().endswith(' (short)'):
txt = field_type
else:
txt = field_type + ' (Short)'
else:
txt = field_type
txt = row[LDELCOL] + "%(" + \
SrcAttributeType(txt).xml_str().upper().replace(' ', '_') + \
txt.upper().replace(' ', '_') + \
")s" + row[RDELCOL]
if len(row[RDELCOL]) and row[RDELCOL][-1] in ['.', ',', ':', ';', '-']:
txt += ' '
@ -412,6 +535,10 @@ def load_srctemplate_csv(csvfile):
template.set_map_element(target, template.get_map_element(target)[:-1])
template.set_map_element(target, template.get_map_element(target) + txt)
msg = _("Add template (%s)") % template.get_name()
with DbTxn(msg, db) as trans:
db.commit_template(template, trans)
# Now we adjust some fields that could not be changed till all the data had
# been read in
for source_type in TYPE2FIELDS:
@ -427,17 +554,25 @@ def load_srctemplate_csv(csvfile):
te.set_citation(True)
# Set the hint and tooltip to default if not already set
if not te.get_hint():
te.set_hint(SrcAttributeType.get_default_hint(te.get_name()))
if not te.get_tooltip():
te.set_tooltip(SrcAttributeType.get_default_tooltip(te.get_name()))
if DEFAULTS.get(te.get_name()):
te.set_hint(hint or (DEFAULTS[te.get_name()][0] or ""))
te.set_tooltip(tooltip or (DEFAULTS[te.get_name()][1] or ""))
else:
te.set_hint("")
te.set_tooltip("")
# If this is a short version, set the name accordingly. This could
# not be done earlier because we needed to keep the old 'non-short'
# name to find which fields belonged to citations as opposed to
# sources
if te.get_short() == True:
te.set_name(int(SrcAttributeType().short_version(te.get_name())))
if te.get_name().lower().endswith(' (short)'):
te.set_name(te.get_name())
else:
te.set_name(te.get_name() + ' (Short)')
msg = _("Add template (%s)") % template.get_name()
with DbTxn(msg, db) as trans:
db.commit_template(template, trans)
# Finally we setup the GEDCOM page fields
for source_type in TYPE2FIELDS:
@ -447,6 +582,9 @@ def load_srctemplate_csv(csvfile):
target = "GEDCOM_PAGE"
template.set_map_element(target,
", ".join((template.get_map_element(target), txt)))
msg = _("Add template (%s)") % template.get_name()
with DbTxn(msg, db) as trans:
db.commit_template(template, trans)
# Proof of concept for CSL mapping
template = TYPE2TEMPLATEMAP.get('ESM254')
@ -465,14 +603,17 @@ def load_srctemplate_csv(csvfile):
}
for key, val in list(amap.items()):
template.set_map_element(key, val)
msg = _("Add template (%s)") % template.get_name()
with DbTxn(msg, db) as trans:
db.commit_template(template, trans)
# for source_type in TYPE2FIELDS:
# LOG.debug("source_type: %s" % source_type)
# LOG.debug("source_type: %s; handle %s" % (template.get_name(), template.get_handle()))
# template = TYPE2TEMPLATEMAP[source_type]
# for te in template.get_template_element_list():
# LOG.debug(" name: %s; display: %s; hint: %s; tooltip: %s; "
# "citation %s; short %s; short_alg %s" %
# (SrcAttributeType(te.get_name()).xml_str(),
# (te.get_name(),
# te.get_display(), te.get_hint(),
# te.get_tooltip(), te.get_citation(),
# te.get_short(), te.get_short_alg()