Repository navigation
v0.2.0
The API now has three levels: ask whether a place has a risk, read the
bulletins day by day, or get the raw DPC files.
async with DpcClient() as dpc:
home = dpc.location(41.9, 12.5)
if await home.has_risk(Day.TOMORROW):
print(await home.risk(Day.TOMORROW)) # yellow (hydrogeological)Added
DpcClient.location()returns aMonitoredLocationthat answers
has_risk()andrisk()for today, tomorrow (Day.TOMORROW) or a date.
It keeps the bulletin and downloads it again only when DPC publishes a new
one, so it can be polled freely.Risk: the alert level, the risk types at that level, the DPC description,
the end of validity and the complete day.Location: coordinates and optional municipality, validated once.Precipitation: the expected precipitation of the vigilance bulletin, from
nonetovery_heavy.- Optional strict DTOs of the raw DPC files (
pip install "aiodpc[schema]"):
get_criticality_file(),get_vigilance_file(),get_phenomena_file()and
theaiodpc.schemadecoders. They raiseDpcParseErrornaming the field
when DPC changes its format. DpcNoDataError: no published bulletin covers the requested day.- Bulletins are iterable and have
today,tomorrowandon(date). - Criticality days have each risk as an attribute (
day.hydrogeological),
is_alertandassessment(risk_type). - Levels print as their name (
str(AlertLevel.ORANGE) == "orange") and
phenomena as a readable sentence (wind: forti, 30.4 km WSW).
Changed
These changes break code written for 0.1.0:
| 0.1.0 | 0.2.0 |
|---|---|
get_criticality(lat, lon, municipality=...) |
get_criticality(Location(lat, lon, municipality=...)) |
get_vigilance(lat, lon, phenomena_radius_km=...) |
get_vigilance(location, phenomena_within_km=...) |
is_location_covered(lat, lon) |
is_location_covered(location) |
Risk (enum, Italian values) |
RiskType (English values: hydraulic, ...) |
AlertLevel.NONE |
AlertLevel.GREEN |
day.zone_name |
day.zone |
day.expires |
day.valid_until |
day.summary, day.max_level |
day.description, day.level |
day.risks[Risk.HYDRAULIC] |
day.hydraulic (day.risks is now a tuple) |
Assessment(info, alert, level) |
RiskAssessment(type, level, description) |
VigilanceDay.level (int) and .precipitation (text) |
VigilanceDay.precipitation (Precipitation) |
PhenomenonCategory Italian values (PRECIPITAZIONI) |
English values (precipitation) |
bulletin.today(now), tomorrow(now), day_for(date) |
bulletin.today, tomorrow (properties), on(date) |
aiodpc.parsers.day_expires |
aiodpc.parsers.end_of_day |
The functions of aiodpc.parsers take a Location, and parse_assessment
returns the level and the description.