def parse_blob_info(field_storage):
 if (field_storage is None):
  return None
 field_name = field_storage.name
 def get_value(dct, name):
  value = dct.get(name, None)
  if (value is None):
   raise BlobInfoParseError(('Field %s has no %s.' % (field_name, name)))
  return value
 filename = get_value(field_storage.disposition_options, 'filename')
 blob_key_str = get_value(field_storage.type_options, 'blob-key')
 blob_key = BlobKey(blob_key_str)
 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)
 md5_hash_encoded = get_value(upload_content, 'content-md5')
 md5_hash = base64.urlsafe_b64decode(md5_hash_encoded)
 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 as err:
  raise BlobInfoParseError(str(err))
 return BlobInfo(id=blob_key_str, content_type=content_type, creation=creation, filename=filename, size=size, md5_hash=md5_hash)

def parse_blob_info ( field_storage ) : if ( field_storage is None ) : return None field_name = field_storage . name def get_value ( dct , name ) : value = dct . get ( name , None ) if ( value is None ) : raise BlobInfoParseError ( ( 'Field %s has no %s.' % ( field_name , name ) ) ) return value filename = get_value ( field_storage . disposition_options , 'filename' ) blob_key_str = get_value ( field_storage . type_options , 'blob-key' ) blob_key = BlobKey ( blob_key_str ) 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 ) md5_hash_encoded = get_value ( upload_content , 'content-md5' ) md5_hash = base64 . urlsafe_b64decode ( md5_hash_encoded ) 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 as err : raise BlobInfoParseError ( str ( err ) ) return BlobInfo ( id = blob_key_str , content_type = content_type , creation = creation , filename = filename , size = size , md5_hash = md5_hash )
parse a blobinfo record from file upload field_storage .