fixed bug occurring for one item lines.

shortened logic here and there.
This commit is contained in:
Philip Eisenlohr 2012-04-25 13:53:56 +00:00
parent d9843fdd77
commit b87b2160e7
1 changed files with 9 additions and 11 deletions

View File

@ -78,7 +78,7 @@ for file in files:
begin = -1 begin = -1
outType = '' outType = ''
current=-1 # current material ID current=-1 # current material ID
charactersWritten=0 # number of words per line in the output file wordsWritten=0 # number of words per line in the output file
currentLine=0 currentLine=0
if file['name'] != 'STDIN': print file['name'] if file['name'] != 'STDIN': print file['name']
for line in file['input']: for line in file['input']:
@ -91,16 +91,14 @@ for file in files:
file['output'].write(line) file['output'].write(line)
else: else:
if options.unpack: # unpacking the geometry file if options.unpack: # unpacking the geometry file
words = line.split() words = map(str.lower,line.split())
if (words[1].lower()=='to'): line = ''.join(['%d '%i for i in xrange(int(words[0]), int(words[2])+1)]) if len(words) > 1: # any packing keywords?
if (words[1].lower()=='copies' and words[2].lower()=='of'): line=''.join(['%s '%words[3] for i in range(int(words[0]))]) if (words[1] == 'to'): line = ' '.join(map(str,range(int(words[0]),int(words[2])+1)))
words = line.split() if (words[1] == 'copies' and words[2] == 'of'): line = ' '.join([words[3]]*int(words[0]))
for i in xrange(len(words)):
file['output'].write(words[i]+' ') for word in line.split():
charactersWritten+=1 wordsWritten += 1
if(charactersWritten==options.lineLength): file['output'].write(word+{True:'\n',False:' '}[wordsWritten%options.lineLength == 0]) # newline every options.linelength words
file['output'].write('\n')
charactersWritten=0
if options.pack: # packing the geometry file if options.pack: # packing the geometry file
numbers=line.split() numbers=line.split()