def setUp(self): self.ind_1 = Individual.Individual("01") self.ind_2 = Individual.Individual("02") self.ind_3 = Individual.Individual("03") self.fam_1 = Family.Family("01") self.fam_2 = Family.Family("02")
def add_new_family_record(families, family_id, parents, kid): if family_id in families: if kid: families[family_id].kids.append(kid) else: families[family_id] = Family(parents, [kid]) if kid else Family( parents, [])
def tearDown(self): self.ind_1 = Individual.Individual("01") self.ind_2 = Individual.Individual("02") self.ind_3 = Individual.Individual("03") self.fam_1 = Family.Family("01") self.fam_2 = Family.Family("02")
def members(): body = request.get_json() if request.method == 'GET': family = Family('Doe') members = family.get_all_members() lucky_numbers = [member['lucky_numbers'] for member in members] sum_of_lucky = sum([number for sub in lucky_numbers for number in sub]) response_body = { "family_name": family.last_name, "members": family.get_all_members(), "lucky_numbers": lucky_numbers, "sum_of_lucky": str(sum_of_lucky) } return jsonify(response_body), 200 if request.method == 'POST': if body is not None: family = Family('Doe') body = request.get_json() response_body = family.add_member(body) return jsonify(response_body), 200 else: raise APIException( 'You need to specify the request body as a json object', status_code=404)
def test_fewer_than_15_siblings(self): husband: Individual = Individual(_id="I0") wife: Individual = Individual(_id="I1") child1: Individual = Individual(_id="I2") child2: Individual = Individual(_id="I3") child3: Individual = Individual(_id="I4") child4: Individual = Individual(_id="I5") child5: Individual = Individual(_id="I6") child6: Individual = Individual(_id="I7") child7: Individual = Individual(_id="I8") child8: Individual = Individual(_id="I9") child9: Individual = Individual(_id="I10") child10: Individual = Individual(_id="I12") child11: Individual = Individual(_id="I13") child12: Individual = Individual(_id="I14") child13: Individual = Individual(_id="I15") child14: Individual = Individual(_id="I16") child15: Individual = Individual(_id="I17") family: Family = Family(husb=husband.id, wife=wife.id) family.chil.extend([ child1.id, child2.id, child3.id, child4.id, child5.id, child6.id, child7.id, child8.id, child9.id, child10.id, child11.id, child12.id, child13.id, child14.id, child15.id ]) self.assertFalse(us.fewer_than_15_siblings(family)) family: Family = Family(husb=husband.id, wife=wife.id) family.chil.extend( [child1.id, child2.id, child3.id, child4.id, child5.id, child6.id]) self.assertTrue(us.fewer_than_15_siblings(family))
def test_were_parents_over_14(self): """ test were_parents_over_14 method """ # husband is 20 and wife is 14 at the marriage date -> Both are over 14 -> True husband: Individual = Individual(_id="I0", birt={'date': "19 SEP 1995"}) wife: Individual = Individual(_id="I1", birt={'date': "3 JAN 2000"}) individuals: List[Individual] = [husband, wife] family: Family = Family(_id="F0", husb=husband.id, wife=wife.id, marr={'date': "11 FEB 2015"}) self.assertTrue(us.were_parents_over_14(family, individuals)) # husband 11, wife 20 -> Only wife is over 14 -> False husband: Individual = Individual(_id="I2", birt={'date': "2 MAR 2007"}) wife: Individual = Individual(_id="I3", birt={'date': "11 FEB 2000"}) individuals: List[Individual] = [husband, wife] family: Family = Family(_id="F1", husb=husband.id, wife=wife.id, marr={'date': "11 FEB 2019"}) self.assertFalse(us.were_parents_over_14(family, individuals)) # husband 17, wife 10 -> Only husband is over 14 -> False husband: Individual = Individual(_id="I4", birt={'date': "22 AUG 2000"}) wife: Individual = Individual(_id="I5", birt={'date': "5 DEC 2007"}) individuals: List[Individual] = [husband, wife] family: Family = Family(_id="F2", husb=husband.id, wife=wife.id, marr={'date': "11 FEB 2018"}) self.assertFalse(us.were_parents_over_14(family, individuals)) # husband 12, wife 12 -> Both are under 14 -> False husband: Individual = Individual(_id="I6", birt={'date': "19 SEP 2007"}) wife: Individual = Individual(_id="I7", birt={'date': "3 JAN 2008"}) individuals: List[Individual] = [husband, wife] family: Family = Family(_id="F3", husb=husband.id, wife=wife.id, marr={'date': "11 FEB 2020"}) self.assertFalse(us.were_parents_over_14(family, individuals)) # husband 18, wife 16 -> Both are over 14 -> True husband: Individual = Individual(_id="I8", birt={'date': "7 FEB 1980"}) wife: Individual = Individual(_id="I9", birt={'date': "8 FEB 1982"}) individuals: List[Individual] = [husband, wife] family: Family = Family(_id="F4", husb=husband.id, wife=wife.id, marr={'date': "11 FEB 1998"}) self.assertTrue(us.were_parents_over_14(family, individuals))
def add_family(teacher_id): if teacher_id == session[CURR_USER_KEY] and session[IS_TEACHER] == True: form = FamilyForm() if form.validate_on_submit(): guardian = Guardian.query.filter_by( first_name=form.guardian_first_name.data, last_name=form.guardian_last_name.data, username=form.guardian_username.data).first() student = Student.query.filter_by( first_name=form.student_first_name.data, last_name=form.student_last_name.data).first() family = Family(guardian_id=guardian.id, student_id=student.id) db.session.add(family) db.session.commit() flash( f"Family created! Guardian: {guardian.first_name} {guardian.last_name}, Student: {student.first_name} {student.last_name}!", "good") return redirect(f'/teacher/{session[CURR_USER_KEY]}') students = Student.query.all() guardians = Guardian.query.all() return render_template('/teacher/add-family.html', form=form, students=students, guardians=guardians)
def test_birth_before_death_of_parents(self): """ test birth_before_death_of_parents method """ # mother and father are alive (no death date) husband: Individual = Individual(_id="I0") wife: Individual = Individual(_id="I1") child: Individual = Individual(_id="I2", birt={'date': "4 OCT 2000"}) individuals: List[Individual] = [husband, wife, child] family: Family = Family(_id="F0", husb=husband.id, wife=wife.id) family.chil.append(child.id) self.assertTrue(us.birth_before_death_of_parents(family, individuals)) # child born on: mother death, 270 day after father death husband: Individual = Individual(_id="I0", deat={'date': "8 JAN 2000"}) wife: Individual = Individual(_id="I1", deat={'date': "4 OCT 2000"}) child: Individual = Individual(_id="I2", birt={'date': "4 OCT 2000"}) individuals: List[Individual] = [husband, wife, child] family: Family = Family(_id="F1", husb=husband.id, wife=wife.id) family.chil.append(child.id) self.assertTrue(us.birth_before_death_of_parents(family, individuals)) # child born on: 1 day before mother death, 1 day after father death husband: Individual = Individual(_id="I0", deat={'date': "3 OCT 2000"}) wife: Individual = Individual(_id="I1", deat={'date': "5 OCT 2000"}) child: Individual = Individual(_id="I2", birt={'date': "4 OCT 2000"}) individuals: List[Individual] = [husband, wife, child] family: Family = Family(_id="F2", husb=husband.id, wife=wife.id) family.chil.append(child.id) self.assertTrue(us.birth_before_death_of_parents(family, individuals)) # child born on: after mother death, 10 day after father death husband: Individual = Individual(_id="I0", deat={'date': "3 OCT 2000"}) wife: Individual = Individual(_id="I1", deat={'date': "12 OCT 2000"}) child: Individual = Individual(_id="I2", birt={'date': "13 OCT 2000"}) individuals: List[Individual] = [husband, wife, child] family: Family = Family(_id="F3", husb=husband.id, wife=wife.id) family.chil.append(child.id) self.assertFalse(us.birth_before_death_of_parents(family, individuals)) # child born on: before mother death, 1 year after father death husband: Individual = Individual(_id="I0", deat={'date': "11 OCT 1999"}) wife: Individual = Individual(_id="I1", deat={'date': "12 OCT 2000"}) child: Individual = Individual(_id="I2", birt={'date': "11 OCT 2000"}) individuals: List[Individual] = [husband, wife, child] family: Family = Family(_id="F4", husb=husband.id, wife=wife.id) family.chil.append(child.id) self.assertFalse(us.birth_before_death_of_parents(family, individuals))
def single_member(member_id=None): body = request.get_json() if request.method == 'GET': family = Family('Doe') response_body = family.get_member(member_id) return jsonify(response_body), 200 if request.method == 'DELETE': family = Family('Doe') family.delete_member(member_id) response_body = {"msg": "member was successfully deleted"} return jsonify(response_body), 200 return "Invalid Method", 404
def setUp(self): self.school = School(name='Minnesota') db.session.add(self.school) db.session.commit() self.tch = Teacher(first_name='Jess', last_name='Christensen', title='K4-2nd Sped', school_id=self.school.id, username='******', password='******') db.session.add(self.tch) db.session.commit() self.stu = Student(first_name='Fake', last_name='Kid', dob=date(2012, 1, 24), grade=1, teacher_id=self.tch.id, dis_area='OHI') db.session.add(self.stu) db.session.commit() self.guardian = Guardian(first_name='Fake', last_name='Dad', relation='Dad', username='******', password='******') self.guardian2 = Guardian(first_name='Fake', last_name='Mom', relation='Mom', username='******', password='******') db.session.add(self.guardian) db.session.add(self.guardian2) db.session.commit() self.family = Family(guardian_id=self.guardian.id, student_id=self.stu.id) self.family2 = Family(guardian_id=self.guardian2.id, student_id=self.stu.id) db.session.add(self.family) db.session.add(self.family2) db.session.commit()
def create_new_member(): data = request.get_json() new_member = Family(public_id=str(uuid.uuid4()), first_name=data["first_name"], last_name=data["last_name"], age=data["age"], lucky_numbers=data["lucky_numbers"]) db.session.add(new_member) db.session.commit() return jsonify({"message": "New User Created!"})
def test_divorce_before_death(self): husband: Individual = Individual(_id="I0", deat={'date': "1 JAN 2020"}) wife: Individual = Individual(_id="I1", deat={'date': "2 JAN 2019"}) individuals: List[Individual] = [husband, wife] family: Family = Family(husb=husband.id, wife=wife.id, div={'date': "11 FEB 1999"}) self.assertTrue(us.divorce_before_death(family, individuals)) """Husband and wife they both die before their divorce so False (not possible)""" husband: Individual = Individual(_id="I2", deat={'date': "1 JAN 2000"}) wife: Individual = Individual(_id="I3", deat={'date': "2 JAN 2000"}) individuals: List[Individual] = [husband, wife] family: Family = Family(husb=husband.id, wife=wife.id, div={'date': "11 FEB 2001"}) self.assertFalse(us.divorce_before_death(family, individuals)) """ Husband dies before divorce wife is alive so False (not possible)""" husband: Individual = Individual(_id="I4", deat={'date': "1 JAN 2000"}) wife: Individual = Individual(_id="I5") individuals: List[Individual] = [husband, wife] family: Family = Family(husb=husband.id, wife=wife.id, div={'date': "11 FEB 2001"}) self.assertFalse(us.divorce_before_death(family, individuals)) """ Husband dies after divorce and wife is alive so true""" husband: Individual = Individual(_id="I4", deat={'date': "1 JAN 2002"}) wife: Individual = Individual(_id="I5") individuals: List[Individual] = [husband, wife] family: Family = Family(husb=husband.id, wife=wife.id, div={'date': "11 FEB 2001"}) self.assertTrue(us.divorce_before_death(family, individuals)) """Wife dies before divorce and Husband is alive so False (not possible)""" husband: Individual = Individual(_id="I6") wife: Individual = Individual(_id="I7", deat={'date': "1 JAN 2000"}) individuals: List[Individual] = [husband, wife] family: Family = Family(husb=husband.id, wife=wife.id, div={'date': "11 FEB 2001"}) self.assertFalse(us.divorce_before_death(family, individuals)) """Wife dies after divorce and Husband is alive so true""" husband: Individual = Individual(_id="I8") wife: Individual = Individual(_id="I9", deat={'date': "1 JAN 2002"}) individuals: List[Individual] = [husband, wife] family: Family = Family(husb=husband.id, wife=wife.id, div={'date': "11 FEB 2001"}) self.assertTrue(us.divorce_before_death(family, individuals)) """ Husband and wife they both are alive no divorce date is found so false""" husband: Individual = Individual(_id="I10") wife: Individual = Individual(_id="I11") individuals: List[Individual] = [husband, wife] family: Family = Family(husb=husband.id, wife=wife.id, div={'date': "11 FEB 2002"}) self.assertFalse(us.divorce_before_death(family, individuals))
def setUp(self): db.create_all() # Adding Users user = User(name='user1', email="*****@*****.**") user2 = User(name='user2', email="*****@*****.**") user3 = User(name='user3', email="*****@*****.**") db.session.add_all([user, user2, user3]) # Adding Families family = Family(name='Family-name-1', members=[user, user2]) family2 = Family(name='Family-name-2', members=[user, user3]) db.session.add_all([family, family2, user3]) # Adding Fridges fridge = Fridge() fridge2 = Fridge() db.session.add_all([fridge, fridge2]) family.fridge = fridge family2.fridge = fridge2 # Adding Grocery Lists grocery_list = GroceryList(name="listname1") grocery_list2 = GroceryList(name="listname2") grocery_list3 = GroceryList(name="listname3") db.session.add_all([grocery_list, grocery_list2, grocery_list3]) family.grocery_lists.append(grocery_list) family.grocery_lists.append(grocery_list2) family2.grocery_lists.append(grocery_list3) db.session.commit() # Adding items item1 = Item(name="item1", family_pk=family.pk) item2 = Item(name="item2", family_pk=family.pk) item3 = Item(name="item3", family_pk=family.pk) item4 = Item(name="item4", family_pk=family2.pk) item5 = Item(name="item5", family_pk=family2.pk) db.session.add_all([item1, item2, item3, item4, item5]) # Adding items to fridge fridge.items.append(item1) fridge2.items.append(item2) # Adding items to grocery lists grocery_list.items.append(item3) grocery_list3.items.append(item4) grocery_list3.items.append(item5) db.session.commit()
def getFamily(): family = Family("Doe") familyMembers = family.get_all_members() luckyNumbers = [] for member in familyMembers: luckyNumbers = luckyNumbers + member['lucky_numbers'] response_body = { "family_name": family.last_name, "members": familyMembers, "lucky_numbers": luckyNumbers, "sum_of_lucky": sum(luckyNumbers) } return jsonify(response_body), 200
def test_add_Family1(self): with app.test_request_context(): family1 = Family(id=1000000, name="family1") db.session.add(family1) db.session.commit() gamequery = db.session.query(Family).filter_by( id="1000000").first() self.assertEqual(gamequery.id, 1000000) self.assertEqual(gamequery.name, "family1") db.session.delete(family1) db.session.commit()
def test_add_Family2(self): with app.test_request_context(): family2 = Family() init_len = len(Family.query.all()) db.session.add(family2) db.session.commit() changed_len = len(Family.query.all()) self.assertEqual(init_len + 1, changed_len) init_len = changed_len db.session.delete(family2) db.session.commit() changed_len = len(Family.query.all()) self.assertEqual(init_len - 1, changed_len)
def newMember(): if not request.is_json: return jsonify({"msg": "Missing JSON in request"}), 400 family = Family('Doe') name = request.json.get('name', None) if not name: return({"msg": "Missing name parameter"}) age = request.json.get('age', None) if not age: return({"msg": "Missing age parameter"}) lucky_numbers = request.json.get('lucky_numbers', None) if not lucky_numbers: return({"msg": "Missing lucky numbers"}) new_member = { "id": family._generateId(), "first_name": name, "age": age, "lucky_numbers": lucky_numbers } family.add_member(new_member) return jsonify(family.get_all_members())
def generate_classes( lines: List[str]) -> Tuple[List[Individual], List[Family]]: """ get lines read from a .ged file """ individuals: List[Individual] = [] families: List[Family] = [] current_record: Optional[Individual, Family] = None current_tag: Optional[str] = None for line in lines: row_fields: List[str] = line.rstrip("\n").split(' ', 2) pattern_type = pattern_finder(line) if pattern_type == 'ZERO_1': current_record = Individual( ) if row_fields[2] == 'INDI' else Family() (individuals if isinstance(current_record, Individual) else families) \ .append(current_record) current_record.id = row_fields[1] elif pattern_type == 'ZERO_2': pass # nothing to do with this elif pattern_type == 'NO_ARGUMENT': if row_fields[0] == '1': setattr(current_record, row_fields[1].lower(), {}) current_tag = row_fields[1].lower() elif pattern_type == 'ARGUMENT': if row_fields[0] == '1': if isinstance(getattr(current_record, row_fields[1].lower()), list): current_list = getattr( current_record, row_fields[1].lower()) + [row_fields[2]] setattr(current_record, row_fields[1].lower(), current_list) else: setattr(current_record, row_fields[1].lower(), row_fields[2]) elif row_fields[0] == '2': setattr(current_record, current_tag, {row_fields[1].lower(): row_fields[2]}) return individuals, families
""" This module takes care of starting the API Server, Loading the DB and Adding the endpoints """ import os from flask import Flask, request, jsonify, url_for from utils import APIException, generate_sitemap from models import Family app = Flask(__name__) app.url_map.strict_slashes = False doe = Family("Londono") john = { "age": "33 Years old", "gender": "Male", "Lucky Numbers": [7, 13, 22], "member_id": 1 } jane = { "age": "35 Years old", "gender": "Female", "Lucky Numbers": [10, 14, 3], "member_id": 2 } jimmy = { "age": "5 Years old", "gender": "Male", "Lucky Numbers": [1], "member_id": 3 }
last_name='Dad', relation='Father', username='******', password='******') par3 = Guardian.register(first_name='Fake', last_name='Aunt', relation='Aunt', username='******', password='******') par4 = Guardian.register(first_name='Fake', last_name='Brother', relation='Brother', username='******', password='******') fam1 = Family(student_id=1, guardian_id=1) fam2 = Family(student_id=2, guardian_id=1) fam5 = Family(student_id=1, guardian_id=2) fam6 = Family(student_id=2, guardian_id=2) fam3 = Family(student_id=2, guardian_id=3) fam4 = Family(student_id=3, guardian_id=4) db.session.add(fam1) db.session.add(fam2) db.session.add(fam3) db.session.add(fam4) db.session.add(fam5) db.session.add(fam6) db.session.commit()
from flask import Flask, render_template, request, jsonify from models import Family import json app = Flask(__name__) fam = Family("Jackson") @app.route("/") def main(): return render_template("index.html") @app.route("/members/", methods=["GET", "POST"]) @app.route("/members/member/<int:id>", methods=["GET", "PUT", "DELETE"]) def members(id=None): ####### G E T - M I E M B R O S ######## if request.method == "GET": if id == None: miembros = fam.get_all_members() return jsonify(miembros), 201 ####### G E T - M I E M B R O ######## if id: member = fam.get_member(id) if member: return jsonify(member), 200 else:
def test_male_last_names(self): husband: Individual = Individual(_id="I0", name="Pablo /Escobar/", sex='M') wife: Individual = Individual(_id="I1", name="Veronika /Esco/", sex='F') child1: Individual = Individual(_id="I2", name="Terry /Escobart/", sex='M') child2: Individual = Individual(_id="I3", name="Maria /Escobar/", sex='F') family = Family(husb=husband.id, wife=wife.id) family.chil = [child1.id, child2.id] individuals = [husband, wife, child1, child2] self.assertFalse(us.male_last_names(family, individuals)) husband: Individual = Individual(_id="I112", name="Naal /Wagas/", sex='M') wife: Individual = Individual(_id="I22", name="Veron /Wagadi/", sex='F') child1: Individual = Individual(_id="I33", name="Ter /Wagada/", sex='M') child2: Individual = Individual(_id="I44", name="Mara /Wagadi/", sex='F') family = Family(husb=husband.id, wife=wife.id) family.chil = [child1.id, child2.id] individuals = [husband, wife, child1, child2] self.assertFalse(us.male_last_names(family, individuals)) husband: Individual = Individual(_id="I9", name="Eden /Hazard/", sex='M') wife: Individual = Individual(_id="I99", name="Veva /Hazard/", sex='F') child1: Individual = Individual(_id="I999", name="JR /Hazard/", sex='M') child2: Individual = Individual(_id="I9999", name="SR /Hazard/", sex='M') family = Family(husb=husband.id, wife=wife.id) family.chil = [child1.id, child2.id] individuals = [husband, wife, child1, child2] self.assertTrue(us.male_last_names(family, individuals)) husband: Individual = Individual(_id="I07", name="Reese /Walter/", sex='M') wife: Individual = Individual(_id="I177", name="Monica /Walter/", sex='F') child1: Individual = Individual(_id="I277", name="Malcom /Walter/", sex='M') child2: Individual = Individual(_id="I377", name="Hal /Walters/", sex='M') family = Family(husb=husband.id, wife=wife.id) family.chil = [child1.id, child2.id] individuals = [husband, wife, child1, child2] self.assertFalse(us.male_last_names(family, individuals)) husband: Individual = Individual(_id="I007", name="Elon /Drogba/", sex='M') wife: Individual = Individual(_id="I1008", name="Emma /Drogba/", sex='F') child1: Individual = Individual(_id="I2009", name="Agua /Drogba/", sex='F') child2: Individual = Individual(_id="I3000", name="Win /Drogbaaa/", sex='F') family = Family(husb=husband.id, wife=wife.id) family.chil = [child1.id, child2.id] individuals = [husband, wife, child1, child2] self.assertTrue(us.male_last_names(family, individuals))
""" This module takes care of starting the API Server, Loading the DB and Adding the endpoints """ import os from flask import Flask, request, jsonify, url_for from flask_migrate import Migrate from flask_swagger import swagger from flask_cors import CORS from utils import APIException, generate_sitemap from models import db from models import Family myFamily = Family('Doe') app = Flask(__name__) app.url_map.strict_slashes = False app.config['SQLALCHEMY_DATABASE_URI'] = os.environ.get('DB_CONNECTION_STRING') app.config['SQLALCHEMY_TRACK_MODIFICATIONS'] = False MIGRATE = Migrate(app, db) db.init_app(app) CORS(app) # Handle/serialize errors like a JSON object @app.errorhandler(APIException) def handle_invalid_usage(error): return jsonify(error.to_dict()), error.status_code # generate sitemap with all your endpoints @app.route('/')
def getMember(member_id = None): family = Family('Doe') member_id = request.view_args['member_id'] member = family.get_member(member_id) return jsonify(member)
def run(): F = Family() F.create_pollyanna()
""" This module takes care of starting the API Server, Loading the DB and Adding the endpoints """ import os from flask import Flask, request, jsonify, url_for from flask_migrate import Migrate from flask_swagger import swagger from flask_cors import CORS from utils import APIException, generate_sitemap from models import db from models import Family myFamily = Family("Doe") app = Flask(__name__) app.url_map.strict_slashes = False app.config['SQLALCHEMY_DATABASE_URI'] = os.environ.get('DB_CONNECTION_STRING') app.config['SQLALCHEMY_TRACK_MODIFICATIONS'] = False MIGRATE = Migrate(app, db) db.init_app(app) CORS(app) # Handle/serialize errors like a JSON object @app.errorhandler(APIException) def handle_invalid_usage(error): return jsonify(error.to_dict()), error.status_code # generate sitemap with all your endpoints @app.route('/')
def parse_taxonomy(Document): f = csv.reader(Document, delimiter='\t') f.next() for line in f: subbed = re.sub(r'(\(.*?\)|k__|p__|c__|o__|f__|g__|s__)', '', line[2]) taxon = subbed.split(';') if not Kingdom.objects.filter(kingdomName=taxon[0]).exists(): kid = uuid4().hex record = Kingdom(kingdomid=kid, kingdomName=taxon[0]) record.save() k = Kingdom.objects.get(kingdomName=taxon[0]).kingdomid if not Phyla.objects.filter(kingdomid_id=k, phylaName=taxon[1]).exists(): pid = uuid4().hex record = Phyla(kingdomid_id=k, phylaid=pid, phylaName=taxon[1]) record.save() p = Phyla.objects.get(kingdomid_id=k, phylaName=taxon[1]).phylaid if not Class.objects.filter( kingdomid_id=k, phylaid_id=p, className=taxon[2]).exists(): cid = uuid4().hex record = Class(kingdomid_id=k, phylaid_id=p, classid=cid, className=taxon[2]) record.save() c = Class.objects.get(kingdomid_id=k, phylaid_id=p, className=taxon[2]).classid if not Order.objects.filter( kingdomid_id=k, phylaid_id=p, classid_id=c, orderName=taxon[3]).exists(): oid = uuid4().hex record = Order(kingdomid_id=k, phylaid_id=p, classid_id=c, orderid=oid, orderName=taxon[3]) record.save() o = Order.objects.get(kingdomid_id=k, phylaid_id=p, classid_id=c, orderName=taxon[3]).orderid if not Family.objects.filter(kingdomid_id=k, phylaid_id=p, classid_id=c, orderid_id=o, familyName=taxon[4]).exists(): fid = uuid4().hex record = Family(kingdomid_id=k, phylaid_id=p, classid_id=c, orderid_id=o, familyid=fid, familyName=taxon[4]) record.save() f = Family.objects.get(kingdomid_id=k, phylaid_id=p, classid_id=c, orderid_id=o, familyName=taxon[4]).familyid if not Genus.objects.filter(kingdomid_id=k, phylaid_id=p, classid_id=c, orderid_id=o, familyid_id=f, genusName=taxon[5]).exists(): gid = uuid4().hex record = Genus(kingdomid_id=k, phylaid_id=p, classid_id=c, orderid_id=o, familyid_id=f, genusid=gid, genusName=taxon[5]) record.save() g = Genus.objects.get(kingdomid_id=k, phylaid_id=p, classid_id=c, orderid_id=o, familyid_id=f, genusName=taxon[5]).genusid if not Species.objects.filter(kingdomid_id=k, phylaid_id=p, classid_id=c, orderid_id=o, familyid_id=f, genusid_id=g, speciesName=taxon[6]).exists(): sid = uuid4().hex record = Species(kingdomid_id=k, phylaid_id=p, classid_id=c, orderid_id=o, familyid_id=f, genusid_id=g, speciesid=sid, speciesName=taxon[6]) record.save()
def deleteMember(member_id = None): family = Family('Doe') member_id = request.view_args['member_id'] family.delete_member(member_id) return jsonify(family.get_all_members())
i = 1 for key in err_list: err_chart.add_row([i, err_list[key]]) i += 1 write_file.write("Individual\n") write_file.write(indi_chart.get_string() + "\n") write_file.write("Family\n") write_file.write(fam_chart.get_string() + "\n") write_file.write("Error\n") if (i == 1): write_file.write("\nNo Errors found!") else: write_file.write(err_chart.get_string()) write_file.close() if __name__ == "__main__": from models import Individual from models import Family indi_1 = Individual.Individual("01") indi_2 = Individual.Individual("02") fam_1 = Family.Family("10") fam_2 = Family.Family("20") indi_1.add_to_family(fam_1) indi_2.add_to_family(fam_2) fam_1.set_husband(indi_1) fam_1.set_wife(indi_2) fam_2.set_husband(indi_2) fam_2.set_wife(indi_1) print_pretty_table([indi_1, indi_2], [fam_1, fam_2], [])