appeasing flake8 in environment
This commit is contained in:
parent
0668b6d7ba
commit
df30182a10
@ -64,7 +64,8 @@ def execute(self):
|
|||||||
class AppendPath(NameValueModifier):
|
class AppendPath(NameValueModifier):
|
||||||
def execute(self):
|
def execute(self):
|
||||||
environment_value = os.environ.get(self.name, '')
|
environment_value = os.environ.get(self.name, '')
|
||||||
directories = environment_value.split(self.separator) if environment_value else []
|
directories = environment_value.split(
|
||||||
|
self.separator) if environment_value else []
|
||||||
directories.append(os.path.normpath(self.value))
|
directories.append(os.path.normpath(self.value))
|
||||||
os.environ[self.name] = self.separator.join(directories)
|
os.environ[self.name] = self.separator.join(directories)
|
||||||
|
|
||||||
@ -72,7 +73,8 @@ def execute(self):
|
|||||||
class PrependPath(NameValueModifier):
|
class PrependPath(NameValueModifier):
|
||||||
def execute(self):
|
def execute(self):
|
||||||
environment_value = os.environ.get(self.name, '')
|
environment_value = os.environ.get(self.name, '')
|
||||||
directories = environment_value.split(self.separator) if environment_value else []
|
directories = environment_value.split(
|
||||||
|
self.separator) if environment_value else []
|
||||||
directories = [os.path.normpath(self.value)] + directories
|
directories = [os.path.normpath(self.value)] + directories
|
||||||
os.environ[self.name] = self.separator.join(directories)
|
os.environ[self.name] = self.separator.join(directories)
|
||||||
|
|
||||||
@ -80,9 +82,9 @@ def execute(self):
|
|||||||
class RemovePath(NameValueModifier):
|
class RemovePath(NameValueModifier):
|
||||||
def execute(self):
|
def execute(self):
|
||||||
environment_value = os.environ.get(self.name, '')
|
environment_value = os.environ.get(self.name, '')
|
||||||
directories = environment_value.split(self.separator) if environment_value else []
|
directories = environment_value.split(
|
||||||
directories = [os.path.normpath(x)
|
self.separator) if environment_value else []
|
||||||
for x in directories
|
directories = [os.path.normpath(x) for x in directories
|
||||||
if x != os.path.normpath(self.value)]
|
if x != os.path.normpath(self.value)]
|
||||||
os.environ[self.name] = self.separator.join(directories)
|
os.environ[self.name] = self.separator.join(directories)
|
||||||
|
|
||||||
@ -257,16 +259,13 @@ def set_or_unset_not_first(variable, changes, errstream):
|
|||||||
Check if we are going to set or unset something after other modifications
|
Check if we are going to set or unset something after other modifications
|
||||||
have already been requested
|
have already been requested
|
||||||
"""
|
"""
|
||||||
indexes = [ii
|
indexes = [ii for ii, item in enumerate(changes)
|
||||||
for ii, item in enumerate(changes)
|
|
||||||
if ii != 0 and type(item) in [SetEnv, UnsetEnv]]
|
if ii != 0 and type(item) in [SetEnv, UnsetEnv]]
|
||||||
if indexes:
|
if indexes:
|
||||||
good = '\t \t{context} at {filename}:{lineno}'
|
good = '\t \t{context} at {filename}:{lineno}'
|
||||||
nogood = '\t--->\t{context} at {filename}:{lineno}'
|
nogood = '\t--->\t{context} at {filename}:{lineno}'
|
||||||
message = 'Suspicious requests to set or unset the variable \'{var}\' found' # NOQA: ignore=E501
|
message = 'Suspicious requests to set or unset the variable \'{var}\' found' # NOQA: ignore=E501
|
||||||
errstream(
|
errstream(message.format(var=variable))
|
||||||
message.format(
|
|
||||||
var=variable))
|
|
||||||
for ii, item in enumerate(changes):
|
for ii, item in enumerate(changes):
|
||||||
print_format = nogood if ii in indexes else good
|
print_format = nogood if ii in indexes else good
|
||||||
errstream(print_format.format(**item.args))
|
errstream(print_format.format(**item.args))
|
||||||
|
Loading…
Reference in New Issue
Block a user