gedcom_constants.py
Dec 25, 2023 23:43:24 GMT -8
Post by Uncle Buddy on Dec 25, 2023 23:43:24 GMT -8
<drive>:\treebard\app\python\gedcom_constants.py Last Changed 2024-01-10
# gedcom_constants.py
import sqlite3
import dev_tools as dt
from dev_tools import look, seeline
DATE_WORDS = (
"jan", "feb", "mar", "apr", "may", "jun", "jul", "aug", "sep", "oct",
"nov", "dec", "january", "february", "march", "april", "june", "july",
"august", "sept", "september", "october", "november", "december")
superior = {0: None,
1: None, 2: None, 3: None, 4: None, 5: None, 6: None, 7: None, 8: None,
9: None, 10: None, 11: None, 12: None, 13: None, 14: None, 15: None,
16: None, 17: None, 18: None, 19: None, 20: None, 21: None, 22: None,
23: None, 24: None, 25: None, 26: None, 27: None, 28: None, 29: None,
30: None, 31: None, 32: None, 33: None, 34: None, 35: None, 36: None,
37: None, 38: None, 39: None, 40: None, 41: None, 42: None, 43: None,
44: None, 45: None, 46: None, 47: None, 48: None, 49: None, 50: None,
51: None, 52: None, 53: None, 54: None, 55: None, 56: None, 57: None,
58: None, 59: None, 60: None, 61: None, 62: None, 63: None, 64: None,
65: None, 66: None, 67: None, 68: None, 69: None, 70: None, 71: None,
72: None, 73: None, 74: None, 75: None, 76: None, 77: None, 78: None,
79: None, 80: None, 81: None, 82: None, 83: None, 84: None, 85: None,
86: None, 87: None, 88: None, 89: None, 90: None, 91: None, 92: None,
93: None, 94: None, 95: None, 96: None, 97: None, 98: None, 99: None}
EVENT_TAGGER = {
"DEAT": "death", "RESI": "residence", "OCCU": "occupation",
"EDUC": "education", "BURI": "burial", "CAST": "caste", "BIRT": "birth",
"DSCR": "description", "NATI": "nationality", "NCHI": "number of children",
"NMR": "number of marriages", "PROP": "property", "RELI": "religion",
"MARR": "marriage", "MARC": "marriage contract", "MARL": "marriage license",
"MARS": "marriage settlement", "MARB": "marriage banns", "DIV": "divorce",
"DIVF": "filed for divorce", "ENGA": "engagement", "ANUL": "annulment",
"CENS": "census enumeration", "CHR": "christening", "BAPM": "baptism",
"CREM": "cremation", "BARM": "bar mitzvah", "ADOP": "adoption",
"BASM": "bas mitzvah", "BLES": "blessing", "CHRA": "christening",
"CONF": "confirmation", "FCOM": "first communion", "ORDN": "ordination",
"NATU": "naturalization", "EMIG": "emigration", "IMMI": "immigration",
"PROB": "probate", "WILL": "reading of the will", "GRAD": "graduation",
"RETI": "retirement"}
EVENT_TAGS = (
"DEAT", "RESI", "OCCU",
"EDUC", "BURI", "BIRT",
"DSCR", "NATI", "NCHI",
"NMR", "PROP", "RELI",
"MARR", "MARC", "MARL",
"MARS", "MARB", "DIV",
"DIVF", "ENGA", "ANUL",
"CENS", "CHR", "BAPM",
"CREM", "BARM", "ADOP",
"BASM", "BLES", "CHRA",
"CONF", "FCOM", "ORDN",
"NATU", "EMIG", "IMMI",
"PROB", "WILL", "GRAD",
"RETI", "CAST")
COUPLE_EVENT_TAGS = (
"MARR", "MARC", "MARL",
"MARS", "MARB", "DIV",
"DIVF", "ENGA", "ANUL")
EVENT_TYPES = {
"EVEN": "EVEN", "EVEN_death": "death", "EVEN_residence": "residence",
"EVEN_occupation": "occupation", "EVEN_education": "education",
"EVEN_burial": "burial", "EVEN_caste": "caste", "EVEN_birth": "birth",
"EVEN_description": "description", "EVEN_nationality": "nationality",
"EVEN_number_of_children": "number of children",
"EVEN_number_of_marriages": "number_of_marriages",
"EVEN_property": "property", "EVEN_religion": "religion",
"EVEN_marriage": "marriage", "EVEN_marriage_contract": "marriage_contract",
"EVEN_marriage_license": "marriage_license",
"EVEN_marriage_settlement": "marriage_settlement",
"EVEN_marriage_banns": "marriage_banns", "EVEN_divorce": "divorce",
"EVEN_filed_for_divorce": "filed_for_divorce",
"EVEN_engagement": "engagement", "EVEN_annulment": "annulment",
"EVEN_census_enumeration": "census_enumeration",
"EVEN_christening": "christening", "EVEN_baptism": "baptism",
"EVEN_cremation": "cremation", "EVEN_bar_mitzvah": "bar_mitzvah",
"EVEN_adoption": "adoption", "EVEN_bas_mitzvah": "bas_mitzvah",
"EVEN_blessing": "blessing", "EVEN_christening": "christening",
"EVEN_confirmation": "confirmation", "EVEN_first_communion": "first_communion",
"EVEN_ordination": "ordination", "EVEN_naturalization": "naturalization",
"EVEN_emigration": "emigration", "EVEN_immigration": "immigration",
"EVEN_probate": "probate", "EVEN_reading_of_the_will": "reading_of_the_will",
"EVEN_graduation": "graduation", "EVEN_retirement": "retirement",
"EVEN_cause_of_death": "cause_of_death"}
IGNORE = (
"DATA", "ABBR", "QUAY",
"CHAN", "TIME",
"ADDR", "ADR1", "ADR2", "ADR3", "PHON", "FAX", "STAE", "WWW", "URL", "WEB",
"EMAIL", "CITY", "CTRY", "POST",
"ASSO", "RELA",
"GIVN", "SURN", "NPFX", "SPRX", "NSFX",
"ANCI", "DESI", "REFN", "RIN", "AFN", "MAP",
"ALIA", "ROLE",
"SLGS", "SLGC", "TEMP", "STAT", "BAPL", "CONL", "ENDL")
MAX_TYPE_IDS = {
"repository_type": 0, "locator_type": 0, "role_type": 0,
"media_type": 0, "source_type": 0, "name_type": 0, "event_type": 0,
"kin_type": 0, "place_type": 0, "transcription_type": 0}
NAME_TYPES = {
"IDNO": "ID_number", "SSN": "social_security_number", "SURN": "surname",
"ALIA": "also_known_as", "_AKA": "also_known_as", "_AKAN": "also_known_as",
"GIVN": "given_name", "NICK": "nickname", "NPFX": "name_prefix",
"NSFX": "name_suffix", "SPFX": "surname_prefix", "_USED": "usual_name",
"TITL": "title"}
GEDCOM_NAME_TYPES = {
"aka": "also known as", "birth": "birth name", "immigrant": "immigrant name",
"maiden": "maiden name", "married": "married name"}
NAME_TYPE_TAGS = {
"IDNO": "ID number", "SSN": "social security number",
"TITL_name_type": "title", "NICK": "nickname"}
SPELL_IT = {"M": "male", "F": "female", "U": "unknown"}
PEDI_TAGS = {
"birth": "birth", "adopted": "adoption", "foster": "fosterage",
"sealing": "LDS sealing", "legal guardian": "guardianship",
"guardian": "guardianship", "guardianship": "guardianship",
"legal guardianship": "guardianship"}
GEDCOM_TRANSCRIPTION_TYPES = {
'pinyin': 'Hanyu Pinyin (Pinyin)', 'wadegiles': 'Wade-Giles',
'romaji': 'Wapuro romaji (romaji)', 'hangul': 'hangul', 'kana': 'kana'}
ROLE_TO_EVENT = {
"resident": "residence", "emigrant": "emigration",
"immigrant": "immigration"}
NOTE_LINKS = {
"PRSN_FK": "person_id", "PLACE_FK": "place_id",
"PLACE_NAME_FK": "place_name_id", "NAME_FK": "name_id",
"SORC_FK": "source_id", "CTTN_FK": "citation_id", "EVNT_FK": "event_id",
"ASRTN_FK": "assertion_id", "RPST_FK": "repository_id",
"MDIA_FK": "media_id", "CUPL_FK": "couple_id"}
MEDIA_LINKS = {
"PRSN_FK": "person_id", "CUPL_FK": "couple_id", "PLACE_FK": "place_id",
"SORC_FK": "source_id", "CTTN_FK": "citation_id", "EVNT_FK": "event_id",
"ASRTN_FK": "assertion_id", "NAME_FK": "name_id"}
DATE_PREFIXES = ("abt", "est", "cal", "bef", "aft", "bet", "from", "to", "and")
MONTHS = {
"jan": "ja", "feb": "f", "mar": "mar", "apr": "ap", "may": "may",
"jun": "jun", "jul": "jul", "aug": "au", "sep": "s", "oct": "oc",
"nov": "no", "dec": "d"}
MONTHS2 = {
"ja": "jan", "f": "feb", "mar": "mar", "ap": "apr", "may": "may",
"jun": "jun", "jul": "jul", "au": "aug", "s": "sep", "oc": "oct",
"no": "nov", "d": "dec"}
MONTH_NUMS = {mo:str(idx + 1) for (idx, mo) in enumerate(MONTHS.values())}
# line 152 MONTH_NUMS: {'ja': '1', 'f': '2', 'mar': '3', 'ap': '4', 'may': '5', 'jun': '6', 'jul': '7', 'au': '8', 's': '9', 'oc': '10', 'no': '11', 'd': '12'}
RENAME = {"male": "M", "female": "F", "unknown": "U"}
MODEL_DATE = (None, None, None, None, None, None, None, None, None, None, None)
GEDCOM_MEDIA_TYPES = (
"audio", "book", "card", "electronic", "fiche", "film", "magazine",
"manuscript", "map", "newspaper", "photo", "tombstone", "video")
def split_compound_dates(value):
date_input = value.lower().replace("bet ", "", 1).replace("from ", "", 1)
split_input = None
for link in (" and ", " to "):
if link in date_input:
split_input = date_input.split(link)
break
else:
link = None
if split_input:
compound_date = split_input
else:
compound_date = (date_input, None)
return compound_date, link
def get_date_parts(date_input, idx, slots=None):
default_storable_date = "-0000-00-00-------"
day = ""
month = ""
year = ""
if slots is None:
slots = default_storable_date.split("-")
date_input = date_input.replace("(", "")
date_input = date_input.replace(")", "")
date_input = date_input.replace("um ", "abt ")
date_input = strip_anno_domini(date_input)
for stg in DATE_PREFIXES:
pos = {0: 0, 1: 6}
if date_input.startswith(stg):
slots[pos[idx]] = stg.lower()
date_input = date_input[4:]
break
date_only = date_input.split()
if len(date_only) == 3:
day, month, year = date_only
elif len(date_only) == 2:
month, year = date_only
elif len(date_only) == 1:
year = date_only[0]
return year, month, day, slots
def strip_anno_domini(date_input):
date_output = date_input.replace(
"A.D.", "").replace("AD", "").replace("a.d.", "").replace("ad", "")
return date_output
def validate_date(year, month, day):
def validate_day_year(day, year):
nonlocal date_is_bad
for stg in (day, year):
for char in stg:
if char.isdigit() is False:
date_is_bad = True
else:
date_is_bad = False
return date_is_bad
def validate_month(month):
nonlocal date_is_bad
for char in month:
if char.isdigit():
date_is_bad = True
if len(month) != 0:
if month.lower() not in MONTHS:
date_is_bad = True
else:
month = MONTHS[month]
return date_is_bad
date_is_bad = False
date_is_bad = validate_day_year(day, year)
if date_is_bad:
return date_is_bad, month
date_is_bad = validate_month(month)
if date_is_bad:
return date_is_bad, month
""" Validate months by number of days. """
if len(day) == 0:
pass
elif month == "feb":
if int(year) % 4 != 0 and int(day) > 28:
date_is_bad = True
elif int(year) % 4 == 0 and int(day) > 29:
date_is_bad = True
elif month in ("ap", "jun", "s", "no") and int(day) > 30:
date_is_bad = True
elif len(day) != 0:
if int(day) > 31 or int(day) < 1:
date_is_bad = True
if date_is_bad:
return date_is_bad, month
if len(day) > 2:
len(day)
date_is_bad = True
elif len(day) == 1:
day = f"0{day}"
if len(year) == 0 or len(year) > 4:
date_is_bad = True
elif int(year) == 0:
date_is_bad = True
return date_is_bad, month
def make_date_sorter(year, month, day):
sort_mo = month
sort_day = day
if len(month) == 0:
sort_mo = "0"
else:
sort_mo = MONTH_NUMS[MONTHS[month]]
if len(day.lstrip("0")) == 0:
sort_day = "0"
else:
sort_day = day.lstrip("0")
sorter = [year.lstrip("0"), sort_mo, sort_day]
sorter = ",".join(sorter)
return sorter
insert_new_person = '''
INSERT INTO person (person_id, gender) VALUES (?, ?)
'''
update_person_1 = '''
UPDATE person set gender = ? WHERE person_id = 1
'''
insert_new_name = '''
INSERT INTO name (name_id, person_id, names, sort_order, name_type_id)
VALUES (?, ?, ?, ?, ?)
'''
update_name_1_person_1 = '''
UPDATE name set (names, name_type_id, sort_order) = (?, ?, ?)
WHERE name_id = 1 and person_id = 1
'''
update_name_1 = '''
UPDATE name set (names, name_type_id, sort_order) = (?, ?, ?)
WHERE name_id = 2 and person_id = ?
'''
update_name_person_1 = '''
UPDATE name set (names, name_type_id, sort_order) = (?, ?, ?)
WHERE person_id = 1 and name_id = ?
'''
insert_new_couple = '''
INSERT INTO couple (couple_id, person_id1, person_id2) VALUES (?, ?, ?)
'''
insert_new_place = '''
INSERT INTO place (place_id, latitude, longitude)
VALUES (?, ?, ?)
'''
insert_new_place_name = '''
INSERT INTO place_name (place_name_id, place_names, place_id, main_place_name)
VALUES (?, ?, ?, 1)
'''
insert_new_nested_place = '''
INSERT INTO nested_place (
nested_place_id, nest0, nest1, nest2, nest3, nest4, nest5, nest6,
nest7, nest8)
VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
'''
insert_new_event = '''
INSERT INTO event (event_id, event_type_id)
VALUES (?, ?)
'''
update_event = '''
UPDATE event
SET (person_id, couple_id, date, date_sorter, nested_place_id, particulars,
age, age1, age2) = (?, ?, ?, ?, ?, ?, ?, ?, ?)
WHERE event_id = ?
'''
insert_new_source = '''
INSERT INTO source (source_id, sources, author, description)
VALUES (?, ?, ?, ?)
'''
insert_new_citation = '''
INSERT INTO citation (citation_id, source_id, citations)
VALUES (?, ?, ?)
'''
insert_new_assertion = '''
INSERT INTO assertion (
assertion_id, citation_id, event_id, name_id, dates, particulars, names)
VALUES (?, ?, ?, ?, ?, ?, ?)
'''
insert_new_media = '''
INSERT INTO media (media_id, media_type_id, file_names, titles)
VALUES (?, ?, ?, ?)
'''
insert_new_repository = '''
INSERT INTO repository (repository_id, repositories)
VALUES (?, ?)
'''
insert_new_transcription = '''
INSERT INTO transcription (
transcription_id, transcriptions, transcription_type_id, name_id,
nested_place_id)
VALUES (?, ?, ?, ?, ?)
'''
insert_gedcom_submitter = '''
INSERT INTO contact (contact_id, contacts, detail, language, submitted)
VALUES (?, ?, ?, ?, ?)
'''
insert_new_note = '''
INSERT INTO note (note_id, notes) VALUES (?, ?)
'''
SELECT_PERSON_VALUES = '''
SELECT person_id, gender
FROM person
'''
SELECT_COUPLE_VALUES = '''
SELECT couple_id, person_id1, person_id2
FROM couple
'''
SELECT_MEDIA_VALUES = '''
SELECT media_id, file_names, titles, captions, media_types
FROM media
JOIN media_type
ON media.media_type_id = media_type.media_type_id
'''
SELECT_NOTES_VALUES = '''
SELECT note_id, notes
FROM note
'''
SELECT_REPOSITORIES_VALUES = '''
SELECT repository_id, repositories
FROM repository
'''
SELECT_SOURCES_VALUES = '''
SELECT source_id, sources, author, description
FROM source
'''
SELECT_OFFSPRING_EVENTS = '''
SELECT event.person_id
FROM person
JOIN event
ON person.person_id = event.person_id
JOIN event_type
ON event.event_type_id = event_type.event_type_id
WHERE event.person_id IS NOT null
AND couple_id = ?
AND event.event_type_id in (
SELECT event_type_id
FROM event_type
WHERE event_types in (
'birth', 'adoption', 'fosterage', 'guardianship'))
'''
SELECT_COUPLE_EVENTS = '''
SELECT event_types, particulars, age1, age2, date, nested_place_id, event_id
FROM event
JOIN event_type
ON event.event_type_id = event_type.event_type_id
WHERE person_id IS null
AND couple_id = ?
'''
SELECT_PERSON_NAMES = '''
SELECT sort_order, name_types, name_id
FROM name
JOIN name_type
ON name.name_type_id = name_type.name_type_id
WHERE person_id = ?
'''
SELECT_GENERIC_EVENTS = '''
SELECT event_types, date, nested_place_id, particulars, age, event.couple_id, event_id
FROM event
LEFT JOIN person
ON person.person_id = event.person_id
LEFT JOIN event_type
ON event.event_type_id = event_type.event_type_id
LEFT JOIN couple
ON event.couple_id = couple.couple_id
WHERE event.person_id = ?
'''
SELECT_EVENTS_COUPLE = '''
SELECT event.couple_id
FROM event
JOIN event_type
ON event.event_type_id = event_type.event_type_id
JOIN couple
ON couple.couple_id = event.couple_id
WHERE person_id is null AND event_type.couple = 1
AND (person_id1 = ? OR person_id2 = ?)
'''
SELECT_NESTED_PLACES = '''
SELECT nest0, nest1, nest2, nest3, nest4, nest5, nest6, nest7, nest8
FROM nested_place
WHERE nested_place_id = ?
'''
SELECT_PLACE_NAMES = '''
SELECT place_names FROM place_name WHERE place_id = ? AND main_place_name = 1
'''
SELECT_PLACE_TYPE = '''
SELECT place_types
FROM places_types
JOIN place_type
ON place_type.place_type_id = places_types.place_type_id
WHERE places_types.place_id = ?
'''
SELECT_TRANSCRIPTIONS_PLACE = '''
SELECT romanized, phonetic, transcriptions, transcription_types
FROM transcription
JOIN transcription_type
ON transcription.transcription_type_id = transcription_type.transcription_type_id
WHERE nested_place_id = ?
'''
SELECT_TRANSCRIPTIONS_NAME = '''
SELECT romanized, phonetic, transcriptions, transcription_types
FROM transcription
JOIN transcription_type
ON transcription.transcription_type_id = transcription_type.transcription_type_id
WHERE name_id = ?
'''
SELECT_COORDINATES = '''
SELECT latitude, longitude FROM place WHERE place_id = ?
'''
SELECT_COUPLE_PARTNERS = '''
SELECT person_id1, person_id2 FROM couple WHERE couple_id = ?
'''
SELECT_NAME_PER_ID = '''
SELECT names
FROM name
JOIN name_type
ON name_type.name_type_id = name.name_type_id
WHERE person_id = ?
AND hierarchy <= (SELECT min(hierarchy) FROM name_type)
'''
SELECT_COUPLE_PER_PERSON = '''
SELECT couple_id FROM couple WHERE person_id1 = ? OR person_id2 = ?
'''
SELECT_CITATION_SOURCE_NAME = '''
SELECT citation.source_id, citations, assertion.names, surety
FROM assertion
JOIN citation
ON assertion.citation_id = citation.citation_id
JOIN name
ON name.name_id = assertion.name_id
JOIN name_type
ON name.name_type_id = name_type.name_type_id
WHERE assertion.name_id = ? and person_id = ?
ORDER BY hierarchy
'''
SELECT_CITATION_SOURCE_EVENT = '''
SELECT citation.source_id, citations, dates, places,
assertion.particulars, ages, roles, surety
FROM assertion
JOIN citation
ON assertion.citation_id = citation.citation_id
JOIN event
ON event.event_id = assertion.event_id
WHERE assertion.event_id = ? AND event.person_id IS NOT null
'''
SELECT_CITATION_SOURCE_EVENT_COUPLE = '''
SELECT citation.source_id, citations, dates, places,
assertion.particulars, ages, roles, surety
FROM assertion
JOIN citation
ON assertion.citation_id = citation.citation_id
JOIN event
ON event.event_id = assertion.event_id
JOIN event_type
ON event.event_type_id = event_type.event_type_id
WHERE assertion.event_id = ? AND event.couple_id IS NOT null
AND event_type.couple = 1
'''
SELECT_MEDIA_PERSON_LINK = '''
SELECT media_id FROM media_links WHERE person_id = ?
'''
SELECT_MEDIA_COUPLE_LINK = '''
SELECT media_id FROM media_links WHERE couple_id = ?
'''
SELECT_MEDIA_SOURCE_NAME_LINK = '''
SELECT media_id
FROM media_links
LEFT JOIN name
ON name.name_id = media_links.name_id
LEFT JOIN person
ON person.person_id = name.person_id
WHERE media_links.name_id in
(SELECT name_id FROM name WHERE person_id = ?)
AND source_id = ?
'''
SELECT_MEDIA_SOURCE_EVENT_LINK = '''
SELECT media_id
FROM media_links
LEFT JOIN event
ON event.event_id = media_links.event_id
LEFT JOIN person
ON person.person_id = event.person_id
WHERE media_links.event_id in
(SELECT event_id FROM event WHERE person_id = ?)
AND source_id = ?
'''
SELECT_MEDIA_SOURCE_EVENT_LINK_COUPLE = '''
SELECT media_id
FROM media_links
LEFT JOIN event
ON event.event_id = media_links.event_id
LEFT JOIN couple
ON couple.couple_id = event.couple_id
WHERE media_links.event_id in
(SELECT event_id FROM event WHERE couple_id = ? AND person_id IS null)
AND source_id = ?
'''
SELECT_NOTE_SOURCE_PERSON_LINK = '''
SELECT source_id, note_id
FROM notes_links
LEFT JOIN person
ON person.person_id = notes_links.person_id
WHERE notes_links.person_id = ?
AND source_id IS NOT null
'''
SELECT_NOTE_SOURCE_NAME_LINK = '''
SELECT note_id
FROM notes_links
LEFT JOIN name
ON name.name_id = notes_links.name_id
LEFT JOIN person
ON person.person_id = name.person_id
WHERE notes_links.name_id in
(SELECT name_id FROM name WHERE person_id = ?)
AND source_id = ?
'''
SELECT_NOTE_SOURCE_EVENT_LINK = '''
SELECT note_id
FROM notes_links
WHERE event_id = ?
AND source_id = ?
'''
SELECT_MEDIA_EVENT_LINKS = '''
SELECT media_id
FROM media_links
WHERE event_id = ?
'''
SELECT_NOTE_PERSON_LINKS = '''
SELECT note_id
FROM notes_links
WHERE person_id = ?
AND source_id IS null
'''
SELECT_NOTE_MEDIA_LINKS = '''
SELECT note_id
FROM notes_links
WHERE media_id = ?
'''
SELECT_SOURCE_MEDIA_LINKS = '''
SELECT source_id, citation_id
FROM repositories_links
WHERE media_id = ?
'''
SELECT_SOURCE_CITATION_LINK = '''
SELECT citation.source_id, citations
FROM citation
JOIN source
ON source.source_id = citation.source_id
WHERE citation_id = ?
'''
SELECT_NOTE_EVENT_LINKS = '''
SELECT note_id
FROM notes_links
WHERE event_id = ? AND place_id IS null AND source_id IS null
'''
SELECT_NOTE_PLACE_LINKS = '''
SELECT note_id
FROM notes_links
WHERE place_id = ? and event_id = ?
'''
SELECT_NOTE_NAME_LINKS = '''
SELECT note_id
FROM notes_links
WHERE name_id = ?
'''
SELECT_PLACE_NEST0 = '''
SELECT nest0
FROM nested_place
WHERE nested_place_id = ?
'''
SELECT_NOTE_COUPLE_LINKS = '''
SELECT note_id
FROM notes_links
WHERE couple_id = ?
'''
SELECT_NOTE_REPOSITORY_LINKS = '''
SELECT note_id
FROM notes_links
WHERE repository_id = ?
'''
SELECT_NOTE_SOURCE_LINKS = '''
SELECT note_id
FROM notes_links
WHERE source_id = ?
AND person_id IS null AND event_id IS null AND name_id IS null
'''
IMPORT_TEXT = "Browse for a GEDCOM file to import. Treebard supports GEDCOM v. 5.5.1 when possible and not too painful. Your input will be needed in order to upgrade GEDCOM places to Treebard's standards, so don't go anywhere until you've pressed DONE on the places dialog, and then pressed ADD GEDCOM DATA TO NEW TREE. Then the app will be unavailable till the import is finished or your computer melts. To import a second GEDCOM file, restart Treebard. An exceptions log will be saved in Treebard's `etc` folder for data that could not be imported till I come out of retirement and write more code."
PLACES_HEADER = "In Treebard, 'Salt Lake City, Utah, United States of America' is three places. But in GEDCOM, it is one place. Before the import process can proceed:\n\n1) Click one place at a time to auto-highlight all places that are spelled the same as the place you clicked.\n\n2) Click any highlighted place that is not the same place as the first place you clicked, to unhighlight it.\n\n3) CTRL + click each single place that is also the same place even though spelled different, such as 'Dallas' and 'Dallas City'.\n\n4) Press NEXT to repeat this process for each single place.\n\n5) When no remaining places are the same as any other, press UNHIGHLIGHTED PLACES ARE UNIQUE, then DONE.\n\nExample: 'Paris, Texas' and 'Paris, France' are not the same place, but 'Paris, Lamar County, Texas' is the same place as 'Paris, Texas'."
BAD_DATES_HEADER = "Dates for the events below could not be entered because they are not real dates."
LOCATORS_HEADER = "A locator is a code that takes you straight to something in a repository, even if you don't know anything else about that thing (such as its subject, title or author). While a citation is a location in a source, a locator is a location in a repository, such as a call number in a library or a URL (web page address) in a website. UNIGEDS' locators can be linked to citations, repositories, sources, repository types, and multimedia files, while GEDCOM's locators can only be linked to a repository. The locators, sources and repositories listed below are all that can be gleaned from the GEDCOM file. The data can be used in manually updating your tree's sources. The sources and repositories have been imported, but if the data below is ignored, the locators will not be saved."
PEDI_HEADER = "GEDCOM indicates one or more alternative parentage relationships without a corresponding alternative parentage event (adoption, fosterage, or guardianship). In Treebard or other UNIGEDS-employing genealogy software, to include the relationships listed below, manually create corresponding events, then add the names of the event participants in the current person's family table."
FAMILY_EVENTS_HEADER = "GEDCOM counts as 'family events' such things as residence and immigration, but in the interest of historical accuracy, UNIGEDS treats these as individual events. The events listed below have to be created manually in Treebard for each member of the family that actually participated in the event.\n\nExample: a GEDCOM family event 'residence' is linked to a couple, John and Mary. But the census for that event shows Mary as a widow, and only two of her 8 children are living with her. In Treebard, create the event separately for Mary (not John), and for each of the two children, adding date, place, and particulars if any. The unimported family events are listed below as original GEDCOM lines."
NON_GEDCOM_TAGS = "The GEDCOM file being imported uses non-GEDCOM tags which can't be imported since the GEDCOM specifications don't know what they mean. The tags were invented by the programmer who wrote the export program that created the GEDCOM file. The tags and their dependent GEDCOM lines are reproduced below. If you see something you don't understand, you can try asking the exporting app's creator what these lines mean so you can input the data manually via the Treebard interface. You may want to ignore redundant data as well as data that appears to be tech noise caused by the exporting GEDCOM application using GEDCOM to do tasks specific to their own software and which have nothing to do with GEDCOM's primary task of transferring genealogy data to other software. In each block below, the first tag is the identifier for a primary GEDCOM record. Each indented tag below that is part of that primary record. Each sub-record can be identified by a chain of ascending leading line numbers which increment by one. When the line number doesn't increase by one, that is a new sub-record.\n"
# For more on those items below which were not used, see superceded `gedkandu.py`.
EXCEPTION_MENU_ITEMS = {
'bad_dates': ('BAD DATES', BAD_DATES_HEADER),
'gedcom_fam_events': ('IMPRECISE FAMILY EVENTS', FAMILY_EVENTS_HEADER),
'custom_records': ('NON-GEDCOM TAGS', NON_GEDCOM_TAGS),
'PEDI_tag_is_useless': ('ALT PARENTAGE EVENT NOT IMPORTED', PEDI_HEADER),
'single_adopters': ('SINGLE-PARTNER ADOPTIONS', ''),
'event_address_parts': ('EVENT ADDRESS PARTS', ''),
'researcher_interests': ('RESEARCHER INTERESTS', ''),
'unknown_Y_values': ("UNKNOWN VALUES INSTEAD OF 'Y' OR 'NULL'", ''),
'per_specs_ALIA': ('ALIA TAG USED PER SPECS', ''),
'missing_citations': ('MISSING CITATIONS', ''),
'undefined_assertions': ('UNDEFINED ASSERTIONS', ''),
'eventless_roles': ('ROLES IN UNDEFINED EVENTS', ''),
'locators_linked_to_sources_via_repositories': (
'LOCATORS LINKED ONLY TO REPOSITORIES', LOCATORS_HEADER),
'assertion_made_date_not_linked_to_citation': (
'ASSERTION-MADE DATE; NO CITATION', '')}