Merge branch 'Marc-spelling' into 'development'

following official naming and website

See merge request damask/DAMASK!453
This commit is contained in:
Franz Roters 2021-11-16 16:33:05 +00:00
commit 3c7598c189
2 changed files with 27 additions and 27 deletions

View File

@ -8,7 +8,7 @@ from pathlib import Path
import damask
def copy_and_patch(patch,orig,msc_root,editor):
def copy_and_patch(patch,orig,marc_root,editor):
try:
shutil.copyfile(orig,orig.parent/patch.stem)
except shutil.SameFileError:
@ -17,31 +17,31 @@ def copy_and_patch(patch,orig,msc_root,editor):
with open(orig.parent/patch.stem) as f_in:
content = f_in.read()
with open(orig.parent/patch.stem,'w') as f_out:
f_out.write(content.replace('%INSTALLDIR%',msc_root).replace('%EDITOR%',editor))
f_out.write(content.replace('%INSTALLDIR%',marc_root).replace('%EDITOR%',editor))
parser = argparse.ArgumentParser(
description='Apply DAMASK modification to MSC.Marc/Mentat',
description='Apply DAMASK modification to MSC Marc/Mentat',
prog = Path(__file__).name,
formatter_class=argparse.ArgumentDefaultsHelpFormatter)
parser.add_argument('--editor', dest='editor', metavar='string', default='vi',
help='Name of the editor for MSC.Mentat (executable)')
parser.add_argument('--msc-root', dest='msc_root', metavar='string',
default=damask.solver._marc._msc_root,
help='MSC.Marc/Mentat root directory')
parser.add_argument('--msc-version', dest='msc_version', type=float, metavar='float',
default=damask.solver._marc._msc_version,
help='MSC.Marc/Mentat version')
help='Name of the editor for Marc Mentat (executable)')
parser.add_argument('--marc-root', dest='marc_root', metavar='string',
default=damask.solver._marc._marc_root,
help='Marc root directory')
parser.add_argument('--marc-version', dest='marc_version', type=float, metavar='float',
default=damask.solver._marc._marc_version,
help='Marc version')
parser.add_argument('--damask-root', dest='damask_root', metavar = 'string',
default=damask.solver._marc._damask_root,
help='DAMASK root directory')
args = parser.parse_args()
msc_root = Path(args.msc_root).expanduser()
marc_root = Path(args.marc_root).expanduser()
damask_root = Path(args.damask_root).expanduser()
msc_version = int(args.msc_version) if str(args.msc_version).split('.')[1] == '0' else \
args.msc_version
marc_version = int(args.marc_version) if str(args.marc_version).split('.')[1] == '0' else \
args.marc_version
matches = {'Marc_tools': [['comp_user','comp_damask_*mp'],
['run_marc','run_damask_*mp'],
@ -54,15 +54,15 @@ matches = {'Marc_tools': [['comp_user','comp_damask_*mp'],
print('patching files...\n')
for directory in glob.glob(str(damask_root/f'install/MarcMentat/{msc_version}/*')):
for directory in glob.glob(str(damask_root/f'install/MarcMentat/{marc_version}/*')):
for orig, mods in matches[Path(directory).name]:
product,subfolder = (msc_root/Path(directory)).name.split('_')
orig = msc_root/f'{product.lower()}{msc_version}/{subfolder}/{orig}'
product,subfolder = (marc_root/Path(directory)).name.split('_')
orig = marc_root/f'{product.lower()}{marc_version}/{subfolder}/{orig}'
for patch in glob.glob(f'{directory}/{mods}.patch'):
copy_and_patch(Path(patch),orig,msc_root,args.editor)
copy_and_patch(Path(patch),orig,marc_root,args.editor)
print('compiling Mentat menu binaries...')
executable = msc_root/f'mentat{msc_version}/bin/mentat'
menu_file = msc_root/f'mentat{msc_version}/menus/linux64/main.msb'
executable = marc_root/f'mentat{marc_version}/bin/mentat'
menu_file = marc_root/f'mentat{marc_version}/menus/linux64/main.msb'
os.system(f'xvfb-run -a {executable} -compile {menu_file}')

View File

@ -3,14 +3,14 @@ import shlex
import re
from pathlib import Path
_msc_version = 2021.2
_msc_root = '/opt/msc'
_marc_version = 2021.2
_marc_root = '/opt/msc'
_damask_root = str(Path(__file__).parents[3])
class Marc:
"""Wrapper to run DAMASK with MSC.Marc."""
"""Wrapper to run DAMASK with MSC Marc."""
def __init__(self,msc_version=_msc_version,msc_root=_msc_root,damask_root=_damask_root):
def __init__(self,marc_version=_marc_version,marc_root=_marc_root,damask_root=_damask_root):
"""
Create a Marc solver object.
@ -20,14 +20,14 @@ class Marc:
Marc version
"""
self.msc_version = msc_version
self.msc_root = Path(msc_root)
self.marc_version = marc_version
self.marc_root = Path(marc_root)
self.damask_root = Path(damask_root)
@property
def library_path(self):
path_lib = self.msc_root/f'mentat{self.msc_version}/shlib/linux64'
path_lib = self.marc_root/f'mentat{self.marc_version}/shlib/linux64'
if not path_lib.is_dir():
raise FileNotFoundError(f'library path "{path_lib}" not found')
@ -37,7 +37,7 @@ class Marc:
@property
def tools_path(self):
path_tools = self.msc_root/f'marc{self.msc_version}/tools'
path_tools = self.marc_root/f'marc{self.marc_version}/tools'
if not path_tools.is_dir():
raise FileNotFoundError(f'tools path "{path_tools}" not found')