Update version and removed _str

This commit is contained in:
Samuel Roach 2022-07-06 22:09:52 +01:00
parent 61641df804
commit 7a287b64c4
5 changed files with 42 additions and 62 deletions

View File

@ -58,7 +58,7 @@ Queries can then be built up with function calls in a sequential manner. Once yo
race_results = e.season(2008).round(5).get_results() race_results = e.season(2008).round(5).get_results()
# http://ergast.com/api/f1/drivers/massa # http://ergast.com/api/f1/drivers/massa
felipe_massa = e.driver_str("massa").get_driver() felipe_massa = e.driver("massa").get_driver()
# http://ergast.com/api/f1/current/constructorStandings/3 # http://ergast.com/api/f1/current/constructorStandings/3
constructor_standings = e.season().standing(3).get_constructor_standings() constructor_standings = e.season().standing(3).get_constructor_standings()
@ -112,19 +112,15 @@ More detail on the available functions within the ``Ergast()`` class is availabl
| --------------- | ------------------------ | ------------------------------------------------------------------------------ | | --------------- | ------------------------ | ------------------------------------------------------------------------------ |
| season | year: int | If you call season with no arguments it will default to the current season | | season | year: int | If you call season with no arguments it will default to the current season |
| round | round_no: int | If you call round with no arguments it will default to the last round | | round | round_no: int | If you call round with no arguments it will default to the last round |
| driver | driver: Driver | The Driver equivalent of ``driver_str`` | | driver | driver: Driver | |
| driver_str | driver: str | The String equivalent of ``driver``. Must use driver's driverId | | constructor | constructor: Constructor | |
| constructor | constructor: Constructor | The Constructor equivalent of ``constructor_str`` |
| constructor_str | constructor: str | The String equivalent of ``constructor``. Must use constructor's constructorId |
| qualifying | position: int | Position at the <i>end</i> of qualifying | | qualifying | position: int | Position at the <i>end</i> of qualifying |
| sprint | position: int | | | sprint | position: int | |
| grid | position: int | Position lined up on the grid | | grid | position: int | Position lined up on the grid |
| result | position: int | | | result | position: int | |
| fastest | position: int | Ranking in list of each drivers fastest lap | | fastest | position: int | Ranking in list of each drivers fastest lap |
| circuit | circuit: Circuit | The Circuit equivalent of ``circuit_str`` | | circuit | circuit: Circuit | |
| circuit_str | circuit: str | The String equivalent of ``circuit``. Must use circuit's circuitId | | status | status: int | Must use statusId or string representation |
| status | status: int | The Integer equivalent of ``status_string``. Must use statusId |
| status_str | status: str | The String equivalent of ``status`` |
| standing | position: int | Position of Driver or Constructor in standing | | standing | position: int | Position of Driver or Constructor in standing |
| lap | lap_number: int | | | lap | lap_number: int | |
| pit_stop | stop_number: int | | | pit_stop | stop_number: int | |

View File

@ -8,7 +8,7 @@ Basic usage:
>>> import ergast_py >>> import ergast_py
>>> e = ergast_py.Ergast() >>> e = ergast_py.Ergast()
>>> e.driver_str("alonso").get_driver() >>> e.driver("alonso").get_driver()
Driver( Driver(
driverId=alonso, driverId=alonso,
permanentNumber=14, permanentNumber=14,
@ -44,4 +44,4 @@ from ergast_py.models.standings_list import StandingsList
from ergast_py.models.status import Status from ergast_py.models.status import Status
from ergast_py.models.timing import Timing from ergast_py.models.timing import Timing
__version__ = '0.3.0' __version__ = '0.5.0'

View File

@ -26,7 +26,7 @@ class Ergast():
Build up the queries using the available functions. Build up the queries using the available functions.
>>> e = ergast_py.Ergast() >>> e = ergast_py.Ergast()
>>> e.season(2021).round(1).driver_str("alonso") >>> e.season(2021).round(1).driver("alonso")
Get the data using ``.get_xyz()`` functions. Get the data using ``.get_xyz()`` functions.
@ -88,42 +88,34 @@ class Ergast():
self.params["round"] = round_no self.params["round"] = round_no
return self return self
def driver(self, driver: Driver) -> Ergast: def driver(self, driver) -> Ergast:
""" """
Add a driver to the current query Add a driver to the current query
>>> alonso = e.driver_str("alonso").get_driver() >>> alonso = e.driver("alonso").get_driver()
>>> e.driver(alonso).get_results() >>> e.driver(alonso).get_results()
""" """
self.params["driver"] = driver.driverId if isinstance(driver, str):
return self
def driver_str(self, driver: str) -> Ergast:
"""
Add a driver to the current query
>>> e.driver_str("alonso").get_driver()
"""
self.params["driver"] = driver self.params["driver"] = driver
elif isinstance(driver, Driver):
self.params["driver"] = driver.driverId
else:
raise TypeError("Function parameter must be of type Driver or str")
return self return self
def constructor(self, constructor: Constructor) -> Ergast: def constructor(self, constructor: Constructor) -> Ergast:
""" """
Add a constructor to the current query Add a constructor to the current query
>>> mercedes = e.constructor_str("mercedes").get_constructor() >>> mercedes = e.constructor("mercedes").get_constructor()
>>> e.constructor(mercedes).get_constructor_standings() >>> e.constructor(mercedes).get_constructor_standings()
""" """
self.params["constructor"] = constructor.constructorId if isinstance(constructor, str):
return self
def constructor_str(self, constructor: str) -> Ergast:
"""
Add a constructor to the current query
>>> e.constructor_str("mercedes").get_constructor()
"""
self.params["constructor"] = constructor self.params["constructor"] = constructor
elif isinstance(constructor, Constructor):
self.params["constructor"] = constructor.constructorId
else:
raise TypeError("Function parameter must be of type Constructor or str")
return self return self
def qualifying(self, position: int) -> Ergast: def qualifying(self, position: int) -> Ergast:
@ -171,41 +163,33 @@ class Ergast():
self.params["fastest"] = position self.params["fastest"] = position
return self return self
def circuit(self, circuit: Circuit) -> Ergast: def circuit(self, circuit) -> Ergast:
""" """
Add a circuit to the current query Add a circuit to the current query
>>> silverstone = e.circuit_str("silverstone").get_circuit() >>> silverstone = e.circuit("silverstone").get_circuit()
>>> e.circuit(silverstone) >>> e.circuit(silverstone)
""" """
self.params["circuit"] = circuit.circuitId if isinstance(circuit, str):
return self
def circuit_str(self, circuit: str) -> Ergast:
"""
Add a circuit to the current query
>>> e.circuit_str("silverstone").get_circuit()
"""
self.params["circuit"] = circuit self.params["circuit"] = circuit
elif isinstance(circuit, Circuit):
self.params["circuit"] = circuit.circuitId
else:
raise TypeError("Function parameter must be of type Circuit or str")
return self return self
def status(self, status: int) -> Ergast: def status(self, status) -> Ergast:
""" """
Add a finishing status to the current query Add a finishing status to the current query
>>> e.driver_str("alonso").status(2) >>> e.driver("alonso").status(2)
""" """
if isinstance(status, str):
self.params["status"] = status self.params["status"] = status
return self elif isinstance(status, int):
def status_str(self, status: str) -> Ergast:
"""
Add a finishing status to the current query
>>> e.season(2021).round(1).status_str("Disqualified")
"""
self.params["status"] = StatusType().string_to_id[status] self.params["status"] = StatusType().string_to_id[status]
else:
raise TypeError("Function parameter must be of type int or str")
return self return self
def standing(self, position: int) -> Ergast: def standing(self, position: int) -> Ergast:

View File

@ -1,6 +1,6 @@
[tool.poetry] [tool.poetry]
name = "ergast-py" name = "ergast-py"
version = "0.3.0" version = "0.5.0"
description = "A comprehensive Python wrapper for the Ergast API." description = "A comprehensive Python wrapper for the Ergast API."
authors = ["Samuel Roach <samuelroach.2000@gmail.com>"] authors = ["Samuel Roach <samuelroach.2000@gmail.com>"]
repository = "https://github.com/Samuel-Roach/ergast-py" repository = "https://github.com/Samuel-Roach/ergast-py"
@ -8,7 +8,7 @@ license = "GPL-3.0-only"
readme = "README.md" readme = "README.md"
[tool.poetry.dependencies] [tool.poetry.dependencies]
python = "^3.10" python = "^3.9"
requests = "^2.27.1" requests = "^2.27.1"
uritemplate = "^4.1.1" uritemplate = "^4.1.1"

View File

@ -10,7 +10,7 @@ class TestErgastPy():
def test_version(self): def test_version(self):
""" Assert the version of the system """ """ Assert the version of the system """
assert __version__ == '0.3.0' assert __version__ == '0.5.0'
def test_ergast(self): def test_ergast(self):
""" Basic test to check Ergast functions """ """ Basic test to check Ergast functions """