2018-11-17 12:42:12 +05:30
|
|
|
#!/usr/bin/env python3
|
2012-09-05 20:45:11 +05:30
|
|
|
# -*- coding: UTF-8 no BOM -*-
|
|
|
|
|
2019-05-25 12:06:00 +05:30
|
|
|
import os
|
|
|
|
import sys
|
2014-08-25 18:23:11 +05:30
|
|
|
from optparse import OptionParser
|
2019-05-25 13:44:53 +05:30
|
|
|
from io import StringIO
|
2013-06-30 06:09:48 +05:30
|
|
|
import damask
|
2012-09-05 20:45:11 +05:30
|
|
|
|
2016-01-27 22:36:00 +05:30
|
|
|
scriptName = os.path.splitext(os.path.basename(__file__))[0]
|
|
|
|
scriptID = ' '.join([scriptName,damask.version])
|
2013-07-10 14:45:42 +05:30
|
|
|
|
2013-05-13 18:40:31 +05:30
|
|
|
#--------------------------------------------------------------------------------------------------
|
|
|
|
# MAIN
|
|
|
|
#--------------------------------------------------------------------------------------------------
|
2012-09-05 20:45:11 +05:30
|
|
|
|
2014-08-25 18:23:11 +05:30
|
|
|
parser = OptionParser(option_class=damask.extendableOption, usage='%prog options [file[s]]', description = """
|
2012-10-30 21:17:11 +05:30
|
|
|
Unpack geometry files containing ranges "a to b" and/or "n of x" multiples (exclusively in one line).
|
2012-09-05 20:45:11 +05:30
|
|
|
|
2015-11-16 16:22:56 +05:30
|
|
|
""", version = scriptID)
|
2012-09-05 20:45:11 +05:30
|
|
|
|
2016-03-21 00:31:47 +05:30
|
|
|
parser.add_option('-1', '--onedimensional',
|
|
|
|
dest = 'oneD',
|
|
|
|
action = 'store_true',
|
|
|
|
help = 'output geom file with one-dimensional data arrangement')
|
|
|
|
|
|
|
|
parser.set_defaults(oneD = False,
|
|
|
|
)
|
|
|
|
|
2012-09-05 20:45:11 +05:30
|
|
|
(options, filenames) = parser.parse_args()
|
|
|
|
|
2015-08-08 00:33:26 +05:30
|
|
|
# --- loop over input files -------------------------------------------------------------------------
|
|
|
|
|
2015-08-21 01:12:05 +05:30
|
|
|
if filenames == []: filenames = [None]
|
2015-08-08 00:33:26 +05:30
|
|
|
|
|
|
|
for name in filenames:
|
2019-05-25 13:44:53 +05:30
|
|
|
damask.util.report(scriptName,name)
|
|
|
|
|
2019-05-25 12:06:00 +05:30
|
|
|
if name is None:
|
|
|
|
virt_file = StringIO(''.join(sys.stdin.read()))
|
|
|
|
geom = damask.Geom.from_file(virt_file)
|
|
|
|
else:
|
|
|
|
geom = damask.Geom.from_file(name)
|
2013-06-30 06:09:48 +05:30
|
|
|
|
2019-05-25 12:06:00 +05:30
|
|
|
geom.add_comment(scriptID + ' ' + ' '.join(sys.argv[1:]))
|
2013-06-30 06:09:48 +05:30
|
|
|
|
2019-05-25 13:44:53 +05:30
|
|
|
damask.util.croak(geom)
|
2019-05-25 12:06:00 +05:30
|
|
|
if name is None:
|
2019-05-25 13:44:53 +05:30
|
|
|
sys.stdout.write(str(geom.show()))
|
2019-05-25 12:06:00 +05:30
|
|
|
else:
|
|
|
|
geom.to_file(name)
|