From a47d2c59af1425055d24f66833e090707778fc51 Mon Sep 17 00:00:00 2001 From: emkael Date: Tue, 28 Oct 2014 16:57:06 +0100 Subject: * find_driver moved to appropriate module --- f1elo/model.py | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'f1elo/model.py') diff --git a/f1elo/model.py b/f1elo/model.py index 4b893dc..7865198 100644 --- a/f1elo/model.py +++ b/f1elo/model.py @@ -85,5 +85,16 @@ class Ranking(Base): def __repr__(self): return ("%s: %0.2f (%s)" % (self.driver.__repr__().decode('utf8'), self.ranking, self. rank_date)).encode('utf8') +def find_driver(name, country, session): + driver = session.query(Driver).filter(Driver.driver==name).first() + if driver: + return driver + else: + driver = Driver() + driver.driver = name + driver.country = country + session.add(driver) + return driver + __all__ = ['Driver', 'Entry', 'Ranking', 'Race', 'RaceType'] -- cgit v1.2.3