X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2F__init__.py;h=fb5316936c1d56348647adfde5c5f649821eef05;hb=d0af985239882d85f2b5d8ef75ed230102e78ed8;hp=7a4ac04af6224aa37a7cfb13a3d6c320e771ba2d;hpb=7a3cc682bb0557c0450fd2f594afc1aa568d8f84;p=tools%2Fsat.git diff --git a/src/__init__.py b/src/__init__.py index 7a4ac04..fb53169 100644 --- a/src/__init__.py +++ b/src/__init__.py @@ -33,6 +33,7 @@ from . import environment from . import fileEnviron from . import compilation from . import test_module +from . import template OK_STATUS = "OK" KO_STATUS = "KO" @@ -119,12 +120,14 @@ def get_base_path(config): :return: The path of the product base. :rtype: str ''' - if "base" in config.SITE: - base_path = config.SITE.base - else: - # default base - base_path = config.USER.base - return base_path + if "base" not in config.SITE: + site_file_path = os.path.join(config.VARS.salometoolsway, + "data", + "site.pyconf") + msg = _("Please define a base path in the file %s" % site_file_path) + raise SatException(msg) + + return config.SITE.base def get_salome_version(config): if hasattr(config.APPLICATION, 'version_salome'): @@ -190,6 +193,9 @@ class Path: def isdir(self): return os.path.isdir(self.path) + def isfile(self): + return os.path.isfile(self.path) + def list(self): return [Path(p) for p in os.listdir(self.path)] @@ -342,3 +348,14 @@ def merge_dicts(*dict_args): for dictionary in dict_args: result.update(dictionary) return result + +def replace_in_file(filein, strin, strout): + '''Replace by in file + ''' + shutil.move(filein, filein + "_old") + fileout= filein + filein = filein + "_old" + fin = open(filein, "r") + fout = open(fileout, "w") + for line in fin: + fout.write(line.replace(strin, strout)) \ No newline at end of file