コード例 #1
0
def marriageAfter14(husband, wife, family, repository):
    marriageDate = parseDate(family.getMarriageDate())
    husbandBirthDate = parseDate(husband.getBirthDate())
    wifeBirthDate = parseDate(wife.getBirthDate())

    if relativedelta(marriageDate, husbandBirthDate).years < 14:
        raise Exceptions.MarriageBefore14(husband, family)
    if relativedelta(marriageDate, wifeBirthDate).years < 14:
        raise Exceptions.MarriageBefore14(wife, family)
コード例 #2
0
def ageMorethan150(person, repository):
    birthDate = parseDate(person.getBirthDate())
    deathDate = parseDate(person.getDeathDate())
    if deathDate is not None and birthDate is not None and (relativedelta(
            deathDate, birthDate).years >= 150):
        raise Exceptions.AgeMorethan150(person)
    if deathDate is None and birthDate is not None and (relativedelta(
            datetime.today(), birthDate).years >= 150):
        raise Exceptions.AgeMorethan150(person)
コード例 #3
0
def birthBfMarriageOfParents(husband, wife, family, repository):
    marriageDate = parseDate(family.getMarriageDate())
    divorceDate = parseDate(family.getDivorceDate())
    for cid in family.getChildrenIds():
        child = repository.getPerson(cid)
        childBdate = parseDate(child.getBirthDate())
        if marriageDate > childBdate:
            raise Exceptions.BirthBeforeMarriageOfParents(child, family)
        if divorceDate is not None and relativedelta(childBdate,
                                                     divorceDate).months >= 9:
            raise Exceptions.BirthAfterDivorceOfParents(child, family)
コード例 #4
0
def birthBeforeMarriage(husband, wife, family, repository):
    marriageDate = parseDate(family.getMarriageDate())
    if marriageDate is None:
        return
    husbandBirthday = parseDate(husband.getBirthDate())
    wifeBirthday = parseDate(wife.getBirthDate())
    if husbandBirthday is None and wifeBirthday is None:
        return
    if husbandBirthday is not None and husbandBirthday > marriageDate:
        raise Exceptions.MarriageBeforeBirth(husband, family)
    if wifeBirthday is not None and wifeBirthday > marriageDate:
        raise Exceptions.MarriageBeforeBirth(wife, family)
コード例 #5
0
def divorceBeforeDeath(husband, wife, family, repository):
    divorceDate = parseDate(family.getDivorceDate())
    if divorceDate is None:
        return
    husbandDeathDate = parseDate(husband.getDeathDate())
    wifeDeathDate = parseDate(wife.getDeathDate())
    if husbandDeathDate is None and wifeDeathDate is None:
        return
    if husbandDeathDate is not None and husbandDeathDate < divorceDate:
        raise Exceptions.DivorceAfterDeath(husband, family)
    if wifeDeathDate is not None and wifeDeathDate < divorceDate:
        raise Exceptions.DivorceAfterDeath(wife, family)
    return
コード例 #6
0
def marriageBeforeDeath(husband, wife, family, repository):
    marriageDate = parseDate(family.getMarriageDate())
    if marriageDate is None:
        return
    husbandDeathDate = parseDate(husband.getDeathDate())
    wifeDeathDate = parseDate(wife.getDeathDate())
    if husbandDeathDate is None and wifeDeathDate is None:
        return
    if husbandDeathDate is not None and husbandDeathDate < marriageDate:
        raise Exceptions.MarriageAfterDeath(husband, family)
    if wifeDeathDate is not None and wifeDeathDate < marriageDate:
        raise Exceptions.MarriageAfterDeath(wife, family)
    return
コード例 #7
0
ファイル: Print.py プロジェクト: brendanreis/ssw555-tm06-17A
def recentBirths(repository):
    table = PrettyTable()
    table.field_names = ["ID", "Name", "Birth Date"]
    for person in repository.getPeople():
        if person.getBirthDate() is not None and (datetime.today() - timedelta(
                days=30)) <= parseDate(person.getBirthDate()) and parseDate(
                    person.getBirthDate()) <= datetime.today():
            table.add_row(
                [person.getIndiId(),
                 person.getName(),
                 person.getBirthDate()])
    print('US35: List of recently born people')
    print(table)
コード例 #8
0
def birthBeforeParentDeath(person, repository):
    famId = person.getChildFamilyId()

    if famId is not None:
        family = repository.getFamily(famId)
        father = repository.getPerson(family.getHusbandId())
        mother = repository.getPerson(family.getWifeId())

        fatherDeathDate = parseDate(father.getDeathDate())
        motherDeathDate = parseDate(mother.getDeathDate())
        childBirthDate = parseDate(person.getBirthDate())

        if (fatherDeathDate is not None) and relativedelta(
                childBirthDate, fatherDeathDate).months >= 9:
            raise Exceptions.BirthOver9MonthsAfterFatherDeath(
                person, father.getDeathDate())
        elif (motherDeathDate
              is not None) and childBirthDate > motherDeathDate:
            raise Exceptions.BirthAfterMotherDeath(person,
                                                   mother.getDeathDate())
コード例 #9
0
def recentDeadPeople(repository):
    recentDeathTable = PrettyTable()
    recentDeathTable.field_names = ["ID", "Name", "Death Date"]
    for person in repository.getPeople():
        if person.getDeathDate() is not None and (
                datetime.today() - timedelta(days=30)) <= parseDate(
                    person.getDeathDate()) <= datetime.today():
            recentDeathTable.add_row(
                [person.getIndiId(),
                 person.getName(),
                 person.getDeathDate()])
    print('US36: List of recently dead prople')
    print(recentDeathTable)
コード例 #10
0
def upcomingBirthdays(repository):
    upcomingBirthdayTable = PrettyTable()
    upcomingBirthdayTable.field_names = ["ID", "Name", "Birth Date"]
    for person in repository.getPeople():
        birthDate = parseDate(person.getBirthDate())
        currentYear = datetime.now().year
        birthDate = str(birthDate.day) + " " + str(
            birthDate.month) + " " + str(currentYear)
        birthDate = datetime.strptime(birthDate, '%d %m %Y')
        if person.getBirthDate() is not None and (datetime.today(
        )) <= birthDate <= (datetime.today() + timedelta(days=30)):
            upcomingBirthdayTable.add_row(
                [person.getIndiId(),
                 person.getName(),
                 person.getBirthDate()])
    print('US38: List of upcoming birthdays')
    print(upcomingBirthdayTable)
コード例 #11
0
def deathInFuture(person, repository):
    if person.getDeathDate() is not None:
        if inFuture(parseDate(person.getDeathDate())):
            raise Exceptions.DeathInFuture(person)
コード例 #12
0
def birthInFuture(person, repository):
    if inFuture(parseDate(person.getBirthDate())):
        raise Exceptions.BirthInFuture(person)
コード例 #13
0
def birthBeforeDeath(person, repository):
    birthDate = parseDate(person.getBirthDate())
    deathDate = parseDate(person.getDeathDate())

    if deathDate is not None and birthDate is not None and birthDate > deathDate:
        raise Exceptions.BirthAfterDeath(person)
コード例 #14
0
def marriageBeforeDivorce(husband, wife, family, repository):
    marriageDate = parseDate(family.getMarriageDate())
    divorceDate = parseDate(family.getDivorceDate())

    if divorceDate is not None and marriageDate is not None and marriageDate > divorceDate:
        raise Exceptions.MarriageAfterDivorce(husband, family)
コード例 #15
0
def divorceInFuture(husband, wife, family, repository):
    if family.getDivorceDate() is not None:
        if inFuture(parseDate(family.getDivorceDate())):
            raise Exceptions.DivorceInFuture(husband, family)
コード例 #16
0
def marriageInFuture(husband, wife, family, repository):
    if inFuture(parseDate(family.getMarriageDate())):
        raise Exceptions.MarriageInFuture(husband, family)