Skip to main content

A simple collector of the french AMAP network in a structured way.

Project description

AMAP collector

This is a simple information collector of the french AMAP Île-de-France network. It scrapes the AMAP Île-de-France website and returns a structured list of objects.

Usage

The client can be imported as a package or launched in the command line via the cli. See the embedded docstrings for full documentation on parameters or read this README further.

Package usage

The typical use case is importing the AmapClient in your code and the AmapClientError class eventually.

An AmapClient object exposes a fluent interface to easily set the target parameters. Here below an example of integration to fetch results around the 75th department (Paris area) over 10 km radius:

from amap_collector.core import AmapClient

c = AmapClient().with_department(75).with_km_radius(10)
results = c.get_amap_list()

where results is a list of dicts like:

{
  "name": "AMAP Coquéron",
  "status": "available_places",
  "website": "",
  "contact": {
  "name": "Agnès",
  "emails": [
      "email1@gmail.com",
      "email2@sauvegarde-paris.fr"
  ],
  "phones": [
      "01 XX XX XX XX",
      "07 XX XX XX XX"
  ]
  },
      "place": {
      "name": "Sauvegarde Paris",
      "address": "3 rue Coq Héron, 75001 PARIS",
      "delivery_time": "Mardi 17H-19H"
  },
  "comment": "Venez nombreux"
}

Cli usage

The cli is built with Typer, you can explore command parameters via the --help modifier:

--department The department zip code (available options: 75, 77, 78, 91, 92, 93, 94, 95) [default: 75]

--zip-code The french zip code to search around (when specified, it fully overrides the --department parameter)

--km-radius The Search radius in km (available options: 2, 5, 10, 15, 20) [default: 2]

--output-file The otput file path (.json or .csv)

--help It summarizes all these parameters and exit

Note 1: Results are shown by default in the standard output, unless a file path is specified via the --output-file modifier (JSON and CSV formats are only supported).

Note 2: The executable command name exposed after package installation is amap_collector.

Docker containerization

Build image

docker build -t amap-collector .

Run the command

Pass any amap_collector option directly after the image name:

# stdout — all AMAPs in dept 93 within 5 km
docker run --rm amap-collector --department 93 --km-radius 5

# save to a JSON file on the host
docker run --rm -v /tmp:/out amap-collector --department 75 --output-file /out/amaps.json

# narrow search by zip code
docker run --rm amap-collector --zip-code 75012

Run tests

Tests require the dev dependencies. Run them with:

uv run pytest

To run a specific test file:

uv run pytest tests/core/test_parser.py -v

Run the linter

Using ruff for linting:

docker run --rm amap-collector uv run --with ruff ruff check .

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

amap_collector-0.1.1.tar.gz (25.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

amap_collector-0.1.1-py3-none-any.whl (10.7 kB view details)

Uploaded Python 3

File details

Details for the file amap_collector-0.1.1.tar.gz.

File metadata

  • Download URL: amap_collector-0.1.1.tar.gz
  • Upload date:
  • Size: 25.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.9.30 {"installer":{"name":"uv","version":"0.9.30","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Fedora Linux","version":"43","id":"","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for amap_collector-0.1.1.tar.gz
Algorithm Hash digest
SHA256 2e7aead7ce65cb0325f495ee8051d793b072a16cc2509aecacf91dcc28135efb
MD5 220b9aebb4f64f8d58c7687f02d9e53d
BLAKE2b-256 8fb53a5e79db3f0cc89b9022ae3a9c7612a0afeadef69784d05373a838fdf3ef

See more details on using hashes here.

File details

Details for the file amap_collector-0.1.1-py3-none-any.whl.

File metadata

  • Download URL: amap_collector-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 10.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.9.30 {"installer":{"name":"uv","version":"0.9.30","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Fedora Linux","version":"43","id":"","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for amap_collector-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 e4aa0a5e88935c55474fdd597a134b4f8bbd34e2c289b8126a3b8160b5257f14
MD5 cb467b504980d9ac074f607001d0d3d4
BLAKE2b-256 bac338a683d7a3275bb4742494504cad503ec87f3c20bb3a929131db242cfcba

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page