@@ -66,11 +66,12 @@ def __init__(self, distance=None, duration=None, mode=None):
6666 self .duration = None
6767
6868 def __repr__ (self ):
69- display_str = f"<distance={ self .distance .text } "
69+ fields = []
70+ if self .distance :
71+ fields .append (f"distance={ self .distance .text } " )
7072 if self .duration :
71- display_str += f" duration={ self .duration .text } >"
72- else :
73- display_str += ">"
73+ fields .append (f"duration={ self .duration .text } " )
74+ display_str = f"<{ ' ' .join (fields )} >"
7475 return display_str
7576
7677
@@ -96,15 +97,12 @@ def __init__(self, radar, data={}):
9697 self ._radar = radar
9798 self .raw_json = data
9899 for attribute , value in data .items ():
99- if attribute in ["transit" , "car" , "bike" , "foot" ]:
100+ if attribute in ["geodesic" , " transit" , "car" , "bike" , "foot" ]:
100101 route = Route (
101102 distance = value .get ("distance" ),
102103 duration = value .get ("duration" ),
103104 mode = attribute ,
104105 )
105106 setattr (self , attribute , route )
106- elif attribute in ["geodesic" ]:
107- route = Route (distance = value , mode = attribute )
108- setattr (self , attribute , route )
109107 else :
110108 setattr (self , attribute , value )
0 commit comments