2008-04-17 04:52:37 +02:00
|
|
|
# vim:sw=4:et
|
|
|
|
#############################################################################
|
|
|
|
# File : CheckIconSizes.py
|
|
|
|
# Package : rpmlint
|
|
|
|
# Author : Dirk Mueller
|
|
|
|
# Purpose : Check for common scaling errors in icons
|
|
|
|
#############################################################################
|
|
|
|
|
|
|
|
from Filter import *
|
|
|
|
import AbstractCheck
|
|
|
|
import rpm
|
|
|
|
import re
|
|
|
|
import commands
|
|
|
|
import stat
|
|
|
|
import Config
|
|
|
|
import os
|
|
|
|
import string
|
|
|
|
|
|
|
|
class IconSizesCheck(AbstractCheck.AbstractCheck):
|
|
|
|
def __init__(self):
|
2009-08-21 18:19:06 +02:00
|
|
|
AbstractCheck.AbstractCheck.__init__(self, "CheckIconSizes")
|
2008-04-17 04:52:37 +02:00
|
|
|
self.file_size_regex = re.compile('/icons/[^/]+/(\d+)x(\d+)/')
|
|
|
|
self.info_size_regex = re.compile('(\d+) x (\d+)')
|
|
|
|
|
|
|
|
def check(self, pkg):
|
|
|
|
|
|
|
|
if pkg.isSource():
|
|
|
|
return
|
|
|
|
|
2009-08-21 18:19:06 +02:00
|
|
|
for fname, pkgfile in pkg.files().items():
|
|
|
|
res = self.file_size_regex.search(fname)
|
2008-04-17 04:52:37 +02:00
|
|
|
if res:
|
|
|
|
sizes = (res.group(1), res.group(2))
|
2009-08-21 18:19:06 +02:00
|
|
|
res = self.info_size_regex.search(pkgfile.magic)
|
2008-04-17 04:52:37 +02:00
|
|
|
if res:
|
|
|
|
actualsizes = (res.group(1), res.group(2))
|
|
|
|
|
|
|
|
if abs(int(sizes[0])-int(actualsizes[0])) > 2 or \
|
|
|
|
abs(int(sizes[1])-int(actualsizes[1])) > 2:
|
2009-08-21 18:19:06 +02:00
|
|
|
printError(pkg,"wrong-icon-size", fname, "expected:",
|
2008-04-17 04:52:37 +02:00
|
|
|
"x".join(sizes), "actual:", "x".join(actualsizes))
|
|
|
|
|
|
|
|
|
|
|
|
check=IconSizesCheck()
|
|
|
|
|
|
|
|
if Config.info:
|
|
|
|
addDetails(
|
|
|
|
'wrong-icon-size',
|
|
|
|
"""Your icon file is installed in a fixed-size directory, but has a largely incorrect size.
|
|
|
|
Some desktop environments (e.g. GNOME) display them incorrectly."""
|
|
|
|
)
|