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
|
from optparse import OptionParser
|
||||||
import damask
|
import damask
|
||||||
|
|
||||||
scriptID = '$Id$'
|
scriptID = string.replace('$Id$','\n','\\n')
|
||||||
scriptName = scriptID.split()[1]
|
scriptName = scriptID.split()[1][:-3]
|
||||||
|
|
||||||
#--------------------------------------------------------------------------------------------------
|
#--------------------------------------------------------------------------------------------------
|
||||||
# MAIN
|
# MAIN
|
||||||
|
@ -37,18 +37,26 @@ compress geometry files with ranges "a to b" and/or multiples "n of x".
|
||||||
(options, filenames) = parser.parse_args()
|
(options, filenames) = parser.parse_args()
|
||||||
|
|
||||||
# ------------------------------------------ setup file handles -----------------------------------
|
# ------------------------------------------ setup file handles -----------------------------------
|
||||||
|
|
||||||
files = []
|
files = []
|
||||||
if filenames == []:
|
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:
|
else:
|
||||||
for name in filenames:
|
for name in filenames:
|
||||||
if os.path.exists(name):
|
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 --------------------------------
|
# ------------------------------------------ loop over input files --------------------------------
|
||||||
for file in files:
|
for file in files:
|
||||||
if file['name'] != 'STDIN': file['croak'].write('\033[1m'+scriptName+'\033[0m: '+file['name']+'\n')
|
file['croak'].write('\033[1m'+scriptName+'\033[0m'+(': '+file['name'] if file['name'] != 'STDIN' else '')+'\n')
|
||||||
else: file['croak'].write('\033[1m'+scriptName+'\033[0m\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 = damask.ASCIItable(file['input'],file['output'],labels = False,buffered = False) # make unbuffered ASCII_table
|
||||||
table.head_read() # read ASCII header info
|
table.head_read() # read ASCII header info
|
||||||
|
|
Loading…
Reference in New Issue