From 87283d36e055f3f36726e4db1c8f8fd197ff40db Mon Sep 17 00:00:00 2001 From: Sasha MOREL Date: Sat, 13 Nov 2021 09:36:02 +0100 Subject: [PATCH] =?UTF-8?q?V=C2=B3=C2=A0:=20ajout=20de=20l'utilisation=20d?= =?UTF-8?q?e=20donn=C3=A9es=20d=C3=A9j=C3=A0=20disponibles?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- vcub.py | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/vcub.py b/vcub.py index ac80b2b..7425dc4 100644 --- a/vcub.py +++ b/vcub.py @@ -29,10 +29,13 @@ class Vcub (): ] } ''' - def __init__ (self, autoupdate_at_creation = True, autoupdate = False, autoupdate_delay = -1): + def __init__ (self, autoupdate_at_creation = None, autoupdate = False, autoupdate_delay = -1, data = None): self.last_update = 0 - self.data = None - if autoupdate_at_creation: + if type (data) == dict: + self.data = data + else: + self.data = None + if autoupdate_at_creation or (autoupdate_at_creation is None and self.data is None): self.update () def update (self, auto = False): @@ -109,5 +112,8 @@ class Vcub (): if __name__ == '__main__': v = Vcub () - for i in (v.get_by_id (149), v.get_by_id (v.get_names () ['Buttiniere']), v.get_by_id (v.get_locations () [(44.8875, -0.51763)])): + for i in (v.get_by_id (149), v.get_by_id (v.get_names () ['Buttiniere'])): + print ('%s (%d) (%f, %f)%s%s\n\tbikes: %d\n\te-bikes: %d\n\tfree: %d\n\t' % (i.name, i, i.location [0], i.location [1], i.isplus and ' (VCUB+)' or '', i.online and ' ' or ' OFFLINE', i.bikes, i.ebikes, i.empty)) + v = Vcub (data = v.data) + for i in (v.get_by_id (v.get_locations () [(44.8875, -0.51763)]), ): print ('%s (%d) (%f, %f)%s%s\n\tbikes: %d\n\te-bikes: %d\n\tfree: %d\n\t' % (i.name, i, i.location [0], i.location [1], i.isplus and ' (VCUB+)' or '', i.online and ' ' or ' OFFLINE', i.bikes, i.ebikes, i.empty)) \ No newline at end of file