Podpora Food API na Windows
This commit is contained in:
parent
4aadb346ee
commit
783340bf06
@ -7,6 +7,7 @@ import tempfile
|
||||
import sys
|
||||
import os
|
||||
import urllib.request
|
||||
import platform
|
||||
from datetime import date, timedelta
|
||||
|
||||
URL_SLADOVNICKA = "https://sladovnicka.unasplzenchutna.cz/cz/denni-nabidka"
|
||||
@ -52,7 +53,7 @@ def getOrDownloadHtml(prefix: str, url: str):
|
||||
filepath = os.path.join(tempfile.gettempdir(), filename)
|
||||
if not os.path.isfile(filepath):
|
||||
urllib.request.urlretrieve(url, filepath)
|
||||
file = open(filepath, "r")
|
||||
file = open(filepath, "r", encoding='utf-8')
|
||||
contents = file.read()
|
||||
file.close()
|
||||
return contents
|
||||
@ -113,7 +114,12 @@ def getMenuSladovnicka(mock: bool = False) -> List[Food]:
|
||||
split = datumDen.split(".")
|
||||
denMesic = split[0] + "." + split[1] + "."
|
||||
# nazevDen = split[2]
|
||||
dnesniDatum = date.today().strftime("%-d.%-m.")
|
||||
# Windows má pro padding '#', POSIX systémy '-'
|
||||
if platform.system() == 'Windows':
|
||||
format = "%#d.%#m."
|
||||
else:
|
||||
format = "%-d.%-m."
|
||||
dnesniDatum = date.today().strftime(format)
|
||||
if denMesic != dnesniDatum:
|
||||
print('Chyba: neočekávané datum na stránce Sladovnické (' +
|
||||
denMesic + '), očekáváno ' + dnesniDatum, file=sys.stderr)
|
||||
|
Loading…
x
Reference in New Issue
Block a user