Adjust str() of HLDS models to deal with int price
This commit is contained in:
parent
fe593fece6
commit
a346220896
2 changed files with 10 additions and 6 deletions
|
@ -1,10 +1,10 @@
|
|||
#!/usr/bin/env python3
|
||||
# pylint: disable=too-few-public-methods
|
||||
|
||||
from typing import List, Mapping, Any
|
||||
from typing import Iterable, List, Mapping, Any
|
||||
|
||||
|
||||
def _format_tags(tags):
|
||||
def _format_tags(tags: Iterable[str]) -> str:
|
||||
return (
|
||||
" :: {}".format(" ".join(["{" + tag + "}" for tag in tags]))
|
||||
if tags else
|
||||
|
@ -12,6 +12,10 @@ def _format_tags(tags):
|
|||
)
|
||||
|
||||
|
||||
def _format_price(price: int) -> str:
|
||||
return " € {}.{:02}".format(*divmod(price, 100)) if price else ""
|
||||
|
||||
|
||||
def _format_type_and_choice(type_and_choice):
|
||||
type_, choice = type_and_choice
|
||||
return "{} {}".format(type_, choice)
|
||||
|
@ -30,7 +34,7 @@ class Option:
|
|||
self,
|
||||
" -- {}".format(self.description) if self.description else "",
|
||||
_format_tags(self.tags),
|
||||
" {}".format(self.price) if self.price else ""
|
||||
_format_price(self.price)
|
||||
)
|
||||
|
||||
|
||||
|
@ -65,7 +69,7 @@ class Dish:
|
|||
self,
|
||||
" -- {}".format(self.description) if self.description else "",
|
||||
_format_tags(self.tags),
|
||||
" {}".format(self.price) if self.price else "",
|
||||
_format_price(self.price),
|
||||
"\n\t".join(map(_format_type_and_choice, self.choices))
|
||||
)
|
||||
|
||||
|
|
|
@ -6,8 +6,8 @@ testfrituur: Testfrituur
|
|||
sauce: Saus
|
||||
ketchup: Ketchup -- Een tomatensaus met veel suiker € 0.8
|
||||
mayo: Mayonaise -- Eierdooier en olie € 0.8
|
||||
curry: Currysaus € 0.8
|
||||
stoofvlees: Stoofvleessaus € 1.4
|
||||
curry: Currysaus € 0.80
|
||||
stoofvlees: Stoofvleessaus € 1.41
|
||||
|
||||
base veggieburger: Veggieburger € 4.2
|
||||
|
||||
|
|
Loading…
Reference in a new issue