From 07b9319fc25a20b8f23b4a178604d08a98e76bfe Mon Sep 17 00:00:00 2001 From: Peter Date: Mon, 4 Mar 2024 14:02:15 -0500 Subject: [PATCH] httpx --- poetry.lock | 113 +++++++++++++++++- pyproject.toml | 1 + .../data/input/ignore_constructors.csv | 1 - src/f1_fantasy/game_objects.py | 8 +- src/f1_fantasy/main.py | 12 +- test.http | 4 + 6 files changed, 127 insertions(+), 12 deletions(-) create mode 100644 test.http diff --git a/poetry.lock b/poetry.lock index eda321b..e090ceb 100644 --- a/poetry.lock +++ b/poetry.lock @@ -11,6 +11,39 @@ files = [ {file = "annotated_types-0.6.0.tar.gz", hash = "sha256:563339e807e53ffd9c267e99fc6d9ea23eb8443c08f112651963e24e22f84a5d"}, ] +[[package]] +name = "anyio" +version = "4.3.0" +description = "High level compatibility layer for multiple asynchronous event loop implementations" +optional = false +python-versions = ">=3.8" +files = [ + {file = "anyio-4.3.0-py3-none-any.whl", hash = "sha256:048e05d0f6caeed70d731f3db756d35dcc1f35747c8c403364a8332c630441b8"}, + {file = "anyio-4.3.0.tar.gz", hash = "sha256:f75253795a87df48568485fd18cdd2a3fa5c4f7c5be8e5e36637733fce06fed6"}, +] + +[package.dependencies] +exceptiongroup = {version = ">=1.0.2", markers = "python_version < \"3.11\""} +idna = ">=2.8" +sniffio = ">=1.1" +typing-extensions = {version = ">=4.1", markers = "python_version < \"3.11\""} + +[package.extras] +doc = ["Sphinx (>=7)", "packaging", "sphinx-autodoc-typehints (>=1.2.0)", "sphinx-rtd-theme"] +test = ["anyio[trio]", "coverage[toml] (>=7)", "exceptiongroup (>=1.2.0)", "hypothesis (>=4.0)", "psutil (>=5.9)", "pytest (>=7.0)", "pytest-mock (>=3.6.1)", "trustme", "uvloop (>=0.17)"] +trio = ["trio (>=0.23)"] + +[[package]] +name = "certifi" +version = "2024.2.2" +description = "Python package for providing Mozilla's CA Bundle." +optional = false +python-versions = ">=3.6" +files = [ + {file = "certifi-2024.2.2-py3-none-any.whl", hash = "sha256:dc383c07b76109f368f6106eee2b593b04a011ea4d55f652c6ca24a754d1cdd1"}, + {file = "certifi-2024.2.2.tar.gz", hash = "sha256:0569859f95fc761b18b45ef421b1290a0f65f147e92a1e5eb3e635f9a5e4e66f"}, +] + [[package]] name = "click" version = "8.1.7" @@ -50,6 +83,73 @@ files = [ [package.extras] test = ["pytest (>=6)"] +[[package]] +name = "h11" +version = "0.14.0" +description = "A pure-Python, bring-your-own-I/O implementation of HTTP/1.1" +optional = false +python-versions = ">=3.7" +files = [ + {file = "h11-0.14.0-py3-none-any.whl", hash = "sha256:e3fe4ac4b851c468cc8363d500db52c2ead036020723024a109d37346efaa761"}, + {file = "h11-0.14.0.tar.gz", hash = "sha256:8f19fbbe99e72420ff35c00b27a34cb9937e902a8b810e2c88300c6f0a3b699d"}, +] + +[[package]] +name = "httpcore" +version = "1.0.4" +description = "A minimal low-level HTTP client." +optional = false +python-versions = ">=3.8" +files = [ + {file = "httpcore-1.0.4-py3-none-any.whl", hash = "sha256:ac418c1db41bade2ad53ae2f3834a3a0f5ae76b56cf5aa497d2d033384fc7d73"}, + {file = "httpcore-1.0.4.tar.gz", hash = "sha256:cb2839ccfcba0d2d3c1131d3c3e26dfc327326fbe7a5dc0dbfe9f6c9151bb022"}, +] + +[package.dependencies] +certifi = "*" +h11 = ">=0.13,<0.15" + +[package.extras] +asyncio = ["anyio (>=4.0,<5.0)"] +http2 = ["h2 (>=3,<5)"] +socks = ["socksio (==1.*)"] +trio = ["trio (>=0.22.0,<0.25.0)"] + +[[package]] +name = "httpx" +version = "0.27.0" +description = "The next generation HTTP client." +optional = false +python-versions = ">=3.8" +files = [ + {file = "httpx-0.27.0-py3-none-any.whl", hash = "sha256:71d5465162c13681bff01ad59b2cc68dd838ea1f10e51574bac27103f00c91a5"}, + {file = "httpx-0.27.0.tar.gz", hash = "sha256:a0cb88a46f32dc874e04ee956e4c2764aba2aa228f650b06788ba6bda2962ab5"}, +] + +[package.dependencies] +anyio = "*" +certifi = "*" +httpcore = "==1.*" +idna = "*" +sniffio = "*" + +[package.extras] +brotli = ["brotli", "brotlicffi"] +cli = ["click (==8.*)", "pygments (==2.*)", "rich (>=10,<14)"] +http2 = ["h2 (>=3,<5)"] +socks = ["socksio (==1.*)"] + +[[package]] +name = "idna" +version = "3.6" +description = "Internationalized Domain Names in Applications (IDNA)" +optional = false +python-versions = ">=3.5" +files = [ + {file = "idna-3.6-py3-none-any.whl", hash = "sha256:c05567e9c24a6b9faaa835c4821bad0590fbb9d5779e7caa6e1cc4978e7eb24f"}, + {file = "idna-3.6.tar.gz", hash = "sha256:9ecdbbd083b06798ae1e86adcbfe8ab1479cf864e4ee30fe4e46a003d12491ca"}, +] + [[package]] name = "iniconfig" version = "2.0.0" @@ -357,6 +457,17 @@ files = [ {file = "shellingham-1.5.4.tar.gz", hash = "sha256:8dbca0739d487e5bd35ab3ca4b36e11c4078f3a234bfce294b0a0291363404de"}, ] +[[package]] +name = "sniffio" +version = "1.3.1" +description = "Sniff out which async library your code is running under" +optional = false +python-versions = ">=3.7" +files = [ + {file = "sniffio-1.3.1-py3-none-any.whl", hash = "sha256:2f6da418d1f1e0fddd844478f41680e794e6051915791a034ff65e5f100525a2"}, + {file = "sniffio-1.3.1.tar.gz", hash = "sha256:f4324edc670a0f49750a81b895f35c3adb843cca46f0530f79fc1babb23789dc"}, +] + [[package]] name = "tomli" version = "2.0.1" @@ -406,4 +517,4 @@ files = [ [metadata] lock-version = "2.0" python-versions = "^3.10" -content-hash = "8ea9a1acd3d54635d19c957ca9390be4d6ca07ec3a903d3856cb83998ccf6316" +content-hash = "82d9d5af2ea9f6657561db921502a075dd451b7da4d5163640b12e44d2b1c066" diff --git a/pyproject.toml b/pyproject.toml index 181d19a..809e9c6 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -18,6 +18,7 @@ python = "^3.10" pydantic = "^2.6.3" pydantic-settings = "^2.2.1" typer = {extras = ["all"], version = "^0.9.0"} +httpx = "^0.27.0" [tool.poetry.group.dev.dependencies] diff --git a/src/f1_fantasy/data/input/ignore_constructors.csv b/src/f1_fantasy/data/input/ignore_constructors.csv index 5e84174..f121bdb 100644 --- a/src/f1_fantasy/data/input/ignore_constructors.csv +++ b/src/f1_fantasy/data/input/ignore_constructors.csv @@ -1,2 +1 @@ name - diff --git a/src/f1_fantasy/game_objects.py b/src/f1_fantasy/game_objects.py index 5a2b91a..60413ab 100644 --- a/src/f1_fantasy/game_objects.py +++ b/src/f1_fantasy/game_objects.py @@ -427,10 +427,6 @@ def load_prices(cls, constructor_prices: list[ConstructorPriceModel]): cls.get(constructor_price.name).price = float(constructor_price.price) -DRIVERS_IGNORE_LIST = [ - # Drivers.MAX, -] +DRIVERS_IGNORE_LIST = [] -CONSTRUCTORS_IGNORE_LIST = [ - # Constructors.RED_BULL, -] +CONSTRUCTORS_IGNORE_LIST = [] diff --git a/src/f1_fantasy/main.py b/src/f1_fantasy/main.py index 862ee07..19c9f8e 100644 --- a/src/f1_fantasy/main.py +++ b/src/f1_fantasy/main.py @@ -209,11 +209,15 @@ def set_ignores_from_csvs(ignore_constructors: Path, ignore_drivers: Path): def write_csv_to_output(f: TextIO, csv_path: Path): - with csv_path.open() as cp_csv: - reader = csv.DictReader(cp_csv) + with csv_path.open() as read_csv: + reader = csv.DictReader(read_csv) + dict_writer = csv.DictWriter(f, reader.fieldnames) + + f.write("\n" + "#" * 120) f.write(f"\n{csv_path.name}:\n") + dict_writer.writeheader() for row in reader: - f.write(str(row) + "\n") + dict_writer.writerow(row) def main( @@ -248,7 +252,7 @@ def main( f.write(f"Total teams: {len(_max_score_teams)}\n") for team in _max_score_teams: print(team) - f.write(f"{team}\n") + f.write(f"{team}\n\n") f.write("\n" + "#" * 120) f.write("\n" + "#" * 120) diff --git a/test.http b/test.http new file mode 100644 index 0000000..665bbc5 --- /dev/null +++ b/test.http @@ -0,0 +1,4 @@ +### +GET https://fantasy.formula1.com/feeds/drivers/2_en.json + +