コード例 #1
0
               birthday=datetime(day=2, month=3, year=1962)),
    Individual('5',
               name='Ava /White/',
               sex='F',
               birthday=datetime(day=1, month=4, year=1985),
               child='F2'),
    Individual('6',
               name='Maria /White/',
               sex='F',
               birthday=datetime(day=9, month=10, year=1988),
               child='F2'),
    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', '9', '10']),
    Family('F2', husband_id='7', wife_id='8', children=['5', '6'])
]

three_sons_one_diff = Tree()

[three_sons_one_diff.add_individual(i) for i in _individuals]
[three_sons_one_diff.add_family(f) for f in _families]
コード例 #2
0
               birthday=datetime(day=2, month=3, year=1962)),
    Individual('5',
               name='Ava /White/',
               sex='F',
               birthday=datetime(day=1, month=4, year=1985),
               child='F2'),
    Individual('6',
               name='Maria /White/',
               sex='F',
               birthday=datetime(day=9, month=10, year=1988),
               child='F2'),
    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']),
    Family('F2', husband_id='7', wife_id='8', children=['5', '6'])
]

father_diff = Tree()

[father_diff.add_individual(i) for i in _individuals]
[father_diff.add_family(f) for f in _families]
コード例 #3
0
           wife_id='2',
           married=datetime(day=1, month=1, year=1948)),
    Family('F2',
           husband_id='3',
           wife_id='4',
           married=datetime(day=1, month=1, year=1963)),
    Family('F3',
           husband_id='5',
           wife_id='6',
           married=datetime(day=1, month=1, year=1951)),
]

born_wed = Tree()

[born_wed.add_individual(i) for i in _individuals]
[born_wed.add_family(f) for f in _families]

_individuals2 = [
    Individual('a',
               name='Toddy /Frod/',
               sex='M',
               birthday=datetime(day=20, month=1, year=1947)),
    Individual('b',
               name='Loddy /Frod/',
               sex='F',
               birthday=datetime(day=20, month=2, year=1948)),
    Individual('c',
               name='Moosy /Goose/',
               sex='M',
               birthday=datetime(day=10, month=3, year=1949)),
    Individual('d',
コード例 #4
0
    Family('F1',
           husband_id='1',
           wife_id='2',
           children='3',
           married=datetime(day=1, month=1, year=1948)),
    Family('F2',
           husband_id='5',
           wife_id='6',
           children='4',
           married=datetime(day=1, month=1, year=1963)),
]

parents_age_okay = Tree()

[parents_age_okay.add_individual(i) for i in _individuals]
[parents_age_okay.add_family(f) for f in _families]

_individuals2 = [
    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=2009)),
    Individual('4',
コード例 #5
0
               birthday=datetime(1987, 11, 8, 0, 0),
               death=None,
               spouse=None),
    Individual('6',
               name='John /Name/',
               birthday=datetime(1986, 12, 31, 0, 0),
               death=datetime(2007, 4, 19, 0, 0),
               spouse='F3')
]

all_correct_tree = Tree()
some_correct_tree = Tree()
all_fail_tree = Tree()

[all_correct_tree.add_individual(i) for i in _individuals1]
[all_correct_tree.add_family(f) for f in _families]
[some_correct_tree.add_individual(i) for i in _individuals2]
[some_correct_tree.add_family(f) for f in _families]
[all_fail_tree.add_individual(i) for i in _individuals4]
[all_fail_tree.add_family(f) for f in _families]


class TestLivingandSingle(unittest.TestCase):
    def test_all_correct(self):
        self.assertEqual(
            [res[:-1] for res in all_correct_tree.list_large_age_difference()],
            [['Bob /Burger/', '15-06-1935', '01-12-1980'],
             ['Linda /Burger/', '10-05-1960', '01-12-1980'],
             ['Shawn /Sheep/', '12-07-1960', '15-09-1993'],
             ['Sherry /Sheep/', '10-08-1978', '15-09-1993'],
             ['John /Name/', '30-01-1993', '28-04-2014'],
コード例 #6
0
ファイル: AngelicaTree.py プロジェクト: cbethin/SSW555
               death=datetime(day=23, month=5, year=2018)),
    Individual('4',
               name='Leslie /Maple/',
               sex='F',
               birthday=datetime(day=12, month=9, year=1950))
]

_families = [
    Family('F1', married=datetime(1973, 4, 11, 0, 0)),
    Family('F2',
           married=datetime(2000, 10, 31, 0, 0),
           divorced=datetime(2007, 12, 25, 0, 0))
]
correct_dates = Tree()
[correct_dates.add_individual(i) for i in _individuals]
[correct_dates.add_family(f) for f in _families]
"""Tree for Test Case 2"""
_individuals1 = [
    Individual('1',
               name='Super /Man/',
               sex='M',
               birthday=datetime(day=28, month=1, year=1954),
               death=datetime(day=5, month=11, year=2017)),
    Individual('2',
               name='Angela /Brown/',
               sex='F',
               birthday=datetime(day=16, month=2, year=1987)),
    Individual('3',
               name='Jimmy /Gold/',
               sex='M',
               birthday=datetime(day=1, month=8, year=1942),
コード例 #7
0
               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)),
    Individual('g',
               name='Ken /White/',
               sex='F',
               birthday=datetime(day=30, month=1, year=1946)),
    Individual('h',
               name='Ana /White/',
               sex='M',
               birthday=datetime(day=3, month=5, year=1940))
]

_families = [
    Family('F1', husband_id='c', wife_id='d', children=['1', '2']),
    Family('F2', husband_id='g', wife_id='h', children=['5', '6'])
]

two_husb_and_wife_incorrect = Tree()

[two_husb_and_wife_incorrect.add_individual(i) for i in _individuals]
[two_husb_and_wife_incorrect.add_family(f) for f in _families]
コード例 #8
0
           married=datetime(day=1, month=1, year=1948)),
    Family('F2',
           husband_id='3',
           wife_id='4',
           married=datetime(day=1, month=1, year=1963)),
    Family('F3',
           husband_id='5',
           wife_id='6',
           children='5',
           married=datetime(day=1, month=1, year=1951)),
]

in_wed = Tree()

[in_wed.add_individual(i) for i in _individuals]
[in_wed.add_family(f) for f in _families]

_individuals2 = [
    Individual('a',
               name='Toddy /Frod/',
               sex='M',
               birthday=datetime(day=20, month=1, year=1947)),
    Individual('b',
               name='Loddy /Frod/',
               sex='F',
               birthday=datetime(day=20, month=2, year=1948)),
    Individual('c',
               name='Moosy /Goose/',
               sex='M',
               birthday=datetime(day=10, month=3, year=1949)),
    Individual('d',
コード例 #9
0
    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)),
]

_families = [Family('F1', children=['1', '2', '3', '4', '5', '6'])]

sextuplet_check = Tree()

[sextuplet_check.add_individual(i) for i in _individuals]
[sextuplet_check.add_family(f) for f in _families]

_individuals2 = [
    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=1998)),
    Individual('3',
               name='Tonty /Python/',
               sex='M',
               birthday=datetime(day=23, month=3, year=1997)),
    Individual('4',
コード例 #10
0
               birthday=datetime(day=2, month=3, year=1962)),
    Individual('5',
               name='Ava /White/',
               sex='F',
               birthday=datetime(day=1, month=4, year=1985),
               child='F2'),
    Individual('6',
               name='Maria /White/',
               sex='F',
               birthday=datetime(day=9, month=10, year=1988),
               child='F2'),
    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']),
    Family('F2', husband_id='7', wife_id='8', children=['5', '6'])
]

all_same_names = Tree()

[all_same_names.add_individual(i) for i in _individuals]
[all_same_names.add_family(f) for f in _families]
コード例 #11
0
               name='Jane /Doe/',
               sex='M',
               birthday=datetime(day=2, month=3, year=1962)),  # 4444 is wrong
    Individual('5555',
               name='Ava /White/',
               sex='M',
               birthday=datetime(day=1, month=4, year=1985)),
    Individual('6666',
               name='Maria /White/',
               sex='F',
               birthday=datetime(day=9, month=10, year=1988)),
    Individual('7777',
               name='Ken /White/',
               sex='M',
               birthday=datetime(day=30, month=1, year=1946)),
    Individual('8888',
               name='Ana /White/',
               sex='F',
               birthday=datetime(day=3, month=5, year=1940))
]

_families = [
    Family('F1', husband_id='3333', wife_id='4444', children=['1', '2']),
    Family('F2', husband_id='7777', wife_id='8888', children=['5', '6'])
]

wife_incorrect = Tree()

[wife_incorrect.add_individual(i) for i in _individuals]
[wife_incorrect.add_family(f) for f in _families]
コード例 #12
0
               birthday=datetime(day=2, month=3, year=1962)),
    Individual('5',
               name='Ava /White/',
               sex='F',
               birthday=datetime(day=1, month=4, year=1985),
               child='F2'),
    Individual('6',
               name='Maria /White/',
               sex='F',
               birthday=datetime(day=9, month=10, year=1988),
               child='F2'),
    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']),
    Family('F2', husband_id='7', wife_id='8', children=['5', '6'])
]

son_diff = Tree()

[son_diff.add_individual(i) for i in _individuals]
[son_diff.add_family(f) for f in _families]
コード例 #13
0
ファイル: GedBuilder.py プロジェクト: cbethin/SSW555
    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
コード例 #14
0
               name='Snow /White',
               sex='F',
               birthday=datetime(day=6, month=1, year=1996)),
    Individual('10',
               name='Prince /Charming',
               sex='M',
               birthday=datetime(day=13, month=4, year=1993))
]

_families = [
    Family('F1',
           husband_id='1',
           wife_id='2',
           children=['3'],
           married=datetime(day=1, month=1, year=1963)),
    Family('F2',
           husband_id='4',
           wife_id='5',
           children=['6', '7', '8'],
           married=datetime(day=3, month=5, year=1967)),
    Family('F3',
           husband_id='10',
           wife_id='9',
           married=datetime(day=24, month=12, year=2018))
]

of_age = Tree()

[of_age.add_individual(i) for i in _individuals]
[of_age.add_family(f) for f in _families]