-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
14 changed files
with
174 additions
and
79 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
"""Access bee flight forecast information published by Deutscher Wetterdienst (DWD)""" | ||
|
||
__appname__ = "apicast" | ||
__version__ = "0.8.6" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,14 +2,19 @@ | |
# (c) 2020-2021 Andreas Motl <[email protected]> | ||
# License: GNU Affero General Public License, Version 3 | ||
import logging | ||
from typing import List, Dict | ||
from typing import Dict, List | ||
|
||
from fastapi import FastAPI, Query | ||
from fastapi.responses import HTMLResponse, PlainTextResponse | ||
|
||
from apicast import __appname__, __version__ | ||
from apicast.core import (DwdBeeflightForecast, dwd_copyright, dwd_source, | ||
producer_link, producer_name) | ||
from apicast.core import ( | ||
DwdBeeflightForecast, | ||
dwd_copyright, | ||
dwd_source, | ||
producer_link, | ||
producer_name, | ||
) | ||
from apicast.format import Formatter | ||
|
||
app = FastAPI() | ||
|
@@ -21,9 +26,11 @@ | |
|
||
@app.get("/", response_class=HTMLResponse) | ||
def index(): | ||
|
||
appname = f"{__appname__} {__version__}" | ||
description = "Apicast acquires bee flight forecast information published by Deutscher Wetterdienst (DWD)." | ||
description = ( | ||
"Apicast acquires bee flight forecast information " | ||
"published by Deutscher Wetterdienst (DWD)." | ||
) | ||
|
||
data_index_items = [] | ||
for location in dbf.get_station_slugs(): | ||
|
@@ -44,7 +51,7 @@ def index(): | |
</div> | ||
<div style="clear: both"/> | ||
</li> | ||
""" | ||
""" # noqa: E501 | ||
data_index_items.append(item) | ||
|
||
data_index_items_html = "\n".join(data_index_items) | ||
|
@@ -105,12 +112,12 @@ def index(): | |
</ul> | ||
</body> | ||
</html> | ||
""" | ||
""" # noqa: E501 | ||
|
||
|
||
@app.get("/robots.txt", response_class=PlainTextResponse) | ||
def robots(): | ||
return f""" | ||
return """ | ||
User-agent: * | ||
Disallow: /beeflight/ | ||
""".strip() | ||
|
@@ -135,7 +142,6 @@ def beeflight_forecast_by_slug( | |
format: str = Query(default="json"), | ||
translate: bool = Query(default=False), | ||
): | ||
|
||
station_slug = f"{state}/{station}" | ||
|
||
try: | ||
|
@@ -164,7 +170,7 @@ def beeflight_forecast_by_slug( | |
|
||
|
||
def make_json_response(data: List[Dict], location: str = None): | ||
response = { | ||
return { | ||
"meta": { | ||
"source": dwd_source, | ||
"producer": f"{producer_name} - {producer_link}", | ||
|
@@ -175,7 +181,6 @@ def make_json_response(data: List[Dict], location: str = None): | |
}, | ||
"data": data, | ||
} | ||
return response | ||
|
||
|
||
def start_service(listen_address, reload: bool = False): | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,94 @@ | ||
[tool.pytest.ini_options] | ||
addopts = """ | ||
-ra -q --verbosity=3 | ||
--cov --cov-report=term-missing --cov-report=xml | ||
""" | ||
minversion = "2.0" | ||
log_level = "DEBUG" | ||
log_cli_level = "DEBUG" | ||
testpaths = [ | ||
"apicast", | ||
"test", | ||
] | ||
xfail_strict = true | ||
|
||
[tool.coverage.run] | ||
source = ["apicast"] | ||
|
||
[tool.coverage.report] | ||
show_missing = true | ||
fail_under = 0 | ||
omit = [ | ||
"test/*", | ||
] | ||
|
||
[tool.ruff] | ||
line-length = 100 | ||
extend-exclude = [ | ||
] | ||
|
||
[tool.ruff.lint] | ||
select = [ | ||
# Pycodestyle | ||
"E", | ||
"W", | ||
# Pyflakes | ||
"F", | ||
# isort | ||
"I", | ||
# Bandit | ||
"S", | ||
# flake8-quotes | ||
"Q", | ||
# eradicate | ||
"ERA", | ||
# flake8-2020 | ||
"YTT", | ||
"T20", | ||
# return | ||
"RET", | ||
# pyupgrade | ||
# "UP", | ||
# flake8-commas | ||
"COM", | ||
# future-annotations | ||
# "FA", | ||
# flake8-type-checking | ||
"TCH", | ||
# flake8-unused-arguments | ||
"ARG", | ||
# flake8-use-pathlib | ||
# "PTH" | ||
] | ||
extend-ignore = [ | ||
# Unnecessary `elif` after `return` or `raise` statement. | ||
"RET505", | ||
"RET506", | ||
# No trailing commas. | ||
"COM812" | ||
] | ||
unfixable = ["ERA", "F401", "F841", "T20", "ERA001"] | ||
|
||
[tool.ruff.lint.per-file-ignores] | ||
"apicast/cli.py" = ["T201"] | ||
"test/*" = ["S101"] | ||
|
||
|
||
# =================== | ||
# Tasks configuration | ||
# =================== | ||
|
||
[tool.poe.tasks] | ||
format = [ | ||
{cmd="ruff format"}, | ||
{cmd="ruff check --fix"}, | ||
] | ||
lint = [ | ||
{cmd="ruff check"}, | ||
] | ||
test = [ | ||
{cmd="pytest"}, | ||
] | ||
build = {cmd="python -m build"} | ||
check = ["lint", "test"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,7 @@ | ||
datadiff>=2.0,<3 | ||
fastapi[test] | ||
marko<3 | ||
poethepoet<0.26 | ||
pytest>=6.1.0,<8 | ||
pytest-cov<6 | ||
ruff<0.4;python_version>='3.7' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,7 +2,6 @@ | |
|
||
from apicast.api import app | ||
|
||
|
||
client = TestClient(app) | ||
|
||
|
||
|
Oops, something went wrong.