[ TAG 163 ][01.09.2021] -Erfolgreich -IAP-20210601-20210722-1145 -RPRCSL_LOGGER

Ich beginne die Worksession heute um [01.10.2021][0820]. Es sind zwei Module, die ich heute überarbeiten möchte.

  1. PROCESS_ALOG_20210726_0110.py
  2. RPRCSL_LOGGER_20210929.py
Während meiner heutigen Worksession ist mir aufgefallen, dass das Python-Logger-Modul die Ordnerstruktur nicht automatisch anlegt.

Ich muss Methoden schreiben, die die Ordnerstruktur überprüfen und anlegen. Die nächste Frage, die ich mir stelle, zu welchen Zeitpunkt soll die Überprüfung statt finden?

Soll diese Überprüfung bei jeden ALOG-Prozess-Start statt finden oder soll sie nur einmal beim Programm-Start statt finden?

Ich denke, dass die Überprüfung der Ordnerstrukturen separat in einen Modul beim Programmstart ausgeführt werden muss. Somit kann dann die Ordnerstruktur separat überprüft und gegebenenfalls angelegt werden.

Das [RPRCSL_LOGGER_20210929.py]-Modul besitzt eine Methode, die die Ordnerstruktur überprüft und anlegt. Diese wird in [main.py] ausgeführt.

Hier ist ein Beispiel wie man Ordner anlegt.
  • Quellen:
    • [Beispiel - Ordner anlegen]
      • [https://appdividend.com/2021/07/03/how-to-create-directory-if-not-exist-in-python/]
    • [Python - Library os.path]
      • [https://docs.python.org/3/library/os.path.html]
      • [https://docs.python.org/3/library/os.path.html#os.path.exists]
    • [Python - Library os]
      • [https://docs.python.org/3/library/os.html]
      • [https://docs.python.org/3/library/os.html#os.mkdir]
      • [https://docs.python.org/3/library/os.html#os.makedirs]
    • [Python - Library pathlib]
      • [https://www.youtube.com/watch?v=BR_xn-aL5ok]

import pathlib
def CHECK_STRUCTURE_20211001(log_root="LOGFILES", year="2021", month="10", day="01"):
print("")
print("CHECK_STRUCTURE")
print(f"pathlib.Path.cwd():{pathlib.Path.cwd()}")
print(f"pathlib.Path.home():{pathlib.Path.home()}")
print("")
Ausgabe:
--------------------------------------------------
CHECK_STRUCTURE

pathlib.Path.cwd():E:\2021\Projekte\Python\2021\06_jun\IAP-20210601-20210722-1145

pathlib.Path.home():C:\Users\HP Power Pavilion
--------------------------------------------------

path = pathlib.Path.cwd()
for parent in path.parents:
print(f"parent: {parent}")
Ausgabe:
--------------------------------------------------
CHECK_STRUCTURE
pathlib.Path.cwd():E:\2021\Projekte\Python\2021\06_jun\IAP-20210601-20210722-1145
pathlib.Path.home():C:\Users\HP Power Pavilion
parent: E:\2021\Projekte\Python\2021\06_jun
parent: E:\2021\Projekte\Python\2021
parent: E:\2021\Projekte\Python
parent: E:\2021\Projekte
parent: E:\2021
parent: E:\
--------------------------------------------------

Hochachtungsvoll
Artem Kraft


Kommentare

Beliebte Posts aus diesem Blog

[ TAG 38 ][29.05.2021] - Erfolgreich - Freelancer-Portale

[ TAG 747 ][07.04.2023] -Erfolgreich -BNKTRS -Google Code -Objekt und Methodenliste

[ TAG 52 ][12.06.2021] - Erfolgreich - IAP-20210601-20210609-2325