changed file handling to allow for serial processing of large file numbers.
This commit is contained in:
parent
1242aab2bf
commit
f7da804927
|
@ -6,8 +6,8 @@ import numpy as np
|
|||
from optparse import OptionParser
|
||||
import damask
|
||||
|
||||
scriptID = '$Id$'
|
||||
scriptName = scriptID.split()[1]
|
||||
scriptID = string.replace('$Id$','\n','\\n')
|
||||
scriptName = scriptID.split()[1][:-3]
|
||||
|
||||
#--------------------------------------------------------------------------------------------------
|
||||
# MAIN
|
||||
|
@ -37,18 +37,26 @@ compress geometry files with ranges "a to b" and/or multiples "n of x".
|
|||
(options, filenames) = parser.parse_args()
|
||||
|
||||
# ------------------------------------------ setup file handles -----------------------------------
|
||||
|
||||
files = []
|
||||
if filenames == []:
|
||||
files.append({'name':'STDIN', 'input':sys.stdin, 'output':sys.stdout, 'croak':sys.stderr})
|
||||
files.append({'name':'STDIN',
|
||||
'input':sys.stdin,
|
||||
'output':sys.stdout,
|
||||
'croak':sys.stderr})
|
||||
else:
|
||||
for name in filenames:
|
||||
if os.path.exists(name):
|
||||
files.append({'name':name, 'input':open(name), 'output':open(name+'_tmp','w'), 'croak':sys.stderr})
|
||||
files.append({'name':name,
|
||||
'croak':sys.stdout})
|
||||
|
||||
# ------------------------------------------ loop over input files --------------------------------
|
||||
for file in files:
|
||||
if file['name'] != 'STDIN': file['croak'].write('\033[1m'+scriptName+'\033[0m: '+file['name']+'\n')
|
||||
else: file['croak'].write('\033[1m'+scriptName+'\033[0m\n')
|
||||
file['croak'].write('\033[1m'+scriptName+'\033[0m'+(': '+file['name'] if file['name'] != 'STDIN' else '')+'\n')
|
||||
|
||||
if file['name'] != 'STDIN':
|
||||
file['input'] = open(file['name'])
|
||||
file['output'] = open(file['name']+'_tmp','w')
|
||||
|
||||
table = damask.ASCIItable(file['input'],file['output'],labels = False,buffered = False) # make unbuffered ASCII_table
|
||||
table.head_read() # read ASCII header info
|
||||
|
|
Loading…
Reference in New Issue