-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathutil.py
More file actions
94 lines (78 loc) · 2.16 KB
/
Copy pathutil.py
File metadata and controls
94 lines (78 loc) · 2.16 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Hilfsfunktionen für das Datei-Sortierungsprogramm
"""
import os
import time
from datetime import datetime
import tkinter as tk
def check_dependencies():
"""
Überprüft, ob alle benötigten Abhängigkeiten installiert sind
Returns:
Liste fehlender Abhängigkeiten
"""
missing = []
try:
import requests
except ImportError:
missing.append("requests")
try:
import networkx
except ImportError:
missing.append("networkx")
try:
import matplotlib
except ImportError:
missing.append("matplotlib")
# Optional: PDF-Bibliotheken
try:
import PyPDF2
except ImportError:
# Nicht kritisch, da Fallback vorhanden
pass
try:
import pdfplumber
except ImportError:
# Nicht kritisch, da Fallback vorhanden
pass
return missing
def select_folder():
"""
Öffnet einen Dialog zur Auswahl eines Ordners
Returns:
Pfad zum ausgewählten Ordner oder leeren String
"""
from tkinter import filedialog
folder = filedialog.askdirectory(
title="Wähle den obersten Ordner aus",
initialdir=os.path.abspath(os.sep)
)
return folder
def format_time_remaining(seconds):
"""
Formatiert eine Zeitangabe in Sekunden in ein lesbares Format
Args:
seconds: Zeit in Sekunden
Returns:
Formatierte Zeitangabe
"""
if seconds < 60:
return f"{int(seconds)} Sekunden"
elif seconds < 3600:
return f"{int(seconds / 60)} Minuten {int(seconds % 60)} Sekunden"
else:
return f"{int(seconds / 3600)} Stunden {int((seconds % 3600) / 60)} Minuten"
def center_window(window):
"""
Zentriert ein Fenster auf dem Bildschirm
Args:
window: Das zu zentrierende Fenster
"""
window.update_idletasks()
width = window.winfo_width()
height = window.winfo_height()
x = (window.winfo_screenwidth() // 2) - (width // 2)
y = (window.winfo_screenheight() // 2) - (height // 2)
window.geometry(f'{width}x{height}+{x}+{y}')