Collated PEP8 fixes (#25293)

- Make PEP8 compliant
This commit is contained in:
Dag Wieers
2017-06-02 13:14:11 +02:00
committed by John R Barker
parent 2f33c1a1a1
commit 5553b20828
206 changed files with 1853 additions and 1870 deletions

View File

@@ -36,16 +36,16 @@ class ShellBase(object):
if C.DEFAULT_MODULE_SET_LOCALE:
self.env.update(
dict(
LANG = C.DEFAULT_MODULE_LANG,
LC_ALL = C.DEFAULT_MODULE_LANG,
LC_MESSAGES = C.DEFAULT_MODULE_LANG,
LANG=C.DEFAULT_MODULE_LANG,
LC_ALL=C.DEFAULT_MODULE_LANG,
LC_MESSAGES=C.DEFAULT_MODULE_LANG,
)
)
def env_prefix(self, **kwargs):
env = self.env.copy()
env.update(kwargs)
return ' '.join(['%s=%s' % (k, shlex_quote(text_type(v))) for k,v in env.items()])
return ' '.join(['%s=%s' % (k, shlex_quote(text_type(v))) for k, v in env.items()])
def join_path(self, *args):
return os.path.join(*args)

View File

@@ -19,6 +19,7 @@ __metaclass__ = type
from ansible.plugins.shell import ShellBase
class ShellModule(ShellBase):
# Common shell filenames that this plugin handles

View File

@@ -41,7 +41,7 @@ class ShellModule(ShModule):
def env_prefix(self, **kwargs):
env = self.env.copy()
env.update(kwargs)
return ' '.join(['set -lx %s %s;' % (k, shlex_quote(text_type(v))) for k,v in env.items()])
return ' '.join(['set -lx %s %s;' % (k, shlex_quote(text_type(v))) for k, v in env.items()])
def build_module_command(self, env_string, shebang, cmd, arg_path=None, rm_tmp=None):
# don't quote the cmd if it's an empty string, because this will break pipelining mode

View File

@@ -95,7 +95,7 @@ end {
Write-Output $output
}
''' # end exec_wrapper
''' # end exec_wrapper
leaf_exec = br'''
Function Run($payload) {
@@ -144,7 +144,7 @@ Function Run($payload) {
$host.SetShouldExit($exit_code)
}
}
''' # end leaf_exec
''' # end leaf_exec
become_wrapper = br'''
@@ -434,7 +434,7 @@ Function Run($payload) {
}
''' # end become_wrapper
''' # end become_wrapper
async_wrapper = br'''
@@ -836,7 +836,7 @@ Function Run($payload) {
return $result_json
}
''' # end async_wrapper
''' # end async_wrapper
async_watchdog = br'''
Set-StrictMode -Version 2
@@ -964,7 +964,8 @@ Function Run($payload) {
#$rs.Close() | Out-Null
}
''' # end async_watchdog
''' # end async_watchdog
class ShellModule(object):
@@ -1184,7 +1185,10 @@ class ShellModule(object):
subs.append(('$', '`$'))
pattern = '|'.join('(%s)' % re.escape(p) for p, s in subs)
substs = [s for p, s in subs]
replace = lambda m: substs[m.lastindex - 1]
def replace(m):
return substs[m.lastindex - 1]
return re.sub(pattern, replace, value)
def _encode_script(self, script, as_list=False, strict_mode=True, preserve_rc=True):

View File

@@ -41,7 +41,6 @@ class ShellModule(ShellBase):
_SHELL_GROUP_LEFT = '('
_SHELL_GROUP_RIGHT = ')'
def checksum(self, path, python_interp):
# The following test needs to be SH-compliant. BASH-isms will
# not work if /bin/sh points to a non-BASH shell.
@@ -81,4 +80,3 @@ class ShellModule(ShellBase):
cmd = (" %s " % self._SHELL_OR).join(csums)
cmd = "%s; %s %s (echo \'0 \'%s)" % (test, cmd, self._SHELL_OR, shell_escaped_path)
return cmd