Пример #1
0
 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
Пример #2
0
    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
Пример #3
0
        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
Пример #4
0
 def test_invalid_image_returns_false(self):
     assert is_valid_element(self.non_image, check_image=True) is False
Пример #5
0
 def test_valid_content_type(self):
     assert is_valid_element(self.good_image,
                             valid_content_types=['image/png']) is True
Пример #6
0
 def test_invalid_content_type(self):
     assert is_valid_element(self.good_image, valid_content_types=[]) \
            is False
Пример #7
0
 def test_non_data_element(self):
     # Should check that input datum is a DataElement instance.
     # noinspection PyTypeChecker
     assert is_valid_element(False) is False