Fix PyLint duplicate-string-formatting-argument

This commit is contained in:
Pedro Algarvio 2019-12-03 17:00:37 +00:00
parent eeea9d93fa
commit fce524ee73
No known key found for this signature in database
GPG key ID: BB36BF6584A298FF
7 changed files with 21 additions and 52 deletions

View file

@ -698,7 +698,7 @@ def make_repo(repodir,
with salt.utils.files.fopen(repoconfopts, 'w') as fow:
fow.write(salt.utils.stringutils.to_str(repocfg_opts))
cmd = 'chown {0}:{1} -R {2}'.format(runas, runas, repoconf)
cmd = 'chown {0}:{0} -R {1}'.format(runas, repoconf)
retrc = __salt__['cmd.retcode'](cmd, runas='root')
if retrc != 0:
raise SaltInvocationError(

View file

@ -440,9 +440,8 @@ def get_ca(ca_name, as_text=False, cacert_path=None):
salt '*' tls.get_ca test_ca as_text=False cacert_path=/etc/certs
'''
set_ca_path(cacert_path)
certp = '{0}/{1}/{2}_ca_cert.crt'.format(
certp = '{0}/{1}/{1}_ca_cert.crt'.format(
cert_base_path(),
ca_name,
ca_name)
if not os.path.exists(certp):
raise ValueError('Certificate does not exist for {0}'.format(ca_name))
@ -821,8 +820,8 @@ def create_ca(ca_name,
ret = ('Created Private Key: "{0}/{1}/{2}.key." ').format(
cert_base_path(), ca_name, ca_filename)
ret += ('Created CA "{0}": "{1}/{2}/{3}.crt."').format(
ca_name, cert_base_path(), ca_name, ca_filename)
ret += ('Created CA "{0}": "{1}/{0}/{2}.crt."').format(
ca_name, cert_base_path(), ca_filename)
return ret
@ -1581,9 +1580,8 @@ def create_pkcs12(ca_name, CN, passphrase='', cacert_path=None, replace=False):
return 'Certificate "{0}" already exists'.format(CN)
try:
with salt.utils.files.fopen('{0}/{1}/{2}_ca_cert.crt'.format(cert_base_path(),
ca_name,
ca_name)) as fhr:
with salt.utils.files.fopen('{0}/{1}/{1}_ca_cert.crt'.format(cert_base_path(),
ca_name)) as fhr:
ca_cert = OpenSSL.crypto.load_certificate(
OpenSSL.crypto.FILETYPE_PEM,
fhr.read()
@ -1625,11 +1623,10 @@ def create_pkcs12(ca_name, CN, passphrase='', cacert_path=None, replace=False):
)
return ('Created PKCS#12 Certificate for "{0}": '
'"{1}/{2}/certs/{3}.p12"').format(
'"{1}/{2}/certs/{0}.p12"').format(
CN,
cert_base_path(),
ca_name,
CN
)

View file

@ -429,7 +429,7 @@ def _make_regex(pem_type):
r"(?:(?P<proc_type>Proc-Type: 4,ENCRYPTED)\s*)?"
r"(?:(?P<dek_info>DEK-Info: (?:DES-[3A-Z\-]+,[0-9A-F]{{16}}|[0-9A-Z\-]+,[0-9A-F]{{32}}))\s*)?"
r"(?P<pem_body>.+?)\s+(?P<pem_footer>"
r"-----END {1}-----)\s*".format(pem_type, pem_type),
r"-----END {0}-----)\s*".format(pem_type),
re.DOTALL
)

View file

@ -79,7 +79,7 @@ def __init__(opts):
MOD_BASENAME = os.path.basename(__file__)
INVALID_USAGE_ERROR = SaltRenderError(
'Invalid use of {0} renderer!\n'
'''Usage: #!{1} [-GoSp] [<data_renderer> [options] . <template_renderer> [options]]
'''Usage: #!{0} [-GoSp] [<data_renderer> [options] . <template_renderer> [options]]
where an example <data_renderer> would be yaml and a <template_renderer> might
be jinja. Each renderer can be passed its renderer specific options.
@ -99,7 +99,7 @@ Options(for this renderer):
in the sls will have no effect, but other features of the renderer still
apply.
'''.format(MOD_BASENAME, MOD_BASENAME)
'''.format(MOD_BASENAME)
)

View file

@ -240,11 +240,8 @@ def get_fun(fun):
options['db'] +
('/_design/salt/_view/by-minion-fun-times'
'tamp?descending=true&endkey=["{0}","{1}'
'",0]&startkey=["{2}","{3}",9999999999]&'
'limit=1').format(minion,
fun,
minion,
fun))
'",0]&startkey=["{0}","{1}",9999999999]&'
'limit=1').format(minion, fun))
# Skip the minion if we got an error..
if 'error' in _response:
log.warning(

View file

@ -200,10 +200,7 @@ class TLSAddTestCase(TestCase, LoaderModuleMockMixin):
'''
ca_path = '/tmp/test_tls'
ca_name = 'test_ca'
certp = '{0}/{1}/{2}_ca_cert.crt'.format(
ca_path,
ca_name,
ca_name)
certp = '{0}/{1}/{1}_ca_cert.crt'.format(ca_path, ca_name)
mock_opt = MagicMock(return_value=ca_path)
with patch.dict(tls.__salt__, {'config.option': mock_opt}), \
patch('os.path.exists', MagicMock(return_value=True)), \
@ -221,10 +218,7 @@ class TLSAddTestCase(TestCase, LoaderModuleMockMixin):
MagicMock(return_value=True)):
ca_path = '/tmp/test_tls'
ca_name = 'test_ca'
certp = '{0}/{1}/{2}_ca_cert.crt'.format(
ca_path,
ca_name,
ca_name)
certp = '{0}/{1}/{1}_ca_cert.crt'.format(ca_path, ca_name)
ret = {
'not_after': 1462379961,
'signature_algorithm': 'sha256WithRSAEncryption',
@ -309,14 +303,8 @@ class TLSAddTestCase(TestCase, LoaderModuleMockMixin):
Test creating CA cert
'''
ca_name = 'test_ca'
certp = '{0}/{1}/{2}_ca_cert.crt'.format(
ca_path,
ca_name,
ca_name)
certk = '{0}/{1}/{2}_ca_cert.key'.format(
ca_path,
ca_name,
ca_name)
certp = '{0}/{1}/{1}_ca_cert.crt'.format(ca_path, ca_name)
certk = '{0}/{1}/{1}_ca_cert.key'.format(ca_path, ca_name)
ret = 'Created Private Key: "{0}." Created CA "{1}": "{2}."'.format(
certk, ca_name, certp)
mock_opt = MagicMock(return_value=ca_path)
@ -339,14 +327,8 @@ class TLSAddTestCase(TestCase, LoaderModuleMockMixin):
Test creating CA cert when one already exists
'''
ca_name = 'test_ca'
certp = '{0}/{1}/{2}_ca_cert.crt'.format(
ca_path,
ca_name,
ca_name)
certk = '{0}/{1}/{2}_ca_cert.key'.format(
ca_path,
ca_name,
ca_name)
certp = '{0}/{1}/{1}_ca_cert.crt'.format(ca_path, ca_name)
certk = '{0}/{1}/{1}_ca_cert.key'.format(ca_path, ca_name)
ret = 'Created Private Key: "{0}." Created CA "{1}": "{2}."'.format(
certk, ca_name, certp)
mock_opt = MagicMock(return_value=ca_path)
@ -663,14 +645,8 @@ class TLSAddTestCase(TestCase, LoaderModuleMockMixin):
pillarval = {'csr': {'extendedKeyUsage': 'serverAuth'}}
mock_pgt = MagicMock(return_value=pillarval)
ca_name = 'test_ca'
certp = '{0}/{1}/{2}_ca_cert.crt'.format(
ca_path,
ca_name,
ca_name)
certk = '{0}/{1}/{2}_ca_cert.key'.format(
ca_path,
ca_name,
ca_name)
certp = '{0}/{1}/{1}_ca_cert.crt'.format(ca_path, ca_name)
certk = '{0}/{1}/{1}_ca_cert.key'.format(ca_path, ca_name)
ret = 'Created Private Key: "{0}." Created CA "{1}": "{2}."'.format(
certk, ca_name, certp)
mock_opt = MagicMock(return_value=ca_path)

View file

@ -1067,8 +1067,7 @@ class TestFileState(TestCase, LoaderModuleMockMixin):
with patch.object(salt.utils.files, 'mkstemp',
return_value=name):
comt = ('Unable to copy file {0} to {0}: '
.format(name))
comt = 'Unable to copy file {0} to {0}: '.format(name)
ret.update({'comment': comt, 'result': False})
self.assertDictEqual(filestate.managed
(name, user=user,