Back to index

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

List of all members.

Public Member Functions

def __init__
def add_field
def match

Private Attributes

 _re

Detailed Description

A set of fields and regular expressions for matching a Device ID.

Definition at line 33 of file xmldriverprefs.py.


Constructor & Destructor Documentation

Definition at line 37 of file xmldriverprefs.py.

00037 
00038     def __init__ (self):
00039         self._re = dict()


Member Function Documentation

def cupshelpers.xmldriverprefs.DeviceIDMatch.add_field (   self,
  field,
  pattern 
)

Definition at line 40 of file xmldriverprefs.py.

00040 
00041     def add_field (self, field, pattern):
00042         self._re[field.upper ()] = re.compile (pattern, re.I)

def cupshelpers.xmldriverprefs.DeviceIDMatch.match (   self,
  deviceid 
)
Match against a parsed Device ID dictionary.

The CMD field is treated specially.  If any of the
comma-separated words in this field value match, the Device ID
pattern is considered to match.

Definition at line 43 of file xmldriverprefs.py.

00043 
00044     def match (self, deviceid):
00045         """
00046         Match against a parsed Device ID dictionary.
00047 
00048         The CMD field is treated specially.  If any of the
00049         comma-separated words in this field value match, the Device ID
00050         pattern is considered to match.
00051         """
00052 
00053         for field, match in self._re.iteritems ():
00054             if not deviceid.has_key (field):
00055                 return False
00056 
00057             if field == "CMD":
00058                 this_field_matches = False
00059                 for cmd in deviceid[field]:
00060                     if match.match (cmd):
00061                         this_field_matches = True
00062                         break
00063 
00064                 if not this_field_matches:
00065                     return False
00066 
00067             if not match.match (deviceid[field]):
00068                 return False
00069 
00070         return True

Here is the caller graph for this function:


Member Data Documentation

Definition at line 38 of file xmldriverprefs.py.


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