Spaces:
Sleeping
Sleeping
Download src/art_pieces_db/utils.py from ClickMons/CreativUp_Demo: direct link, hf CLI and curl.
- Browser
- Download file 634 Bytes
-
https://huggingface.co/spaces/ClickMons/CreativUp_Demo/resolve/main/src/art_pieces_db/utils.py
- Command line
-
hf download hf://spaces/ClickMons/CreativUp_Demo/src/art_pieces_db/utils.py
-
curl -L -o utils.py https://huggingface.co/spaces/ClickMons/CreativUp_Demo/resolve/main/src/art_pieces_db/utils.py
634 Bytes
| import datetime | |
| import re | |
| def str_to_date(str_date): | |
| return datetime.datetime.strptime(str_date, "%d/%m/%Y").date() | |
| def str_to_list(value, separators=',;\n'): | |
| """ | |
| Tries to translate a string of separated values into a list of strings. | |
| The separators are commas and carriage returns. | |
| In case the string does not seem to represent a list of values, a warning is logged and an empty list is returned. | |
| """ | |
| if not isinstance(value, str): | |
| raise TypeError | |
| if value == '': | |
| return [] | |
| return list(filter(lambda x: x != '', map(lambda x: x.strip(), re.split('['+separators+']', value)))) | |