Coverage for statistic/driver.py: 87%
15 statements
« prev ^ index » next coverage.py v7.8.0, created at 2025-04-21 18:48 +0000
« prev ^ index » next coverage.py v7.8.0, created at 2025-04-21 18:48 +0000
1""" This module contains the Driver class.
2It is used to create a driver object with the following attributes:
3- date_order: the date of the order
4- time_in_list: the time in the loading schedule
5- person: the person who created the order
6- count_driver: the number of drivers created
7"""
9from pprint import pprint
10# from data_drive.data_sql import get_newest_list_beton_or_lista
13class Driver:
15 count_driver = 0
17 def __init__(self, work_day, time_in_list, person):
18 """Card of depart driver
20 Args:
21 work_day (str): date string format "dd.mm.yyyy"
22 time_in_list (datetime.time): time from lista
23 person (str): name of driver and car's number
24 """
25 self.date_order: str = work_day
26 self.time_in_list = time_in_list
27 self.person = person
29 Driver.count_driver += 1
31 def convert_to_dict_for_df(self):
33 return {"date_order": self.date_order,
34 "time_in_list": self.time_in_list,
35 "person": self.person
36 }
38 @classmethod
39 def how_many(cls):
40 '''Prints the current population.'''
41 print('We have {:d} drivers.'.format(cls.count_driver))
44if __name__ == "__main__":
45 pass
47 # drivers = {}
48 # count = 1
49 # work_day = "03.03.2025"
51 # for item in get_newest_list_beton_or_lista("lista", work_day, 'zawod'):
52 # drivers[f"{count}bud"] = Driver(work_day, *item)
53 # count += 1
55 # pprint(drivers)
57 # df_driver = []
58 # for key_driver in drivers.keys():
59 # driver = drivers[key_driver]
60 # pprint(
61 # (
62 # driver.time_in_list,
63 # driver.person,
64 # )
65 # )
66 # df_driver.append({
67 # "time_start": driver.time_in_list,
68 # "person": driver.person,
69 # })