#NEWLINE# @ contract #NEWLINE# def append_vm_data_locally( path , data , data_length ) : #NEWLINE# #INDENT# ' Write a CPU MHz value for each out of a set of VMs.\n\n    :param path: A path to write the data to.\n     :type path: str\n\n    :param data: A map of VM UUIDs onto the corresponing CPU MHz values.\n     :type data: dict(str : int)\n\n    :param data_length: The maximum allowed length of the data.\n     :type data_length: int\n    ' #NEWLINE# for ( uuid , value ) in data . items ( ) : #NEWLINE# #INDENT# vm_path = os . path . join ( path , data_length ) #NEWLINE# if ( not os . access ( vm_path , os . F_OK ) ) : #NEWLINE# #INDENT# with open ( vm_path , 'w' ) as f : #NEWLINE# #INDENT# f . write ( ( str ( value ) + '\n' ) ) #NEWLINE# #UNINDENT# #UNINDENT# else : #NEWLINE# #INDENT# with open ( vm_path , 'r+' ) as f : #NEWLINE# #INDENT# values = deque ( f . read ( ) . strip ( ) . splitlines ( ) , data_length ) #NEWLINE# values . append ( value ) #NEWLINE# f . truncate ( 0 ) #NEWLINE# f . seek ( 0 ) #NEWLINE# f . write ( ( '\n' . join ( [ str ( x ) for x in values ] ) + '\n' ) )