Ejemplo n.º 1
0
class filename_series:
    """ Much like the others, but created from a string filename """
    def __init__(self, filename):
        """ create from a filename (String)"""
        self.obj = FilenameObject(filename)

    def next(self):
        """ increment number """
        self.obj.num += 1
        return self.obj.tostring()

    def previous(self):
        """ decrement number """
        self.obj.num -= 1
        return self.obj.tostring()

    def current(self):
        """ return current filename string"""
        return self.obj.tostring()

    def jump(self, num):
        """ jump to a specific number """
        self.obj.num = num
        return self.obj.tostring()

    # image methods
    def next_image(self):
        """ returns the next image as a fabioimage """
        return openimage(self.next())
    def prev_image(self):
        """ returns the previos image as a fabioimage """
        return openimage(self.previous())
    def current_image(self):
        """ returns the current image as a fabioimage"""
        return openimage(self.current())
    def jump_image(self, num):
        """ returns the image number as a fabioimage"""
        return openimage(self.jump(num))
    # object methods
    def next_object(self):
        """ returns the next filename as a fabio.FilenameObject"""
        self.obj.num += 1
        return self.obj
    def previous_object(self):
        """ returns the previous filename as a fabio.FilenameObject"""
        self.obj.num -= 1
        return self.obj
    def current_object(self):
        """ returns the current filename as a fabio.FilenameObject"""
        return self.obj
    def jump_object(self, num):
        """ returns the filename num as a fabio.FilenameObject"""
        self.obj.num = num
        return self.obj
Ejemplo n.º 2
0
    def first_object(self):
        """
        First image in a sequence

        @return: file_object
        """
        return FilenameObject(self.first())
Ejemplo n.º 3
0
    def current_object(self):
        """
        Current image in sequence

        @return: file_object

        """
        return FilenameObject(self.current())
Ejemplo n.º 4
0
    def jump_object(self, num):
        """
        Jump to and read image

        @return: file_object

        """
        return FilenameObject(self.jump(num))
Ejemplo n.º 5
0
    def previous_object(self):
        """
        Return the previous image

        @return: file_object

        """
        return FilenameObject(self.previous())
Ejemplo n.º 6
0
    def next_object(self):
        """
        Return the next image

        @return: file_object

        """
        return FilenameObject(self.next())
Ejemplo n.º 7
0
    def last_object(self):
        """
        Last image in a sequence

        @return: file_object

        """
        return FilenameObject(self.last())
Ejemplo n.º 8
0
 def __init__(self, filename):
     """ create from a filename (String)"""
     self.obj = FilenameObject(filename)
Ejemplo n.º 9
0
 def __init__(self, filename):
     """ create from a filename (String)"""
     self.obj = FilenameObject(filename)
Ejemplo n.º 10
0
class filename_series:
    """ Much like the others, but created from a string filename """
    def __init__(self, filename):
        """ create from a filename (String)"""
        self.obj = FilenameObject(filename)

    def next(self):
        """ increment number """
        self.obj.num += 1
        return self.obj.tostring()

    def previous(self):
        """ decrement number """
        self.obj.num -= 1
        return self.obj.tostring()

    def current(self):
        """ return current filename string"""
        return self.obj.tostring()

    def jump(self, num):
        """ jump to a specific number """
        self.obj.num = num
        return self.obj.tostring()

    # image methods
    def next_image(self):
        """ returns the next image as a fabioimage """
        return openimage(self.next())

    def prev_image(self):
        """ returns the previos image as a fabioimage """
        return openimage(self.previous())

    def current_image(self):
        """ returns the current image as a fabioimage"""
        return openimage(self.current())

    def jump_image(self, num):
        """ returns the image number as a fabioimage"""
        return openimage(self.jump(num))

    # object methods
    def next_object(self):
        """ returns the next filename as a fabio.FilenameObject"""
        self.obj.num += 1
        return self.obj

    def previous_object(self):
        """ returns the previous filename as a fabio.FilenameObject"""
        self.obj.num -= 1
        return self.obj

    def current_object(self):
        """ returns the current filename as a fabio.FilenameObject"""
        return self.obj

    def jump_object(self, num):
        """ returns the filename num as a fabio.FilenameObject"""
        self.obj.num = num
        return self.obj
Ejemplo n.º 11
0
                    filename = ":".join(col_split[:-1])

    try:
        imo = fabioimage()
        byts = imo._open(filename).read(18)
        filetype = do_magic(byts)
        if filetype == "marccd" and filename.find("mccd") == -1:
            # Cannot see a way around this. Need to find something
            # to distinguish mccd from regular tif...
            filetype = "tif"
    except IOError, error:
        logger.error("%s: File probably does not exist", error)
        raise error
    except:
        try:
            file_obj = FilenameObject(filename=filename)
            if file_obj == None:
                raise Exception("Unable to deconstruct filename")
            if (file_obj.format is not None) and\
                len(file_obj.format) != 1 and \
                type(file_obj.format) != type(["list"]):
                # one of OXD/ ADSC - should have got in previous
                raise Exception("openimage failed on magic bytes & name guess")
            filetype = file_obj.format
            #UNUSED filenumber = file_obj.num
        except Exception, error:
            logger.error(error)
            import traceback
            traceback.print_exc()
            raise Exception("Fabio could not identify " + filename)
    klass_name = "".join(filetype) + 'image'