[ TAG 182 ][20.10.2021] -Erfolgreich -Protokoll -[ PRTKL_202110140000 ]

Ich habe das Modul etwas überarbeitet und so sieht das Ergebnis aus.

PRTKL_202110140000.PATH(str_idnt="ext_prj_2021", prj_idnt="IAP-20210601", locstr=False)
if PRTKL_202110140000.pth is not None:
logger.INIT(logger_name="CHECKPOINTS_LOGGER", path=PRTKL_202110140000.pth, file="CHECKPOINTS.log")
else:
print(f"PRTKL_202110140000 ist gescheitert.")
print(f"PRTKL_202110140000.pth: {PRTKL_202110140000.pth}")
print(f"PRTKL_202110140000.state: {PRTKL_202110140000.state}")
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


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


def PATH(str_idnt, prj_idnt, locstr=False):
'''

:param str_idnt: STORAGE-IDENTIFIER
:param prj_idnt: PROJECT-IDENTIFIER
:return:
True - Ordnerstruktur ist bereit
False - Ordnerstruktur ist nicht bereit
'''
global pth
global state

if locstr is False:
try:
STR_IDNT(str_idnt)
except:
return False
try:
LOCSTR_IDNT(str_idnt)
except:
return False

try:
PRJ_IDNT(prj_idnt)
except:
return False

try:
DATE_YEAR_IDNT()
except:
return False

try:
DATE_MONTH_IDNT()
except:
return False

try:
DATE_DAY_IDNT()
except:
return False

return True


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