User:WindBOT/Filters: Difference between revisions

Jump to navigation Jump to search
m (→‎PNGCrush/jpegtran all PNG/JPG images: Don't laff Mousse I know you did that too >:3)
Line 292: Line 292:
   class imageCrushFilter:
   class imageCrushFilter:
       def __init__(self):
       def __init__(self):
          print 'Initialized'
           self.minRatio = 10 # Compression ratio threshold
           self.minRatio = 10 # Compression ratio threshold
           self.minByteDiff = 2048 # Byte difference threshold
           self.minByteDiff = 2048 # Byte difference threshold
Line 326: Line 325:
                   pass
                   pass
       def __call__(self, content, article, **kwargs):
       def __call__(self, content, article, **kwargs):
          print 'Called on', article
           title = u(article.title).lower()
           title = u(article.title).lower()
           if title[-4:] == '.png':
           if title[-4:] == '.png':
Line 338: Line 336:
           else:
           else:
               return content
               return content
           try: # This is a high-risk filter, lots of I/O, so wrap it in a big try
           if True: # This is a high-risk filter, lots of I/O, so wrap it in a big try
               filePage = wikitools.wikifile.File(wiki(), article.title)
               filePage = wikitools.wikifile.File(wiki(), article.title)
               hashes = [u'', u'']
               hashes = [u'', u'']
Line 381: Line 379:
                   content = content.strip() + u'\n\n' + hashTemplate
                   content = content.strip() + u'\n\n' + hashTemplate
               self.deleteFile(tempOutput)
               self.deleteFile(tempOutput)
           except:
           else:
               pass # Well, that didn't work
               pass # Well, that didn't work
           return content
           return content
   addFileFilter(imageCrushFilter())
   addFileFilter(imageCrushFilter())