Created
October 23, 2014 00:55
-
-
Save jmchilton/54b5d7485fcd16eec984 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Is dataset an image? | |
image = check_image( dataset.path ) | |
if image: | |
if not PIL: | |
image = None | |
# get_image_ext() returns None if nor a supported Image type | |
ext = get_image_ext( dataset.path, image ) | |
data_type = ext | |
# Is dataset content multi-byte? | |
elif dataset.is_multi_byte: | |
data_type = 'multi-byte char' | |
ext = sniff.guess_ext( dataset.path, is_multi_byte=True ) | |
# Is dataset content supported sniffable binary? | |
else: | |
type_info = Binary.is_sniffable_binary( dataset.path ) | |
if type_info: | |
data_type = type_info[0] | |
ext = type_info[1] | |
if not data_type: | |
# See if we have a gzipped file, which, if it passes our restrictions, we'll uncompress | |
is_gzipped, is_valid = check_gzip( dataset.path ) | |
if is_gzipped and not is_valid: | |
file_err( 'The gzipped uploaded file contains inappropriate content', dataset, json_file ) | |
return |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment