Back to index

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

List of all members.

Public Member Functions

def __init__
def __repr__
def __cmp__

Public Attributes

 uri
 device_class
 info
 make_and_model
 id
 location
 type
 is_class
 id_dict

Detailed Description

This class represents a CUPS device.

Definition at line 509 of file cupshelpers.py.


Constructor & Destructor Documentation

def cupshelpers.cupshelpers.Device.__init__ (   self,
  uri,
  kw 
)
@param uri: device URI
@type uri: string
@param kw: device attributes
@type kw: dict

Definition at line 514 of file cupshelpers.py.

00514 
00515     def __init__(self, uri, **kw):
00516         """
00517         @param uri: device URI
00518         @type uri: string
00519         @param kw: device attributes
00520         @type kw: dict
00521         """
00522         self.uri = uri
00523         self.device_class = kw.get('device-class', '')
00524         self.info = kw.get('device-info', '')
00525         self.make_and_model = kw.get('device-make-and-model', '')
00526         self.id = kw.get('device-id', '')
00527         self.location = kw.get('device-location', '')
00528 
00529         uri_pieces = uri.split(":")
00530         self.type =  uri_pieces[0]
00531         self.is_class = len(uri_pieces)==1
00532 
00533         #self.id = 'MFG:HEWLETT-PACKARD;MDL:DESKJET 990C;CMD:MLC,PCL,PML;CLS:PRINTER;DES:Hewlett-Packard DeskJet 990C;SN:US05N1J00XLG;S:00808880800010032C1000000C2000000;P:0800,FL,B0;J:                    ;'
00534 
00535         self.id_dict = parseDeviceID (self.id)
00536 
00537         s = uri.find("serial=")
00538         if s != -1 and not self.id_dict.get ('SN',''):
00539             self.id_dict['SN'] = uri[s + 7:]


Member Function Documentation

def cupshelpers.cupshelpers.Device.__cmp__ (   self,
  other 
)
Compare devices by order of preference.

Definition at line 543 of file cupshelpers.py.

00543 
00544     def __cmp__(self, other):
00545         """
00546         Compare devices by order of preference.
00547         """
00548         if other == None:
00549             return -1
00550 
00551         if self.is_class != other.is_class:
00552             if other.is_class:
00553                 return -1
00554             return 1
00555         if not self.is_class and (self.type != other.type):
00556             # "hp"/"hpfax" before "usb" before * before "parallel" before
00557             # "serial"
00558             if other.type == "serial":
00559                 return -1
00560             if self.type == "serial":
00561                 return 1
00562             if other.type == "parallel":
00563                 return -1
00564             if self.type == "parallel":
00565                 return 1
00566             if other.type == "hp" or other.type == "hpfax":
00567                 return 1
00568             if self.type == "hp" or self.type == "hpfax":
00569                 return -1
00570             if other.type == "dnssd":
00571                 return 1
00572             if self.type == "dnssd":
00573                 return -1
00574             if other.type == "usb":
00575                 return 1
00576             if self.type == "usb":
00577                 return -1
00578         result = cmp(bool(self.id), bool(other.id))
00579         if not result:
00580             result = cmp(self.info, other.info)
00581         
00582         return result

Definition at line 540 of file cupshelpers.py.

00540 
00541     def __repr__ (self):
00542         return "<cupshelpers.Device \"%s\">" % self.uri

Here is the caller graph for this function:


Member Data Documentation

Definition at line 522 of file cupshelpers.py.

Definition at line 525 of file cupshelpers.py.

Definition at line 534 of file cupshelpers.py.

Definition at line 523 of file cupshelpers.py.

Definition at line 530 of file cupshelpers.py.

Definition at line 526 of file cupshelpers.py.

Definition at line 524 of file cupshelpers.py.

Definition at line 529 of file cupshelpers.py.

Definition at line 521 of file cupshelpers.py.


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