Compare commits
No commits in common. "c6d39ace60ebe3f1d94fd31240090a09554b232a" and "09eb44b55dc3dd33f79eed938e4430adc190dc46" have entirely different histories.
c6d39ace60
...
09eb44b55d
2 changed files with 7 additions and 12 deletions
|
|
@ -202,18 +202,13 @@ class Trip:
|
||||||
"""Countries flags for trip."""
|
"""Countries flags for trip."""
|
||||||
return "".join(c.flag for c in self.countries)
|
return "".join(c.flag for c in self.countries)
|
||||||
|
|
||||||
def total_distance(self) -> float:
|
def total_distance(self) -> float | None:
|
||||||
"""Total distance for trip.
|
"""Total distance for trip."""
|
||||||
|
return (
|
||||||
Sums distances for travel items where a distance value is present.
|
sum(t["distance"] for t in self.travel)
|
||||||
Ignores legs with missing or falsy distances rather than returning None.
|
if all(t.get("distance") for t in self.travel)
|
||||||
"""
|
else None
|
||||||
total = 0.0
|
)
|
||||||
for t in self.travel:
|
|
||||||
distance = t.get("distance")
|
|
||||||
if distance:
|
|
||||||
total += distance
|
|
||||||
return total
|
|
||||||
|
|
||||||
def total_co2_kg(self) -> float | None:
|
def total_co2_kg(self) -> float | None:
|
||||||
"""Total CO₂ for trip."""
|
"""Total CO₂ for trip."""
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue