from datetime import datetime from lib.GedObjects import Tree from lib.GedObjects import Family from lib.GedObjects import Individual _individuals = [ Individual('1', name='Evan /Doe/', sex='M', birthday=datetime(day=12, month=4, year=1998), child='F1'), Individual('2', name='Elena /Doe/', sex='F', birthday=datetime(day=15, month=9, year=2000), child='F1'), Individual('9', name='Maxwell /Baker/', sex='M', birthday=datetime(day=2, month=3, year=1997), child='F1'), Individual('10', name='Kevin /Tan/', sex='M', birthday=datetime(day=12, month=8, year=2002), child='F1'), Individual('3', name='John /Doe/', sex='M', birthday=datetime(day=2, month=3, year=1962)),
import unittest from datetime import datetime from lib.GedObjects import Tree, Family, Individual _individuals = [ Individual('1', name='Toddy /Frod/', sex='M', birthday=datetime(day=20, month=1, year=1947)), Individual('2', name='Loddy /Frod/', sex='F', birthday=datetime(day=20, month=2, year=1948)), Individual('3', name='Moosy /Goose/', sex='M', birthday=datetime(day=10, month=3, year=1949)), Individual('4', name='Toosy /Goose/', sex='F', birthday=datetime(day=25, month=4, year=1950)), Individual('5', name='Becky /Tech/', sex='M', birthday=datetime(day=25, month=5, year=1951)), Individual('6', name='Lecky /Tech/', sex='F', birthday=datetime(day=10, month=6, year=1950)),
from datetime import datetime from lib.GedObjects import Tree from lib.GedObjects import Family from lib.GedObjects import Individual _individuals = [ Individual('1', name='Evan /Doe/', sex='M', birthday=datetime(day=12, month=4, year=1998)), Individual('2', name='Elena /Doe/', sex='F', birthday=datetime(day=15, month=9, year=2000)), Individual('3', name='John /Doe/', sex='M', birthday=datetime(day=2, month=3, year=1962)), Individual('4', name='Jane /Doe/', sex='F', birthday=datetime(day=2, month=3, year=1962)), Individual('5', name='Ava /White/', sex='M', birthday=datetime(day=1, month=4, year=1985)), Individual('6', name='Maria /White/', sex='F', birthday=datetime(day=9, month=10, year=1988)), Individual('7', name='Ken /White/', sex='M', birthday=datetime(day=30, month=1, year=1946)), Individual('8', name='Ana /White/', sex='F', birthday=datetime(day=3, month=5, year=1940)) ] _families = [ Family('F1', husband_id='3', wife_id='4', children=['1', '2']) ] all_correct_gender = Tree() [all_correct_gender .add_individual(i) for i in _individuals] [all_correct_gender .add_family(f) for f in _families]
import unittest from datetime import datetime from lib.GedObjects import Tree, Family, Individual _individuals = [ Individual('1', name='Michelle /Obama/', sex='M', birthday=datetime(day=20, month=1, year=1947)), Individual('2', name='Barack /Obama/', sex='F', birthday=datetime(day=20, month=2, year=1948)), Individual('3', name='Bill /Clinton/', sex='M', birthday=datetime(day=10, month=3, year=1988)), Individual('4', name='Hillary /Clinton/', sex='F', birthday=datetime(day=25, month=4, year=1999)), Individual('5', name='Lorry /Tot/', sex='M', birthday=datetime(day=25, month=5, year=1951)), Individual('6', name='Borry /Tot/', sex='F', birthday=datetime(day=10, month=6, year=1950)),
wife_id='1', married=datetime(day=1, month=12, year=1980)), Family('F2', husband_id='3', wife_id='4', married=datetime(day=15, month=9, year=1993)), Family('F3', husband_id='6', wife_id='5', married=datetime(day=28, month=4, year=2014)) ] _individuals1 = [ #all should work (complete) Individual('1', name='Linda /Burger/', birthday=datetime(1960, 5, 10, 0, 0), death=None, spouse='F1'), Individual('2', name='Bob /Burger/', birthday=datetime(1935, 6, 15, 0, 0), death=None, spouse='F1'), Individual('3', name='Shawn /Sheep/', birthday=datetime(1960, 7, 12, 0, 0), death=None, spouse='F2'), Individual('4', name='Sherry /Sheep/', birthday=datetime(1978, 8, 10, 0, 0),
from datetime import datetime from lib.GedObjects import Tree from lib.GedObjects import Family from lib.GedObjects import Individual _individuals = [ Individual('a', name='Evan /Doe/', sex='M', birthday=datetime(day=12, month=4, year=1998)), Individual('b', name='Elena /Doe/', sex='F', birthday=datetime(day=15, month=9, year=2000)), Individual('c', name='John /Doe/', sex='F', birthday=datetime(day=2, month=3, year=1962)), Individual('d', name='Jane /Doe/', sex='M', birthday=datetime(day=2, month=3, year=1962)), Individual('e', name='Ava /White/', sex='M', birthday=datetime(day=1, month=4, year=1985)), Individual('f', name='Maria /White/', sex='F', birthday=datetime(day=9, month=10, year=1988)),
from datetime import datetime from lib.GedObjects import Tree from lib.GedObjects import Family from lib.GedObjects import Individual _individuals = [ Individual('1a1a', name='Evan /Doe/', sex='M', birthday=datetime(day=12, month=4, year=1998)), Individual('2b2b', name='Elena /Doe/', sex='F', birthday=datetime(day=15, month=9, year=2000)), Individual('3c3c', name='John /Doe/', sex='F', birthday=datetime(day=2, month=3, year=1962)), Individual('4d4d', name='Jane /Doe/', sex='F', birthday=datetime(day=2, month=3, year=1962)), Individual('5e5e', name='Ava /White/', sex='M', birthday=datetime(day=1, month=4, year=1985)), Individual('6f6f', name='Maria /White/', sex='F', birthday=datetime(day=9, month=10, year=1988)), Individual('7g7g', name='Ken /White/', sex='M', birthday=datetime(day=30, month=1, year=1946)), Individual('8h8h', name='Ana /White/', sex='F', birthday=datetime(day=3, month=5, year=1940)) ] _families = [ Family('F1', husband_id='3c3c', wife_id='4d4d', children=['1', '2']), Family('F2', husband_id='7g7g', wife_id='8h8h', children=['5', '6']) ] husband_incorrect = Tree() [husband_incorrect .add_individual(i) for i in _individuals] [husband_incorrect .add_family(f) for f in _families]
import unittest from datetime import datetime from lib.GedObjects import Tree, Family, Individual _individuals = [ Individual('1', name='Monty /Python//', sex='M', birthday=datetime(day=23, month=3, year=1999)), Individual('2', name='Ronty /Python/', sex='F', birthday=datetime(day=23, month=3, year=1999)), Individual('3', name='Tonty /Python/', sex='M', birthday=datetime(day=23, month=3, year=1999)), Individual('4', name='Fonty /Python/', sex='F', birthday=datetime(day=23, month=3, year=1999)), Individual('5', name='Lonty /Python/', sex='M', birthday=datetime(day=23, month=3, year=1999)), Individual('6', name='Zonty /Python/', sex='F', birthday=datetime(day=23, month=3, year=1999)),
import unittest from datetime import datetime from lib.GedObjects import Tree from lib.GedObjects import Family from lib.GedObjects import Individual # from lib.test.trees.US1AllCorrect import correct_dates # from lib.test.trees.US1IndAllCorrect import correct_inds # from lib.test.trees.US1IndividIncorr import incorrect_indivs # from lib.test.trees.US1FamIncorr import incorrect_fam # from lib.test.trees.US1CorrFamIncorrInd import correct_incorrect """Tree for Test Case 1""" _individuals = [ Individual('1', name='John /Dean/', sex='M', birthday=datetime(day=20, month=6, year=1939)), Individual('2', name='Hannah /Montana/', sex='F', birthday=datetime(day=30, month=12, year=1996)), Individual('3', name='Ethan /Evans/', sex='M', birthday=datetime(day=8, month=3, year=1970), death=datetime(day=23, month=5, year=2018)), Individual('4', name='Leslie /Maple/', sex='F', birthday=datetime(day=12, month=9, year=1950)) ]
import unittest from datetime import datetime from lib.GedObjects import Tree, Family, Individual _individuals1 = [ #all should work (complete) Individual('1', name='Randy /Pay/', birthday=datetime(1963, 5, 10, 0, 0), death=None, spouse=None), Individual('2', name='Rondy /Pay/', birthday=datetime(1964, 6, 10, 0, 0), death=None, spouse=None), Individual('3', name='Rendy /Day/', birthday=datetime(1965, 7, 10, 0, 0), death=None, spouse=None), Individual('4', name='Rindy /Day/', birthday=datetime(1966, 8, 10, 0, 0), death=None, spouse=None), Individual('5', name='Rundy /Lay/', birthday=datetime(1967, 1, 10, 0, 0), death=None,
import unittest from datetime import datetime, timedelta from lib.GedObjects import Tree, Family, Individual import lib.GedConstants as gc today = datetime.now() _individuals1 = [ # all should be upcoming Individual('1', name='Randy /Pay/', birthday=today + timedelta(days=1), death=None), Individual('2', name='Rondy /Pay/', birthday=today + timedelta(days=2), death=None), Individual('3', name='Rendy /Day/', birthday=today + timedelta(days=3), death=None), Individual('4', name='Rindy /Day/', birthday=today + timedelta(days=4), death=None) ] _individuals2 = [ # some be upcoming Individual('1', name='Randy /Pay/', birthday=today + timedelta(days=46), death=None), Individual('2', name='Rondy /Pay/', birthday=today + timedelta(days=2), death=None), Individual('3', name='Rendy /Day/', birthday=today + timedelta(days=41), death=None), Individual('4', name='Rindy /Day/', birthday=today + timedelta(days=3), death=None) ] _individuals3 = [ # none of these ppl were born lol Individual('1', name='Randy /Pay/', death=None), Individual('2', name='Rondy /Pay/', death=None), Individual('3', name='Rendy /Day/', death=None), Individual('4', name='Rindy /Day/', death=None) ]
import unittest from datetime import datetime from lib.test.trees import us30_us34_tree from lib.GedObjects import Tree, Family, Individual _individuals1 = [ #all should work (complete) Individual('1', name='Linda /Burger/', birthday=datetime(1963, 5, 10, 0, 0), death=None, spouse='F1'), Individual('2', name='Bob /Burger/', birthday=datetime(1964, 6, 10, 0, 0), death=None, spouse='F1'), Individual('3', name='Shawn /Sheep/', birthday=datetime(1965, 7, 10, 0, 0), death=None, spouse='F2'), Individual('4', name='Sherry /Sheep/', birthday=datetime(1966, 8, 10, 0, 0), death=None, spouse='F2'), Individual('5', name='Jane /Name/', birthday=datetime(1967, 1, 10, 0, 0), death=None,
import unittest from datetime import datetime from lib.GedObjects import Tree, Family, Individual _individuals1 = [ #all should work (complete) Individual('1', name='Randy /Pay/', birthday=datetime(1963, 5, 10, 0, 0), death=None, spouse=None), Individual('2', name='Rondy /Pay/', birthday=datetime(1964, 6, 10, 0, 0), death=None, spouse=None), Individual('3', name='Rendy /Day/', birthday=datetime(1965, 7, 10, 0, 0), death=None, spouse=None), Individual('4', name='Rindy /Day/', birthday=datetime(1966, 8, 10, 0, 0), death=None, spouse=None) ] _individuals2 = [ #some are dead
def evaluate(self, tree: Tree, level: int, tag: str, args: str): """ Evaluate a valid line and add information to the tree if necessary :param tree: The Tree currently being built :param level: (unused) The level of the line to evaluate :param tag: The tag of the line to evaluate :param args: The args of the line to evaluate :return: None """ # If we are creating an individual and the next tag is invalid for an individual if self._creating_indi and (tag in Builder.FAMILY_TAGS or tag in Builder.TOP_LEVEL_TAGS): self._creating_indi = False # Try to add the individual try: tree.add_individual(Individual(**self._current_indi_data)) except (TypeError, DuplicateIndividualException): logging.log(logging.DEBUG, traceback.format_exc()) self._current_indi_data = {} # If we are creating a family and the next tag is invalid for a family elif self._creating_fam and (tag in Builder.INDIVIDUAL_TAGS or tag in Builder.TOP_LEVEL_TAGS): self._creating_fam = False # Try to add the family try: tree.add_family(Family(**self._current_fam_data)) except (TypeError, DuplicateFamilyException): logging.log(logging.DEBUG, traceback.format_exc()) self._current_fam_data = {'children': []} # If we are creating some kind of date and the next tag is not 'DATE' or is invalid elif True in (self._creating_birth, self._creating_death, self._creating_marr, self._creating_div) and (tag != 'DATE'): self._creating_birth, self._creating_death, self._creating_marr, self._creating_div = False, False, False, False # Basic cases for each tag if tag == 'INDI': self._creating_indi = True self._current_indi_data['id'] = args elif tag == 'FAM': self._creating_fam = True self._current_fam_data['id'] = args elif tag == 'NAME' and self._creating_indi: self._current_indi_data['name'] = args elif tag == 'SEX' and self._creating_indi: self._current_indi_data['sex'] = args elif tag == 'BIRT' and self._creating_indi: self._creating_birth = True elif tag == 'DEAT' and self._creating_indi: self._creating_death = True elif tag == 'MARR' and self._creating_fam: self._creating_marr = True elif tag == 'DIV' and self._creating_fam: self._creating_div = True elif tag == 'DATE': timestamp = datetime.strptime(args, '%d %b %Y') if self._creating_birth: self._current_indi_data['birthday'] = timestamp elif self._creating_death: self._current_indi_data['death'] = timestamp elif self._creating_marr: self._current_fam_data['married'] = timestamp elif self._creating_div: self._current_fam_data['divorced'] = timestamp elif tag == 'FAMC' and self._creating_indi: self._current_indi_data['child'] = args elif tag == 'FAMS' and self._creating_indi: self._current_indi_data['spouse'] = args elif tag == 'HUSB' and self._creating_fam: self._current_fam_data['husband_id'] = args elif tag == 'WIFE' and self._creating_fam: self._current_fam_data['wife_id'] = args elif tag == 'CHIL' and self._creating_fam: self._current_fam_data['children'].append(args) elif tag == 'HEAD': pass elif tag == 'TRLR': pass elif tag == 'NOTE': pass
from lib.test.trees import kristen_tree from lib.test.trees import michael_tree from lib.test.trees import sprint_one_tree from lib.test.trees import sprint_two_tree from lib.GedObjects import Tree, Family, Individual from datetime import datetime, timedelta import lib.GedConstants as gc birth1 = datetime.today() birth2 = datetime.today() - timedelta(days=1) birth3 = datetime.today() - timedelta(days=29) birth4 = datetime.today() - timedelta(days=15) _recently_born_individuals = [ Individual('1', name='Randy /Pay/', birthday=birth1), Individual('2', name='Rondy /Pay/', birthday=birth2), Individual('3', name='Rendy /Day/', birthday=birth3), Individual('4', name='Rindy /Day/', birthday=birth4) ] all_recent_births_tree = Tree() [all_recent_births_tree.add_individual(i) for i in _recently_born_individuals] birth5 = datetime.today() birth6 = datetime.today() - timedelta(days=40) birth7 = datetime.today() - timedelta(days=27) birth8 = datetime.today() - timedelta(days=1000) some_recently_born_individuals = [
from datetime import datetime from lib.GedObjects import Tree from lib.GedObjects import Family from lib.GedObjects import Individual _individuals = [ Individual('1', name='Mickey /Mouse/', sex='M', birthday=datetime(day=20, month=2, year=1947)), Individual('2', name='Minnie /Mouse/', sex='F', birthday=datetime(day=7, month=10, year=1947)), Individual('3', name='Pluto /Dog/', sex='M', birthday=datetime(day=5, month=6, year=1965)), Individual('4', name='Donald /Duck/', sex='M', birthday=datetime(day=30, month=7, year=1950)), Individual('5', name="Daisy /Duck/", sex='F', birthday=datetime(day=18, month=11, year=1952)), Individual('6', name='Huey / Duck/', sex='M', birthday=datetime(day=29, month=3, year=1970)),