@ -1519,26 +1519,22 @@ class Ec2Inventory(object):
''' Reads the inventory from the cache file and returns it as a JSON
''' Reads the inventory from the cache file and returns it as a JSON
object '''
object '''
cache = open ( self . cache_path_cache , ' r ' )
with open ( self . cache_path_cache , ' r ' ) as f :
json_inventory = cache . read ( )
json_inventory = f . read ( )
return json_inventory
return json_inventory
def load_index_from_cache ( self ) :
def load_index_from_cache ( self ) :
''' Reads the index from the cache file sets self.index '''
''' Reads the index from the cache file sets self.index '''
cache = open ( self . cache_path_index , ' r ' )
with open ( self . cache_path_index , ' r ' ) as f :
json_index = cache . read ( )
self . index = json . load ( f )
self . index = json . loads ( json_index )
def write_to_cache ( self , data , filename ) :
def write_to_cache ( self , data , filename ) :
''' Writes data in JSON format to a file '''
''' Writes data in JSON format to a file '''
json_data = self . json_format_dict ( data , True )
json_data = self . json_format_dict ( data , True )
cache = open ( filename , ' w ' )
with open ( filename , ' w ' ) as f :
cache . write ( json_data )
f . write ( json_data )
cache . close ( )
def uncammelize ( self , key ) :
def uncammelize ( self , key ) :
temp = re . sub ( ' (.)([A-Z][a-z]+) ' , r ' \ 1_ \ 2 ' , key )
temp = re . sub ( ' (.)([A-Z][a-z]+) ' , r ' \ 1_ \ 2 ' , key )