zeiterfassung/users.py
2025-04-09 17:37:06 +02:00

35 lines
1.0 KiB
Python

# Zeiterfassung
# Benutzerfunktionen
import os
import datetime
from definitions import *
# Benutzer anhand Verzeichnisse auflisten
def list_users():
directory = scriptpath() + "/" + userfolder
users = [d for d in os.listdir(directory) if os.path.isdir(os.path.join(directory, d))]
return users
def determine_filename(user, type="stamping"):
if type == "stamping":
year = str(datetime.datetime.now().year)
month = str(datetime.datetime.now().month)
completepath = scriptpath() + "/" + userfolder +"/" + user + "/" + year + "-" + month + ".txt"
return completepath
elif type == "settings":
completepath = scriptpath() + "/" + userfolder +"/" + user + "/" + usersettingsfilename
return completepath
# Benutzerliste anzeigen
def printUserList():
userlist = list_users()
for i in range(0, len(userlist)):
print(str(i + 1) + ": " + str(userlist[i]))
return(userlist)
# Installationsverzeichnis bestimmen
def scriptpath():
return os.path.dirname(os.path.abspath(__file__))