Replace fixed input/output paths in platz.cfg with --indir switch
Tischedatei, XMLdatei_Bestellung, AusgabeTischePersonen and AusgabePersonTisch are no longer configured in platz.cfg. Instead, platz.py now requires a --indir <dir> command-line switch pointing at a directory that must contain tische.ini and bestellung.xml, and into which TischePersonen.txt/PersonenTische.csv are written - e.g. work/test1 or work/test2. This makes it trivial to run against different guest lists without editing platz.cfg. platz.bat/platz.sh forward extra arguments so --indir can be passed through. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
+24
-13
@@ -12,13 +12,29 @@ __license__ = "Python"
|
||||
from ga import *
|
||||
from Strukturdaten import *
|
||||
import ConfigParser
|
||||
import optparse
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
|
||||
# lade Vorgaben fuer Optimierungszyklus und
|
||||
# Kommandozeilenoption --indir: Verzeichnis mit den Eingabedateien
|
||||
# (tische.ini, bestellung.xml) und Ziel fuer die Ausgabedateien
|
||||
# (TischePersonen.txt, PersonenTische.csv)
|
||||
parser = optparse.OptionParser()
|
||||
parser.add_option( "--indir", dest="indir", default=None,
|
||||
help="Verzeichnis mit tische.ini und bestellung.xml; "
|
||||
"dort werden auch TischePersonen.txt und PersonenTische.csv abgelegt" )
|
||||
(options, args) = parser.parse_args()
|
||||
|
||||
if options.indir is None:
|
||||
parser.error( "--indir ist erforderlich" )
|
||||
InDir = os.path.expandvars( os.path.expanduser( options.indir ) )
|
||||
if not os.path.isdir( InDir ):
|
||||
parser.error( "--indir '%s' ist kein Verzeichnis" % InDir )
|
||||
|
||||
# lade Vorgaben fuer Optimierungszyklus und
|
||||
config = ConfigParser.ConfigParser()
|
||||
ConfigPath= os.path.join( os.getenv('PLATZ_CFG'), 'platz.cfg')
|
||||
ConfigPath= os.path.join( os.getenv('PLATZ_CFG'), 'platz.cfg')
|
||||
config.read( os.path.expandvars( ConfigPath ))
|
||||
|
||||
Zyklusconfig = os.path.normpath( config.get( 'Config', 'Zyklusdatei' ))
|
||||
@@ -30,17 +46,13 @@ if __name__ == '__main__':
|
||||
## print Strafenconfig
|
||||
|
||||
# lade Eingabedateien
|
||||
Tischconfig = os.path.normpath(config.get( 'Config', 'Tischedatei' ))
|
||||
Tischconfig = os.path.expandvars(Tischconfig)
|
||||
Bestellung = os.path.normpath(config.get( 'Config', 'XMLdatei_Bestellung' ))
|
||||
Bestellung = os.path.expandvars( Bestellung )
|
||||
Tischconfig = os.path.join( InDir, 'tische.ini' )
|
||||
Bestellung = os.path.join( InDir, 'bestellung.xml' )
|
||||
|
||||
# lade Ausgabedateien
|
||||
AusgabeTP= os.path.normpath(config.get( 'Config', 'AusgabeTischePersonen' ))
|
||||
AusgabeTP = os.path.expandvars(AusgabeTP)
|
||||
AusgabePT = os.path.normpath(config.get( 'Config', 'AusgabePersonTisch' ))
|
||||
AusgabePT = os.path.expandvars(AusgabePT)
|
||||
|
||||
AusgabeTP= os.path.join( InDir, 'TischePersonen.txt' )
|
||||
AusgabePT = os.path.join( InDir, 'PersonenTische.csv' )
|
||||
|
||||
Z = Zyklus()
|
||||
Z.laden( Zyklusconfig, Zyklusart )
|
||||
print Z
|
||||
@@ -67,7 +79,6 @@ if __name__ == '__main__':
|
||||
|
||||
else:
|
||||
pass
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user