def check_image(image_path): if not os.path.exists(image_path): log.warn('Invalid image path given (does not exist): %s', image_path) return False, False else: d = DataFileElement(image_path) return is_valid_element(d, check_image=True), d
def is_valid(dataElementUri): dfe = GirderDataElement.from_uri(dataElementUri) if is_valid_element(dfe, valid_content_types=valid_content_types, check_image=True): return dfe else: return False
def is_valid(file_path): e = DataFileElement(file_path) if is_valid_element( e, valid_content_types=generator.valid_content_types(), check_image=check_image): return e else: return False
def test_invalid_image_returns_false(self): assert is_valid_element(self.non_image, check_image=True) is False
def test_valid_content_type(self): assert is_valid_element(self.good_image, valid_content_types=['image/png']) is True
def test_invalid_content_type(self): assert is_valid_element(self.good_image, valid_content_types=[]) \ is False
def test_non_data_element(self): # Should check that input datum is a DataElement instance. # noinspection PyTypeChecker assert is_valid_element(False) is False