Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
  • Loading branch information
why-not-try-calmer committed Jan 31, 2024
1 parent 306e9bd commit ad336aa
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 17 deletions.
9 changes: 4 additions & 5 deletions comptages/core/importer.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from typing import Callable, Dict, Iterator, List, Optional
from typing import Callable, Iterator, Optional
import pytz
import os
from datetime import datetime, timedelta
Expand Down Expand Up @@ -61,7 +61,6 @@ def _parse_and_write(
with open(file_path, encoding=get_file_encoding(file_path)) as f:
for i, line in enumerate(f):
rows = line_parser(line, **kwargs)
print("i=", i)
if not rows:
continue

Expand Down Expand Up @@ -107,7 +106,7 @@ def _parse_and_write(
bulk_mgr.done()


def _parse_line_vbv1(line: str, **kwargs) -> Optional[List[Dict]]:
def _parse_line_vbv1(line: str, **kwargs) -> Optional[list[dict]]:
if line.startswith("* "):
return None

Expand Down Expand Up @@ -156,7 +155,7 @@ def _parse_line_vbv1(line: str, **kwargs) -> Optional[List[Dict]]:
return [parsed_line]


def _parse_line_mc(line: str, **kwargs) -> Optional[List[Dict]]:
def _parse_line_mc(line: str, **kwargs) -> Optional[list[dict]]:
if not line.startswith("20"):
return None

Expand Down Expand Up @@ -193,7 +192,7 @@ def _parse_line_mc(line: str, **kwargs) -> Optional[List[Dict]]:
return [parsed_line]


def _parse_line_int2(line, **kwargs) -> Iterator[Optional[Dict]]:
def _parse_line_int2(line, **kwargs) -> Iterator[Optional[dict]]:
if line.startswith("* "):
return None

Expand Down
1 change: 1 addition & 0 deletions comptages/core/report.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
from datetime import timedelta, datetime
from typing import Optional
from openpyxl import load_workbook, Workbook
from qgis.core import QgsMessageLog

from comptages.core import statistics
from comptages.datamodel import models
Expand Down
1 change: 1 addition & 0 deletions comptages/core/statistics.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
from typing import Any
import pandas as pd
from functools import reduce
from datetime import timedelta, datetime

from django.db.models import F, CharField, Value, Q, Sum, QuerySet
Expand Down
18 changes: 6 additions & 12 deletions comptages/test/test_report.py
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ def test_busiest_by_season(self):
id_installation=installation,
)

path_to_file = Path("/OpenComptage/comptages/test/test_data").joinpath(
path_to_file = Path("/test_data").joinpath(
"64540060_Latenium_PS2021_ChMixte.txt"
)
importer.import_file(str(path_to_file), count)
Expand All @@ -121,9 +121,7 @@ def inspect_leaves(d, res) -> list[int]:

# Prepare workbook
path_to_inputs = Path("comptages/report").joinpath("template_yearly_bike.xlsx")
path_to_outputs = Path("/OpenComptage/test_outputs").joinpath(
"yearly_bike.xlsx"
)
path_to_outputs = Path("/test_outputs").joinpath("yearly_bike.xlsx")
wb = load_workbook(path_to_inputs)

# Write data & save
Expand Down Expand Up @@ -161,7 +159,7 @@ def test_busiest_by_day_month(self):
id_installation=installation,
)

path_to_file = Path("/OpenComptage/comptages/test/test_data").joinpath(
path_to_file = Path("/test_data").joinpath(
"64540060_Latenium_PS2021_ChMixte.txt"
)
importer.import_file(str(path_to_file), count)
Expand All @@ -172,9 +170,7 @@ def test_busiest_by_day_month(self):

# Prepare workbook
path_to_inputs = Path("comptages/report").joinpath("template_yearly_bike.xlsx")
path_to_outputs = Path("/OpenComptage/test_outputs").joinpath(
"yearly_bike.xlsx"
)
path_to_outputs = Path("/test_outputs").joinpath("yearly_bike.xlsx")
wb = load_workbook(path_to_inputs)

# Write data & save
Expand Down Expand Up @@ -209,7 +205,7 @@ def test_busiest_by_various_criteria(self):
id_installation=installation,
)

path_to_file = Path("/OpenComptage/comptages/test/test_data").joinpath(
path_to_file = Path("/test_data").joinpath(
"64540060_Latenium_PS2021_ChMixte.txt"
)
importer.import_file(str(path_to_file), count)
Expand All @@ -220,9 +216,7 @@ def test_busiest_by_various_criteria(self):

# Prepare workbook
path_to_inputs = Path("comptages/report").joinpath("template_yearly_bike.xlsx")
path_to_outputs = Path("/OpenComptage/test_outputs").joinpath(
"yearly_bike.xlsx"
)
path_to_outputs = Path("/test_outputs").joinpath("yearly_bike.xlsx")
wb = load_workbook(path_to_inputs)

# Write data & save
Expand Down

0 comments on commit ad336aa

Please sign in to comment.