Back to index

system-config-printer  1.3.9+20120706
Public Member Functions | Public Attributes
cupshelpers.xmldriverprefs.DriverTypes Class Reference

List of all members.

Public Member Functions

def __init__
def load
def match
def filter
def get_ordered_ppdnames

Public Attributes

 drivertypes

Detailed Description

A list of driver types.

Definition at line 217 of file xmldriverprefs.py.


Constructor & Destructor Documentation

Definition at line 222 of file xmldriverprefs.py.

00222 
00223     def __init__ (self):
00224         self.drivertypes = []


Member Function Documentation

def cupshelpers.xmldriverprefs.DriverTypes.filter (   self,
  pattern 
)
Return the subset of driver type names that match a glob
pattern.

Definition at line 267 of file xmldriverprefs.py.

00267 
00268     def filter (self, pattern):
00269         """
00270         Return the subset of driver type names that match a glob
00271         pattern.
00272         """
00273 
00274         return fnmatch.filter (map (lambda x: x.get_name (),
00275                                     self.drivertypes),
00276                                pattern)

def cupshelpers.xmldriverprefs.DriverTypes.get_ordered_ppdnames (   self,
  drivertypes,
  ppdsdict,
  fit 
)
Given a list of driver type names, a dict of PPD attributes by
PPD name, and a dict of driver fitness status codes by PPD
name, return a list of tuples in the form (driver-type-name,
PPD-name), representing PPDs that match the list of driver
types.

The returned tuples will have driver types in the same order
as the driver types given, with the exception that any
blacklisted driver types will be omitted from the returned
result.

Definition at line 277 of file xmldriverprefs.py.

00277 
00278     def get_ordered_ppdnames (self, drivertypes, ppdsdict, fit):
00279         """
00280         Given a list of driver type names, a dict of PPD attributes by
00281         PPD name, and a dict of driver fitness status codes by PPD
00282         name, return a list of tuples in the form (driver-type-name,
00283         PPD-name), representing PPDs that match the list of driver
00284         types.
00285 
00286         The returned tuples will have driver types in the same order
00287         as the driver types given, with the exception that any
00288         blacklisted driver types will be omitted from the returned
00289         result.
00290         """
00291 
00292         ppdnames = []
00293 
00294         # First find out what driver types we have
00295         ppdtypes = {}
00296         fit_default = DriverType.FIT_CLOSE
00297         for ppd_name, ppd_dict in ppdsdict.iteritems ():
00298             drivertype = self.match (ppd_name, ppd_dict, fit.get (ppd_name,
00299                                                                   fit_default))
00300             if drivertype:
00301                 name = drivertype.get_name ()
00302             else:
00303                 name = "none"
00304 
00305             m = ppdtypes.get (name, [])
00306             m.append (ppd_name)
00307             ppdtypes[name] = m
00308 
00309         # Now construct the list.
00310         for drivertypename in drivertypes:
00311             for ppd_name in ppdtypes.get (drivertypename, []):
00312                 if ppd_name in ppdnames:
00313                     continue
00314 
00315                 ppdnames.append ((drivertypename, ppd_name))
00316 
00317         return ppdnames

Here is the call graph for this function:

def cupshelpers.xmldriverprefs.DriverTypes.load (   self,
  drivertypes 
)
Load the list of driver types from an XML file.

Definition at line 225 of file xmldriverprefs.py.

00225 
00226     def load (self, drivertypes):
00227         """
00228         Load the list of driver types from an XML file.
00229         """
00230 
00231         types = []
00232         for drivertype in drivertypes.getchildren ():
00233             t = DriverType (drivertype.attrib["name"])
00234 
00235             for child in drivertype.getchildren ():
00236                 if child.tag == "ppdname":
00237                     t.add_ppd_name (child.attrib["match"])
00238                 elif child.tag == "attribute":
00239                     t.add_attribute (child.attrib["name"],
00240                                      child.attrib["match"])
00241                 elif child.tag == "deviceid":
00242                     deviceid_match = DeviceIDMatch ()
00243                     for field in child.getchildren ():
00244                         if field.tag == "field":
00245                             deviceid_match.add_field (field.attrib["name"],
00246                                                       field.attrib["match"])
00247 
00248                     t.add_deviceid_match (deviceid_match)
00249                 elif child.tag == "fit":
00250                     t.add_fit (child.text)
00251 
00252             types.append (t)
00253 
00254         self.drivertypes = types

Here is the caller graph for this function:

def cupshelpers.xmldriverprefs.DriverTypes.match (   self,
  ppdname,
  ppddict,
  fit 
)
Return the first matching drivertype for a PPD, given its name,
attributes, and fitness, or None if there is no match.

Definition at line 255 of file xmldriverprefs.py.

00255 
00256     def match (self, ppdname, ppddict, fit):
00257         """
00258         Return the first matching drivertype for a PPD, given its name,
00259         attributes, and fitness, or None if there is no match.
00260         """
00261 
00262         for drivertype in self.drivertypes:
00263             if drivertype.match (ppdname, ppddict, fit):
00264                 return drivertype
00265 
00266         return None

Here is the caller graph for this function:


Member Data Documentation

Definition at line 223 of file xmldriverprefs.py.


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