From 59782412a11ad6a7cee7f2176dba38f4c6026fc0 Mon Sep 17 00:00:00 2001 From: crouzet Date: Tue, 16 Jul 2019 15:39:18 +0200 Subject: [PATCH] =?utf8?q?petit=20correctif=20suite=20=C3=A0=20discussion?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- src/compilation.py | 2 +- src/environment.py | 34 +++++++--------------- src/fileEnviron.py | 72 +++++++++++++--------------------------------- 3 files changed, 31 insertions(+), 77 deletions(-) diff --git a/src/compilation.py b/src/compilation.py index 7eb5071..b8b8ce0 100644 --- a/src/compilation.py +++ b/src/compilation.py @@ -284,7 +284,7 @@ CC=\\"hack_libtool\\"%g" libtool''' ## # Runs 'make install'. def install(self): - if self.config.VARS.dist_name==distrib_cfg.DISTRIBUTIONS["Windows"]: + if src.architecture.is_windows(): command = 'msbuild INSTALL.vcxproj' if self.debug_mode: command = command + " /p:Configuration=Debug /p:Platform=x64 " diff --git a/src/environment.py b/src/environment.py index ae27354..08565ce 100644 --- a/src/environment.py +++ b/src/environment.py @@ -73,18 +73,11 @@ class Environ: :param value str: the value to append to key :param sep str: the separator string """ - if src.architecture.is_windows(): - separators = [';'] - else: - separators = [':'] - for c in separators: # windows or linux path separators - isOK = True - if c in value and not src.architecture.is_windows(): - isOK = False - elif c in value and src.architecture.is_windows() and value.count(':') > 1: - isOK = False - if not isOK: - raise Exception("Environ append key '%s' value '%s' contains forbidden character '%s'" % (key, value, c)) + # check that value so no contain the system separator + separator=os.pathsep + if separator in value: + raise Exception("Environ append key '%s' value '%s' contains forbidden character '%s'" % (key, value, separator)) + # check if the key is already in the environment if key in self.environ: value_list = self.environ[key].split(sep) @@ -120,18 +113,11 @@ class Environ: :param value str: the value to prepend to key :param sep str: the separator string """ - if src.architecture.is_windows(): - separators = [';'] - else: - separators = [':'] - for c in separators: # windows or linux path separators - isOK = True - if c in value and not src.architecture.is_windows(): - isOK = False - elif c in value and src.architecture.is_windows() and value.count(':') > 1: - isOK = False - if not isOK: - raise Exception("Environ prepend key '%s' value '%s' contains forbidden character '%s'" % (key, value, c)) + # check that value so no contain the system separator + separator=os.pathsep + if separator in value: + raise Exception("Environ append key '%s' value '%s' contains forbidden character '%s'" % (key, value, separator)) + # check if the key is already in the environment if key in self.environ: value_list = self.environ[key].split(sep) diff --git a/src/fileEnviron.py b/src/fileEnviron.py index 851b7c9..8061c44 100644 --- a/src/fileEnviron.py +++ b/src/fileEnviron.py @@ -181,19 +181,11 @@ class FileEnviron(object): :param value str: the value to append to key :param sep str: the separator string """ - separators = [] - if src.architecture.is_windows(): - separators = [':'] - else: - separators = [';'] - for c in separators: # windows or linux path separators - isOK = True - if c in value and not src.architecture.is_windows(): - isOK = False - elif c in value and src.architecture.is_windows() and value.count(':') > 1: - isOK = False - if not isOK: - raise Exception("FileEnviron append key '%s' value '%s' contains forbidden character '%s'" % (key, value, c)) + # check that value so no contain the system separator + separator=os.pathsep + if separator in value: + raise Exception("FileEnviron append key '%s' value '%s' contains forbidden character '%s'" % (key, value, separator)) + self.set(key, self.get(key) + sep + value) if (key, sep) not in self.toclean: self.toclean.append((key, sep)) @@ -221,19 +213,11 @@ class FileEnviron(object): :param value str: the value to prepend to key :param sep str: the separator string """ - separators = [] - if src.architecture.is_windows(): - separators = [':'] - else: - separators = [';'] - for c in separators: # windows or linux path separators - isOK = True - if c in value and not src.architecture.is_windows(): - isOK = False - elif c in value and src.architecture.is_windows() and value.count(':') > 1: - isOK = False - if not isOK: - raise Exception("FileEnviron prepend key '%s' value '%s' contains forbidden character '%s'" % (key, value, c)) + # check that value so no contain the system separator + separator=os.pathsep + if separator in value: + raise Exception("FileEnviron append key '%s' value '%s' contains forbidden character '%s'" % (key, value, separator)) + self.set(key, value + sep + self.get(key)) if (key, sep) not in self.toclean: self.toclean.append((key, sep)) @@ -576,19 +560,11 @@ class LauncherFileEnviron: :param value str: the value to append to key :param sep str: the separator string """ - separators = [] - if src.architecture.is_windows(): - separators = [':'] - else: - separators = [';'] - for c in separators: # windows or linux path separators - isOK = True - if c in value and not src.architecture.is_windows(): - isOK = False - elif c in value and src.architecture.is_windows() and value.count(':') > 1: - isOK = False - if not isOK: - raise Exception("LauncherFileEnviron append key '%s' value '%s' contains forbidden character '%s'" % (key, value, c)) + # check that value so no contain the system separator + separator=os.pathsep + if separator in value: + raise Exception("LauncherFileEnviron append key '%s' value '%s' contains forbidden character '%s'" % (key, value, separator)) + if self.is_defined(key) : self.add(key, value) else : @@ -615,19 +591,11 @@ class LauncherFileEnviron: :param value str: the value to prepend to key :param sep str: the separator string """ - separators = [] - if src.architecture.is_windows(): - separators = [':'] - else: - separators = [';'] - for c in separators: # windows or linux path separators - isOK = True - if c in value and not src.architecture.is_windows(): - isOK = False - elif c in value and src.architecture.is_windows() and value.count(':') > 1: - isOK = False - if not isOK: - raise Exception("LauncherFileEnviron prepend key '%s' value '%s' contains forbidden character '%s'" % (key, value, c)) + # check that value so no contain the system separator + separator=os.pathsep + if separator in value: + raise Exception("LauncherFileEnviron append key '%s' value '%s' contains forbidden character '%s'" % (key, value, separator)) + if self.is_defined(key) : self.add(key, value) else : -- 2.30.2