simplified $Id treatment.

now reports own name in bold during runtime.
This commit is contained in:
Philip Eisenlohr 2013-07-10 09:15:42 +00:00
parent 31e0469b34
commit cb09c17fa2
5 changed files with 38 additions and 18 deletions

View File

@ -5,6 +5,9 @@ import os,sys,string,re,numpy,vtk
import damask
from optparse import OptionParser, OptionGroup, Option, SUPPRESS_HELP
scriptID = '$Id$'
scriptName = scriptID.split()[1]
#--------------------------------------------------------------------------------------------------
class extendedOption(Option):
#--------------------------------------------------------------------------------------------------
@ -47,7 +50,7 @@ mappings = {
parser = OptionParser(option_class=extendedOption, usage='%prog [geomfile[s]]', description = """
Produce VTK rectilinear mesh of structure data from geom description
""" + string.replace('$Id$','\n','\\n')
""" + string.replace(scriptID,'\n','\\n')
)
(options, filenames) = parser.parse_args()
@ -71,7 +74,8 @@ else:
#--- loop over input files ------------------------------------------------------------------------
for file in files:
if file['name'] != 'STDIN': file['croak'].write(file['name']+'\n')
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')
theTable = damask.ASCIItable(file['input'],file['output'],labels=False)
theTable.head_read()
@ -146,7 +150,7 @@ for file in files:
outWriter = vtk.vtkRectilinearGridWriter()
outWriter.WriteToOutputStringOn()
outWriter.SetFileTypeToASCII()
outWriter.SetHeader('# powered by $Id$')
outWriter.SetHeader('# powered by '+scriptID)
outWriter.SetInput(grid)
outWriter.Write()
sys.stdout.write(outWriter.GetOutputString()[0:outWriter.GetOutputStringLength()])

View File

@ -5,6 +5,9 @@ import os,sys,string,re,math,numpy
import damask
from optparse import OptionParser, OptionGroup, Option, SUPPRESS_HELP
scriptID = '$Id$'
scriptName = scriptID.split()[1]
#--------------------------------------------------------------------------------------------------
class extendedOption(Option):
#--------------------------------------------------------------------------------------------------
@ -46,7 +49,7 @@ mappings = {
parser = OptionParser(option_class=extendedOption, usage='%prog options [file[s]]', description = """
compress geometry files with ranges "a to b" and/or multiples "n of x".
""" + string.replace('$Id$','\n','\\n')
""" + string.replace(scriptID,'\n','\\n')
)
(options, filenames) = parser.parse_args()
@ -70,7 +73,8 @@ else:
#--- loop over input files ------------------------------------------------------------------------
for file in files:
if file['name'] != 'STDIN': file['croak'].write(file['name']+'\n')
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')
theTable = damask.ASCIItable(file['input'],file['output'],labels=False)
theTable.head_read()
@ -105,7 +109,7 @@ for file in files:
'size x y z: %s\n'%(' x '.join(map(str,info['size']))) + \
'origin x y z: %s\n'%(' : '.join(map(str,info['origin']))) + \
'homogenization: %i\n'%info['homogenization'] + \
'microstructures: %i\n\n'%info['microstructures'])
'microstructures: %i\n'%info['microstructures'])
if numpy.any(info['grid'] < 1):
file['croak'].write('invalid grid a b c.\n')
@ -118,7 +122,7 @@ for file in files:
theTable.labels_clear()
theTable.info_clear()
theTable.info_append(extra_header+[
"$Id$",
scriptID,
"grid\ta %i\tb %i\tc %i"%(info['grid'][0],info['grid'][1],info['grid'][2],),
"size\tx %f\ty %f\tz %f"%(info['size'][0],info['size'][1],info['size'][2],),
"origin\tx %f\ty %f\tz %f"%(info['origin'][0],info['origin'][1],info['origin'][2],),

View File

@ -5,6 +5,9 @@ import os,sys,string,re,math,numpy
import damask
from optparse import OptionParser, OptionGroup, Option, SUPPRESS_HELP
scriptID = '$Id$'
scriptName = scriptID.split()[1]
#--------------------------------------------------------------------------------------------------
class extendedOption(Option):
#--------------------------------------------------------------------------------------------------
@ -47,7 +50,7 @@ mappings = {
parser = OptionParser(option_class=extendedOption, usage='%prog options [file[s]]', description = """
Scales a geometry description independently in x, y, and z direction in terms of grid and/or size.
Either absolute values or relative factors (like "0.25x") can be used.
""" + string.replace('$Id$','\n','\\n')
""" + string.replace(scriptID,'\n','\\n')
)
parser.add_option('-g', '--grid', dest='grid', type='string', nargs = 3, \
@ -79,7 +82,8 @@ else:
#--- loop over input files ------------------------------------------------------------------------
for file in files:
if file['name'] != 'STDIN': file['croak'].write(file['name']+'\n')
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')
theTable = damask.ASCIItable(file['input'],file['output'],labels=False)
theTable.head_read()
@ -187,7 +191,7 @@ for file in files:
theTable.labels_clear()
theTable.info_clear()
theTable.info_append(extra_header+[
"$Id$",
scriptID,
"grid\ta %i\tb %i\tc %i"%(newInfo['grid'][0],newInfo['grid'][1],newInfo['grid'][2],),
"size\tx %f\ty %f\tz %f"%(newInfo['size'][0],newInfo['size'][1],newInfo['size'][2],),
"origin\tx %f\ty %f\tz %f"%(info['origin'][0],info['origin'][1],info['origin'][2],),

View File

@ -5,6 +5,9 @@ import os,sys,string,re,math,numpy
import damask
from optparse import OptionParser, OptionGroup, Option, SUPPRESS_HELP
scriptID = '$Id$'
scriptName = scriptID.split()[1]
#--------------------------------------------------------------------------------------------------
class extendedOption(Option):
#--------------------------------------------------------------------------------------------------
@ -45,7 +48,7 @@ mappings = {
parser = OptionParser(option_class=extendedOption, usage='%prog options [file[s]]', description = """
translate microstructure indices (shift or substitute) and/or geometry origin.
""" + string.replace('$Id$','\n','\\n')
""" + string.replace(scriptID,'\n','\\n')
)
parser.add_option('-o', '--origin', dest='origin', type='float', nargs = 3, \
@ -85,7 +88,8 @@ else:
#--- loop over input files ------------------------------------------------------------------------
for file in files:
if file['name'] != 'STDIN': file['croak'].write(file['name']+'\n')
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')
theTable = damask.ASCIItable(file['input'],file['output'],labels=False)
theTable.head_read()
@ -123,7 +127,7 @@ for file in files:
'size x y z: %s\n'%(' x '.join(map(str,info['size']))) + \
'origin x y z: %s\n'%(' : '.join(map(str,info['origin']))) + \
'homogenization: %i\n'%info['homogenization'] + \
'microstructures: %i\n\n'%info['microstructures'])
'microstructures: %i\n'%info['microstructures'])
if numpy.any(info['grid'] < 1):
file['croak'].write('invalid grid a b c.\n')
@ -170,7 +174,7 @@ for file in files:
theTable.labels_clear()
theTable.info_clear()
theTable.info_append(extra_header+[
"$Id$",
scriptID,
"grid\ta %i\tb %i\tc %i"%(info['grid'][0],info['grid'][1],info['grid'][2],),
"size\tx %f\ty %f\tz %f"%(info['size'][0],info['size'][1],info['size'][2],),
"origin\tx %f\ty %f\tz %f"%(newInfo['origin'][0],newInfo['origin'][1],newInfo['origin'][2],),

View File

@ -5,6 +5,9 @@ import os,sys,string,re,math,numpy
import damask
from optparse import OptionParser, OptionGroup, Option, SUPPRESS_HELP
scriptID = '$Id$'
scriptName = scriptID.split()[1]
#--------------------------------------------------------------------------------------------------
class extendedOption(Option):
#--------------------------------------------------------------------------------------------------
@ -46,7 +49,7 @@ mappings = {
parser = OptionParser(option_class=extendedOption, usage='%prog options [file[s]]', description = """
Unpack geometry files containing ranges "a to b" and/or "n of x" multiples (exclusively in one line).
""" + string.replace('$Id$','\n','\\n')
""" + string.replace(scriptID,'\n','\\n')
)
parser.add_option('-1', '--onedimensional', dest='oneD', action='store_true', \
@ -75,7 +78,8 @@ else:
#--- loop over input files ------------------------------------------------------------------------
for file in files:
if file['name'] != 'STDIN': file['croak'].write(file['name']+'\n')
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')
theTable = damask.ASCIItable(file['input'],file['output'],labels=False)
theTable.head_read()
@ -110,7 +114,7 @@ for file in files:
'size x y z: %s\n'%(' x '.join(map(str,info['size']))) + \
'origin x y z: %s\n'%(' : '.join(map(str,info['origin']))) + \
'homogenization: %i\n'%info['homogenization'] + \
'microstructures: %i\n\n'%info['microstructures'])
'microstructures: %i\n'%info['microstructures'])
if numpy.any(info['grid'] < 1):
file['croak'].write('invalid grid a b c.\n')
@ -139,7 +143,7 @@ for file in files:
theTable.labels_clear()
theTable.info_clear()
theTable.info_append(extra_header+[
"$Id$",
scriptID,
"grid\ta %i\tb %i\tc %i"%(info['grid'][0],info['grid'][1],info['grid'][2],),
"size\tx %f\ty %f\tz %f"%(info['size'][0],info['size'][1],info['size'][2],),
"origin\tx %f\ty %f\tz %f"%(info['origin'][0],info['origin'][1],info['origin'][2],),