[ TAG 180 ][18.10.2021] -Erfolgreich -Protokoll -[ PRTKL_202110140000 ]
Ich beginne die WORKSESSION um [18.10.2021][0400].
Für meine heutige Worksession sind heute zwei Quellen wichtig.
Für meine heutige Worksession sind heute zwei Quellen wichtig.
- Quellen:
[18.10.2021][0820]
Ich habe die IDENTIFIER-Methoden [STR_IDNT], [LOCSTR_IDNT] umgesetzt. Dazu habe ich mit den oberen Quellen gearbeitet.
Für die [DATE-STRUCTURE-IDENTIFIER] benötige ich zusätzlich Datum-Module. In Python gibt es mehre Möglichkeiten Daten über das aktuelle Datum zu bekommen.
Das erste Modul, was ich mir anschaue ist das Modul [datetime]
import pathlib
import ctypes
import datetime
pth = None
state = {"STR_IDNT": None,
"LOCSTR_IDNT": None,
"PRJ_IDNT": None,
"DATE_YEAR_IDNT": None,
"DATE_MONTH_IDNT": None,
"DATE_DAY_IDNT": None
}
def YEAR():
datenow = datetime.datetime.now()
return f"{datenow.year}"
def MONTH():
datenow = datetime.datetime.now()
return f"{datenow.month:02d}"
def DAY():
datenow = datetime.datetime.now()
return f"{datenow.day:02d}"
def CHKSTRC_LOGICALDRIVES():
string = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
drives = []
bitmask = ctypes.windll.kernel32.GetLogicalDrives()
for letter in string:
if bitmask & 1:
drives.append(letter)
bitmask >>= 1
return drives
def CHKSTRC_VOLUME_NAME(VOLUME_LETTER):
kernel32 = ctypes.windll.kernel32
volumeNameBuffer = ctypes.create_unicode_buffer(1024)
fileSystemNameBuffer = ctypes.create_unicode_buffer(1024)
serial_number = None
max_component_length = None
file_system_flags = None
rc = kernel32.GetVolumeInformationW(
ctypes.c_wchar_p(VOLUME_LETTER+":\\"),
volumeNameBuffer,
ctypes.sizeof(volumeNameBuffer),
serial_number,
max_component_length,
file_system_flags,
fileSystemNameBuffer,
ctypes.sizeof(fileSystemNameBuffer)
)
return volumeNameBuffer.value
def CHKSTRC_DRIVE():
pth = pathlib.Path.cwd()
str = pth.drive
return str[0]
def STR_IDNT(str_idnt):
global state
global pth
drives = CHKSTRC_LOGICALDRIVES()
for d in drives:
vol_name = CHKSTRC_VOLUME_NAME(d)
if str_idnt == vol_name:
state["STR_IDNT"] = True
pth = pathlib.Path(f"{d}:\\")
if state["STR_IDNT"] is None:
state["STR_IDNT"] = False
def LOCSTR_IDNT(str_idnt):
global pth
global state
if state["STR_IDNT"] is not True:
tmp_pth = pathlib.Path.home() / pathlib.Path("Documents") / pathlib.Path(str_idnt)
if tmp_pth.exists() is False:
tmp_pth.mkdir(parents=True)
pth = tmp_pth
state["LOCSTR_IDNT"] = True
else:
pth = tmp_pth
state["LOCSTR_IDNT"] = True
#hier ist der Fehler in Else-Teil
def PRJ_IDNT(prj_idnt):
global pth
global state
b1 = state["STR_IDNT"]
b2 = state["LOCSTR_IDNT"]
if b1 is True or b2 is True:
tmp_pth = pth / pathlib.Path(prj_idnt)
if tmp_pth.exists() is False:
tmp_pth.mkdir(parents=True)
pth = tmp_pth
state["PRJ_IDNT"] = True
else:
pth = tmp_pth
state["PRJ_IDNT"] = True
print(f"PRJ_IDNT")
print(f"b1: {b1}")
print(f"b2: {b2}")
print(f"pth: {pth}")
def DATE_YEAR_IDNT():
global pth
global state
b0 = True
b1 = state["STR_IDNT"]
b2 = state["LOCSTR_IDNT"]
b3 = state["PRJ_IDNT"]
if b1 is not True and b2 is not True:
b0 = False
if b3 is not True:
b0 = False
if b0 is True:
tmp_pth = pth / pathlib.Path(YEAR())
if tmp_pth.exists() is False:
tmp_pth.mkdir(parents=True)
pth = tmp_pth
state["DATE_YEAR_IDNT"] = True
else:
pth = tmp_pth
state["DATE_YEAR_IDNT"] = True
def DATE_MONTH_IDNT():
global pth
global state
b0 = True
b1 = state["STR_IDNT"]
b2 = state["LOCSTR_IDNT"]
b3 = state["PRJ_IDNT"]
b4 = state["DATE_YEAR_IDNT"]
if b1 is not True and b2 is not True:
b0 = False
if b3 is not True:
b0 = False
if b4 is not True:
b0 = False
if b0 is True:
tmp_pth = pth / pathlib.Path(MONTH())
if tmp_pth.exists() is False:
tmp_pth.mkdir(parents=True)
pth = tmp_pth
state["DATE_MONTH_IDNT"] = True
else:
pth = tmp_pth
state["DATE_MONTH_IDNT"] = True
def DATE_DAY_IDNT():
global pth
global state
b0 = True
b1 = state["STR_IDNT"]
b2 = state["LOCSTR_IDNT"]
b3 = state["PRJ_IDNT"]
b4 = state["DATE_YEAR_IDNT"]
b5 = state["DATE_MONTH_IDNT"]
if b1 is not True and b2 is not True:
b0 = False
if b3 is not True:
b0 = False
if b4 is not True:
b0 = False
if b5 is not True:
b0 = False
if b0 is True:
tmp_pth = pth / pathlib.Path(DAY())
if tmp_pth.exists() is False:
tmp_pth.mkdir(parents=True)
pth = tmp_pth
state["DATE_DAY_IDNT"] = True
else:
pth = tmp_pth
state["DATE_DAY_IDNT"] = True
Hochachtungsvoll
Artem Kraft
Kommentare
Kommentar veröffentlichen