All pastes #1454272 Raw Edit

Untitled

public text v1 · immutable
#1454272 ·published 2009-06-09 20:22 UTC
rendered paste body
    def sizes(self):
        """return image sizes"""
        sizes = { 'default': self.default_size,
                  'thumbnail': self.thumbnail }
        for option, value in self.env.config.options('ticket-image'):
            if option.startswith('size.'):
                sizes[option.split('.', -1)] = value

        for size in sizes:
            try:
                width, height = [ i.strip() for i in sizes[size].split('x') ]
            except ValueError:
                sizes.pop(size)
                continue
            dimension = {}
            for d in 'width', 'height':
                try:
                    dimension[d] = locals()[d] and int(locals()[d]) or None
                except: ValueError:
                    sizes.pop(size)
                    continue
            sizes[size] = dimension