oleksiisaiun_lab6_monaco 2.1__py3-none-any.whl → 4.1__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- oleksiisaiun_lab6_monaco/__init__.py +2 -5
- oleksiisaiun_lab6_monaco/race_report.py +47 -9
- {oleksiisaiun_lab6_monaco-2.1.dist-info → oleksiisaiun_lab6_monaco-4.1.dist-info}/METADATA +2 -2
- {oleksiisaiun_lab6_monaco-2.1.dist-info → oleksiisaiun_lab6_monaco-4.1.dist-info}/RECORD +7 -7
- {oleksiisaiun_lab6_monaco-2.1.dist-info → oleksiisaiun_lab6_monaco-4.1.dist-info}/WHEEL +1 -1
- {oleksiisaiun_lab6_monaco-2.1.dist-info → oleksiisaiun_lab6_monaco-4.1.dist-info}/licenses/LICENSE +0 -0
- {oleksiisaiun_lab6_monaco-2.1.dist-info → oleksiisaiun_lab6_monaco-4.1.dist-info}/top_level.txt +0 -0
@@ -1,7 +1,6 @@
|
|
1
1
|
import os
|
2
2
|
from dataclasses import dataclass
|
3
3
|
from datetime import datetime
|
4
|
-
import utilities as util
|
5
4
|
from constants import *
|
6
5
|
|
7
6
|
|
@@ -59,8 +58,50 @@ class RecordData:
|
|
59
58
|
)
|
60
59
|
|
61
60
|
|
61
|
+
def _is_valid_datetime(value: str, datetime_format: str = "%Y-%m-%d_%H:%M:%S.%f") -> bool:
|
62
|
+
try:
|
63
|
+
datetime.strptime(value, datetime_format)
|
64
|
+
return True
|
65
|
+
except ValueError:
|
66
|
+
return False
|
67
|
+
|
68
|
+
|
69
|
+
def _validate_if_file_exists(filepath) -> bool:
|
70
|
+
"""Check if the folder and file exist, raise error if not."""
|
71
|
+
if not os.path.isfile(filepath):
|
72
|
+
raise FileNotFoundError(f"File not found: {filepath}")
|
73
|
+
|
74
|
+
folder = os.path.dirname(filepath)
|
75
|
+
if folder and not os.path.exists(folder):
|
76
|
+
raise FileNotFoundError(f"Folder does not exist: {folder}")
|
77
|
+
return True
|
78
|
+
|
79
|
+
|
80
|
+
def _validate_abbreviation_row(row: str) -> RecordData:
|
81
|
+
match = ABBR_ROW_PATTERN.match(row)
|
82
|
+
if match:
|
83
|
+
driver_entry = RecordData(abbr=match.group('abbr'), driver=match.group('driver'), team=match.group('team'))
|
84
|
+
return driver_entry
|
85
|
+
|
86
|
+
return None
|
87
|
+
|
88
|
+
|
89
|
+
def _validate_start_stop_row(row: str) -> (str, datetime):
|
90
|
+
match = START_STOP_ROW_PATTERN.match(row)
|
91
|
+
if match:
|
92
|
+
abbr = match.group('abbr')
|
93
|
+
time_event_raw = match.group('time_event')
|
94
|
+
if _is_valid_datetime(time_event_raw):
|
95
|
+
time_event = datetime.strptime(time_event_raw, "%Y-%m-%d_%H:%M:%S.%f")
|
96
|
+
event_time_out = (abbr, time_event)
|
97
|
+
return event_time_out
|
98
|
+
|
99
|
+
print(f"discard row: [{row}], because {ERR_MSG__INVALID_FORMAT_OF_TIME_EVENT_ROW}")
|
100
|
+
return None # if start or stop row has invalid then a row is discarded
|
101
|
+
|
102
|
+
|
62
103
|
def _create_driver_record(row) -> RecordData:
|
63
|
-
record_driver_out =
|
104
|
+
record_driver_out = _validate_abbreviation_row(row)
|
64
105
|
if record_driver_out is None:
|
65
106
|
error_val = {row: ERR_PREFIX}
|
66
107
|
record_driver_out = RecordData(error=[error_val])
|
@@ -94,7 +135,7 @@ def _read_file_start_stop(filepath: str) -> dict[str, datetime]:
|
|
94
135
|
if not line:
|
95
136
|
continue # Skip empty lines
|
96
137
|
|
97
|
-
time_event_record =
|
138
|
+
time_event_record = _validate_start_stop_row(line)
|
98
139
|
|
99
140
|
if time_event_record is not None:
|
100
141
|
abbr = time_event_record[0]
|
@@ -115,8 +156,8 @@ def build_report(
|
|
115
156
|
list_records_good = list()
|
116
157
|
list_records_bad = list()
|
117
158
|
|
118
|
-
if (
|
119
|
-
|
159
|
+
if (_validate_if_file_exists(filepath_abbr)) and (_validate_if_file_exists(filepath_start)) and (
|
160
|
+
_validate_if_file_exists(filepath_stop)):
|
120
161
|
[dict_records_good, dict_records_bad] = _read_file_abbreviation(filepath_abbr)
|
121
162
|
|
122
163
|
dict_start = _read_file_start_stop(filepath=filepath_start)
|
@@ -167,16 +208,13 @@ def print_report(records_good: list[RecordData], records_bad: list[RecordData],
|
|
167
208
|
|
168
209
|
|
169
210
|
def main_run():
|
170
|
-
|
171
|
-
#folder = '/Users/oleksiisaiun/Documents/ALESHA/REPO/PYCHARM/GIT_FOXMINDED_LABS/TRAINING_PYTHON/python_lab_6_oop_monaco_report/data'
|
172
211
|
folder = 'data'
|
173
212
|
file_abbr = 'abbreviations.txt'
|
174
213
|
file_start = 'start.log'
|
175
214
|
file_stop = 'end.log'
|
176
215
|
|
177
|
-
|
178
216
|
data_report = build_report(folder=folder, file_abbr=file_abbr, file_start=file_start, file_stop=file_stop)
|
179
|
-
print_report(records_good=data_report[0], records_bad=data_report[1],sort_by_lap_asc=False)
|
217
|
+
print_report(records_good=data_report[0], records_bad=data_report[1], sort_by_lap_asc=False)
|
180
218
|
|
181
219
|
|
182
220
|
if __name__ == '__main__':
|
@@ -1,6 +1,6 @@
|
|
1
1
|
Metadata-Version: 2.4
|
2
2
|
Name: oleksiisaiun_lab6_monaco
|
3
|
-
Version:
|
3
|
+
Version: 4.1
|
4
4
|
Summary: The Python application that implements Monaco Racing Report in OOP format
|
5
5
|
Author-email: Oleksii Saiun <oleksiisaiun@example.com>
|
6
6
|
License: MIT
|
@@ -39,4 +39,4 @@ uv pip install oleksiisaiun_lab6_monaco
|
|
39
39
|
#1. Go to root folder of this package:
|
40
40
|
#2. Run command
|
41
41
|
uv build
|
42
|
-
uv publish --token pypi-
|
42
|
+
uv publish --token pypi-AgEIcHlwaS5vcmcCJDUyMzdmMjgzLTc4MGItNDhkYy1hNDRjLWNkMDZiNjczMWQ1OAACKlszLCIzM2M1MmJiZS01NzhhLTQ5NGYtYjlmOS1hYzQzZTI4NTVkZTQiXQAABiA428Uogwjs1PKhckDGrAhK0Mp8qv0-8_N7OLBIb66x1Q
|
@@ -1,12 +1,12 @@
|
|
1
|
-
oleksiisaiun_lab6_monaco/__init__.py,sha256=
|
1
|
+
oleksiisaiun_lab6_monaco/__init__.py,sha256=6RVWsHhSn20meF0sg-al1_6WHkzuH5bInJRhLhZHQ8Q,56
|
2
2
|
oleksiisaiun_lab6_monaco/constants.py,sha256=AhfKQOCkcLiILoQ5vf9CD-oBoPMSrXIaPiQhegg5tAw,504
|
3
|
-
oleksiisaiun_lab6_monaco/race_report.py,sha256=
|
3
|
+
oleksiisaiun_lab6_monaco/race_report.py,sha256=R9boLa6OaA1pG4JHoFaNvc7jyr_AnUCEPlr39qj-qyg,7500
|
4
4
|
oleksiisaiun_lab6_monaco/utilities.py,sha256=c3BCr1RdAsvCGNUhQW-Rx4eZszDGjFsIs_POL5BXs3M,1628
|
5
5
|
oleksiisaiun_lab6_monaco/data/abbreviations.txt,sha256=3GAAVS7XOzXvfIC90WS8pEuCKtavQwGHV97do8xJ20o,663
|
6
6
|
oleksiisaiun_lab6_monaco/data/end.log,sha256=4wE9PQZfaPeFOfKGf24XUCiNfVe2DJwbOzyDuIt7FNs,513
|
7
7
|
oleksiisaiun_lab6_monaco/data/start.log,sha256=rKe7QZzeUVN8j4KVzs11sFfGtGZUw2Zuz3z-1RA9gv8,514
|
8
|
-
oleksiisaiun_lab6_monaco-
|
9
|
-
oleksiisaiun_lab6_monaco-
|
10
|
-
oleksiisaiun_lab6_monaco-
|
11
|
-
oleksiisaiun_lab6_monaco-
|
12
|
-
oleksiisaiun_lab6_monaco-
|
8
|
+
oleksiisaiun_lab6_monaco-4.1.dist-info/licenses/LICENSE,sha256=SLpkaez9xkCMD5ce3l3sJM59kS962nWIiMb-jdywXlg,1070
|
9
|
+
oleksiisaiun_lab6_monaco-4.1.dist-info/METADATA,sha256=t54vvqatAWuG1pfeWj_0B0XmTtA4mT5wCSC-O3Tqkac,1460
|
10
|
+
oleksiisaiun_lab6_monaco-4.1.dist-info/WHEEL,sha256=lTU6B6eIfYoiQJTZNc-fyaR6BpL6ehTzU3xGYxn2n8k,91
|
11
|
+
oleksiisaiun_lab6_monaco-4.1.dist-info/top_level.txt,sha256=M7B-GnGgDZrj10nblmrJGJMRFcOZ7d2hU_J_mijACfQ,25
|
12
|
+
oleksiisaiun_lab6_monaco-4.1.dist-info/RECORD,,
|
{oleksiisaiun_lab6_monaco-2.1.dist-info → oleksiisaiun_lab6_monaco-4.1.dist-info}/licenses/LICENSE
RENAMED
File without changes
|
{oleksiisaiun_lab6_monaco-2.1.dist-info → oleksiisaiun_lab6_monaco-4.1.dist-info}/top_level.txt
RENAMED
File without changes
|