-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1 from lnx85/library-deploy
Library deploy
- Loading branch information
Showing
10 changed files
with
259 additions
and
31 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
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 +1,57 @@ | ||
# Client Library for Osservaprezzi | ||
|
||
## Installation | ||
|
||
If you have a recent version of Python 3, you should be able to | ||
do `pip install osservaprezzi` to get the most recently released version of | ||
this. | ||
|
||
## Usage | ||
|
||
You are welcome to try using this as a python library for other efforts. | ||
A simple usage might go something like this: | ||
|
||
```python | ||
import aiohttp | ||
import asyncio | ||
import logging | ||
|
||
from osservaprezzi.client import Osservaprezzi | ||
from osservaprezzi.models import GPSCoordinates | ||
|
||
|
||
async def main(): | ||
async with aiohttp.ClientSession() as session: | ||
logging.basicConfig(level=logging.DEBUG) | ||
client = Osservaprezzi(session) | ||
|
||
# brands list | ||
brands = await client.get_brands() | ||
for brand in brands: | ||
print(brand.name) | ||
|
||
# fuels list | ||
fuels = await client.get_fuels() | ||
for fuel in fuels: | ||
print(fuel) | ||
|
||
# stations list 5 km near 45.541553,10.211802 | ||
location = GPSCoordinates(latitude=45.541553, longitude=10.211802) | ||
stations = await client.get_stations(location, radius=5) | ||
for station in stations: | ||
print(station.name) | ||
|
||
# station details | ||
station = await client.get_station(47997) | ||
print(station.name) | ||
|
||
|
||
if __name__ == '__main__': | ||
asyncio.run(main()) | ||
``` | ||
|
||
## Thanks | ||
|
||
My heartfelt thanks to: | ||
|
||
- All the users who have given useful feedback and contributed code! |
Binary file not shown.
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,169 @@ | ||
[build-system] | ||
requires = ["setuptools>=60", | ||
"setuptools-scm>=8.0"] | ||
build-backend = "setuptools.build_meta" | ||
|
||
[project] | ||
name = "osservaprezzi" | ||
license = {text = "GPL-3.0"} | ||
description = "Python library for Osservaprezzi Carburanti " | ||
readme = "README.md" | ||
authors = [ | ||
{name = "Lorenzo Monaco", email = "[email protected]"} | ||
] | ||
keywords = ["osservaprezzi", "carburanti", "mise"] | ||
classifiers = [ | ||
"Development Status :: 4 - Beta", | ||
"Intended Audience :: Developers", | ||
"License :: OSI Approved :: GNU General Public License v3 (GPLv3)", | ||
"Programming Language :: Python :: 3.12", | ||
"Topic :: Software Development :: Libraries :: Python Modules", | ||
] | ||
requires-python = ">=3.12.0" | ||
dynamic = ["dependencies", "version"] | ||
|
||
[project.urls] | ||
"Homepage" = "https://github.com/lnx85/osservaprezzi.py" | ||
"Source Code" = "https://github.com/lnx85/osservaprezzi.py" | ||
"Bug Reports" = "https://github.com/lnx85/osservaprezzi.py/issues" | ||
|
||
[tool.setuptools] | ||
include-package-data = true | ||
|
||
[tool.setuptools.dynamic] | ||
dependencies = {file = ["requirements.txt"]} | ||
|
||
[tool.setuptools.packages.find] | ||
include = ["osservaprezzi*"] | ||
|
||
[tool.setuptools_scm] | ||
[tool.black] | ||
target-version = ['py311'] | ||
safe = true | ||
|
||
|
||
|
||
[tool.ruff.lint] | ||
select = [ | ||
"ALL", | ||
] | ||
|
||
ignore = [ | ||
"ANN101", # Self... explanatory | ||
"ANN102", # Cls... explanatory | ||
"ANN401", # Opinioated warning on disallowing dynamically typed expressions | ||
"D203", # Conflicts with other rules | ||
"D213", # Conflicts with other rules | ||
"EM101", # raw-string-in-exception | ||
|
||
"D105", # Missing docstring in magic method | ||
"D107", # Missing docstring in `__init__` | ||
"E501", # line too long | ||
|
||
"PLR2004", # Magic value used in comparison, consider replacing {value} with a constant variable | ||
|
||
|
||
# Conflicts with the Ruff formatter | ||
"COM812", | ||
"ISC001", | ||
|
||
# Remove later | ||
"TD", # Todos | ||
"A", # bultins | ||
"DTZ", # use tz need to test it first | ||
"TRY", # tryceratops | ||
"FIX002", # Line contains TODO, consider resolving the issue | ||
"BLE001", # Do not catch blind exception: `Exception` | ||
|
||
] | ||
|
||
[tool.ruff.lint.flake8-pytest-style] | ||
fixture-parentheses = false | ||
|
||
|
||
[tool.ruff.lint.isort] | ||
combine-as-imports = true | ||
force-sort-within-sections = true | ||
known-first-party = [ | ||
"osservaprezzi", | ||
] | ||
required-imports = ["from __future__ import annotations"] | ||
|
||
|
||
[tool.ruff.lint.per-file-ignores] | ||
"tests/**" = [ | ||
"D100", # Missing docstring in public module | ||
"D103", # Missing docstring in public function | ||
"D104", # Missing docstring in public package | ||
"N802", # Function name {name} should be lowercase | ||
"N816", # Variable {name} in global scope should not be mixedCase | ||
"PLR0913", # Too many arguments in function definition | ||
"S101", # Use of assert detected | ||
"SLF001", # Private member accessed: {access} | ||
"T201", # print found | ||
] | ||
|
||
|
||
[tool.ruff.lint.mccabe] | ||
max-complexity = 12 | ||
|
||
[tool.ruff.lint.pylint] | ||
max-args = 7 | ||
|
||
|
||
[tool.pylint.MAIN] | ||
py-version = "3.12" | ||
ignore = [ | ||
"tests", | ||
] | ||
fail-on = [ | ||
"I", | ||
] | ||
|
||
[tool.pylint.BASIC] | ||
good-names= ["i","j","k","ex","_","T","x","y","id","tg"] | ||
|
||
[tool.pylint."MESSAGES CONTROL"] | ||
# Reasons disabled: | ||
# format - handled by black | ||
# duplicate-code - unavoidable | ||
# cyclic-import - doesn't test if both import on load | ||
# abstract-class-little-used - prevents from setting right foundation | ||
# too-many-* - are not enforced for the sake of readability | ||
# too-few-* - same as too-many-* | ||
# abstract-method - with intro of async there are always methods missing | ||
# inconsistent-return-statements - doesn't handle raise | ||
# too-many-ancestors - it's too strict. | ||
# wrong-import-order - isort guards this | ||
# --- | ||
# Pylint CodeStyle plugin | ||
# consider-using-namedtuple-or-dataclass - too opinionated | ||
# consider-using-assignment-expr - decision to use := better left to devs | ||
disable = [ | ||
"format", | ||
"cyclic-import", | ||
"duplicate-code", | ||
"too-many-arguments", | ||
"too-many-instance-attributes", | ||
"too-many-locals", | ||
"too-many-ancestors", | ||
"too-few-public-methods", | ||
"invalid-name", | ||
] | ||
enable = [ | ||
"useless-suppression", | ||
"use-symbolic-message-instead", | ||
] | ||
|
||
[tool.pylint.REPORTS] | ||
score = false | ||
|
||
|
||
[tool.pylint.FORMAT] | ||
expected-line-ending-format = "LF" | ||
|
||
[tool.pylint.EXCEPTIONS] | ||
overgeneral-exceptions = [ | ||
"builtins.BaseException", | ||
"builtins.Exception", | ||
] |
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,3 @@ | ||
-r requirements.txt | ||
-r requirements_test.txt | ||
ruff==0.5.0 | ||
ruff==0.5.0 |
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