From: vsr Date: Mon, 24 Sep 2012 08:33:43 +0000 (+0000) Subject: 0021781: [CEA 616] Suppress . in the user's config files X-Git-Tag: V6_6_0a1~31 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=f59d6f825228320ccf5b15e39905258cde70ffd1;p=modules%2Fkernel.git 0021781: [CEA 616] Suppress . in the user's config files --- diff --git a/bin/launchConfigureParser.py b/bin/launchConfigureParser.py index 5ffb99b98..1bb30d33a 100755 --- a/bin/launchConfigureParser.py +++ b/bin/launchConfigureParser.py @@ -122,11 +122,18 @@ def version_id(fname): if len(vers) > 0: major = int(vers[0]) if len(vers) > 1: minor = int(vers[1]) if len(vers) > 2: - mr = re.search(r'^([0-9]+)([A-Za-z]?)([0-9]*)',vers[2]) + mr = re.search(r'^([0-9]+)([A-Z]|RC)?([0-9]*)',vers[2], re.I) if mr: release = int(mr.group(1)) - if mr.group(2).strip(): dev1 = ord(mr.group(2).strip()) - if mr.group(3).strip(): dev2 = int(mr.group(3).strip()) + if mr.group(2): + tag = mr.group(2).strip().lower() + if tag == "rc": + dev1 = 49 # release candidate + elif tag: + dev1 = ord(tag)-ord('a')+1 + pass + if mr.group(3): + dev2 = int(mr.group(3).strip()) pass pass dev = dev1 * 100 + dev2 @@ -134,15 +141,15 @@ def version_id(fname): ver = ver * 100 + minor ver = ver * 100 + release ver = ver * 10000 - if dev > 0: ver = ver - 10000 + dev + if dev > 0: ver = ver - dev return ver ### # Get default user configuration file name # For SALOME, it is: -# - on Linux: ~/.config/salome/.SalomeApprc.[version] -# - on Windows: ~/SalomeApp.xml.[version] -# where [version] is a version number +# - on Linux: ~/.config/salome/SalomeApprc[.] +# - on Windows: ~/SalomeApp.xml[.] +# where is an optional version number ### def defaultUserFile(appname=salomeappname, cfgname=salomecfgname): v = version() @@ -151,7 +158,7 @@ def defaultUserFile(appname=salomeappname, cfgname=salomecfgname): filename = os.path.join(getHomeDir(), "%s.xml%s" % (appname, v)) else: if cfgname: - filename = os.path.join(getHomeDir(), ".config", cfgname, ".%src%s" % (appname, v)) + filename = os.path.join(getHomeDir(), ".config", cfgname, "%src%s" % (appname, v)) pass else: filename = os.path.join(getHomeDir(), ".%src%s" % (appname, v)) @@ -185,18 +192,25 @@ def userFile(appname, cfgname): files = glob.glob(os.path.join(getHomeDir(), "%s.xml.*" % appname)) else: files = [] - if cfgname: files += glob.glob(os.path.join(getHomeDir(), ".config", cfgname, ".%src.*" % appname)) - files += glob.glob(os.path.join(getHomeDir(), ".%src.*" % appname)) + if cfgname: + # Since v6.6.0 - in ~/.config/salome directory, without dot prefix + files += glob.glob(os.path.join(getHomeDir(), ".config", cfgname, "%src.*" % appname)) + # Since v6.5.0 - in ~/.config/salome directory, dot-prefixed (backward compatibility) + files += glob.glob(os.path.join(getHomeDir(), ".config", cfgname, ".%src.*" % appname)) + pass + # old style (before v6.5.0) - in ~ directory, dot-prefixed + files += glob.glob(os.path.join(getHomeDir(), ".%src.*" % appname)) pass # ... loop through all files and find most appopriate file (with closest id) appr_id = -1 appr_file = "" for f in files: + ff = os.path.basename( f ) if sys.platform == "win32": - match = re.search( r'%s\.xml\.([a-zA-Z0-9.]+)$'%appname, f ) + match = re.search( r'^%s\.xml\.([a-zA-Z0-9.]+)$'%appname, ff ) else: - match = re.search( r'\.%src\.([a-zA-Z0-9.]+)$'%appname, f ) + match = re.search( r'^\.?%src\.([a-zA-Z0-9.]+)$'%appname, ff ) if match: ver = version_id(match.group(1)) if not ver: continue # bad version id -> skip file @@ -204,6 +218,9 @@ def userFile(appname, cfgname): appr_id = ver appr_file = f pass + elif abs(appr_id-id0) == abs(ver-id0): + if not os.path.basename(f).startswith("."): appr_file = f + pass pass pass return appr_file