2019-09-10 15:17:35 +02:00
|
|
|
"Script which contains several utils for Haldis"
|
|
|
|
|
2020-01-27 02:31:02 +01:00
|
|
|
from typing import Iterable
|
|
|
|
|
2019-09-10 15:17:35 +02:00
|
|
|
|
2019-09-08 01:58:21 +02:00
|
|
|
def euro_string(value: int) -> str:
|
2019-08-28 03:46:04 +02:00
|
|
|
"""
|
|
|
|
Convert cents to string formatted euro
|
|
|
|
"""
|
2020-01-27 02:31:02 +01:00
|
|
|
return "€ {}.{:02}".format(*divmod(value, 100))
|
|
|
|
|
|
|
|
|
|
|
|
def first(iterable: Iterable, default=None):
|
|
|
|
"""
|
|
|
|
Return first element of iterable
|
|
|
|
"""
|
|
|
|
try:
|
|
|
|
return next(iter(iterable))
|
|
|
|
except StopIteration:
|
|
|
|
return default
|
|
|
|
|
2020-02-24 00:31:14 +01:00
|
|
|
|
|
|
|
def ignore_none(iterable: Iterable):
|
|
|
|
return filter(lambda x: x is not None, iterable)
|