Esempio n. 1
0
    def __init__(self, **kwargs):
        from smush.scratch import Scratch
        from smush.optimisers.formats.png import OptimisePNG
        from smush.optimisers.formats.jpg import OptimiseJPG
        from smush.optimisers.formats.gif import OptimiseGIF
        from smush.optimisers.formats.animated_gif import OptimiseAnimatedGIF

        self.optimisers = {
            'PNG': OptimisePNG(**kwargs),
            'JPEG': OptimiseJPG(**kwargs),
            'GIF': OptimiseGIF(**kwargs),
            'GIFGIF': OptimiseAnimatedGIF(**kwargs)
        }

        self.__files_scanned = 0
        self.__start_time = time.time()
        self.exclude = {}
        for dir in kwargs.get('exclude'):
            if len(dir) == 0:
                continue
            self.exclude[dir] = True
        self.quiet = kwargs.get('quiet')
        self.identify_mime = kwargs.get('identify_mime')

        # setup tempfile for stdout and stderr
        self.stdout = Scratch()
        self.stderr = Scratch()
Esempio n. 2
0
 def __init__(self, **kwargs):
     # the number of times the _get_command iterator has been run
     self.iterations = 0
     self.files_scanned = 0
     self.files_optimised = 0
     self.bytes_saved = 0
     self.list_only = kwargs.get('list_only')
     self.array_optimised_file = []
     self.quiet = kwargs.get('quiet')
     self.stdout = Scratch()
     self.stderr = Scratch()