Firmendaten portabel suchen + Menuepunkt zum Auswaehlen
Die config.json des Rechnungstools wurde nur unter dem festen Entwicklungspfad gesucht - als EXE auf einem anderen Rechner haette der Bericht keinen Briefkopf bekommen. Jetzt: neben dem Programm, im Nachbarordner, in Dokumente, und ueber "Daten -> Firmendaten waehlen". Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
parent
80967de26f
commit
2b7990b1b6
2 changed files with 35 additions and 5 deletions
23
firma.py
23
firma.py
|
|
@ -11,15 +11,28 @@ Bericht wird trotzdem gedruckt (nur ohne Logo/Bankzeile).
|
|||
"""
|
||||
|
||||
import os
|
||||
import sys
|
||||
import json
|
||||
import logging
|
||||
|
||||
log = logging.getLogger("bst.firma")
|
||||
|
||||
SUCHPFADE = [
|
||||
r"C:\claude\rechnungstool\config.json",
|
||||
os.path.join(os.path.expanduser("~"), "Documents", "rechnungstool", "config.json"),
|
||||
]
|
||||
_HIER = os.path.dirname(os.path.abspath(
|
||||
sys.argv[0] if getattr(sys, "frozen", False) else __file__))
|
||||
_HEIM = os.path.expanduser("~")
|
||||
|
||||
|
||||
def _suchpfade():
|
||||
"""Übliche Orte der config.json des Rechnungstools – erst neben uns, dann daneben."""
|
||||
kandidaten = [
|
||||
os.path.join(_HIER, "config.json"), # direkt daneben gelegt
|
||||
os.path.join(_HIER, "..", "rechnungstool", "config.json"),
|
||||
os.path.join(_HIER, "..", "Rechnungstool", "config.json"),
|
||||
os.path.join(_HEIM, "Documents", "rechnungstool", "config.json"),
|
||||
os.path.join(_HEIM, "Documents", "Rechnungstool", "config.json"),
|
||||
r"C:\claude\rechnungstool\config.json", # Entwicklungsrechner
|
||||
]
|
||||
return [os.path.normpath(p) for p in kandidaten]
|
||||
|
||||
ERSATZ = {
|
||||
"name": "Campinghof Bartl",
|
||||
|
|
@ -32,7 +45,7 @@ ERSATZ = {
|
|||
|
||||
def config_pfad(gespeichert: str = "") -> str:
|
||||
"""Erster gefundener Pfad zur config.json des Rechnungstools ('' = keiner)."""
|
||||
for p in ([gespeichert] if gespeichert else []) + SUCHPFADE:
|
||||
for p in ([gespeichert] if gespeichert else []) + _suchpfade():
|
||||
if p and os.path.isfile(p):
|
||||
return os.path.abspath(p)
|
||||
return ""
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue