Add packaging dependency and fallback version compare
This commit is contained in:
@@ -114,7 +114,7 @@ source ~/.bashrc
|
|||||||
|
|
||||||
```bat
|
```bat
|
||||||
py -3 -m venv .venv --upgrade-deps
|
py -3 -m venv .venv --upgrade-deps
|
||||||
.\.venv\Scripts\python.exe -m pip install -q pdfplumber icalendar pypdf2 pytz
|
.\.venv\Scripts\python.exe -m pip install -q pdfplumber icalendar pypdf2 pytz packaging
|
||||||
.\.venv\Scripts\pythonw.exe gui.py
|
.\.venv\Scripts\pythonw.exe gui.py
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|||||||
@@ -110,7 +110,7 @@ Die erforderlichen Dependencies sind bereits installiert. Falls Sie das Projekt
|
|||||||
```bash
|
```bash
|
||||||
python3 -m venv .venv
|
python3 -m venv .venv
|
||||||
source .venv/bin/activate
|
source .venv/bin/activate
|
||||||
pip install pdfplumber icalendar pypdf2 pytz
|
pip install pdfplumber icalendar pypdf2 pytz packaging
|
||||||
```
|
```
|
||||||
|
|
||||||
## Verwendung
|
## Verwendung
|
||||||
@@ -243,7 +243,7 @@ ICS-Import/
|
|||||||
|
|
||||||
### Technische Spezifikationen
|
### Technische Spezifikationen
|
||||||
|
|
||||||
- **Abhängigkeiten**: pdfplumber, icalendar, pytz, pypdf2
|
- **Abhängigkeiten**: pdfplumber, icalendar, pytz, pypdf2, packaging
|
||||||
- **Optional für GUI**: tkinter (Python-Standard), tkinterdnd2 (Drag & Drop)
|
- **Optional für GUI**: tkinter (Python-Standard), tkinterdnd2 (Drag & Drop)
|
||||||
- **Python-Version**: 3.6+
|
- **Python-Version**: 3.6+
|
||||||
- **Format**: iCalendar 2.0 (RFC 5545)
|
- **Format**: iCalendar 2.0 (RFC 5545)
|
||||||
|
|||||||
@@ -98,7 +98,7 @@ Doppelklick auf start.cmd
|
|||||||
## 🔧 Technische Details
|
## 🔧 Technische Details
|
||||||
|
|
||||||
- **Sprache:** Python 3.6+
|
- **Sprache:** Python 3.6+
|
||||||
- **Abhängigkeiten:** pdfplumber, icalendar, pytz, pypdf2
|
- **Abhängigkeiten:** pdfplumber, icalendar, pytz, pypdf2, packaging
|
||||||
- **Format:** iCalendar 2.0 (RFC 5545)
|
- **Format:** iCalendar 2.0 (RFC 5545)
|
||||||
- **Umgebung:** Python virtual environment (.venv)
|
- **Umgebung:** Python virtual environment (.venv)
|
||||||
|
|
||||||
@@ -108,6 +108,7 @@ pdfplumber==0.10.0+ - PDF-Datenextraktion
|
|||||||
icalendar==5.0.0+ - ICS-Datei-Erstellung
|
icalendar==5.0.0+ - ICS-Datei-Erstellung
|
||||||
pytz - Zeitzonenverwaltung
|
pytz - Zeitzonenverwaltung
|
||||||
pypdf2 - PDF-Parsing
|
pypdf2 - PDF-Parsing
|
||||||
|
packaging - Versionsvergleich
|
||||||
```
|
```
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|||||||
@@ -10,7 +10,7 @@ REM Überprüfe, ob venv existiert
|
|||||||
if not exist ".venv" (
|
if not exist ".venv" (
|
||||||
echo Python-Umgebung wird eingerichtet...
|
echo Python-Umgebung wird eingerichtet...
|
||||||
python3 -m venv .venv
|
python3 -m venv .venv
|
||||||
call .venv\Scripts\pip.exe install -q pdfplumber icalendar pypdf2 pytz
|
call .venv\Scripts\pip.exe install -q pdfplumber icalendar pypdf2 pytz packaging
|
||||||
)
|
)
|
||||||
|
|
||||||
REM Starte das Menü
|
REM Starte das Menü
|
||||||
|
|||||||
4
start.sh
4
start.sh
@@ -36,7 +36,7 @@ if ! $PYTHON_VENV -c "import pdfplumber" 2>/dev/null; then
|
|||||||
echo "📚 Installiere Abhängigkeiten..."
|
echo "📚 Installiere Abhängigkeiten..."
|
||||||
|
|
||||||
# Nutze python -m pip statt pip direkt
|
# Nutze python -m pip statt pip direkt
|
||||||
if $PYTHON_VENV -m pip install -q pdfplumber icalendar pypdf2 pytz 2>/dev/null; then
|
if $PYTHON_VENV -m pip install -q pdfplumber icalendar pypdf2 pytz packaging 2>/dev/null; then
|
||||||
echo "✓ Abhängigkeiten installiert"
|
echo "✓ Abhängigkeiten installiert"
|
||||||
else
|
else
|
||||||
echo "❌ Installation fehlgeschlagen"
|
echo "❌ Installation fehlgeschlagen"
|
||||||
@@ -46,7 +46,7 @@ if ! $PYTHON_VENV -c "import pdfplumber" 2>/dev/null; then
|
|||||||
echo "❌ venv konnte nicht neu erstellt werden"
|
echo "❌ venv konnte nicht neu erstellt werden"
|
||||||
exit 1
|
exit 1
|
||||||
}
|
}
|
||||||
$PYTHON_VENV -m pip install -q pdfplumber icalendar pypdf2 pytz || {
|
$PYTHON_VENV -m pip install -q pdfplumber icalendar pypdf2 pytz packaging || {
|
||||||
echo "❌ Abhängigkeiten konnten nicht installiert werden"
|
echo "❌ Abhängigkeiten konnten nicht installiert werden"
|
||||||
exit 1
|
exit 1
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -19,7 +19,7 @@ REM Überprüfe, ob Abhängigkeiten installiert sind
|
|||||||
.venv\Scripts\python.exe -c "import pdfplumber" 2>nul
|
.venv\Scripts\python.exe -c "import pdfplumber" 2>nul
|
||||||
if errorlevel 1 (
|
if errorlevel 1 (
|
||||||
echo 📚 Installiere Abhängigkeiten...
|
echo 📚 Installiere Abhängigkeiten...
|
||||||
call .venv\Scripts\python.exe -m pip install -q pdfplumber icalendar pypdf2 pytz
|
call .venv\Scripts\python.exe -m pip install -q pdfplumber icalendar pypdf2 pytz packaging
|
||||||
echo ✓ Abhängigkeiten installiert
|
echo ✓ Abhängigkeiten installiert
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|||||||
@@ -35,7 +35,7 @@ PYTHON_VENV=".venv/bin/python"
|
|||||||
if ! $PYTHON_VENV -c "import pdfplumber" 2>/dev/null; then
|
if ! $PYTHON_VENV -c "import pdfplumber" 2>/dev/null; then
|
||||||
echo "📚 Installiere Abhängigkeiten..."
|
echo "📚 Installiere Abhängigkeiten..."
|
||||||
|
|
||||||
if $PYTHON_VENV -m pip install -q pdfplumber icalendar pypdf2 pytz 2>/dev/null; then
|
if $PYTHON_VENV -m pip install -q pdfplumber icalendar pypdf2 pytz packaging 2>/dev/null; then
|
||||||
echo "✓ Abhängigkeiten installiert"
|
echo "✓ Abhängigkeiten installiert"
|
||||||
else
|
else
|
||||||
echo "❌ Installation fehlgeschlagen"
|
echo "❌ Installation fehlgeschlagen"
|
||||||
@@ -45,7 +45,7 @@ if ! $PYTHON_VENV -c "import pdfplumber" 2>/dev/null; then
|
|||||||
echo "❌ venv konnte nicht neu erstellt werden"
|
echo "❌ venv konnte nicht neu erstellt werden"
|
||||||
exit 1
|
exit 1
|
||||||
}
|
}
|
||||||
$PYTHON_VENV -m pip install -q pdfplumber icalendar pypdf2 pytz || {
|
$PYTHON_VENV -m pip install -q pdfplumber icalendar pypdf2 pytz packaging || {
|
||||||
echo "❌ Abhängigkeiten konnten nicht installiert werden"
|
echo "❌ Abhängigkeiten konnten nicht installiert werden"
|
||||||
exit 1
|
exit 1
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,7 +7,11 @@ Prüft auf Updates über Gitea API
|
|||||||
import urllib.request
|
import urllib.request
|
||||||
import json
|
import json
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
from packaging import version as pkg_version
|
|
||||||
|
try:
|
||||||
|
from packaging import version as pkg_version
|
||||||
|
except Exception: # pragma: no cover - packaging may be missing in user envs
|
||||||
|
pkg_version = None
|
||||||
|
|
||||||
# Gitea-Konfiguration
|
# Gitea-Konfiguration
|
||||||
GITEA_URL = "https://git.file-archive.de"
|
GITEA_URL = "https://git.file-archive.de"
|
||||||
@@ -81,14 +85,53 @@ def check_for_updates():
|
|||||||
|
|
||||||
try:
|
try:
|
||||||
# Vergleiche Versionen
|
# Vergleiche Versionen
|
||||||
if pkg_version.parse(latest) > pkg_version.parse(current):
|
if pkg_version is not None:
|
||||||
return True, latest, url
|
if pkg_version.parse(latest) > pkg_version.parse(current):
|
||||||
|
return True, latest, url
|
||||||
|
else:
|
||||||
|
if _simple_version_compare(latest, current) > 0:
|
||||||
|
return True, latest, url
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
print(f"Warnung: Versionenvergleich fehlgeschlagen: {e}")
|
print(f"Warnung: Versionenvergleich fehlgeschlagen: {e}")
|
||||||
|
|
||||||
return False, None, None
|
return False, None, None
|
||||||
|
|
||||||
|
|
||||||
|
def _simple_version_compare(left, right):
|
||||||
|
"""
|
||||||
|
Fallback-Versionsvergleich ohne externe Abhaengigkeiten.
|
||||||
|
Gibt 1 zurueck wenn left > right, -1 wenn left < right, sonst 0.
|
||||||
|
"""
|
||||||
|
def to_parts(value):
|
||||||
|
parts = []
|
||||||
|
for item in value.replace("v", "").split("."):
|
||||||
|
try:
|
||||||
|
parts.append(int(item))
|
||||||
|
except ValueError:
|
||||||
|
parts.append(item)
|
||||||
|
return parts
|
||||||
|
|
||||||
|
left_parts = to_parts(left)
|
||||||
|
right_parts = to_parts(right)
|
||||||
|
max_len = max(len(left_parts), len(right_parts))
|
||||||
|
|
||||||
|
for i in range(max_len):
|
||||||
|
l_val = left_parts[i] if i < len(left_parts) else 0
|
||||||
|
r_val = right_parts[i] if i < len(right_parts) else 0
|
||||||
|
if l_val == r_val:
|
||||||
|
continue
|
||||||
|
try:
|
||||||
|
return 1 if l_val > r_val else -1
|
||||||
|
except TypeError:
|
||||||
|
l_str = str(l_val)
|
||||||
|
r_str = str(r_val)
|
||||||
|
if l_str == r_str:
|
||||||
|
continue
|
||||||
|
return 1 if l_str > r_str else -1
|
||||||
|
|
||||||
|
return 0
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
# Test
|
# Test
|
||||||
current = get_current_version()
|
current = get_current_version()
|
||||||
|
|||||||
Reference in New Issue
Block a user