fix pisitools and shelltools

This commit is contained in:
Safa Ariman
2019-08-04 17:35:59 +03:00
parent cfaae5471b
commit ba4b14741d
2 changed files with 32 additions and 1 deletions
+31
View File
@@ -282,3 +282,34 @@ def removeDir(destinationDirectory):
for directory in destdirGlob:
unlinkDir(directory)
class Flags:
def __init__(self, *evars):
self.evars = evars
def add(self, *flags):
for evar in self.evars:
os.environ[evar] = " ".join(os.environ[evar].split() + [f.strip() for f in flags])
def remove(self, *flags):
for evar in self.evars:
os.environ[evar] = " ".join([v for v in os.environ[evar].split() if v not in [f.strip() for f in flags]])
def replace(self, old_val, new_val):
for evar in self.evars:
os.environ[evar] = " ".join([new_val if v == old_val else v for v in os.environ[evar].split()])
def sub(self, pattern, repl, count=0, flags=0):
for evar in self.evars:
os.environ[evar] = re.sub(pattern, repl, os.environ[evar], count, flags)
def reset(self):
for evar in self.evars:
os.environ[evar] = ""
cflags = Flags("CFLAGS")
ldflags = Flags("LDFLAGS")
cxxflags = Flags("CXXFLAGS")
flags = Flags("CFLAGS", "CXXFLAGS")
+1 -1
View File
@@ -271,7 +271,7 @@ def dirName(filePath):
def system(command):
command = string.join(string.split(command))
command = ' '.join(command.split())
retValue = run_logged(command)
#if return value is different than 0, it means error, raise exception