예제 #1
0
 def pattern_open(self, image):
     if isinstance(image, Pattern):
         return image
     elif isinstance(image, basestring):
         image_path = base.search_image(image, self.image_path)
         if image_path is None:
             raise IOError('image file not found: {}'.format(image))
         return Pattern(image_path)
     elif 'numpy' in str(type(image)):
         return Pattern(image)
     else:
         raise TypeError("Not supported image type: {}".format(type(image)))
예제 #2
0
 def pattern_open(self, image):
     if isinstance(image, Pattern):
         return image
     elif isinstance(image, basestring):
         image_path = base.search_image(image, self.image_path)
         if image_path is None:
             raise IOError('image file not found: {}'.format(image))
         return Pattern(image_path)
     elif 'numpy' in str(type(image)):
         return Pattern(image)
     else:
         raise TypeError("Not supported image type: {}".format(type(image)))
예제 #3
0
    def pattern_open(self, image):
        if self.__screensize is None:
            self.__screensize = self.display

        if isinstance(image, Pattern):
            if image._image is None:
                image_path = self._search_image(image._name)
                image._image = imutils.open(image_path)
            return image
        elif isinstance(image, basestring):
            image_path = base.search_image(image, self.image_path)
            if image_path is None:
                raise IOError('image file not found: {}'.format(image))
            return Pattern(image_path, image=imutils.open(image_path))
        elif 'numpy' in str(type(image)):
            return Pattern('unknown', image=image)
        else:
            raise TypeError("Not supported image type: {}".format(type(image)))
예제 #4
0
 def _search_image(self, name, raise_error=True):
     image_path = base.search_image(name, self.image_path)
     if raise_error and image_path is None:
         raise IOError('image file not found: {}'.format(name))
     return image_path
예제 #5
0
 def _search_image(self, name, raise_error=True):
     image_path = base.search_image(name, self.image_path)
     if raise_error and image_path is None:
         raise IOError('image file not found: {}'.format(name))
     return image_path
예제 #6
0
def test_search_image():
    imgpath = base.search_image('haima', path=['media'])
    assert imgpath is not None
    assert 'haima.png' in imgpath
    assert 'media' in imgpath
예제 #7
0
def test_search_image():
    imgpath = base.search_image('haima', path=['media'])
    assert imgpath is not None
    assert strutils.encode('haima.png') in imgpath
    assert strutils.encode('media') in imgpath
예제 #8
0
def test_search_image():
    imgpath = base.search_image('haima', path=['media'])
    assert imgpath is not None
    assert 'haima.png' in imgpath
    assert 'media' in imgpath
예제 #9
0
def test_search_image():
    imgpath = base.search_image('haima', path=['media'])
    assert imgpath is not None
    assert strutils.encode('haima.png') in imgpath
    assert strutils.encode('media') in imgpath