V³ : ajout de l'utilisation de données déjà disponibles
This commit is contained in:
parent
74fff341be
commit
87283d36e0
12
vcub.py
12
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
|
||||
if type (data) == dict:
|
||||
self.data = data
|
||||
else:
|
||||
self.data = None
|
||||
if autoupdate_at_creation:
|
||||
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))
|
Loading…
Reference in New Issue