Compare commits
3
Commits
ca08bc282d
...
a92b63b855
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
a92b63b855 | ||
|
|
712c7615a6 | ||
|
|
1b5d009cdf |
@@ -6,4 +6,5 @@ PYTHON_VERSION=$(grep -m 1 'python' ./pyproject.toml | grep -oP 'python\s*=\s*"\
|
||||
DOCKER_PROJECTS=("gallery")
|
||||
DOCKER_TAG=latest
|
||||
|
||||
OPENWEATHER_KEY="<EMPTY>"
|
||||
OPENWEATHER_KEY=""
|
||||
GISMETEO_AUTH=""
|
||||
@@ -4,23 +4,12 @@ ignore=.venv
|
||||
[MESSAGES CONTROL]
|
||||
disable=
|
||||
missing-docstring,
|
||||
too-few-public-methods,
|
||||
too-many-instance-attributes,
|
||||
too-many-arguments,
|
||||
too-many-locals,
|
||||
too-many-boolean-expressions,
|
||||
too-many-public-methods,
|
||||
no-else-return,
|
||||
singleton-comparison,
|
||||
unused-argument,
|
||||
unspecified-encoding,
|
||||
fixme,
|
||||
invalid-name,
|
||||
duplicate-code,
|
||||
|
||||
extension-pkg-allow-list=
|
||||
lxml,
|
||||
GeoIP,
|
||||
pydantic
|
||||
too-few-public-methods,
|
||||
too-many-locals,
|
||||
no-else-return
|
||||
|
||||
[MISCELLANEOUS]
|
||||
notes=FIXME,TODO
|
||||
|
||||
@@ -13,6 +13,7 @@ services:
|
||||
environment:
|
||||
- REDIS_HOST=redis
|
||||
- OPENWEATHER_KEY=$OPENWEATHER_KEY
|
||||
- GISMETEO_AUTH=$GISMETEO_AUTH
|
||||
- DEBUG=1
|
||||
ports:
|
||||
- 8000:80
|
||||
|
||||
@@ -13,6 +13,7 @@ services:
|
||||
environment:
|
||||
- REDIS_HOST=redis
|
||||
- OPENWEATHER_KEY=$OPENWEATHER_KEY
|
||||
- GISMETEO_AUTH=$GISMETEO_AUTH
|
||||
depends_on:
|
||||
- redis
|
||||
ports:
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import datetime
|
||||
import json
|
||||
import logging
|
||||
from os import environ
|
||||
from typing import Any
|
||||
|
||||
from bs4 import BeautifulSoup
|
||||
@@ -9,6 +10,7 @@ from fastapi import HTTPException, status
|
||||
from gallery.sketch.source import ApiSource
|
||||
from gallery.sketch.weather.api import WeatherApi
|
||||
from gallery.sketch.weather.model import Location, WeatherResponse, WeatherValue
|
||||
from gallery.sketch.weather.util import merge_weather_values
|
||||
|
||||
from . import datehelp
|
||||
from .parser import DAYS_PARSER, LOCATION_PARSER, ONE_DAY_PARSER, ROW_PARSERS
|
||||
@@ -20,18 +22,7 @@ class GismeteoApi(WeatherApi):
|
||||
PROVIDER = "gismeteo"
|
||||
SOURCE = ApiSource(
|
||||
"https://www.gismeteo.ru",
|
||||
cookies={
|
||||
"cf_clearance": (
|
||||
"zPj8qeaYZWp5BUZsWIRD7kd32s59IDWWaVvD7GGf6b4-1724254262-1.2.1.1-"
|
||||
"R1PaHoqlm4OEgHfrOg6oAJmVmFJ7053JI_QDjIFlCAmbNY0oyw1J4QtgmEkAkTWF4C99X5hpXmZB2en."
|
||||
"9Ey3NL0kzaE10UGBHPli5OLxHNKC3wQ34xmxTxg6GcKouXOPRgqo92lVRpQP7ghvDmvvT_"
|
||||
"S6YXDbRonkamptWhZiAsIhsnIQg2Mt7Lk1fxSEVbaey_RXVQBvaR2ofiFgIavcbQPRFSvJ."
|
||||
"Ct_FujmymTAZWh1XHTptK32kur81NXyPuARThetOKQm8AklaMa855Oom6Bms1a4F9b0yEHSd2inA4j3FR7uauu8hhwO0Z2goa3."
|
||||
"ktpXXAQLz6dm.fBEWIHD7wooda15X57tCcDOely4hxhO4LK2lIH6TbOr."
|
||||
"rZQAiRRhltHiCizP1Ou2SiF_81lb1umoDh739tQD1cnw_USnL."
|
||||
"JwTHvkB00ZnaHRMi4FCBrsKIE0NxJO6kiv1QANqumzf5.8_pSIGRo2cKeO8xCydduDNFbStdOmLR6FU7ZKqVu"
|
||||
)
|
||||
},
|
||||
cookies={"xauth": auth} if (auth := environ.get("GISMETEO_AUTH")) else None,
|
||||
)
|
||||
|
||||
def _parse_oneday(self, date: datetime.date, data: str) -> WeatherResponse:
|
||||
@@ -45,6 +36,10 @@ class GismeteoApi(WeatherApi):
|
||||
result.append({})
|
||||
result[index][parser.KEY] = value
|
||||
values = [WeatherValue(**item) for item in result]
|
||||
# group values by 3 hours
|
||||
if len(values) > 8:
|
||||
n = 3
|
||||
values = [merge_weather_values(values[i].date, values[i : i + n]) for i in range(0, len(values), n)]
|
||||
return WeatherResponse(
|
||||
location=location or "n/a",
|
||||
date=date,
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
# pylint: skip-file
|
||||
from pathlib import Path
|
||||
|
||||
from lxml import etree
|
||||
@@ -17,8 +18,8 @@ def icon_optimizator(file: Path):
|
||||
for node in tree.findall(".//{*}path"):
|
||||
d = node.attrib["d"]
|
||||
node.attrib["d"] = " ".join(map(normalize_value, d.split(" ")))
|
||||
#file = file.parent.parent / "icons.tmp" / file.name
|
||||
#file.parent.mkdir(parents=True, exist_ok=True)
|
||||
# file = file.parent.parent / "icons.tmp" / file.name
|
||||
# file.parent.mkdir(parents=True, exist_ok=True)
|
||||
tree.write(file)
|
||||
target_size = file.stat().st_size
|
||||
print(file.name, source_size, target_size)
|
||||
|
||||
@@ -0,0 +1,3 @@
|
||||
from os import environ
|
||||
|
||||
environ.setdefault("OPENWEATHER_KEY", "test")
|
||||
Reference in New Issue
Block a user