def get_trailing_data(record, extra_data_flags):
 data = OrderedDict()
 flags = (extra_data_flags >> 1)
 num = 0
 while flags:
  num += 1
  if (flags & 1):
   (sz, consumed) = decint(record, forward=False)
   if (sz > consumed):
    data[num] = record[(- sz):(- consumed)]
   record = record[:(- sz)]
  flags >>= 1
 if (extra_data_flags & 1):
  sz = ((ord(record[(-1)]) & 3) + 1)
  consumed = 1
  if (sz > consumed):
   data[0] = record[(- sz):(- consumed)]
  record = record[:(- sz)]
 return (data, record)

def get_trailing_data ( record , extra_data_flags ) : data = OrderedDict ( ) flags = ( extra_data_flags >> 1 ) num = 0 while flags : num += 1 if ( flags & 1 ) : ( sz , consumed ) = decint ( record , forward = False ) if ( sz > consumed ) : data [ num ] = record [ ( - sz ) : ( - consumed ) ] record = record [ : ( - sz ) ] flags >>= 1 if ( extra_data_flags & 1 ) : sz = ( ( ord ( record [ ( - 1 ) ] ) & 3 ) + 1 ) consumed = 1 if ( sz > consumed ) : data [ 0 ] = record [ ( - sz ) : ( - consumed ) ] record = record [ : ( - sz ) ] return ( data , record )
given a text record as a bytestring and the extra data flags from the mobi header .