Updated code to:
. http://www.gramps-project.org/bugs/view.php?id=3430 . . added a $G[vtdelcspnom] to display . . . researcher information . . . gramps version and database name . be more vim compliant and a little more PEP compliant svn: r22661
This commit is contained in:
parent
afc8a28d6e
commit
bcc17b3700
@ -45,6 +45,7 @@ from gramps.gen.lib import EventType
|
|||||||
from gramps.gen.utils.db import get_birth_or_fallback, get_death_or_fallback
|
from gramps.gen.utils.db import get_birth_or_fallback, get_death_or_fallback
|
||||||
from gramps.gen.constfunc import STRTYPE, cuni
|
from gramps.gen.constfunc import STRTYPE, cuni
|
||||||
|
|
||||||
|
|
||||||
#------------------------------------------------------------------------
|
#------------------------------------------------------------------------
|
||||||
#
|
#
|
||||||
# Local constants
|
# Local constants
|
||||||
@ -135,6 +136,7 @@ class GenericFormat(object):
|
|||||||
|
|
||||||
return main
|
return main
|
||||||
|
|
||||||
|
|
||||||
#------------------------------------------------------------------------
|
#------------------------------------------------------------------------
|
||||||
# Name Format strings
|
# Name Format strings
|
||||||
#------------------------------------------------------------------------
|
#------------------------------------------------------------------------
|
||||||
@ -178,6 +180,7 @@ class NameFormat(GenericFormat):
|
|||||||
|
|
||||||
return self.generic_format(name, code, upper, function)
|
return self.generic_format(name, code, upper, function)
|
||||||
|
|
||||||
|
|
||||||
#------------------------------------------------------------------------
|
#------------------------------------------------------------------------
|
||||||
# Date Format strings
|
# Date Format strings
|
||||||
#------------------------------------------------------------------------
|
#------------------------------------------------------------------------
|
||||||
@ -286,6 +289,7 @@ class DateFormat(GenericFormat):
|
|||||||
|
|
||||||
return self.generic_format(date, code, upper, function)
|
return self.generic_format(date, code, upper, function)
|
||||||
|
|
||||||
|
|
||||||
#------------------------------------------------------------------------
|
#------------------------------------------------------------------------
|
||||||
# Place Format strings
|
# Place Format strings
|
||||||
#------------------------------------------------------------------------
|
#------------------------------------------------------------------------
|
||||||
@ -312,7 +316,7 @@ class PlaceFormat(GenericFormat):
|
|||||||
if self.is_blank(place):
|
if self.is_blank(place):
|
||||||
return
|
return
|
||||||
|
|
||||||
code = "elcuspnitxy"
|
code = "elcuspn" + "oitxy"
|
||||||
upper = code.upper()
|
upper = code.upper()
|
||||||
function = [place.get_main_location().get_street,
|
function = [place.get_main_location().get_street,
|
||||||
place.get_main_location().get_locality,
|
place.get_main_location().get_locality,
|
||||||
@ -321,6 +325,8 @@ class PlaceFormat(GenericFormat):
|
|||||||
place.get_main_location().get_state,
|
place.get_main_location().get_state,
|
||||||
place.get_main_location().get_postal_code,
|
place.get_main_location().get_postal_code,
|
||||||
place.get_main_location().get_country,
|
place.get_main_location().get_country,
|
||||||
|
|
||||||
|
place.get_main_location().get_phone,
|
||||||
place.get_main_location().get_parish,
|
place.get_main_location().get_parish,
|
||||||
place.get_title,
|
place.get_title,
|
||||||
place.get_longitude,
|
place.get_longitude,
|
||||||
@ -329,6 +335,7 @@ class PlaceFormat(GenericFormat):
|
|||||||
|
|
||||||
return self.generic_format(place, code, upper, function)
|
return self.generic_format(place, code, upper, function)
|
||||||
|
|
||||||
|
|
||||||
#------------------------------------------------------------------------
|
#------------------------------------------------------------------------
|
||||||
# Event Format strings
|
# Event Format strings
|
||||||
#------------------------------------------------------------------------
|
#------------------------------------------------------------------------
|
||||||
@ -409,6 +416,50 @@ class EventFormat(GenericFormat):
|
|||||||
|
|
||||||
return self.generic_format(None, code, "", function)
|
return self.generic_format(None, code, "", function)
|
||||||
|
|
||||||
|
|
||||||
|
#------------------------------------------------------------------------
|
||||||
|
# gramps info Format strings
|
||||||
|
#------------------------------------------------------------------------
|
||||||
|
class GrampsFormat():
|
||||||
|
""" The Gramps Info Format class.
|
||||||
|
This only polls information from system information.
|
||||||
|
"""
|
||||||
|
|
||||||
|
def __init__(self, _in, _db):
|
||||||
|
self.string_in = _in
|
||||||
|
self.db = _db
|
||||||
|
|
||||||
|
def parse_format(self):
|
||||||
|
""" Parse the Gramps format string.
|
||||||
|
let the date or place classes handle any sub-format strings """
|
||||||
|
from gramps.version import VERSION
|
||||||
|
|
||||||
|
from gramps.gen.utils.config import get_researcher
|
||||||
|
owner = get_researcher()
|
||||||
|
|
||||||
|
code = "vtd" + "elcspn" + "om"
|
||||||
|
info = [VERSION,
|
||||||
|
owner.get_name(),
|
||||||
|
self.db.get_dbname(),
|
||||||
|
|
||||||
|
owner.get_address(),
|
||||||
|
owner.get_locality(),
|
||||||
|
owner.get_city(),
|
||||||
|
owner.get_state(),
|
||||||
|
owner.get_postal_code(),
|
||||||
|
owner.get_country(),
|
||||||
|
|
||||||
|
owner.get_phone(),
|
||||||
|
owner.get_email()
|
||||||
|
]
|
||||||
|
|
||||||
|
where = code.find(self.string_in.this)
|
||||||
|
if where != -1:
|
||||||
|
self.string_in.step()
|
||||||
|
return info[where]
|
||||||
|
return "$G"
|
||||||
|
|
||||||
|
|
||||||
#------------------------------------------------------------------------
|
#------------------------------------------------------------------------
|
||||||
# Gallery Format strings
|
# Gallery Format strings
|
||||||
#------------------------------------------------------------------------
|
#------------------------------------------------------------------------
|
||||||
@ -480,6 +531,7 @@ class GalleryFormat(GenericFormat):
|
|||||||
|
|
||||||
return self.generic_format(None, code, "", function)
|
return self.generic_format(None, code, "", function)
|
||||||
|
|
||||||
|
|
||||||
#------------------------------------------------------------------------
|
#------------------------------------------------------------------------
|
||||||
#
|
#
|
||||||
# ConsumableString - The Input string class
|
# ConsumableString - The Input string class
|
||||||
@ -719,7 +771,7 @@ class VariableParse(object):
|
|||||||
def is_a(self):
|
def is_a(self):
|
||||||
""" check """
|
""" check """
|
||||||
return self._in.this == "$" and self._in.next is not None and \
|
return self._in.this == "$" and self._in.next is not None and \
|
||||||
"nsijbBdDmMvVauetTpP".find(self._in.next) != -1
|
"nsijbBdDmMvVauetTpPG".find(self._in.next) != -1
|
||||||
|
|
||||||
def get_event_by_type(self, marriage, e_type):
|
def get_event_by_type(self, marriage, e_type):
|
||||||
""" get an event from a type """
|
""" get an event from a type """
|
||||||
@ -942,6 +994,10 @@ class VariableParse(object):
|
|||||||
#photo for the marriage
|
#photo for the marriage
|
||||||
return self.__parse_photo(self.friend.family)
|
return self.__parse_photo(self.friend.family)
|
||||||
|
|
||||||
|
elif next_char == "G":
|
||||||
|
gramps_format = GrampsFormat(self._in, self.database)
|
||||||
|
return gramps_format.parse_format()
|
||||||
|
|
||||||
|
|
||||||
#------------------------------------------------------------------------
|
#------------------------------------------------------------------------
|
||||||
#
|
#
|
||||||
@ -1184,6 +1240,7 @@ if __name__ == '__main__':
|
|||||||
from gramps.gen.lib.date import Date
|
from gramps.gen.lib.date import Date
|
||||||
y_or_n = ()
|
y_or_n = ()
|
||||||
date_to_test = Date()
|
date_to_test = Date()
|
||||||
|
|
||||||
def date_set():
|
def date_set():
|
||||||
date_to_test.set_yr_mon_day(
|
date_to_test.set_yr_mon_day(
|
||||||
1970 if 0 in y_or_n else 0,
|
1970 if 0 in y_or_n else 0,
|
||||||
@ -1259,6 +1316,7 @@ if __name__ == '__main__':
|
|||||||
from gramps.gen.lib.name import Name
|
from gramps.gen.lib.name import Name
|
||||||
y_or_n = ()
|
y_or_n = ()
|
||||||
name_to_test = Name()
|
name_to_test = Name()
|
||||||
|
|
||||||
def name_set():
|
def name_set():
|
||||||
#code = "tfcnxslg"
|
#code = "tfcnxslg"
|
||||||
name_to_test.set_call_name("Bob" if 0 in y_or_n else "")
|
name_to_test.set_call_name("Bob" if 0 in y_or_n else "")
|
||||||
@ -1318,7 +1376,7 @@ if __name__ == '__main__':
|
|||||||
consume_str = ConsumableString(line_in)
|
consume_str = ConsumableString(line_in)
|
||||||
answer = main_level_test(consume_str, NameFormat, name_to_test)
|
answer = main_level_test(consume_str, NameFormat, name_to_test)
|
||||||
print(answer)
|
print(answer)
|
||||||
print("Good" if answer == "BobDr.2Billy3Buck4BobIV6The Clubs" \
|
print("Good" if answer == "BobDr.2Billy3Buck4BobIV6The Clubs"
|
||||||
else "!! bad !!")
|
else "!! bad !!")
|
||||||
|
|
||||||
|
|
||||||
@ -1330,6 +1388,7 @@ if __name__ == '__main__':
|
|||||||
from gramps.gen.lib.place import Place
|
from gramps.gen.lib.place import Place
|
||||||
y_or_n = ()
|
y_or_n = ()
|
||||||
place_to_test = Place()
|
place_to_test = Place()
|
||||||
|
|
||||||
def place_set():
|
def place_set():
|
||||||
#code = "elcuspnitxy"
|
#code = "elcuspnitxy"
|
||||||
main_loc = place_to_test.get_main_location()
|
main_loc = place_to_test.get_main_location()
|
||||||
@ -1412,4 +1471,3 @@ if __name__ == '__main__':
|
|||||||
34, 35, 38, 39, 38, 33, 32, 33, 36, 37, 36, 40, 41, 40, 44, 33, 32, 33,
|
34, 35, 38, 39, 38, 33, 32, 33, 36, 37, 36, 40, 41, 40, 44, 33, 32, 33,
|
||||||
36, 37, 36, 40, 41, 40, 44, 38, 39, 38, 42, 46] else "!! bad !!")
|
36, 37, 36, 40, 41, 40, 44, 38, 39, 38, 42, 46] else "!! bad !!")
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user