Skip to content

Commit

Permalink
feat: add maps feature + ruff format
Browse files Browse the repository at this point in the history
  • Loading branch information
Guillaume Latour committed Jun 27, 2024
1 parent d0447aa commit de916f7
Show file tree
Hide file tree
Showing 11 changed files with 189 additions and 116 deletions.
8 changes: 4 additions & 4 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,22 +13,22 @@ dependencies = [
'pandas',
'pyarrow',
'tabulate',
'geojson'
'geojson',
]
description = "API client allowing to interact with the tomtom REST services."
maintainers = [
{ name = "Guillaume Latour", email = "guillaume.latour@macq.eu" }
{ name = "Guillaume Latour", email = "guillaume.latour@macq.eu" },
]
name = "tomtom_api"
readme = "readme.md"
requires-python = ">=3.8"
version = "2023.5.24"
version = "2024.6.27"

[project.urls]
repository = "https://stash.macq.eu/projects/RDDS/repos/tomtom-api"

[project.optional-dependencies]
dev = ['autopep8', 'pytest', 'pdoc']
dev = ['ruff', 'pytest']
pyproj = ['pyproj']

[project.scripts]
Expand Down
2 changes: 1 addition & 1 deletion src/tomtom_api/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ def client():
@click.option('-t', '--job-type', type=click.Choice(['routeanalysis', 'areaanalysis', 'trafficdensity']), multiple=True,
help="The type of jobs.")
@click.option('-s', '--state', type=click.Choice([n.name for n in TomtomJobState]), multiple=True,
help=f"The current state of jobs.")
help="The current state of jobs.")
def list_all_job_info(
base_url: Optional[str] = None,
version: Optional[int] = None,
Expand Down
274 changes: 176 additions & 98 deletions src/tomtom_api/client.py

Large diffs are not rendered by default.

2 changes: 0 additions & 2 deletions src/tomtom_api/priority_queue/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@

import click

from tomtom_api import config
from tomtom_api.priority_queue.lib import (pretty_print_queue,
priority_queue_add_job,
priority_queue_clean_folder,
Expand All @@ -12,7 +11,6 @@
priority_queue_update_job)
from tomtom_api.priority_queue.models.daemon import PriorityQueueDaemon
from tomtom_api.priority_queue.models.database import PriorityQueueDB
from tomtom_api.priority_queue.models.queue import QueueItem
from tomtom_api.priority_queue.models.status import QueueItemStatus
from tomtom_api.traffic_stats.models.jobs.route import TomtomRouteJob

Expand Down
3 changes: 1 addition & 2 deletions src/tomtom_api/priority_queue/models/daemon.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,7 @@
from tomtom_api.priority_queue.models.queue import QueueItem
from tomtom_api.priority_queue.models.status import QueueItemStatus
from tomtom_api.traffic_stats import N_CONCURRENT_JOB_IN_PROGRESS
from tomtom_api.traffic_stats.models.status import (TomtomJobState,
TomtomReportType)
from tomtom_api.traffic_stats.models.status import (TomtomJobState)
from tomtom_api.utils.daemon import Daemon

DAEMON_LOG_FILE = config.path.home / 'daemon.log'
Expand Down
2 changes: 1 addition & 1 deletion src/tomtom_api/priority_queue/models/database.py
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ def get_filtered_items(
uid, name, priority, status = uid or [], name or [], priority or [], status or []

# uid filter
uid_filter_str = '' if len(uid) < 1 else f'(uid in @uid)'
uid_filter_str = '' if len(uid) < 1 else '(uid in @uid)'

# name filter
name_filters = [f'name.str.contains("{n}")' for n in name]
Expand Down
4 changes: 2 additions & 2 deletions src/tomtom_api/traffic_stats/models/geospatial.py
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ def __init__(
raise TooManyViaPointsException(f'The TomtomRoad {self.name} has too many via points.')

if self.length() > MAX_ROAD_LENGTH:
raise RoadTooLongException(f'The road length is greater than the maximum allowed.')
raise RoadTooLongException('The road length is greater than the maximum allowed.')

@classmethod
def from_dict(cls, dict_object: Dict[str, Any], ignore_consecutive_points: bool = False) -> TomtomRoad:
Expand Down Expand Up @@ -316,7 +316,7 @@ def __init__(
self.geometry = geometry

if self.area() > MAX_ROAD_LENGTH:
raise RoadTooLongException(f'The road length is greater than the maximum allowed.')
raise RoadTooLongException('The road length is greater than the maximum allowed.')

@classmethod
def from_dict(cls, dict_object: Dict[str, Any]) -> TomtomNetwork:
Expand Down
2 changes: 1 addition & 1 deletion src/tomtom_api/traffic_stats/models/jobs/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import json
from typing import Any, Dict, List, Literal, Optional

from tomtom_api.traffic_stats import MAX_DATE_RANGE_COUNT, MAX_TIME_SETS_COUNT
from tomtom_api.traffic_stats import MAX_TIME_SETS_COUNT
from tomtom_api.traffic_stats.models.time import TomtomDateRange, TomtomTimeSet


Expand Down
4 changes: 1 addition & 3 deletions src/tomtom_api/traffic_stats/models/jobs/route.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
from __future__ import annotations

import json
from typing import Any, Dict, List, Literal, Optional

from tomtom_api.traffic_stats import (MAX_DATE_RANGE_COUNT, MAX_ROAD_COUNT,
MAX_TIME_SETS_COUNT)
from tomtom_api.traffic_stats import (MAX_DATE_RANGE_COUNT, MAX_ROAD_COUNT)
from tomtom_api.traffic_stats.models.geospatial import TomtomRoad
from tomtom_api.traffic_stats.models.jobs.base import TomtomJob
from tomtom_api.traffic_stats.models.time import TomtomDateRange, TomtomTimeSet
Expand Down
2 changes: 1 addition & 1 deletion src/tomtom_api/traffic_stats/models/time.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ def __init__(
if e < s:
raise ValueError(f'The start date ({self.start}) is after the end date ({self.end})')
if (e - s).days > MAX_DATE_RANGE_LENGTH:
raise ValueError(f'The given date range is greater than the maximum allowed.')
raise ValueError('The given date range is greater than the maximum allowed.')

self.exclusions = None if exclusions is None else [date_as_str(d, date_fmt) for d in exclusions]
self.excluded_days_of_week = None if excluded_days_of_week is None else dow(excluded_days_of_week)
Expand Down
2 changes: 1 addition & 1 deletion src/tomtom_api/utils/time.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ def dow(days: List[str]) -> List[str]:
all_dow = {d.upper() for d in calendar.day_abbr}
days = [d.upper() for d in days]
if not all([d in all_dow for d in days]):
raise ValueError(f'At least one of the input in `days` is not a 3 first letters day word.')
raise ValueError('At least one of the input in `days` is not a 3 first letters day word.')
return days


Expand Down

0 comments on commit de916f7

Please sign in to comment.