From d5ab6e7b3157fdeeb7ceb849c0faf1af3e7fdd5f Mon Sep 17 00:00:00 2001 From: ageay Date: Tue, 4 Jun 2013 11:19:27 +0000 Subject: [PATCH] directory settings --- src/MEDLoader/Swig/CaseReader.py | 5 +++-- src/MEDLoader/Swig/case2med | 9 ++++++++- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/src/MEDLoader/Swig/CaseReader.py b/src/MEDLoader/Swig/CaseReader.py index d4593ddcf..2a67d420e 100644 --- a/src/MEDLoader/Swig/CaseReader.py +++ b/src/MEDLoader/Swig/CaseReader.py @@ -38,6 +38,7 @@ class CaseReader(CaseIO): def __init__(self,fileName): """ Constructor """ self._fileName=fileName + self._dirName=os.path.dirname(self._fileName) pass def __traduceMesh(self,name,typ,coords,cells): @@ -104,7 +105,7 @@ class CaseReader(CaseIO): def __convertGeo2MED(self,geoFileName): """ Convert all the geometry (all the meshes) contained in teh CASE file into MEDCouplingUMesh'es. """ - fd=open(geoFileName,"r+b") ; fd.seek(0,2) ; end=fd.tell() ; fd.seek(0) ; fd.readline() ; fd.readline() + fd=open(os.path.join(self._dirName,geoFileName),"r+b") ; fd.seek(0,2) ; end=fd.tell() ; fd.seek(0) ; fd.readline() ; fd.readline() name=fd.readline().strip() ; fd.readline() ; fd.readline() pos=fd.tell() mcmeshes=[] @@ -177,7 +178,7 @@ class CaseReader(CaseIO): stars=re.search("[\*]+",fileName).group() st="%0"+str(len(stars))+"i" trueFileName=fileName.replace(stars,st%(it)) - fd=open(trueFileName,"r+b") ; fd.seek(0,2) ; end=fd.tell() ; fd.seek(0) + fd=open(os.path.join(self._dirName,trueFileName),"r+b") ; fd.seek(0,2) ; end=fd.tell() ; fd.seek(0) name=fd.readline().strip().split(" ")[0] if name!=fieldName: raise Exception("ConvertField : mismatch") diff --git a/src/MEDLoader/Swig/case2med b/src/MEDLoader/Swig/case2med index 539fb2d41..b4281d776 100755 --- a/src/MEDLoader/Swig/case2med +++ b/src/MEDLoader/Swig/case2med @@ -25,6 +25,8 @@ import os parser = OptionParser() parser.set_usage("Convert a Case file to a MED file.\n %prog [options] case_file") +parser.add_option("-c", "--currentdir", action="store_true", dest="here", default=False, + help="Are generated MED file generated in current directory. By default not, MED file is generated in directory containing the input file (default False)") (opts, args) = parser.parse_args() if len(args) != 1: @@ -33,7 +35,12 @@ if len(args) != 1: pass fname=args[0] #"cas_test_simple.case" -fOut=os.path.splitext(fname)[0]+".med" +if opts.here: + fOut=os.path.splitext(os.path.basename(fname))[0]+".med" + pass +else: + fOut=os.path.splitext(fname)[0]+".med" + pass ### cr=CaseReader(fname) try: -- 2.39.2