Extracting constants from python code

Thanks again, Paul. That works fine now for EventType. I should be able to figure out the other ones.

FYI, in case anyone else wants this, here are the changes I made in my copy of ExportSQL.py.

Added these Gramps modules:

from gramps.gen.lib.attrtype import AttributeType
from gramps.gen.lib.eventroletype import EventRoleType
from gramps.gen.lib.eventtype import EventType
from gramps.gen.lib.familyreltype import FamilyRelType
from gramps.gen.lib.childreftype import ChildRefType
from gramps.gen.lib.nameorigintype import NameOriginType
from gramps.gen.lib.nametype import NameType
from gramps.gen.lib.notetype import NoteType
from gramps.gen.lib.placetype import PlaceType
from gramps.gen.lib.repotype import RepositoryType
from gramps.gen.lib.srcmediatype import SourceMediaType
from gramps.gen.lib.srcattrtype import SrcAttributeType
from gramps.gen.lib.styledtexttagtype import StyledTextTagType
from gramps.gen.lib.urltype import UrlType

Changed this line in export_url_list():

# type_[1],
str(UrlType(type_)),

Changed these lines in export_note():

# note_type[1], change, private)
str(NoteType(note_type)), change, private)

# export_markup(db, “note”, handle, markup_code[0], markup_code[1],
export_markup(db, “note”, handle, markup_code[0], str(StyledTextTagType(markup_code)),

(Note: I haven’t used markup in my Notes, so I had no data of my own for testing this. Using the Gramps “example” database, I got results like this:

handle,markup0,markup1,value,start_stop_list
e8b4d90b33ad9a8eb8e741a6a9,0,Bold,"[(0, 10)]"

I don’t know if that’s how the start_stop_list should be formatted. The following line of code, which I did not change, looks like this:

value, str(start_stop_list)) # Not normal form; use eval

I don’t know what that comment means.)

Changed this line in export_event():

# the_type[1],
str(EventType(the_type)),

Changed this line in export_event_ref():

# role[1],
str(EventRoleType(role)),

Changed this line in export_surname():

# origin_type[1], connector)
str(NameOriginType(origin_type)), connector)

Changed this line in export_name():

# name_type[0], name_type[1], group_as,
name_type[0], str(NameType(name_type)), group_as,

Changed this line in export_attribute():

# handle, the_type[0], the_type[1], value, private)
handle, the_type[0], str(AttributeType(the_type)), value, private)

Changed these lines in export_child_ref_list:

# handle, ref, frel[0], frel[1],
handle, ref, frel[0], str(ChildRefType(frel)),
# mrel[0], mrel[1], private)
mrel[0], str(ChildRefType(mrel)), private)

Changed this line in export_datamap_list():

# from_handle, data_type[0], data_type[1],
from_handle, data_type[0], str(SrcAttributeType(data_type)),

Changed this line in export_repository_ref():

# source_media_type[1],
str(SourceMediaType(source_media_type)),

Changed these lines in export_data():

# the_type[0], the_type[1], change,
the_type[0], str(FamilyRelType(the_type)), change,

# handle, gid, the_type[0], the_type[1],
handle, gid, the_type[0], str(RepositoryType(the_type)),

# place_type[0], place_type[1],
place_type[0], str(PlaceType(place_type)),

2 Likes