2018-12-09 12:37:40 +05:30
|
|
|
#!/usr/bin/env python3
|
2016-04-24 23:36:37 +05:30
|
|
|
|
|
|
|
import os
|
2019-12-05 13:05:34 +05:30
|
|
|
import sys
|
|
|
|
from io import StringIO
|
2016-04-24 23:36:37 +05:30
|
|
|
from optparse import OptionParser
|
2019-06-14 16:33:30 +05:30
|
|
|
|
2016-04-24 23:36:37 +05:30
|
|
|
import damask
|
|
|
|
|
2019-06-14 16:33:30 +05:30
|
|
|
|
2016-04-24 23:36:37 +05:30
|
|
|
scriptName = os.path.splitext(os.path.basename(__file__))[0]
|
|
|
|
scriptID = ' '.join([scriptName,damask.version])
|
|
|
|
|
|
|
|
|
|
|
|
# --------------------------------------------------------------------
|
|
|
|
# MAIN
|
|
|
|
# --------------------------------------------------------------------
|
|
|
|
|
2019-02-16 22:11:56 +05:30
|
|
|
parser = OptionParser(option_class=damask.extendableOption, usage='%prog options [ASCIItable(s)]', description = """
|
2016-04-24 23:36:37 +05:30
|
|
|
Add info lines to ASCIItable header.
|
|
|
|
|
|
|
|
""", version = scriptID)
|
|
|
|
|
|
|
|
parser.add_option('-i',
|
|
|
|
'--info',
|
|
|
|
dest = 'info', action = 'extend', metavar = '<string LIST>',
|
|
|
|
help = 'items to add')
|
|
|
|
|
|
|
|
(options,filenames) = parser.parse_args()
|
2019-12-05 11:20:06 +05:30
|
|
|
if filenames == []: filenames = [None]
|
2016-04-24 23:36:37 +05:30
|
|
|
|
2019-02-16 19:23:56 +05:30
|
|
|
if options.info is None:
|
|
|
|
parser.error('no info specified.')
|
|
|
|
|
2016-04-24 23:36:37 +05:30
|
|
|
for name in filenames:
|
2019-12-05 11:20:06 +05:30
|
|
|
damask.util.report(scriptName,name)
|
2016-04-24 23:36:37 +05:30
|
|
|
|
2019-12-05 11:20:06 +05:30
|
|
|
table = damask.Table.from_ASCII(StringIO(''.join(sys.stdin.read())) if name is None else name)
|
|
|
|
table.comments += options.info
|
2016-04-24 23:36:37 +05:30
|
|
|
|
2019-12-05 11:20:06 +05:30
|
|
|
table.to_ASCII(sys.stdout if name is None else name)
|