Add exercises from sw5 theory lesson
This commit is contained in:
parent
4f1450fe6e
commit
ecf4a2ed7a
17
src/exercises/my_logger.py
Normal file
17
src/exercises/my_logger.py
Normal file
@ -0,0 +1,17 @@
|
||||
import logging
|
||||
from pathlib import Path
|
||||
|
||||
Path("data/logs").mkdir(parents=True, exist_ok=True)
|
||||
Path("data/logs/app.log").open("a")
|
||||
logging.basicConfig(
|
||||
level=logging.ERROR,
|
||||
filename="data/logs/app.log",
|
||||
filemode="a",
|
||||
format="%(asctime)s - %(levelname)s - %(name)s - %(message)s",
|
||||
)
|
||||
|
||||
logging.debug("Application started")
|
||||
logging.info("Application started")
|
||||
logging.warning("Application started")
|
||||
logging.error("Application started")
|
||||
logging.critical("Application started")
|
||||
22
src/exercises/pathlib_test.py
Normal file
22
src/exercises/pathlib_test.py
Normal file
@ -0,0 +1,22 @@
|
||||
import json
|
||||
from pathlib import Path
|
||||
|
||||
|
||||
def create_orders():
|
||||
path = Path("data/processed")
|
||||
path.mkdir(parents=True, exist_ok=True)
|
||||
|
||||
orders_path = path / "orders.csv"
|
||||
orders_path.open("w", encoding="utf-8")
|
||||
|
||||
|
||||
def create_settings():
|
||||
settings = {"mode": "debug", "retries": 3}
|
||||
|
||||
with Path("data/processed/settings.json").open("w", encoding="utf-8") as f:
|
||||
json.dump(settings, f, indent=2, ensure_ascii=False)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
# create_orders()
|
||||
(create_settings())
|
||||
Loading…
x
Reference in New Issue
Block a user