GEP18: refractor: move template stuff to srctemplate.py

svn: r22554
This commit is contained in:
Benny Malengier 2013-06-22 16:09:24 +00:00
parent 8ad6600746
commit 99671bdfaf
7 changed files with 8261 additions and 8237 deletions

View File

@ -1036,14 +1036,14 @@
;;;;;;;;"[PAGE]";;",";;;;;;; ;;;;;;;;"[PAGE]";;",";;;;;;;
;;;;;;;;"[HOUSEHOLD]";;",";;;;;;; ;;;;;;;;"[HOUSEHOLD]";;",";;;;;;;
;;;;;;;;"[ITEM OF INTEREST]";"Person of Interest";".";;;;;;; ;;;;;;;;"[ITEM OF INTEREST]";"Person of Interest";".";;;;;;;
57;"EE Census Records";"Microfilm (U.S.)";"Nonpopulation schedules";"NARA film";"L";"ESM244";;"[JURISDICTION]";;".";"T";"REV.";;;;; 57;"EE Census Records";"Microfilm (U.S.)";"Nonpopulation schedules";"NARA film";"L";"ESM244";;"[JURISDICTION]";;".";"T";"REV.";;;;;
;;;;;;;;"[ID]";"Census ID";".";"T";;;;;; ;;;;;;;;"[ID]";"Census ID";".";"T";;;;;;
;;;;;;;;"[TITLE]";"Schedule Title";"schedule.";"T";;"Quoted";;;; ;;;;;;;;"[TITLE]";"Schedule Title";"schedule.";"T";;"Quoted";;;;
;;;;;;;;"[FILM ID]";;".";"P";;;;;; ;;;;;;;;"[FILM ID]";;".";"P";;;;;;
;;;;;;;;"[PUBLICATION PLACE]";;":";"P";;;;;; ;;;;;;;;"[PUBLICATION PLACE]";;":";"P";;;;;;
;;;;;;;;"[PUBLISHER]";;",";"P";;;;;; ;;;;;;;;"[PUBLISHER]";;",";"P";;;;;;
;;;;;;;;"[YEAR]";"Year(s)";".";"P";;;;;; ;;;;;;;;"[YEAR]";"Year(s)";".";"P";;;;;;
57;"EE Census Records";"Microfilm (U.S.)";"Nonpopulation schedules";"NARA film";"F";"ESM244";;"[ID]";"Census ID";",";;;;;;; 57;"EE Census Records";"Microfilm (U.S.)";"Nonpopulation schedules";"NARA film";"F";"ESM244";;"[ID]";"Census ID";",";;;;;;;
;;;;;;;;"[JURISDICTION]";;",";;;;;;; ;;;;;;;;"[JURISDICTION]";;",";;;;;;;
;;;;;;;;"[TITLE]";"Schedule Title";",";;;"Quoted";;;; ;;;;;;;;"[TITLE]";"Schedule Title";",";;;"Quoted";;;;
;;;;;;;;"[SECTION]";;",";;;;;;; ;;;;;;;;"[SECTION]";;",";;;;;;;
@ -1052,7 +1052,7 @@
;;;;;;;;"[PAGE]";"Page(s)";",";;;;;;; ;;;;;;;;"[PAGE]";"Page(s)";",";;;;;;;
;;;;;;;;"[ITEM OF INTEREST]";"Person of Interest";";";;;;;;; ;;;;;;;;"[ITEM OF INTEREST]";"Person of Interest";";";;;;;;;
;;;;;;;;"[FILM ID]";;".";;;;;;; ;;;;;;;;"[FILM ID]";;".";;;;;;;
57;"EE Census Records";"Microfilm (U.S.)";"Nonpopulation schedules";"NARA film";"S";"ESM244";;"[ID]";"Census ID";",";;;;;;; 57;"EE Census Records";"Microfilm (U.S.)";"Nonpopulation schedules";"NARA film";"S";"ESM244";;"[ID]";"Census ID";",";;;;;;;
;;;;;;;;"[JURISDICTION]";;",";;;;;;; ;;;;;;;;"[JURISDICTION]";;",";;;;;;;
;;;;;;;;"[TITLE]";"Schedule Title";",";;;"Quoted";;;; ;;;;;;;;"[TITLE]";"Schedule Title";",";;;"Quoted";;;;
;;;;;;;;"[SECTION]";;",";;;;;;; ;;;;;;;;"[SECTION]";;",";;;;;;;
@ -1060,7 +1060,7 @@
;;;;;;;;"[DISTRICT]";"Enumeration District";",";;;;;;; ;;;;;;;;"[DISTRICT]";"Enumeration District";",";;;;;;;
;;;;;;;"p.";"[PAGE]";"Page(s)";",";;;;;;; ;;;;;;;"p.";"[PAGE]";"Page(s)";",";;;;;;;
;;;;;;;;"[ITEM OF INTEREST]";"Person of Interest";".";;;;;;; ;;;;;;;;"[ITEM OF INTEREST]";"Person of Interest";".";;;;;;;
58;"EE Census Records";"Microfilm (U.S.)";"Nonpopulation schedules";"FHL-GSU preservation film";"L";"ESM245";;"[JURISDICTION]";;".";"T";"REV.";;;;; 58;"EE Census Records";"Microfilm (U.S.)";"Nonpopulation schedules";"FHL-GSU preservation film";"L";"ESM245";;"[JURISDICTION]";;".";"T";"REV.";;;;;
;;;;;;;;"[ID]";"Census ID";",";"T";;;;;; ;;;;;;;;"[ID]";"Census ID";",";"T";;;;;;
;;;;;;;;"[SCHEDULE]";;".";"T";;;;;; ;;;;;;;;"[SCHEDULE]";;".";"T";;;;;;
;;;;;;;;"[ORIGINAL REPOSITORY]";;",";"P";;;;;; ;;;;;;;;"[ORIGINAL REPOSITORY]";;",";"P";;;;;;
@ -1068,7 +1068,7 @@
;;;;;;;;"[FILM ID]";;".";"P";;;;;; ;;;;;;;;"[FILM ID]";;".";"P";;;;;;
;;;;;;;;"[REPOSITORY]";;",";"P";;;;;; ;;;;;;;;"[REPOSITORY]";;",";"P";;;;;;
;;;;;;;;"[REPOSITORY ADDRESS]";;".";"P";"LOC";;;;; ;;;;;;;;"[REPOSITORY ADDRESS]";;".";"P";"LOC";;;;;
58;"EE Census Records";"Microfilm (U.S.)";"Nonpopulation schedules";"FHL-GSU preservation film";"F";"ESM245";;"[ID]";"Census ID";",";;;;;;; 58;"EE Census Records";"Microfilm (U.S.)";"Nonpopulation schedules";"FHL-GSU preservation film";"F";"ESM245";;"[ID]";"Census ID";",";;;;;;;
;;;;;;;;"[JURISDICTION]";;",";;;;;;; ;;;;;;;;"[JURISDICTION]";;",";;;;;;;
;;;;;;;;"[SCHEDULE]";;",";;;;;;; ;;;;;;;;"[SCHEDULE]";;",";;;;;;;
;;;;;;;;"[PAGE]";;",";;;;;;; ;;;;;;;;"[PAGE]";;",";;;;;;;
@ -1076,12 +1076,12 @@
;;;;;;;;"[ORIGINAL REPOSITORY]";;",";;;;;;; ;;;;;;;;"[ORIGINAL REPOSITORY]";;",";;;;;;;
;;;;;;;;"[ORIGINAL REPOSITORY LOCATION]";;";";;;;;;; ;;;;;;;;"[ORIGINAL REPOSITORY LOCATION]";;";";;;;;;;
;;;;;;;;"[FILM ID]";;".";;;;;;; ;;;;;;;;"[FILM ID]";;".";;;;;;;
58;"EE Census Records";"Microfilm (U.S.)";"Nonpopulation schedules";"FHL-GSU preservation film";"S";"ESM245";;"[ID]";"Census ID";",";;;;;;; 58;"EE Census Records";"Microfilm (U.S.)";"Nonpopulation schedules";"FHL-GSU preservation film";"S";"ESM245";;"[ID]";"Census ID";",";;;;;;;
;;;;;;;;"[JURISDICTION]";;",";;;;;;; ;;;;;;;;"[JURISDICTION]";;",";;;;;;;
;;;;;;;;"[SCHEDULE]";;",";;;;;;; ;;;;;;;;"[SCHEDULE]";;",";;;;;;;
;;;;;;;;"[PAGE]";;",";;;;;;; ;;;;;;;;"[PAGE]";;",";;;;;;;
;;;;;;;;"[ITEM OF INTEREST]";;".";;;"Quoted";;;; ;;;;;;;;"[ITEM OF INTEREST]";;".";;;"Quoted";;;;
59;"EE Census Records";"Microfilm (U.S.)";"Nonpopulation schedules";"UNC microfilm publication";"L";"ESM246";;"[JURISDICTION]";;".";"T";"REV.";;;;; 59;"EE Census Records";"Microfilm (U.S.)";"Nonpopulation schedules";"UNC microfilm publication";"L";"ESM246";;"[JURISDICTION]";;".";"T";"REV.";;;;;
;;;;;;;;"[ID]";"Census ID";",";"T";;;;;; ;;;;;;;;"[ID]";"Census ID";",";"T";;;;;;
;;;;;;;;"[SCHEDULE]";;".";"T";;;;;; ;;;;;;;;"[SCHEDULE]";;".";"T";;;;;;
;;;;;;;;"[TITLE]";"Film Title";".";"T";;"Italics";;;; ;;;;;;;;"[TITLE]";"Film Title";".";"T";;"Italics";;;;
@ -1089,7 +1089,7 @@
;;;;;;;;"[PUBLICATION PLACE]";;":";"P";;;;;; ;;;;;;;;"[PUBLICATION PLACE]";;":";"P";;;;;;
;;;;;;;;"[PUBLISHER]";;",";"P";;;;;; ;;;;;;;;"[PUBLISHER]";;",";"P";;;;;;
;;;;;;;;"[YEAR]";"Year(s)";".";"P";;;;;; ;;;;;;;;"[YEAR]";"Year(s)";".";"P";;;;;;
59;"EE Census Records";"Microfilm (U.S.)";"Nonpopulation schedules";"UNC microfilm publication";"F";"ESM246";;"[ID]";"Census ID";",";;;;;;; 59;"EE Census Records";"Microfilm (U.S.)";"Nonpopulation schedules";"UNC microfilm publication";"F";"ESM246";;"[ID]";"Census ID";",";;;;;;;
;;;;;;;;"[JURISDICTION]";;",";;;;;;; ;;;;;;;;"[JURISDICTION]";;",";;;;;;;
;;;;;;;;"[SCHEDULE]";;",";;;;;;; ;;;;;;;;"[SCHEDULE]";;",";;;;;;;
;;;;;;;"p.";"[PAGE]";"Page(s)";",";;;;;;; ;;;;;;;"p.";"[PAGE]";"Page(s)";",";;;;;;;
@ -1100,7 +1100,7 @@
;;;;;;;;"[PUBLISHER]";;",";;;;;;; ;;;;;;;;"[PUBLISHER]";;",";;;;;;;
;;;;;;;;"[YEAR]";"Year(s)";"),";;;;;;; ;;;;;;;;"[YEAR]";"Year(s)";"),";;;;;;;
;;;;;;;;"[ROLL]";;".";;;;;;; ;;;;;;;;"[ROLL]";;".";;;;;;;
59;"EE Census Records";"Microfilm (U.S.)";"Nonpopulation schedules";"UNC microfilm publication";"S";"ESM246";;"[ID]";"Census ID";",";;;;;;; 59;"EE Census Records";"Microfilm (U.S.)";"Nonpopulation schedules";"UNC microfilm publication";"S";"ESM246";;"[ID]";"Census ID";",";;;;;;;
;;;;;;;;"[JURISDICTION]";;",";;;;;;; ;;;;;;;;"[JURISDICTION]";;",";;;;;;;
;;;;;;;;"[SCHEDULE]";;",";;;;;;; ;;;;;;;;"[SCHEDULE]";;",";;;;;;;
;;;;;;;"p.";"[PAGE]";"Page(s)";",";;;;;;; ;;;;;;;"p.";"[PAGE]";"Page(s)";",";;;;;;;
@ -2592,16 +2592,16 @@
140;"EE Publications: Books, CDs, Maps, Leaflets & Videos";"Electronic Publications";"Video";;"S";"ESM656";;"[AUTHOR]";"Presenter";",";;"S";;;;; 140;"EE Publications: Books, CDs, Maps, Leaflets & Videos";"Electronic Publications";"Video";;"S";"ESM656";;"[AUTHOR]";"Presenter";",";;"S";;;;;
;;;;;;;;"[TITLE]";;",";;;"Italics";;;; ;;;;;;;;"[TITLE]";;",";;;"Italics";;;;
;;;;;;;;"[TIMESTAMP]";"Timestamp in Video";".";;;;;;; ;;;;;;;;"[TIMESTAMP]";"Timestamp in Video";".";;;;;;;
141;"EE Publications: Books, CDs, Maps, Leaflets & Videos";"Electronic Publications";"Website as book";;"L";"ESM657";;"[AUTHOR]";;".";"A";"SG";;;;; 141;"EE Publications: Books, CDs, Maps, Leaflets & Videos";"Electronic Publications";"Website as book";;"L";"ESM657";;"[AUTHOR]";;".";"A";"SG";;;;;
;;;;;;;;"[WEBSITE]";;".";"T";;"Italics";;;; ;;;;;;;;"[WEBSITE]";;".";"T";;"Italics";;;;
;;;;;;;;"[URL (DIGITAL LOCATION)] ";;":";"P";;;;;; ;;;;;;;;"[URL (DIGITAL LOCATION)] ";;":";"P";;;;;;
;;;;;;;;"[YEAR]";"Year(s)";".";"P";;;;;; ;;;;;;;;"[YEAR]";"Year(s)";".";"P";;;;;;
141;"EE Publications: Books, CDs, Maps, Leaflets & Videos";"Electronic Publications";"Website as book";;"F";"ESM657";;"[AUTHOR]";;",";;"GS";;;;; 141;"EE Publications: Books, CDs, Maps, Leaflets & Videos";"Electronic Publications";"Website as book";;"F";"ESM657";;"[AUTHOR]";;",";;"GS";;;;;
;;;;;;;;"[WEBSITE]";;;;;"Italics";;;; ;;;;;;;;"[WEBSITE]";;;;;"Italics";;;;
;;;;;;;"(";"[URL (DIGITAL LOCATION)]";;":";;;;;;; ;;;;;;;"(";"[URL (DIGITAL LOCATION)]";;":";;;;;;;
;;;;;;;"accessed";"[DATE ACCESSED]";;"),";;;;;;; ;;;;;;;"accessed";"[DATE ACCESSED]";;"),";;;;;;;
;;;;;;;;"[ITEM OF INTEREST]";;".";;;"Quoted";;;; ;;;;;;;;"[ITEM OF INTEREST]";;".";;;"Quoted";;;;
141;"EE Publications: Books, CDs, Maps, Leaflets & Videos";"Electronic Publications";"Website as book";;"S";"ESM657";;"[AUTHOR]";;",";;"S";;;;; 141;"EE Publications: Books, CDs, Maps, Leaflets & Videos";"Electronic Publications";"Website as book";;"S";"ESM657";;"[AUTHOR]";;",";;"S";;;;;
;;;;;;;;"[WEBSITE]";;",";;;"Italics";;;; ;;;;;;;;"[WEBSITE]";;",";;;"Italics";;;;
;;;;;;;;"[ITEM OF INTEREST]";;".";;;"Quoted";;;; ;;;;;;;;"[ITEM OF INTEREST]";;".";;;"Quoted";;;;
142;"EE Publications: Books, CDs, Maps, Leaflets & Videos";"Image Copies";"CD/DVD publication";;"L";"ESM658";;"[AUTHOR]";;".";"A";"SG";;;;; 142;"EE Publications: Books, CDs, Maps, Leaflets & Videos";"Image Copies";"CD/DVD publication";;"L";"ESM658";;"[AUTHOR]";;".";"A";"SG";;;;;

1 N Category Category Type Type Description Type Identifier LDEL Fields Label RDEL GEDCOM Shorten Attribute Privacy Optional Hint Tooltip
1036 [PAGE] ,
1037 [HOUSEHOLD] ,
1038 [ITEM OF INTEREST] Person of Interest .
1039 57 EE Census Records Microfilm (U.S.) “Nonpopulation” schedules Nonpopulation schedules NARA film L ESM244 [JURISDICTION] . T REV.
1040 [ID] Census ID . T
1041 [TITLE] Schedule Title schedule. T Quoted
1042 [FILM ID] . P
1043 [PUBLICATION PLACE] : P
1044 [PUBLISHER] , P
1045 [YEAR] Year(s) . P
1046 57 EE Census Records Microfilm (U.S.) “Nonpopulation” schedules Nonpopulation schedules NARA film F ESM244 [ID] Census ID ,
1047 [JURISDICTION] ,
1048 [TITLE] Schedule Title , Quoted
1049 [SECTION] ,
1052 [PAGE] Page(s) ,
1053 [ITEM OF INTEREST] Person of Interest ;
1054 [FILM ID] .
1055 57 EE Census Records Microfilm (U.S.) “Nonpopulation” schedules Nonpopulation schedules NARA film S ESM244 [ID] Census ID ,
1056 [JURISDICTION] ,
1057 [TITLE] Schedule Title , Quoted
1058 [SECTION] ,
1060 [DISTRICT] Enumeration District ,
1061 p. [PAGE] Page(s) ,
1062 [ITEM OF INTEREST] Person of Interest .
1063 58 EE Census Records Microfilm (U.S.) “Nonpopulation” schedules Nonpopulation schedules FHL-GSU preservation film L ESM245 [JURISDICTION] . T REV.
1064 [ID] Census ID , T
1065 [SCHEDULE] . T
1066 [ORIGINAL REPOSITORY] , P
1068 [FILM ID] . P
1069 [REPOSITORY] , P
1070 [REPOSITORY ADDRESS] . P LOC
1071 58 EE Census Records Microfilm (U.S.) “Nonpopulation” schedules Nonpopulation schedules FHL-GSU preservation film F ESM245 [ID] Census ID ,
1072 [JURISDICTION] ,
1073 [SCHEDULE] ,
1074 [PAGE] ,
1076 [ORIGINAL REPOSITORY] ,
1077 [ORIGINAL REPOSITORY LOCATION] ;
1078 [FILM ID] .
1079 58 EE Census Records Microfilm (U.S.) “Nonpopulation” schedules Nonpopulation schedules FHL-GSU preservation film S ESM245 [ID] Census ID ,
1080 [JURISDICTION] ,
1081 [SCHEDULE] ,
1082 [PAGE] ,
1083 [ITEM OF INTEREST] . Quoted
1084 59 EE Census Records Microfilm (U.S.) “Nonpopulation” schedules Nonpopulation schedules UNC microfilm publication L ESM246 [JURISDICTION] . T REV.
1085 [ID] Census ID , T
1086 [SCHEDULE] . T
1087 [TITLE] Film Title . T Italics
1089 [PUBLICATION PLACE] : P
1090 [PUBLISHER] , P
1091 [YEAR] Year(s) . P
1092 59 EE Census Records Microfilm (U.S.) “Nonpopulation” schedules Nonpopulation schedules UNC microfilm publication F ESM246 [ID] Census ID ,
1093 [JURISDICTION] ,
1094 [SCHEDULE] ,
1095 p. [PAGE] Page(s) ,
1100 [PUBLISHER] ,
1101 [YEAR] Year(s) ),
1102 [ROLL] .
1103 59 EE Census Records Microfilm (U.S.) “Nonpopulation” schedules Nonpopulation schedules UNC microfilm publication S ESM246 [ID] Census ID ,
1104 [JURISDICTION] ,
1105 [SCHEDULE] ,
1106 p. [PAGE] Page(s) ,
2592 140 EE Publications: Books, CDs, Maps, Leaflets & Videos Electronic Publications Video S ESM656 [AUTHOR] Presenter , S
2593 [TITLE] , Italics
2594 [TIMESTAMP] Timestamp in Video .
2595 141 EE Publications: Books, CDs, Maps, Leaflets & Videos Electronic Publications Website as “book” Website as book L ESM657 [AUTHOR] . A SG
2596 [WEBSITE] . T Italics
2597 [URL (DIGITAL LOCATION)] : P
2598 [YEAR] Year(s) . P
2599 141 EE Publications: Books, CDs, Maps, Leaflets & Videos Electronic Publications Website as “book” Website as book F ESM657 [AUTHOR] , GS
2600 [WEBSITE] Italics
2601 ( [URL (DIGITAL LOCATION)] :
2602 accessed [DATE ACCESSED] ),
2603 [ITEM OF INTEREST] . Quoted
2604 141 EE Publications: Books, CDs, Maps, Leaflets & Videos Electronic Publications Website as “book” Website as book S ESM657 [AUTHOR] , S
2605 [WEBSITE] , Italics
2606 [ITEM OF INTEREST] . Quoted
2607 142 EE Publications: Books, CDs, Maps, Leaflets & Videos Image Copies CD/DVD publication L ESM658 [AUTHOR] . A SG

View File

@ -66,6 +66,11 @@ SHORTERALG = {'LOC': 'SHORTERALG_LOC', 'YEAR': 'SHORTERALG_YEAR',
STYLES = {'Quoted': 'STYLE_QUOTE', 'Italics': 'STYLE_EMPH', STYLES = {'Quoted': 'STYLE_QUOTE', 'Italics': 'STYLE_EMPH',
'QuotedCont': 'STYLE_QUOTECONT', 'Bold': 'STYLE_BOLD'} 'QuotedCont': 'STYLE_QUOTECONT', 'Bold': 'STYLE_BOLD'}
#already defined srcattrtypes
KNOWN_FIELDS = ['EVEN_REC', 'EVEN_CITED', 'EVEN_ROLE', 'GEN_BY', 'REPOSITORY',
'REPOSITORY_ADDRESS', 'REPOSITORY_SHORT_VERSION', 'REPOSITORY_CALL_NUMBER',
'DATE']
DEFAULT_HINTS = { DEFAULT_HINTS = {
"ACT": "Public Law 12-98", "ACT": "Public Law 12-98",
"ADDRESS": "Broadway Avenue, New York", "ADDRESS": "Broadway Avenue, New York",
@ -351,6 +356,9 @@ with open(csvfilename, 'rb') as csvfile:
field_label = field_label.replace("'", "\\'") field_label = field_label.replace("'", "\\'")
if field_type in FIELDTYPEMAP: if field_type in FIELDTYPEMAP:
assert field_descr == FIELDTYPEMAP[field_type][1], 'Problem %s %s %s' % (field_type, field_descr, FIELDTYPEMAP[field_type][1]) assert field_descr == FIELDTYPEMAP[field_type][1], 'Problem %s %s %s' % (field_type, field_descr, FIELDTYPEMAP[field_type][1])
elif field_type in KNOWN_FIELDS:
#no need to add it
pass
else: else:
FIELDTYPEMAP[field_type] = (index, field_descr) FIELDTYPEMAP[field_type] = (index, field_descr)
index += 1 index += 1
@ -374,7 +382,7 @@ with open(csvfilename, 'rb') as csvfile:
#this #this
if shortcite and shorteralg == 'EMPTY': if shortcite and shorteralg == 'EMPTY':
field_type_short = field_type + '_SHORT_VERSION' field_type_short = field_type + '_SHORT_VERSION'
if field_type_short in FIELDTYPEMAP: if field_type_short in FIELDTYPEMAP or field_type_short in KNOWN_FIELDS:
pass pass
else: else:
FIELDTYPEMAP[field_type_short] = (index, field_descr + ' (Short)') FIELDTYPEMAP[field_type_short] = (index, field_descr + ' (Short)')
@ -451,7 +459,7 @@ for source_type in allkeys:
tooltip = '_("' + field[10] + '")' tooltip = '_("' + field[10] + '")'
else: else:
tooltip = 'None' tooltip = 'None'
code += " ('"+ field[0] + "', " + field[1] + ", _('"\ code += " ('"+ field[0] + "', SrcAttributeType." + field[1] + ", _('"\
+field[3] + "'), '"+ field[2] + "', " + field[4] + ", " + field[5] + ", "\ +field[3] + "'), '"+ field[2] + "', " + field[4] + ", " + field[5] + ", "\
+ field[6] + ", " + field[7] + ", " + field[8] + ",\n" \ + field[6] + ", " + field[7] + ", " + field[8] + ",\n" \
+ " " +hint + ", " + tooltip + "),\n" + " " +hint + ", " + tooltip + "),\n"

View File

@ -32,6 +32,7 @@ SrcAttributeBase class for GRAMPS.
from .attrbase import AttributeRootBase from .attrbase import AttributeRootBase
from .srcattribute import SrcAttribute from .srcattribute import SrcAttribute
from .srcattrtype import SrcAttributeType from .srcattrtype import SrcAttributeType
from .srctemplate import SrcTemplate
#------------------------------------------------------------------------- #-------------------------------------------------------------------------
# #
@ -56,27 +57,27 @@ class SrcAttributeBase(AttributeRootBase):
:rtype tuple: (index, description, string_key_as stored) :rtype tuple: (index, description, string_key_as stored)
""" """
#no template is UNKNOWN! #no template is UNKNOWN!
templ = SrcAttributeType.UNKNOWN templ = SrcTemplate.UNKNOWN
for attr in self.attribute_list: for attr in self.attribute_list:
if int(attr.get_type()) == SrcAttributeType.SRCTEMPLATE: if int(attr.get_type()) == SrcAttributeType.SRCTEMPLATE:
val = attr.get_value() val = attr.get_value()
try: try:
templ = SrcAttributeType.K2I_SRCTEMPLATEMAP[val] templ = SrcTemplate.K2I_SRCTEMPLATEMAP[val]
except KeyError: except KeyError:
# a template not in the predefined list. convert to unknown # a template not in the predefined list. convert to unknown
print ('SrcAttributeBase: Keyerror "', val, print ('SrcAttributeBase: Keyerror "', val,
'"for now UNKNOWN taken, later custom templates?') '"for now UNKNOWN taken, later custom templates?')
break break
try: try:
retval = (templ, SrcAttributeType.I2S_SRCTEMPLATEMAP[templ], retval = (templ, SrcTemplate.I2S_SRCTEMPLATEMAP[templ],
SrcAttributeType.I2K_SRCTEMPLATEMAP[templ]) SrcTemplate.I2K_SRCTEMPLATEMAP[templ])
except KeyError: except KeyError:
#templ is not present, return the default GEDCOM value as actual #templ is not present, return the default GEDCOM value as actual
#template #template
templ = SrcAttributeType.UNKNOWN templ = SrcTemplate.UNKNOWN
retval = (templ, retval = (templ,
SrcAttributeType.I2S_SRCTEMPLATEMAP[SrcAttributeType.UNKNOWN], SrcTemplate.I2S_SRCTEMPLATEMAP[SrcTemplate.UNKNOWN],
SrcAttributeType.I2K_SRCTEMPLATEMAP[SrcAttributeType.UNKNOWN]) SrcTemplate.I2K_SRCTEMPLATEMAP[SrcTemplate.UNKNOWN])
return retval return retval
def set_source_template(self, tempindex, tempcustom_str): def set_source_template(self, tempindex, tempcustom_str):
@ -100,11 +101,11 @@ class SrcAttributeBase(AttributeRootBase):
#we create a new attribute and add it #we create a new attribute and add it
attrtemp = SrcAttribute() attrtemp = SrcAttribute()
self.add_attribute(attrtemp) self.add_attribute(attrtemp)
if tempindex == SrcAttributeType.UNKNOWN or \ if tempindex == SrcTemplate.UNKNOWN or \
(tempindex == SrcAttributeType.CUSTOM and tempcustom_str.strip() == ''): (tempindex == SrcTemplate.CUSTOM and tempcustom_str.strip() == ''):
self.remove_attribute(attrtemp) self.remove_attribute(attrtemp)
elif not (tempindex == SrcAttributeType.CUSTOM): elif not (tempindex == SrcTemplate.CUSTOM):
attrtemp.set_value(SrcAttributeType.I2K_SRCTEMPLATEMAP[tempindex]) attrtemp.set_value(SrcTemplate.I2K_SRCTEMPLATEMAP[tempindex])
else: else:
#custom key, store string as is #custom key, store string as is
attrtemp.set_value(tempindex) attrtemp.set_value(tempindex)

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -120,7 +120,6 @@ class SrcTemplateTab(GrampsTab):
:param scrolled: GtkScrolledWindow to which to add treeview with templates :param scrolled: GtkScrolledWindow to which to add treeview with templates
""" """
srcattr = SrcAttributeType()
templ = self.src.get_source_template() templ = self.src.get_source_template()
self.temp_tv = SrcTemplateTreeView(templ[2], self.temp_tv = SrcTemplateTreeView(templ[2],
sel_callback=self.on_template_selected) sel_callback=self.on_template_selected)
@ -199,10 +198,9 @@ class TemplateFields(object):
Template must be the index of the template. Template must be the index of the template.
""" """
#obtain the template of the index #obtain the template of the index
srcattr = SrcAttributeType() if index in SrcTemplate.EVIDENCETEMPLATES:
if index in srcattr.EVIDENCETEMPLATES:
#a predefined template, #a predefined template,
template = srcattr.EVIDENCETEMPLATES[index] template = SrcTemplate.EVIDENCETEMPLATES[index]
else: else:
return return
@ -298,6 +296,8 @@ class TemplateFields(object):
""" """
self.gridfields.insert_row(row) self.gridfields.insert_row(row)
field = srcattrtype field = srcattrtype
if isinstance(field, basestring):
raise NotImplementedError, "type must be the integer key"
#setup label #setup label
if alt_label: if alt_label:
label = alt_label label = alt_label

View File

@ -44,7 +44,7 @@ from gi.repository import Gtk
# Gramps classes # Gramps classes
# #
#------------------------------------------------------------------------- #-------------------------------------------------------------------------
from gramps.gen.lib import SrcAttributeType from gramps.gen.lib import SrcTemplate
#------------------------------------------------------------------------- #-------------------------------------------------------------------------
# #
@ -54,7 +54,7 @@ from gramps.gen.lib import SrcAttributeType
class SrcTemplateTreeView(Gtk.TreeView): class SrcTemplateTreeView(Gtk.TreeView):
''' '''
TreeView for SrcAttribute templates, to allow fast selection TreeView for SrcTemplate templates, to allow fast selection
''' '''
def __init__(self, default_key, sel_callback): def __init__(self, default_key, sel_callback):
""" """
@ -78,11 +78,11 @@ class SrcTemplateTreeView(Gtk.TreeView):
""" """
Obtains all templates and stores them in a TreeStore Obtains all templates and stores them in a TreeStore
""" """
srcattrt = SrcAttributeType() srctemp = SrcTemplate()
self.I2Str = srcattrt.I2S_SRCTEMPLATEMAP self.I2Str = srctemp.I2S_SRCTEMPLATEMAP
self.I2Key = srcattrt.I2K_SRCTEMPLATEMAP self.I2Key = srctemp.I2K_SRCTEMPLATEMAP
self.Str2I = srcattrt.S2I_SRCTEMPLATEMAP self.Str2I = srctemp.S2I_SRCTEMPLATEMAP
self.Key2I = srcattrt.K2I_SRCTEMPLATEMAP self.Key2I = srctemp.K2I_SRCTEMPLATEMAP
self.Key2Path = {} self.Key2Path = {}
# store (index, key, src_type) # store (index, key, src_type)
self.model = Gtk.TreeStore(int, str, str) self.model = Gtk.TreeStore(int, str, str)