tools/binary_size/libsupersize/file_format.py
def LoadDeltaSizeInfo(path, file_obj=None):
  """Returns a tuple of size infos (before, after).

  To reconstruct the DeltaSizeInfo, diff the two size infos.
  """
  if not file_obj:
    with open(path, 'rb') as f:
      return LoadDeltaSizeInfo(path, f)

  combined_header = _COMMON_HEADER + _SIZEDIFF_HEADER
  actual_header = file_obj.read(len(combined_header))
  if actual_header != combined_header:
    raise Exception('Bad file header.')

  json_len = int(file_obj.readline())
  json_str = file_obj.read(json_len + 1)  # + 1 for \n
  fields = json.loads(json_str)

  assert fields['version'] == _SIZEDIFF_VERSION
  after_pos = file_obj.tell() + fields['before_length']

  before_size_info = LoadSizeInfo(path, file_obj)
  file_obj.seek(after_pos)
  after_size_info = LoadSizeInfo(path, file_obj)

  return before_size_info, after_size_info
Returns a tuple of size infos (before, after).

  To reconstruct the DeltaSizeInfo, diff the two size infos.
  
Returns a tuple of size infos (before, after).
To reconstruct the DeltaSizeInfo, diff the two size infos.
Returns a tuple of size infos ( before after ) . To reconstruct the DeltaSizeInfo diff the two size infos .
def LoadDeltaSizeInfo(path, file_obj=None):
  if not file_obj:
    with open(path, 'rb') as f:
      return LoadDeltaSizeInfo(path, f)
  combined_header = _COMMON_HEADER + _SIZEDIFF_HEADER
  actual_header = file_obj.read(len(combined_header))
  if actual_header != combined_header:
    raise Exception('Bad file header.')
  json_len = int(file_obj.readline())
  json_str = file_obj.read(json_len + 1)  
  fields = json.loads(json_str)
  assert fields['version'] == _SIZEDIFF_VERSION
  after_pos = file_obj.tell() + fields['before_length']
  before_size_info = LoadSizeInfo(path, file_obj)
  file_obj.seek(after_pos)
  after_size_info = LoadSizeInfo(path, file_obj)
  return before_size_info, after_size_info
def LoadDeltaSizeInfo ( path , file_obj = None ) : if not file_obj : with open ( path , 'rb' ) as f : return LoadDeltaSizeInfo ( path , f ) combined_header = _COMMON_HEADER + _SIZEDIFF_HEADER actual_header = file_obj . read ( len ( combined_header ) ) if actual_header != combined_header : raise Exception ( 'Bad file header.' ) json_len = int ( file_obj . readline ( ) ) json_str = file_obj . read ( json_len + 1 ) fields = json . loads ( json_str ) assert fields [ 'version' ] == _SIZEDIFF_VERSION after_pos = file_obj . tell ( ) + fields [ 'before_length' ] before_size_info = LoadSizeInfo ( path , file_obj ) file_obj . seek ( after_pos ) after_size_info = LoadSizeInfo ( path , file_obj ) return before_size_info , after_size_info
Returns a tuple of size infos (before, after).
Returns a tuple of size infos ( before after ) .
"""Returns a tuple of size infos (before, after).

  To reconstruct the DeltaSizeInfo, diff the two size infos.
  """ # + 1 for \n
path
file_obj