def _snapshot_to_data(snapshot):
 data = {}
 data['id'] = snapshot[0]
 data['type'] = ['single', 'pre', 'post'][snapshot[1]]
 if (data['type'] == 'post'):
  data['pre'] = snapshot[2]
 if (snapshot[3] != (-1)):
  data['timestamp'] = snapshot[3]
 else:
  data['timestamp'] = int(time.time())
 data['user'] = getpwuid(snapshot[4])[0]
 data['description'] = snapshot[5]
 data['cleanup'] = snapshot[6]
 data['userdata'] = {}
 for (key, value) in snapshot[7].items():
  data['userdata'][key] = value
 return data

def _snapshot_to_data ( snapshot ) : data = { } data [ 'id' ] = snapshot [ 0 ] data [ 'type' ] = [ 'single' , 'pre' , 'post' ] [ snapshot [ 1 ] ] if ( data [ 'type' ] == 'post' ) : data [ 'pre' ] = snapshot [ 2 ] if ( snapshot [ 3 ] != ( - 1 ) ) : data [ 'timestamp' ] = snapshot [ 3 ] else : data [ 'timestamp' ] = int ( time . time ( ) ) data [ 'user' ] = getpwuid ( snapshot [ 4 ] ) [ 0 ] data [ 'description' ] = snapshot [ 5 ] data [ 'cleanup' ] = snapshot [ 6 ] data [ 'userdata' ] = { } for ( key , value ) in snapshot [ 7 ] . items ( ) : data [ 'userdata' ] [ key ] = value return data
returns snapshot data from a d-bus response .