def parse_blob_info(field_storage):
  """Parse a BlobInfo record from file upload field_storage.

  Args:
    field_storage: cgi.FieldStorage that represents uploaded blob.

  Returns:
    BlobInfo record as parsed from the field-storage instance.
    None if there was no field_storage.

  Raises:
    BlobInfoParseError when provided field_storage does not contain enough
    information to construct a BlobInfo object.
  """
  if field_storage is None:
    return None

  field_name = field_storage.name

  def get_value(dict, name):
    value = dict.get(name, None)
    if value is None:
      raise BlobInfoParseError(
          (field_name, name) % 'Field %s has no %s.')
    return value

  filename = get_value(field_storage.disposition_options, 'filename')
  blob_key = BlobKey(get_value(field_storage.type_options, 'blob-key'))

  upload_content = email.message_from_file(field_storage.file)
  content_type = get_value(upload_content, 'content-type')
  size = get_value(upload_content, 'content-length')
  creation_string = get_value(upload_content, UPLOAD_INFO_CREATION_HEADER)

  try:
    size = int(size)
  except (TypeError, ValueError):
    raise BlobInfoParseError(
        '%s is not a valid value for %s size.' % (size, field_name))

  try:
    creation = blobstore._parse_creation(creation_string, field_name)
  except blobstore._CreationFormatError, err:
    raise BlobInfoParseError(str(err))

  return BlobInfo(blob_key,
                  {'content_type': content_type,
                   'creation': creation,
                   'filename': filename,
                   'size': size,
                   })
dataset/ETHPy150Open livid/v2ex/mapreduce/lib/blobstore/blobstore.py/parse_blob_info/swapped operands of `%`