def post(self): person = model.Person() person.email = self.request.get("email") person.name = self.request.get("name") person.highschool = self.request.get("highschool") person.city1 = self.request.get("city1") person.state1 = self.request.get("state1") person.college = self.request.get("college") person.city2 = self.request.get("city2") person.state2 = self.request.get("state2") trivia_response = urlfetch.fetch( "https://maps.googleapis.com/maps/api/geocode/json?address=" + urllib.quote_plus(person.highschool + ",+" + person.city1 + ",+" + person.state1) + "&key=AIzaSyDanzu3x3EEBjImVNBU_XZPqzcAK2b-mb4").content trivia_as_json = json.loads(trivia_response) person.hslat = float( trivia_as_json['results'][0]['geometry']['location']['lat']) person.hslong = float( trivia_as_json['results'][0]['geometry']['location']['lng']) trivia_response2 = urlfetch.fetch( "https://maps.googleapis.com/maps/api/geocode/json?address=" + urllib.quote_plus(person.college + ",+" + person.city2 + ",+" + person.state2) + "&key=AIzaSyDanzu3x3EEBjImVNBU_XZPqzcAK2b-mb4").content trivia_as_json2 = json.loads(trivia_response2) person.collat = float( trivia_as_json2['results'][0]['geometry']['location']['lat']) person.collong = float( trivia_as_json2['results'][0]['geometry']['location']['lng']) person.put() self.redirect("/map") # auto redirect to map #### LOGIN TO SIGNUP
def register_current_user(): if request.method == 'GET': email = users.get_current_user().email() me = model.Person.by_email(email) if not me: me = model.Person() me.populate(email=email, displayname=users.get_current_user().nickname()) return render_template('user_edit.html', user=me) else: email = request.values.get('email', None) user = model.Person(id=email) user.email = email user.displayname = request.values.get('displayname', None) user.put() flash("Welcome, %s" % user.displayname) return redirect(url_for('register_current_user'))
def get_people(self) -> Iterable[model.Person]: return [ # Construct a new Person model.Person(pid, pname) # For each row returned for pid, pname in self.db.execute( SqliteRepository.__SELECT_ALL_PEOPLE).fetchall() ]
def find_people_by_id(self, people_ids: Iterable[int]) -> Iterable[model.Person]: ids = ','.join([str(id) for id in people_ids]) query = f"SELECT person_id, person_name FROM people WHERE person_id IN ({ids});" return [ # Construct a new Person model.Person(pid, pname) # For each row returned for pid, pname in self.db.execute(query).fetchall() ]
def person(self, store=True, repo_id='haiti', record_id=None, **kwargs): if not record_id: record_id = '%s.%s/Person.%d' % (repo_id, const.HOME_DOMAIN, model.UniqueId.create_id()) key_name = '%s:%s' % (repo_id, record_id) params = copy.deepcopy(TestDataGenerator._DEFAULT_PERSON_A_PARAMS) params.update(kwargs) person = model.Person(key_name=key_name, repo=repo_id, **params) if store: person.put() return person
def put_dummy_person_record(repo, person_record_id): db.put(model.Person( key_name='%s:%s' % (repo, person_record_id), repo=repo, author_name='_test_author_name', full_name='_test_given_name _test_family_name', given_name='_test_given_name', family_name='_test_family_name', source_date=TEST_DATETIME, entry_date=TEST_DATETIME, ))
def run(db_url="sqlite://", xml_path="people.xml"): Session, engine = model.create_initialize_db(db_url, echo=True) session = Session() try: tree = ET.parse(xml_path) root = tree.getroot() for child in root: if child.tag == "person": email = child.find("email").text permissions_list = child.find("permissions").text.split(',') person = model.Person(email=email) session.add(person) for name in permissions_list: person.permissions.append( model.Permission.find_or_create(session, name)) session.commit() for person in session.query(model.Person).all(): print person finally: session.close()
for sid, s in g.skills.items(): print(f" * {s.name} ({s.id})") for p in s.people: print(f" - {p.name} ({p.id})") print(f"People skills: {len(g.people_skills)}") for person, skill in g.people_skills: print(f"{person.name} <-> {skill.name}") ############################# # Model tests ############################# import model p1 = model.Person(1, "Alice") p2 = model.Person(2, "Bob") p3 = model.Person(3, "Charles") s1 = model.Skill(11, "Dancing") s2 = model.Skill(22, "Fishing") g = model.Graph() g.add_person(p1) g.add_person(p2) g.add_person(p3) g.add_skill(s1) g.add_skill(s2)
def __init__(self): super(Controller, self).__init__() self.person = model.Person(name="Chuck Norris", age=73, weight=80) self.view = view.View(self.person) self.view.pb_eat.clicked.connect(self.on_eat)
company = model.Company() company.industry = industry company.balance = 1000000 company.stock = 1000 company.price = 10 + random.randint(1,10) company.max_salary = 40 + random.randint(1,40) companies.append(company) industries[industry].append(company) # SET UP PEOPLE people = [] people_wealth = [] people_alive = [] for x in range(1,100): person = model.Person() person.balance = 1000 person.consumption = 1 person.productivity = 1 + random.randint(1,3) person.salary = 10 + random.randint(1,90) person.min_price = 10 + random.randint(1,10) people.append(person) # ITERATE EACH WEEK FOR A YEAR for week in range(1,500): print('Week', week) # ITERATE PEOPLE - PURCHASE GOOD / SERVICES w = 0 a = 0
def get(self): x = model.Person() self.response.write('Hello world!' + x)
def addPerson(self): p = model.Person(self.fname.text(), self.lname.text(), self.phone.text(), self.adress.text()) csvpath = 'person.csv' control.writeToCSV(p, csvpath)
import model model.Person().say() # => 'hello'
else: person.faceid = encode # 人脸图片转码 person.pic = image_numpy # 添加到数据库 p.addPerson(person) # 更新数据库信息到本地 p.updateGlFaceLib() return True if __name__ == '__main__': # # 加载全局人脸库 # updateGlFaceLib() # # # 打印全局人脸库 # print(gl.face_dict) # # # 添加人脸 # addPerson("image/拜登1.jpg", model.Person("拜登", 1)) # # # 打印全局人脸库 # print(gl.face_dict) print(addPerson("image/拜登1.jpg", model.Person("拜登", 1)))