Back to index

system-config-printer  1.3.9+20120706
Public Member Functions | Private Attributes
validate.Validator Class Reference

List of all members.

Public Member Functions

def __init__
def validate

Private Attributes

 _filename

Detailed Description

Definition at line 30 of file validate.py.


Constructor & Destructor Documentation

def validate.Validator.__init__ (   self,
  filename 
)

Definition at line 31 of file validate.py.

00031 
00032     def __init__ (self, filename):
00033         self._filename = filename


Member Function Documentation

Definition at line 34 of file validate.py.

00034 
00035     def validate (self):
00036         filename = self._filename
00037         print "Validating %s" % filename
00038         preferreddrivers = xml.etree.ElementTree.XML (file (filename).read ())
00039         (drivertypes, preferenceorder) = preferreddrivers.getchildren ()
00040         validates = True
00041 
00042         names = set()
00043         for drivertype in drivertypes.getchildren ():
00044             name = drivertype.get ("name")
00045             names.add (name)
00046 
00047         for printer in preferenceorder.getchildren ():
00048             types = []
00049             drivers = printer.find ("drivers")
00050             if drivers != None:
00051                 types.extend (drivers.getchildren ())
00052 
00053             blacklist = printer.find ("blacklist")
00054             if blacklist != None:
00055                 types.extend (blacklist.getchildren ())
00056 
00057             for drivertype in types:
00058                 pattern = drivertype.text.strip ()
00059                 matches = fnmatch.filter (names, pattern)
00060                 names -= set (matches)
00061 
00062         for name in names:
00063             validates = False
00064             print >>sys.stderr, ("*** Driver type \"%s\" is never used" %
00065                                  name)
00066 
00067         return validates


Member Data Documentation

Definition at line 32 of file validate.py.


The documentation for this class was generated from the following file: