Skip to content

Commit e00b921

Browse files
author
caberos
committed
fix Christopher code review
1 parent d68cef3 commit e00b921

File tree

1 file changed

+22
-8
lines changed

1 file changed

+22
-8
lines changed

SoftLayer/CLI/hardware/create_options.py

Lines changed: 22 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ def _preset_prices_table(sizes, tables):
8181
preset_prices_table.sortby = 'Value'
8282
preset_prices_table.align = 'l'
8383
for size in sizes:
84-
if ("%.4f" % size['hourlyRecurringFee'] != '0.0000') or ("%.4f" % size['recurringFee'] != '0.0000'):
84+
if (_verify_prices("%.4f" % size['hourlyRecurringFee'])) or (_verify_prices("%.4f" % size['recurringFee'])):
8585
preset_prices_table.add_row([size['name'], size['key'], "%.4f" % size['hourlyRecurringFee'],
8686
"%.4f" % size['recurringFee']])
8787
tables.append(preset_prices_table)
@@ -99,8 +99,8 @@ def _os_prices_table(operating_systems, tables):
9999
os_prices_table.align = 'l'
100100
for operating_system in operating_systems:
101101
for price in operating_system['prices']:
102-
if (_get_price_data(price, 'hourlyRecurringFee') != '0') or (
103-
_get_price_data(price, 'recurringFee') != '0'):
102+
if (_verify_prices(_get_price_data(price, 'hourlyRecurringFee'))) or (
103+
_verify_prices(_get_price_data(price, 'recurringFee'))):
104104
cr_max = _get_price_data(price, 'capacityRestrictionMaximum')
105105
cr_min = _get_price_data(price, 'capacityRestrictionMinimum')
106106
cr_type = _get_price_data(price, 'capacityRestrictionType')
@@ -124,8 +124,8 @@ def _port_speed_prices_table(port_speeds, tables):
124124
port_speed_prices_table.align = 'l'
125125
for speed in port_speeds:
126126
for price in speed['prices']:
127-
if (_get_price_data(price, 'hourlyRecurringFee') != '0') or (
128-
_get_price_data(price, 'recurringFee') != '0'):
127+
if (_verify_prices(_get_price_data(price, 'hourlyRecurringFee'))) or (
128+
_verify_prices(_get_price_data(price, 'recurringFee'))):
129129
cr_max = _get_price_data(price, 'capacityRestrictionMaximum')
130130
cr_min = _get_price_data(price, 'capacityRestrictionMinimum')
131131
cr_type = _get_price_data(price, 'capacityRestrictionType')
@@ -137,6 +137,19 @@ def _port_speed_prices_table(port_speeds, tables):
137137
tables.append(port_speed_prices_table)
138138

139139

140+
def _verify_prices(prices):
141+
"""Verify the prices is higher to zero(0) or is '-'.
142+
143+
param prices: value to verify.
144+
Returns: true false.
145+
146+
"""
147+
if prices == '-':
148+
return True
149+
else:
150+
return float(prices) > 0
151+
152+
140153
def _extras_prices_table(extras, tables):
141154
"""Shows Server extras prices cost and capacity restriction.
142155
@@ -148,8 +161,8 @@ def _extras_prices_table(extras, tables):
148161
extras_prices_table.align = 'l'
149162
for extra in extras:
150163
for price in extra['prices']:
151-
if (_get_price_data(price, 'hourlyRecurringFee') != '0') or (
152-
_get_price_data(price, 'recurringFee') != '0'):
164+
if (_verify_prices(_get_price_data(price, 'hourlyRecurringFee'))) or (
165+
_verify_prices(_get_price_data(price, 'recurringFee'))):
153166
cr_max = _get_price_data(price, 'capacityRestrictionMaximum')
154167
cr_min = _get_price_data(price, 'capacityRestrictionMinimum')
155168
cr_type = _get_price_data(price, 'capacityRestrictionType')
@@ -183,7 +196,8 @@ def _location_item_prices(location_prices, tables):
183196
location_prices_table.sortby = 'keyName'
184197
location_prices_table.align = 'l'
185198
for price in location_prices:
186-
if (_get_price_data(price, 'hourlyRecurringFee') != '0') or (_get_price_data(price, 'recurringFee') != '0'):
199+
if (_verify_prices(_get_price_data(price, 'hourlyRecurringFee'))) or (
200+
_verify_prices(_get_price_data(price, 'recurringFee'))):
187201
cr_max = _get_price_data(price, 'capacityRestrictionMaximum')
188202
cr_min = _get_price_data(price, 'capacityRestrictionMinimum')
189203
cr_type = _get_price_data(price, 'capacityRestrictionType')

0 commit comments

Comments
 (0)