This commit is contained in:
Martin Diehl 2021-03-26 20:56:55 +01:00
parent 3a74270946
commit 9fd244d8a0
9 changed files with 11 additions and 62 deletions

View File

@ -76,10 +76,10 @@ def asMFD(mfd_data):
elif type(num) == float: elif type(num) == float:
result += '{:20.12e}'.format(num) result += '{:20.12e}'.format(num)
else: else:
damask.util.croak('WARNING: encountered unknown type: ' + str(type(el))) print(f'WARNING: encountered unknown type: {type(el)}')
result += '\n' result += '\n'
else: else:
damask.util.croak('WARNING: encountered unknown type: ' + str(type(el))) print(f'WARNING: encountered unknown type: {type(el)}')
if section['uid'] > 0: if section['uid'] > 0:
result += '=end=\n' result += '=end=\n'
return result.strip() return result.strip()
@ -244,9 +244,9 @@ if remote:
py_mentat.py_send('*save_as_model "{}" yes'.format(filenames[0])) py_mentat.py_send('*save_as_model "{}" yes'.format(filenames[0]))
py_mentat.py_get_int("nnodes()") py_mentat.py_get_int("nnodes()")
except py_mentat.InputError as err: except py_mentat.InputError as err:
damask.util.croak('{}. Try Tools/Python/"Run as Separate Process" & "Initiate".'.format(err)) print(f'{err}. Try Tools/Python/"Run as Separate Process" & "Initiate".')
sys.exit(-1) sys.exit(-1)
damask.util.croak( 'connected...') print( 'connected...')
for name in filenames: for name in filenames:
while remote and not os.path.exists(name): time.sleep(0.5) while remote and not os.path.exists(name): time.sleep(0.5)

View File

@ -33,9 +33,6 @@ from ._configmaterial import ConfigMaterial # noqa
from ._grid import Grid # noqa from ._grid import Grid # noqa
from ._result import Result # noqa from ._result import Result # noqa
# deprecated # deprecated
from ._asciitable import ASCIItable # noqa from ._asciitable import ASCIItable # noqa
from ._test import Test # noqa from ._test import Test # noqa
from .util import extendableOption # noqa

View File

@ -53,8 +53,7 @@ class Test:
self.dirBase = os.path.dirname(os.path.realpath(sys.modules[self.__class__.__module__].__file__)) self.dirBase = os.path.dirname(os.path.realpath(sys.modules[self.__class__.__module__].__file__))
self.parser = OptionParser(option_class=damask.extendableOption, self.parser = OptionParser(description = f'{self.description} (Test class version: {damask.version})',
description = f'{self.description} (Test class version: {damask.version})',
usage = './test.py [options]') usage = './test.py [options]')
self.parser.add_option("-k", "--keep", self.parser.add_option("-k", "--keep",
action = "store_true", action = "store_true",
@ -70,7 +69,6 @@ class Test:
help = "show all test variants without actual calculation") help = "show all test variants without actual calculation")
self.parser.add_option("-s", "--select", self.parser.add_option("-s", "--select",
dest = "select", dest = "select",
action = 'extend', metavar = '<string LIST>',
help = "run test(s) of given name only") help = "run test(s) of given name only")
self.parser.set_defaults(keep = self.keep, self.parser.set_defaults(keep = self.keep,
accept = self.accept, accept = self.accept,

View File

@ -6,7 +6,6 @@ import shlex
import re import re
import fractions import fractions
from functools import reduce from functools import reduce
from optparse import Option
import numpy as np import numpy as np
import h5py import h5py
@ -16,7 +15,6 @@ from . import version
# limit visibility # limit visibility
__all__=[ __all__=[
'srepr', 'srepr',
'croak',
'report', 'report',
'emph','deemph','warn','strikeout', 'emph','deemph','warn','strikeout',
'execute', 'execute',
@ -25,7 +23,6 @@ __all__=[
'project_stereographic', 'project_stereographic',
'hybrid_IA', 'hybrid_IA',
'return_message', 'return_message',
'extendableOption',
'execution_stamp', 'execution_stamp',
'shapeshifter', 'shapeblender', 'shapeshifter', 'shapeblender',
'extend_docstring', 'extended_docstring', 'extend_docstring', 'extended_docstring',
@ -54,25 +51,6 @@ def srepr(arg,glue = '\n'):
return arg if isinstance(arg,str) else repr(arg) return arg if isinstance(arg,str) else repr(arg)
def croak(what, newline = True):
"""
Write formated to stderr.
DEPRECATED
Parameters
----------
what : str or iterable
Content to be displayed.
newline : bool, optional
Separate items of what by newline. Defaults to True.
"""
if what is not None:
sys.stderr.write(srepr(what,glue = '\n') + ('\n' if newline else ''))
sys.stderr.flush()
def report(who = None, def report(who = None,
what = None): what = None):
""" """
@ -81,7 +59,7 @@ def report(who = None,
DEPRECATED DEPRECATED
""" """
croak( (emph(who)+': ' if who is not None else '') + (what if what is not None else '') + '\n' ) print( (emph(who)+': ' if who is not None else '') + (what if what is not None else '') + '\n' )
def emph(what): def emph(what):
@ -428,27 +406,6 @@ def DREAM3D_cell_data_group(fname):
#################################################################################################### ####################################################################################################
# Classes # Classes
#################################################################################################### ####################################################################################################
class extendableOption(Option):
"""
Used for definition of new option parser action 'extend', which enables to take multiple option arguments.
Adopted from online tutorial http://docs.python.org/library/optparse.html
DEPRECATED
"""
ACTIONS = Option.ACTIONS + ("extend",)
STORE_ACTIONS = Option.STORE_ACTIONS + ("extend",)
TYPED_ACTIONS = Option.TYPED_ACTIONS + ("extend",)
ALWAYS_TYPED_ACTIONS = Option.ALWAYS_TYPED_ACTIONS + ("extend",)
def take_action(self, action, dest, opt, value, values, parser):
if action == "extend":
lvalue = value.split(",")
values.ensure_value(dest, []).extend(lvalue)
else:
Option.take_action(self, action, dest, opt, value, values, parser)
class _ProgressBar: class _ProgressBar:
""" """
Report progress of an interation as a status bar. Report progress of an interation as a status bar.

View File

@ -23,9 +23,6 @@ class TestUtil:
with pytest.raises(RuntimeError): with pytest.raises(RuntimeError):
util.execute('/bin/false') util.execute('/bin/false')
def test_croak(self):
util.croak('Burp!')
@pytest.mark.parametrize('input,output', @pytest.mark.parametrize('input,output',
[ [
([0,-2],[0,-1]), ([0,-2],[0,-1]),