Metadata-Version: 2.1
Name: task_6_syrkin
Version: 0.0.4
Summary: Monaco 2018 Formula 1 Qualification Report
Author-email: Andrii Syrkin <avvaan1981@gmail.com>
Requires-Python: >=3.7
Description-Content-Type: text/markdown
Classifier: License :: OSI Approved :: MIT License
Requires-Dist: pytest>=8.3.2
Requires-Dist: coverage>=7.6.1
Requires-Dist: parameterized>=0.9.0
Requires-Dist: setuptools>=75.1.0
Project-URL: Home, https://git.foxminded.ua/andrii-syrkin-py_ment/task_6.git

# Monaco 2018 Formula 1 Qualification Report

## Description
This project provides a report on the Formula 1 qualification for the Monaco 2018 stage. The program allows analyzing the best lap times of drivers, sorting the results, and filtering data by a specific driver.

## Requirements
The project requires Python version 3.12 or higher, and the following dependencies:
- `pytest>=8.3.2`
- `coverage>=7.6.1`
- `parameterized>=0.9.0`

## Installation
To install the project, use the following command:
```bash
pip install task_6_syrkin
```

## Usage
Once the package is installed, you can run the qualifying report generator from the command line:
```bash
monaco-report --files ./data --desc
```

Command-line options:
- `--files <path>`: Path to the folder containing the log files (start.log, end.log, and abbreviations.txt).
- `--asc`: Sort lap times in ascending order (default).
- `--desc`: Sort lap times in descending order.
- `--driver <name>`: Filter the results to show the lap time and team information for a specific driver by name.

### Example
```bash
monaco-report --files ./data --asc --driver "Lewis Hamilton"
```
This command will parse the log files in the `./data` folder, sort drivers by lap time in ascending order, and display the results for "Lewis Hamilton".

## Log File Format
The log files are expected to follow these formats:

- **start.log**: Contains driver abbreviations and their start times.
    ```text
    HAM2019-09-29_13:01:00.123
    VER2019-09-29_13:02:00.456
    ```

- **end.log**: Contains driver abbreviations and their end times.
    ```text
    HAM2019-09-29_13:03:30.789
    VER2019-09-29_13:03:32.123
    ```

- **abbreviations.txt**: Contains driver abbreviations, full names, and teams, separated by underscores.
    ```text
    HAM_Lewis Hamilton_Mercedes
    VER_Max Verstappen_Red Bull Racing
    ```

## Code Structure
The main modules of the project include:
- `file_parser.py`: Responsible for reading and parsing the log files.
- `report_builder.py`: Contains the logic for calculating lap times, sorting drivers, and building reports.
- `record.py`: Defines the Record class, which stores driver data and calculates lap times.
- `report.py`: The main entry point for the command-line interface (CLI) that ties together the various components and generates the report.

## Testing
Unit tests have been implemented to ensure the correctness of the main functions. You can run the tests using the unittest framework. The tests are located in the `tests/` directory.

To run the tests, execute the following command:
```bash
python -m unittest discover -s tests
```

### Test Coverage:
- `file_parser.py`: Tests for parsing log files, handling missing data, and incorrect formats.
- `report_builder.py`: Tests for calculating lap times, sorting drivers, and generating the report.
- `record.py`: Tests for the Record class and the lap time calculation.

## Example Output
Here is an example of the output generated by the program:
\```
Top-15 drivers:
1. Lewis Hamilton        | Mercedes                     | 01:30.456 sec
2. Max Verstappen        | Red Bull Racing              | 01:31.234 sec
----------------------------------------------------------------------
Eliminated drivers:
16. Charles Leclerc      | Ferrari                      | 01:32.567 sec
    \```

## Error Handling
The program is designed to handle missing or incorrect data in the following ways:
- If a driver’s start or end time is missing, that driver will be excluded from the final report.
- Errors are logged and can be displayed to the user for debugging or correction.

## Known Issues and Limitations
- The log files must be in the correct format. Any deviations from the expected format will cause the program to skip entries or fail to parse them.
- The program assumes that the log files are complete and accurate for the calculation of lap times.

## License
This project is licensed under the MIT License. See the LICENSE file for details.
