2626class Prices (object ):
2727 def __init__ (self ):
2828 with warnings .catch_warnings (record = True ) as price_warnings :
29- curr_url = 'https://aws.amazon.com/ec2/pricing/on-demand/'
30- curr_ri_url = 'https://aws.amazon.com/ec2/pricing/reserved-instances/pricing/'
31- prev_url = 'https://aws.amazon.com/ec2/previous-generation/'
29+ base_url = 'https://aws.amazon.com/ec2/'
30+ curr_url = '{}pricing/on-demand/' .format (base_url )
31+ curr_ri_url = '{}pricing/reserved-instances/pricing/' .format (
32+ base_url
33+ )
34+ prev_url = '{}previous-generation/' .format (base_url )
3235 self .prices = process_ec2 (curr_url )
3336 prices_curr_ri = process_ec2 (curr_ri_url )
3437 prices_prev = process_ec2 (prev_url )
@@ -41,13 +44,40 @@ def __init__(self):
4144 for warning in price_warnings :
4245 self .output += "\n {}" .format (warning .message )
4346
44- def update_ri_prices (self , prices_curr_ri , kind ):
47+ def update_ri_prices (self , prices_ri , kind ):
48+ empty_ri = {
49+ 'yrTerm1Standard' : {
50+ 'noUpfront' : {
51+ 'effectiveHourly' : None ,
52+ },
53+ 'partialUpfront' : {
54+ 'effectiveHourly' : None ,
55+ },
56+ 'allUpfront' : {
57+ 'effectiveHourly' : None ,
58+ },
59+ },
60+ 'yrTerm3Standard' : {
61+ 'noUpfront' : {
62+ 'effectiveHourly' : None ,
63+ },
64+ 'partialUpfront' : {
65+ 'effectiveHourly' : None ,
66+ },
67+ 'allUpfront' : {
68+ 'effectiveHourly' : None ,
69+ },
70+ },
71+ }
4572 for region in self .prices [kind ]:
46- if region in prices_curr_ri [kind ]:
47- for instance_type in self .prices [kind ][region ]:
48- if instance_type in prices_curr_ri [kind ][region ]:
49- if 'ri' in prices_curr_ri [kind ][region ][instance_type ]:
50- self .prices [kind ][region ][instance_type ]['ri' ] = prices_curr_ri [kind ][region ][instance_type ]['ri' ]
73+ for instance_type in self .prices [kind ][region ]:
74+ local_prices = self .prices [kind ][region ][instance_type ]
75+ ri_type = prices_ri [kind ][region ].get (
76+ instance_type ,
77+ {'ri' : empty_ri },
78+ )
79+ if 'ri' in ri_type :
80+ local_prices ['ri' ] = ri_type ['ri' ]
5181
5282 def update_previous_generation_prices (self , prices_prev , kind ):
5383 for region in self .prices [kind ]:
@@ -351,6 +381,7 @@ def process_not_implemented(data, js_name, instances=None):
351381 generic ['name' ]))
352382 return instances
353383
384+
354385SECTION_NAMES = {
355386 'linux-od.min.js' : {
356387 'name' : 'On Demand - Linux' ,
0 commit comments