예제 #1
0
def no_bigamy(indiv, fams):
    """Checks that individuals were not spouses in multiple families at the same time"""
    if "FAMS" in indiv and len(indiv["FAMS"]) > 1:
        spouse = "HUSB" if indiv["SEX"] == "F" else "WIFE"
        all_marrs = {}

        for fam in indiv["FAMS"]:
            if not "MARR" in fams[fam]:
                pass
            else:
                if "DIV" in fams[fam]:
                    curr_marr = (fams[fam]["MARR"], fams[fam]["DIV"])
                elif "DEAT" in fams[fam][spouse]:
                    curr_marr = (fams[fam]["MARR"], spouse["DEAT"])
                else:
                    curr_marr = (fams[fam]["MARR"], time.strftime("%d %b %Y"))
                all_marrs[fam] = curr_marr

        for fam in indiv["FAMS"]:
            for marr_fam in all_marrs:
                if ((not fam == marr_fam)
                        and ("MARR" in fams[fam]) and date_first(
                            all_marrs[marr_fam][0], fams[fam]["MARR"]) and
                        date_first(fams[fam]["MARR"], all_marrs[marr_fam][1])):
                    return (fam, marr_fam)
        return True
    else:
        return True
예제 #2
0
def marr_before_death_husb(fam, indiv):
    """Check for marriage before death of husband"""
    husb = fam['HUSB']
    if not 'DEAT' in indiv[husb]:
        return True

    return date_first(fam['MARR'], indiv[husb]['DEAT'])
예제 #3
0
def marr_before_death_wife(fam, indiv):
    """Check for marriage before death of wife"""
    wife = fam['WIFE']
    if not 'DEAT' in indiv[wife]:
        return True

    return date_first(fam['MARR'], indiv[wife]['DEAT'])
예제 #4
0
def check_children(ind, children, date):
    """Helper function to check birth of each child"""
    for child in children:
        if (child not in ind or 'BIRT' not in ind[child]) or utils.date_first(
                ind[child]['BIRT'], date):
            return False
    return True
예제 #5
0
def divorce_before_death_husb(fam, indiv):
    """Checks that divorce is before death of husband"""
    if not 'DIV' in fam:
        return True

    husb = fam['HUSB']
    if not 'DEAT' in indiv[husb]:
        return True

    return date_first(fam['DIV'], indiv[husb]['DEAT'])
예제 #6
0
def divorce_before_death_wife(fam, indiv):
    """Checks that divorce is before death of wife"""
    if not 'DIV' in fam:
        return True

    wife = fam['WIFE']
    if not 'DEAT' in indiv[wife]:
        return True

    return date_first(fam['DIV'], indiv[wife]['DEAT'])
예제 #7
0
def marr_before_div(fam):
    """Checks if the family's marriage is before its divorce"""
    if 'MARR' not in fam and 'DIV' not in fam:
        return True
    elif 'MARR' not in fam:
        return False
    elif 'DIV' not in fam:
        return True

    return date_first(fam['MARR'], fam['DIV'])
예제 #8
0
def birth_before_death(indiv):
    """Checks if the individuals birth is before their death"""
    if 'BIRT' not in indiv and 'DEAT' not in indiv:
        return True
    elif 'BIRT' not in indiv:
        return False
    elif 'DEAT' not in indiv:
        return True

    return date_first(indiv['BIRT'], indiv['DEAT'])
def wife_check(indiv, children, fam):
    """Checks if wife died before birth of child"""
    wife = fam['WIFE']
    if not 'DEAT' in indiv[wife]:
        return True

    for child in children:
        if date_first(indiv[wife]['DEAT'], indiv[child]['BIRT']):
            return False

    return True
예제 #10
0
def get_oldest_child_birth(fam, indivs):
    """Gets birth date of eldest child or return false"""
    if "CHIL" in fam:
        children = fam["CHIL"]
        oldest_child_birth = indivs[children[0]]["BIRT"]
        for child in children:
            if child in indivs and date_first(indivs[child]["BIRT"],
                                              oldest_child_birth):
                oldest_child_birth = indivs[child]["BIRT"]
        return oldest_child_birth
    else:
        return False
예제 #11
0
def birth_before_marr_husb(fam, indiv):
    """Checks if husband's birth is before marriage"""
    husb = fam['HUSB']
    return date_first(indiv[husb]['BIRT'], fam['MARR'])
예제 #12
0
def birth_before_marr_wife(fam, indiv):
    """Checks if wife's birth is before marriage"""
    wife = fam['WIFE']
    return date_first(indiv[wife]['BIRT'], fam['MARR'])
예제 #13
0
def date_past(date):
    """Helper function for comparing date to now"""
    today = time.strftime("%d %b %Y")

    return date_first(date, today)
예제 #14
0
파일: tests.py 프로젝트: Ahsan45/SSW-CS555
 def test_date_comparer_false(self):
     """Test date comparer when result should be false"""
     test = utils.date_first('04 JUN 2013', '26 MAR 2002')
     self.assertFalse(test)
예제 #15
0
파일: tests.py 프로젝트: Ahsan45/SSW-CS555
 def test_date_comparer_true(self):
     """Test date comparer when result should be true"""
     test = utils.date_first('19 DEC 1999', '21 AUG 2004')
     self.assertTrue(test)