コード例 #1
0
ファイル: no_bigamy.py プロジェクト: Ahsan45/SSW-CS555
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
ファイル: birth_after_marr.py プロジェクト: Ahsan45/SSW-CS555
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
ファイル: marr_before_div.py プロジェクト: Ahsan45/SSW-CS555
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'])
コード例 #9
0
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
ファイル: date_before_now.py プロジェクト: Ahsan45/SSW-CS555
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)