Skip to content

Commit 9e676af

Browse files
Merge pull request #1510 from FernandoOjeda/ft/fix_analysis_issues
Fix Tox-analysis issues.
2 parents f26454a + 4af46bd commit 9e676af

File tree

11 files changed

+50
-42
lines changed

11 files changed

+50
-42
lines changed

SoftLayer/CLI/block/count.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,6 @@ def cli(env, sortby, datacenter):
3737

3838
table = formatting.KeyValueTable(DEFAULT_COLUMNS)
3939
table.sortby = sortby
40-
for datacenter_name in datacenters:
41-
table.add_row([datacenter_name, datacenters[datacenter_name]])
40+
for key, value in datacenters.items():
41+
table.add_row([key, value])
4242
env.fout(table)

SoftLayer/CLI/core.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -54,17 +54,17 @@ def list_commands(self, ctx):
5454

5555
return sorted(env.list_commands(*self.path))
5656

57-
def get_command(self, ctx, name):
57+
def get_command(self, ctx, cmd_name):
5858
"""Get command for click."""
5959
env = ctx.ensure_object(environment.Environment)
6060
env.load()
6161

6262
# Do alias lookup (only available for root commands)
6363
if len(self.path) == 0:
64-
name = env.resolve_alias(name)
64+
cmd_name = env.resolve_alias(cmd_name)
6565

6666
new_path = list(self.path)
67-
new_path.append(name)
67+
new_path.append(cmd_name)
6868
module = env.get_command(*new_path)
6969
if isinstance(module, types.ModuleType):
7070
return CommandLoader(*new_path, help=module.__doc__ or '')

SoftLayer/CLI/file/count.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,6 @@ def cli(env, sortby, datacenter):
3636

3737
table = formatting.KeyValueTable(DEFAULT_COLUMNS)
3838
table.sortby = sortby
39-
for datacenter_name in datacenters:
40-
table.add_row([datacenter_name, datacenters[datacenter_name]])
39+
for key, value in datacenters.items():
40+
table.add_row([key, value])
4141
env.fout(table)

SoftLayer/CLI/formatting.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -248,11 +248,11 @@ def __str__(self):
248248
class CLIJSONEncoder(json.JSONEncoder):
249249
"""A JSON encoder which is able to use a .to_python() method on objects."""
250250

251-
def default(self, obj):
251+
def default(self, o):
252252
"""Encode object if it implements to_python()."""
253-
if hasattr(obj, 'to_python'):
254-
return obj.to_python()
255-
return super().default(obj)
253+
if hasattr(o, 'to_python'):
254+
return o.to_python()
255+
return super().default(o)
256256

257257

258258
class Table(object):

SoftLayer/CLI/loadbal/detail.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -83,8 +83,8 @@ def lbaas_table(this_lb):
8383

8484
# https://sldn.softlayer.com/reference/datatypes/SoftLayer_Network_LBaaS_Member/
8585
member_col = ['UUID', 'Address', 'Weight', 'Modify', 'Active']
86-
for uuid in pools:
87-
member_col.append(pools[uuid])
86+
for uuid in pools.values():
87+
member_col.append(uuid)
8888
member_table = formatting.Table(member_col)
8989
for member in this_lb.get('members', []):
9090
row = [

SoftLayer/CLI/loadbal/pools.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -114,9 +114,9 @@ def edit(env, identifier, listener, **args):
114114
'sslcert': 'tlsCertificateId'
115115
}
116116

117-
for arg in args:
118-
if args[arg]:
119-
new_listener[arg_to_option[arg]] = args[arg]
117+
for key, value in args.items():
118+
if value:
119+
new_listener[arg_to_option[key]] = value
120120

121121
try:
122122
mgr.add_lb_listener(uuid, new_listener)

SoftLayer/CLI/ssl/add.py

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -28,15 +28,19 @@ def cli(env, crt, csr, icc, key, notes):
2828
'certificateSigningRequest': '',
2929
'notes': notes,
3030
}
31-
template['certificate'] = open(crt).read()
32-
template['privateKey'] = open(key).read()
33-
if csr:
34-
body = open(csr).read()
35-
template['certificateSigningRequest'] = body
31+
with open(crt) as file_crt:
32+
template['certificate'] = file_crt.read()
33+
with open(key) as file_key:
34+
template['privateKey'] = file_key.read()
35+
with open(csr) as file_csr:
36+
if csr:
37+
body = file_csr.read()
38+
template['certificateSigningRequest'] = body
3639

37-
if icc:
38-
body = open(icc).read()
39-
template['intermediateCertificate'] = body
40+
with open(icc) as file_icc:
41+
if icc:
42+
body = file_icc.read()
43+
template['intermediateCertificate'] = body
4044

4145
manager = SoftLayer.SSLManager(env.client)
4246
manager.add_certificate(template)

SoftLayer/CLI/ssl/edit.py

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -24,14 +24,18 @@
2424
def cli(env, identifier, crt, csr, icc, key, notes):
2525
"""Edit SSL certificate."""
2626
template = {'id': identifier}
27-
if crt:
28-
template['certificate'] = open(crt).read()
29-
if key:
30-
template['privateKey'] = open(key).read()
31-
if csr:
32-
template['certificateSigningRequest'] = open(csr).read()
33-
if icc:
34-
template['intermediateCertificate'] = open(icc).read()
27+
with open(crt) as file_crt:
28+
if crt:
29+
template['certificate'] = file_crt.read()
30+
with open(key) as file_key:
31+
if key:
32+
template['privateKey'] = file_key.read()
33+
with open(csr) as file_csr:
34+
if csr:
35+
template['certificateSigningRequest'] = file_csr.read()
36+
with open(icc) as file_icc:
37+
if icc:
38+
template['intermediateCertificate'] = file_icc.read()
3539
if notes:
3640
template['notes'] = notes
3741

SoftLayer/CLI/template.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -24,11 +24,11 @@ def __call__(self, ctx, param, value):
2424
if value is None:
2525
return
2626

27-
config = configparser.ConfigParser()
28-
ini_str = '[settings]\n' + open(
29-
os.path.expanduser(value), 'r').read()
30-
ini_fp = io.StringIO(ini_str)
31-
config.read_file(ini_fp)
27+
with open(os.path.expanduser(value), 'r') as file_handle:
28+
config = configparser.ConfigParser()
29+
ini_str = '[settings]\n' + file_handle.read()
30+
ini_fp = io.StringIO(ini_str)
31+
config.read_file(ini_fp)
3232

3333
# Merge template options with the options passed in
3434
args = {}

SoftLayer/CLI/virt/bandwidth.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -71,15 +71,15 @@ def create_bandwidth_table(data, summary_period, title="Bandwidth Report"):
7171
{'keyName': 'privateOut_net_octet', 'sum': 0.0, 'max': 0, 'name': 'Pri Out'},
7272
]
7373

74-
for point in formatted_data:
75-
new_row = [point]
74+
for key, value in formatted_data.items():
75+
new_row = [key]
7676
for bw_type in bw_totals:
77-
counter = formatted_data[point].get(bw_type['keyName'], 0)
77+
counter = value.get(bw_type['keyName'], 0)
7878
new_row.append(mb_to_gb(counter))
7979
bw_type['sum'] = bw_type['sum'] + counter
8080
if counter > bw_type['max']:
8181
bw_type['max'] = counter
82-
bw_type['maxDate'] = point
82+
bw_type['maxDate'] = key
8383
table.add_row(new_row)
8484

8585
for bw_type in bw_totals:

0 commit comments

Comments
 (0)