From a163e7687fed3d994b4a6d755f419e7b9b2126ba Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lo=C3=AFc=20GUEZO?= Date: Sun, 1 Mar 2026 20:37:16 +0100 Subject: [PATCH] ajout: modification dependances et ajout documentation --- .github/workflows/python-app.yml | 52 ++++++++++++++++++-------------- docs/index.md | 5 +++ mkdocs.yml | 14 +++++++++ pyproject.toml | 13 +++----- src/scraper.py | 4 +-- tests/test_scraper.py | 2 +- 6 files changed, 56 insertions(+), 34 deletions(-) create mode 100644 docs/index.md create mode 100644 mkdocs.yml diff --git a/.github/workflows/python-app.yml b/.github/workflows/python-app.yml index 1168bd9..89ac80e 100644 --- a/.github/workflows/python-app.yml +++ b/.github/workflows/python-app.yml @@ -5,35 +5,41 @@ name: Python application on: push: - branches: [ "main" ] + branches: ["main"] pull_request: - branches: [ "main" ] + branches: ["main"] permissions: - contents: read + contents: write jobs: build: - runs-on: ubuntu-latest steps: - - uses: actions/checkout@v4 - - name: Set up Python 3.10 - uses: actions/setup-python@v3 - with: - python-version: "3.10" - - name: Install dependencies - run: | - python -m pip install --upgrade pip - pip install flake8 pytest - if [ -f requirements.txt ]; then pip install -r requirements.txt; fi - - name: Lint with flake8 - run: | - # stop the build if there are Python syntax errors or undefined names - flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics - # exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide - flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics - - name: Test with pytest - run: | - pytest + - uses: actions/checkout@v4 + + - name: Set up Python 3.10 + uses: actions/setup-python@v4 + with: + python-version: "3.10" + + - name: install dependencies + run: | + python -m pip install --upgrade pip + pip install ".[test,doc]" + + - name: Lint with flake8 + run: | + flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics + flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics + + - name: Test with pytest + run: pytest + + - name: Deploy Doc + if: github.event_name == 'push' && github.ref == 'refs/heads/main' + run: | + git config user.name github-actions + git config user.email github-actions@github.com + mkdocs gh-deploy --force diff --git a/docs/index.md b/docs/index.md new file mode 100644 index 0000000..549fea5 --- /dev/null +++ b/docs/index.md @@ -0,0 +1,5 @@ +# Bienvenue sur la doc de Millesima + +Voici la documentation technique de mon scraper. + +::: scraper.Scraper \ No newline at end of file diff --git a/mkdocs.yml b/mkdocs.yml new file mode 100644 index 0000000..4d999dc --- /dev/null +++ b/mkdocs.yml @@ -0,0 +1,14 @@ +site_name: "Projet Millesima S6" + +theme: + name: "material" + +plugins: + - search + - mkdocstrings + +markdown_extensions: + - admonition + - pymdownx.details + - pymdownx.superfences + - pymdownx.tabbed diff --git a/pyproject.toml b/pyproject.toml index 19a13ef..3d9454d 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,15 +1,12 @@ [project] name = "projet-millesima-s6" version = "0.1.0" -dependencies = [ - "requests==2.32.5", - "beautifulsoup4==4.14.3", - "pandas==2.3.3", -] +dependencies = ["requests==2.32.5", "beautifulsoup4==4.14.3", "pandas==2.3.3"] [project.optional-dependencies] -test = ["pytest==8.4.2", "requests-mock==1.12.1"] +test = ["pytest==8.4.2", "requests-mock==1.12.1", "flake8==7.3.0"] +doc = ["mkdocs<2.0.0", "mkdocs-material==9.6.23", "mkdocstrings[python]"] [build-system] -requires = ["setuptools"] -build-backend = "setuptools.build_meta" \ No newline at end of file +requires = ["setuptools", "wheel"] +build-backend = "setuptools.build_meta" diff --git a/src/scraper.py b/src/scraper.py index 94873d0..4f7527f 100755 --- a/src/scraper.py +++ b/src/scraper.py @@ -331,7 +331,7 @@ class Scraper: except (JSONDecodeError, HTTPError): return None - def getvins(self, subdir: str, filename: str) -> None: + def getvins(self, subdir: str, filename: str, reset: bool) -> None: """_summary_ Args: @@ -375,7 +375,7 @@ def main() -> None: if len(argv) != 2: raise ValueError(f"{argv[0]} ") scraper: Scraper = Scraper() - scraper.getvins(argv[1], "donnee.csv") + scraper.getvins(argv[1], "donnee.csv", False) if __name__ == "__main__": diff --git a/tests/test_scraper.py b/tests/test_scraper.py index a75e0c7..5bd6b43 100644 --- a/tests/test_scraper.py +++ b/tests/test_scraper.py @@ -319,7 +319,7 @@ def test_informations(scraper: Scraper): def test_search(scraper: Scraper): m = mock_open() with patch("builtins.open", m): - scraper.getvins("wine.html", "fake_file.csv") + scraper.getvins("wine.html", "fake_file.csv", False) assert m().write.called all_writes = "".join(call.args[0] for call in m().write.call_args_list)