-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathutility.py
More file actions
26 lines (19 loc) · 706 Bytes
/
utility.py
File metadata and controls
26 lines (19 loc) · 706 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
import configparser
from configparser import SectionProxy
import time
# Returns config.ini file as list
def get_config_object(config_object_name: str) -> SectionProxy:
config = configparser.ConfigParser()
config.read("config.ini")
config_object = config[config_object_name]
return config_object
def add_to_txt_file(file_name: str, text: str) -> None:
file = open(file_name, 'a')
file.write(text)
file.close()
def get_txt_file_as_list(file_name: str) -> list[str]:
txt_file_as_list = open(file_name).read().splitlines()
return txt_file_as_list
def get_time_now() -> str:
local_time = time.localtime()
return time.strftime("%d.%m.%Y, %H:%M:%S", local_time)