irgendwie hab ich hier einen Logic bug
Ich möchte von der Comandline 5-6 Werte einlesen. Sobald aber die Option -x gesetzt wird sollen die Werte manuell gesetzt werden. Solange -x nicht angegeben wird soll das Programm die angegebenen Werte importieren.
Ihrgend Wie sehe ich gerade den Baum vor lauter Bäumen nicht mehr oder kann ich aus dieser Schleife eventuell mit einem goto aussteigen?
Code: Alles auswählen
def main(argv):
Processor = ''
input = ''
output = ''
Name = ''
try:
opts, args = getopt.getopt(argv,"xh:p:y:o:n:",["proc=","ifile=","ofile=","name="])
except getopt.GetoptError:
print 'test_.py (-x) -p <processor> -y <input> -0 <output> -n <pname>'
for opt, arg in opts:
if opt == '-x':
processor = Name
id = '08150815'
if opt in ("-p", "--ppath"):
Processor = arg
elif opt in ("-o", "--ofile"):
output = arg
elif opt in ("-n", "--pname"):
Name = arg
else opt == '-h':
print 'test_.py (-x) -p <processor> -y <input> -0 <output> -n <pname>'
sys.exit()
elif opt in ("-p", "--ppath"):
Processor = arg
elif opt in ("-y", "--yfile"):
input = arg
elif opt in ("-o", "--ofile"):
output = arg
elif opt in ("-n", "--pname"):
Name = arg
print 'Processor :', Processor
print 'Input File :', yamlfile
print 'Output File :', output_path
print 'Name :', Name_Prozessor
Vielen Dank im Vorraus