@@ -81,8 +81,9 @@ def _preset_prices_table(sizes, tables):
8181 preset_prices_table .sortby = 'Value'
8282 preset_prices_table .align = 'l'
8383 for size in sizes :
84- preset_prices_table .add_row ([size ['name' ], size ['key' ], "%.4f" % size ['hourlyRecurringFee' ],
85- "%.4f" % size ['recurringFee' ]])
84+ if (_verify_prices ("%.4f" % size ['hourlyRecurringFee' ])) or (_verify_prices ("%.4f" % size ['recurringFee' ])):
85+ preset_prices_table .add_row ([size ['name' ], size ['key' ], "%.4f" % size ['hourlyRecurringFee' ],
86+ "%.4f" % size ['recurringFee' ]])
8687 tables .append (preset_prices_table )
8788
8889
@@ -98,14 +99,16 @@ def _os_prices_table(operating_systems, tables):
9899 os_prices_table .align = 'l'
99100 for operating_system in operating_systems :
100101 for price in operating_system ['prices' ]:
101- cr_max = _get_price_data (price , 'capacityRestrictionMaximum' )
102- cr_min = _get_price_data (price , 'capacityRestrictionMinimum' )
103- cr_type = _get_price_data (price , 'capacityRestrictionType' )
104- os_prices_table .add_row (
105- [operating_system ['key' ],
106- _get_price_data (price , 'hourlyRecurringFee' ),
107- _get_price_data (price , 'recurringFee' ),
108- "%s - %s %s" % (cr_min , cr_max , cr_type )])
102+ if (_verify_prices (_get_price_data (price , 'hourlyRecurringFee' ))) or (
103+ _verify_prices (_get_price_data (price , 'recurringFee' ))):
104+ cr_max = _get_price_data (price , 'capacityRestrictionMaximum' )
105+ cr_min = _get_price_data (price , 'capacityRestrictionMinimum' )
106+ cr_type = _get_price_data (price , 'capacityRestrictionType' )
107+ os_prices_table .add_row (
108+ [operating_system ['key' ],
109+ _get_price_data (price , 'hourlyRecurringFee' ),
110+ _get_price_data (price , 'recurringFee' ),
111+ "%s - %s %s" % (cr_min , cr_max , cr_type )])
109112 tables .append (os_prices_table )
110113
111114
@@ -121,17 +124,32 @@ def _port_speed_prices_table(port_speeds, tables):
121124 port_speed_prices_table .align = 'l'
122125 for speed in port_speeds :
123126 for price in speed ['prices' ]:
124- cr_max = _get_price_data (price , 'capacityRestrictionMaximum' )
125- cr_min = _get_price_data (price , 'capacityRestrictionMinimum' )
126- cr_type = _get_price_data (price , 'capacityRestrictionType' )
127- port_speed_prices_table .add_row (
128- [speed ['key' ], speed ['speed' ],
129- _get_price_data (price , 'hourlyRecurringFee' ),
130- _get_price_data (price , 'recurringFee' ),
131- "%s - %s %s" % (cr_min , cr_max , cr_type )])
127+ if (_verify_prices (_get_price_data (price , 'hourlyRecurringFee' ))) or (
128+ _verify_prices (_get_price_data (price , 'recurringFee' ))):
129+ cr_max = _get_price_data (price , 'capacityRestrictionMaximum' )
130+ cr_min = _get_price_data (price , 'capacityRestrictionMinimum' )
131+ cr_type = _get_price_data (price , 'capacityRestrictionType' )
132+ port_speed_prices_table .add_row (
133+ [speed ['key' ], speed ['speed' ],
134+ _get_price_data (price , 'hourlyRecurringFee' ),
135+ _get_price_data (price , 'recurringFee' ),
136+ "%s - %s %s" % (cr_min , cr_max , cr_type )])
132137 tables .append (port_speed_prices_table )
133138
134139
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+
135153def _extras_prices_table (extras , tables ):
136154 """Shows Server extras prices cost and capacity restriction.
137155
@@ -143,14 +161,16 @@ def _extras_prices_table(extras, tables):
143161 extras_prices_table .align = 'l'
144162 for extra in extras :
145163 for price in extra ['prices' ]:
146- cr_max = _get_price_data (price , 'capacityRestrictionMaximum' )
147- cr_min = _get_price_data (price , 'capacityRestrictionMinimum' )
148- cr_type = _get_price_data (price , 'capacityRestrictionType' )
149- extras_prices_table .add_row (
150- [extra ['key' ],
151- _get_price_data (price , 'hourlyRecurringFee' ),
152- _get_price_data (price , 'recurringFee' ),
153- "%s - %s %s" % (cr_min , cr_max , cr_type )])
164+ if (_verify_prices (_get_price_data (price , 'hourlyRecurringFee' ))) or (
165+ _verify_prices (_get_price_data (price , 'recurringFee' ))):
166+ cr_max = _get_price_data (price , 'capacityRestrictionMaximum' )
167+ cr_min = _get_price_data (price , 'capacityRestrictionMinimum' )
168+ cr_type = _get_price_data (price , 'capacityRestrictionType' )
169+ extras_prices_table .add_row (
170+ [extra ['key' ],
171+ _get_price_data (price , 'hourlyRecurringFee' ),
172+ _get_price_data (price , 'recurringFee' ),
173+ "%s - %s %s" % (cr_min , cr_max , cr_type )])
154174 tables .append (extras_prices_table )
155175
156176
@@ -176,12 +196,14 @@ def _location_item_prices(location_prices, tables):
176196 location_prices_table .sortby = 'keyName'
177197 location_prices_table .align = 'l'
178198 for price in location_prices :
179- cr_max = _get_price_data (price , 'capacityRestrictionMaximum' )
180- cr_min = _get_price_data (price , 'capacityRestrictionMinimum' )
181- cr_type = _get_price_data (price , 'capacityRestrictionType' )
182- location_prices_table .add_row (
183- [price ['item' ]['keyName' ], price ['id' ],
184- _get_price_data (price , 'hourlyRecurringFee' ),
185- _get_price_data (price , 'recurringFee' ),
186- "%s - %s %s" % (cr_min , cr_max , cr_type )])
199+ if (_verify_prices (_get_price_data (price , 'hourlyRecurringFee' ))) or (
200+ _verify_prices (_get_price_data (price , 'recurringFee' ))):
201+ cr_max = _get_price_data (price , 'capacityRestrictionMaximum' )
202+ cr_min = _get_price_data (price , 'capacityRestrictionMinimum' )
203+ cr_type = _get_price_data (price , 'capacityRestrictionType' )
204+ location_prices_table .add_row (
205+ [price ['item' ]['keyName' ], price ['id' ],
206+ _get_price_data (price , 'hourlyRecurringFee' ),
207+ _get_price_data (price , 'recurringFee' ),
208+ "%s - %s %s" % (cr_min , cr_max , cr_type )])
187209 tables .append (location_prices_table )
0 commit comments