GEP18: refractor: move template stuff to srctemplate.py
svn: r22554
This commit is contained in:
parent
8ad6600746
commit
99671bdfaf
@ -1036,14 +1036,14 @@
|
||||
;;;;;;;;"[PAGE]";;",";;;;;;;
|
||||
;;;;;;;;"[HOUSEHOLD]";;",";;;;;;;
|
||||
;;;;;;;;"[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";;;;;;
|
||||
;;;;;;;;"[TITLE]";"Schedule Title";"schedule.";"T";;"Quoted";;;;
|
||||
;;;;;;;;"[FILM ID]";;".";"P";;;;;;
|
||||
;;;;;;;;"[PUBLICATION PLACE]";;":";"P";;;;;;
|
||||
;;;;;;;;"[PUBLISHER]";;",";"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]";;",";;;;;;;
|
||||
;;;;;;;;"[TITLE]";"Schedule Title";",";;;"Quoted";;;;
|
||||
;;;;;;;;"[SECTION]";;",";;;;;;;
|
||||
@ -1052,7 +1052,7 @@
|
||||
;;;;;;;;"[PAGE]";"Page(s)";",";;;;;;;
|
||||
;;;;;;;;"[ITEM OF INTEREST]";"Person of Interest";";";;;;;;;
|
||||
;;;;;;;;"[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]";;",";;;;;;;
|
||||
;;;;;;;;"[TITLE]";"Schedule Title";",";;;"Quoted";;;;
|
||||
;;;;;;;;"[SECTION]";;",";;;;;;;
|
||||
@ -1060,7 +1060,7 @@
|
||||
;;;;;;;;"[DISTRICT]";"Enumeration District";",";;;;;;;
|
||||
;;;;;;;"p.";"[PAGE]";"Page(s)";",";;;;;;;
|
||||
;;;;;;;;"[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";;;;;;
|
||||
;;;;;;;;"[SCHEDULE]";;".";"T";;;;;;
|
||||
;;;;;;;;"[ORIGINAL REPOSITORY]";;",";"P";;;;;;
|
||||
@ -1068,7 +1068,7 @@
|
||||
;;;;;;;;"[FILM ID]";;".";"P";;;;;;
|
||||
;;;;;;;;"[REPOSITORY]";;",";"P";;;;;;
|
||||
;;;;;;;;"[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]";;",";;;;;;;
|
||||
;;;;;;;;"[SCHEDULE]";;",";;;;;;;
|
||||
;;;;;;;;"[PAGE]";;",";;;;;;;
|
||||
@ -1076,12 +1076,12 @@
|
||||
;;;;;;;;"[ORIGINAL REPOSITORY]";;",";;;;;;;
|
||||
;;;;;;;;"[ORIGINAL REPOSITORY LOCATION]";;";";;;;;;;
|
||||
;;;;;;;;"[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]";;",";;;;;;;
|
||||
;;;;;;;;"[SCHEDULE]";;",";;;;;;;
|
||||
;;;;;;;;"[PAGE]";;",";;;;;;;
|
||||
;;;;;;;;"[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";;;;;;
|
||||
;;;;;;;;"[SCHEDULE]";;".";"T";;;;;;
|
||||
;;;;;;;;"[TITLE]";"Film Title";".";"T";;"Italics";;;;
|
||||
@ -1089,7 +1089,7 @@
|
||||
;;;;;;;;"[PUBLICATION PLACE]";;":";"P";;;;;;
|
||||
;;;;;;;;"[PUBLISHER]";;",";"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]";;",";;;;;;;
|
||||
;;;;;;;;"[SCHEDULE]";;",";;;;;;;
|
||||
;;;;;;;"p.";"[PAGE]";"Page(s)";",";;;;;;;
|
||||
@ -1100,7 +1100,7 @@
|
||||
;;;;;;;;"[PUBLISHER]";;",";;;;;;;
|
||||
;;;;;;;;"[YEAR]";"Year(s)";"),";;;;;;;
|
||||
;;;;;;;;"[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]";;",";;;;;;;
|
||||
;;;;;;;;"[SCHEDULE]";;",";;;;;;;
|
||||
;;;;;;;"p.";"[PAGE]";"Page(s)";",";;;;;;;
|
||||
@ -2592,16 +2592,16 @@
|
||||
140;"EE Publications: Books, CDs, Maps, Leaflets & Videos";"Electronic Publications";"Video";;"S";"ESM656";;"[AUTHOR]";"Presenter";",";;"S";;;;;
|
||||
;;;;;;;;"[TITLE]";;",";;;"Italics";;;;
|
||||
;;;;;;;;"[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";;;;
|
||||
;;;;;;;;"[URL (DIGITAL LOCATION)] ";;":";"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";;;;
|
||||
;;;;;;;"(";"[URL (DIGITAL LOCATION)]";;":";;;;;;;
|
||||
;;;;;;;"accessed";"[DATE ACCESSED]";;"),";;;;;;;
|
||||
;;;;;;;;"[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";;;;
|
||||
;;;;;;;;"[ITEM OF INTEREST]";;".";;;"Quoted";;;;
|
||||
142;"EE Publications: Books, CDs, Maps, Leaflets & Videos";"Image Copies";"CD/DVD publication";;"L";"ESM658";;"[AUTHOR]";;".";"A";"SG";;;;;
|
||||
|
|
@ -66,6 +66,11 @@ SHORTERALG = {'LOC': 'SHORTERALG_LOC', 'YEAR': 'SHORTERALG_YEAR',
|
||||
STYLES = {'Quoted': 'STYLE_QUOTE', 'Italics': 'STYLE_EMPH',
|
||||
'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 = {
|
||||
"ACT": "Public Law 12-98",
|
||||
"ADDRESS": "Broadway Avenue, New York",
|
||||
@ -351,6 +356,9 @@ with open(csvfilename, 'rb') as csvfile:
|
||||
field_label = field_label.replace("'", "\\'")
|
||||
if field_type in FIELDTYPEMAP:
|
||||
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:
|
||||
FIELDTYPEMAP[field_type] = (index, field_descr)
|
||||
index += 1
|
||||
@ -374,7 +382,7 @@ with open(csvfilename, 'rb') as csvfile:
|
||||
#this
|
||||
if shortcite and shorteralg == 'EMPTY':
|
||||
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
|
||||
else:
|
||||
FIELDTYPEMAP[field_type_short] = (index, field_descr + ' (Short)')
|
||||
@ -451,7 +459,7 @@ for source_type in allkeys:
|
||||
tooltip = '_("' + field[10] + '")'
|
||||
else:
|
||||
tooltip = 'None'
|
||||
code += " ('"+ field[0] + "', " + field[1] + ", _('"\
|
||||
code += " ('"+ field[0] + "', SrcAttributeType." + field[1] + ", _('"\
|
||||
+field[3] + "'), '"+ field[2] + "', " + field[4] + ", " + field[5] + ", "\
|
||||
+ field[6] + ", " + field[7] + ", " + field[8] + ",\n" \
|
||||
+ " " +hint + ", " + tooltip + "),\n"
|
||||
|
@ -32,6 +32,7 @@ SrcAttributeBase class for GRAMPS.
|
||||
from .attrbase import AttributeRootBase
|
||||
from .srcattribute import SrcAttribute
|
||||
from .srcattrtype import SrcAttributeType
|
||||
from .srctemplate import SrcTemplate
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
#
|
||||
@ -56,27 +57,27 @@ class SrcAttributeBase(AttributeRootBase):
|
||||
:rtype tuple: (index, description, string_key_as stored)
|
||||
"""
|
||||
#no template is UNKNOWN!
|
||||
templ = SrcAttributeType.UNKNOWN
|
||||
templ = SrcTemplate.UNKNOWN
|
||||
for attr in self.attribute_list:
|
||||
if int(attr.get_type()) == SrcAttributeType.SRCTEMPLATE:
|
||||
val = attr.get_value()
|
||||
try:
|
||||
templ = SrcAttributeType.K2I_SRCTEMPLATEMAP[val]
|
||||
templ = SrcTemplate.K2I_SRCTEMPLATEMAP[val]
|
||||
except KeyError:
|
||||
# a template not in the predefined list. convert to unknown
|
||||
print ('SrcAttributeBase: Keyerror "', val,
|
||||
'"for now UNKNOWN taken, later custom templates?')
|
||||
break
|
||||
try:
|
||||
retval = (templ, SrcAttributeType.I2S_SRCTEMPLATEMAP[templ],
|
||||
SrcAttributeType.I2K_SRCTEMPLATEMAP[templ])
|
||||
retval = (templ, SrcTemplate.I2S_SRCTEMPLATEMAP[templ],
|
||||
SrcTemplate.I2K_SRCTEMPLATEMAP[templ])
|
||||
except KeyError:
|
||||
#templ is not present, return the default GEDCOM value as actual
|
||||
#template
|
||||
templ = SrcAttributeType.UNKNOWN
|
||||
templ = SrcTemplate.UNKNOWN
|
||||
retval = (templ,
|
||||
SrcAttributeType.I2S_SRCTEMPLATEMAP[SrcAttributeType.UNKNOWN],
|
||||
SrcAttributeType.I2K_SRCTEMPLATEMAP[SrcAttributeType.UNKNOWN])
|
||||
SrcTemplate.I2S_SRCTEMPLATEMAP[SrcTemplate.UNKNOWN],
|
||||
SrcTemplate.I2K_SRCTEMPLATEMAP[SrcTemplate.UNKNOWN])
|
||||
return retval
|
||||
|
||||
def set_source_template(self, tempindex, tempcustom_str):
|
||||
@ -100,11 +101,11 @@ class SrcAttributeBase(AttributeRootBase):
|
||||
#we create a new attribute and add it
|
||||
attrtemp = SrcAttribute()
|
||||
self.add_attribute(attrtemp)
|
||||
if tempindex == SrcAttributeType.UNKNOWN or \
|
||||
(tempindex == SrcAttributeType.CUSTOM and tempcustom_str.strip() == ''):
|
||||
if tempindex == SrcTemplate.UNKNOWN or \
|
||||
(tempindex == SrcTemplate.CUSTOM and tempcustom_str.strip() == ''):
|
||||
self.remove_attribute(attrtemp)
|
||||
elif not (tempindex == SrcAttributeType.CUSTOM):
|
||||
attrtemp.set_value(SrcAttributeType.I2K_SRCTEMPLATEMAP[tempindex])
|
||||
elif not (tempindex == SrcTemplate.CUSTOM):
|
||||
attrtemp.set_value(SrcTemplate.I2K_SRCTEMPLATEMAP[tempindex])
|
||||
else:
|
||||
#custom key, store string as is
|
||||
attrtemp.set_value(tempindex)
|
||||
|
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@ -120,7 +120,6 @@ class SrcTemplateTab(GrampsTab):
|
||||
|
||||
:param scrolled: GtkScrolledWindow to which to add treeview with templates
|
||||
"""
|
||||
srcattr = SrcAttributeType()
|
||||
templ = self.src.get_source_template()
|
||||
self.temp_tv = SrcTemplateTreeView(templ[2],
|
||||
sel_callback=self.on_template_selected)
|
||||
@ -199,10 +198,9 @@ class TemplateFields(object):
|
||||
Template must be the index of the template.
|
||||
"""
|
||||
#obtain the template of the index
|
||||
srcattr = SrcAttributeType()
|
||||
if index in srcattr.EVIDENCETEMPLATES:
|
||||
if index in SrcTemplate.EVIDENCETEMPLATES:
|
||||
#a predefined template,
|
||||
template = srcattr.EVIDENCETEMPLATES[index]
|
||||
template = SrcTemplate.EVIDENCETEMPLATES[index]
|
||||
else:
|
||||
return
|
||||
|
||||
@ -298,6 +296,8 @@ class TemplateFields(object):
|
||||
"""
|
||||
self.gridfields.insert_row(row)
|
||||
field = srcattrtype
|
||||
if isinstance(field, basestring):
|
||||
raise NotImplementedError, "type must be the integer key"
|
||||
#setup label
|
||||
if alt_label:
|
||||
label = alt_label
|
||||
|
@ -44,7 +44,7 @@ from gi.repository import Gtk
|
||||
# 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):
|
||||
'''
|
||||
TreeView for SrcAttribute templates, to allow fast selection
|
||||
TreeView for SrcTemplate templates, to allow fast selection
|
||||
'''
|
||||
def __init__(self, default_key, sel_callback):
|
||||
"""
|
||||
@ -78,11 +78,11 @@ class SrcTemplateTreeView(Gtk.TreeView):
|
||||
"""
|
||||
Obtains all templates and stores them in a TreeStore
|
||||
"""
|
||||
srcattrt = SrcAttributeType()
|
||||
self.I2Str = srcattrt.I2S_SRCTEMPLATEMAP
|
||||
self.I2Key = srcattrt.I2K_SRCTEMPLATEMAP
|
||||
self.Str2I = srcattrt.S2I_SRCTEMPLATEMAP
|
||||
self.Key2I = srcattrt.K2I_SRCTEMPLATEMAP
|
||||
srctemp = SrcTemplate()
|
||||
self.I2Str = srctemp.I2S_SRCTEMPLATEMAP
|
||||
self.I2Key = srctemp.I2K_SRCTEMPLATEMAP
|
||||
self.Str2I = srctemp.S2I_SRCTEMPLATEMAP
|
||||
self.Key2I = srctemp.K2I_SRCTEMPLATEMAP
|
||||
self.Key2Path = {}
|
||||
# store (index, key, src_type)
|
||||
self.model = Gtk.TreeStore(int, str, str)
|
||||
|
Loading…
Reference in New Issue
Block a user