@contract
def append_vm_data_locally(path, data, data_length):
    for uuid, value in data.items():
        vm_path = os.path.join(path, uuid)
        if not os.access(vm_path, os.F_OK):
            with open(vm_path, 'w') as f:
                f.write(str(value) + '\n')
        else:
            with open(vm_path, 'r+') as f:
                values = deque(f.read().strip().splitlines(), data_length)
                values.append(value)
                f.truncate(0)
                f.seek(0)
                f.write('\n'.join([str(x) for x in values]) + '\n')
similar to pop, but returns payload + last timestamp
dataset/ETHPy150Open beloglazov/openstack-neat/neat/locals/collector.py/append_vm_data_locally--crossover with--dataset/ETHPy150Open pinterest/thrift-tools/thrift_tools/sniffer.py/Stream.pop_data