Back to index

system-config-printer  1.3.9+20120706
Public Member Functions | Public Attributes | Static Public Attributes | Private Member Functions | Private Attributes
statereason.StateReason Class Reference

List of all members.

Public Member Functions

def __init__
def get_printer
def get_level
def get_reason
def __repr__
def get_description
def get_tuple
def __cmp__

Public Attributes

 printer
 reason
 level
 canonical_reason

Static Public Attributes

int REPORT = 1
int WARNING = 2
int ERROR = 3
dictionary LEVEL_ICON

Private Member Functions

def _got_ppd

Private Attributes

 _ppd

Detailed Description

Definition at line 26 of file statereason.py.


Constructor & Destructor Documentation

def statereason.StateReason.__init__ (   self,
  printer,
  reason,
  ppdcache = None 
)

Definition at line 37 of file statereason.py.

00037 
00038     def __init__(self, printer, reason, ppdcache=None):
00039         self.printer = printer
00040         self.reason = reason
00041         self.level = None
00042         self.canonical_reason = None
00043         self._ppd = None
00044         if ppdcache:
00045             ppdcache.fetch_ppd (printer, self._got_ppd)


Member Function Documentation

def statereason.StateReason.__cmp__ (   self,
  other 
)

Definition at line 157 of file statereason.py.

00157 
00158     def __cmp__(self, other):
00159         if other == None:
00160             return 1
00161         if other.get_level () != self.get_level ():
00162             return cmp (self.get_level (), other.get_level ())
00163         if other.get_printer () != self.get_printer ():
00164             return cmp (other.get_printer (), self.get_printer ())
00165         return cmp (other.get_reason (), self.get_reason ())

Here is the call graph for this function:

Definition at line 79 of file statereason.py.

00079 
00080     def __repr__ (self):
00081         self.get_level()
00082         if self.level == self.REPORT:
00083             level = "REPORT"
00084         elif self.level == self.WARNING:
00085             level = "WARNING"
00086         else:
00087             level = "ERROR"
00088 
00089         return "<statereason.StateReason (%s,%s,%s)>" % (level,
00090                                                          self.get_printer (),
00091                                                          self.get_reason ())

Here is the call graph for this function:

def statereason.StateReason._got_ppd (   self,
  name,
  result,
  exc 
) [private]

Definition at line 46 of file statereason.py.

00046 
00047     def _got_ppd (self, name, result, exc):
00048         self._ppd = result

Definition at line 92 of file statereason.py.

00092 
00093     def get_description (self):
00094         messages = {
00095             'toner-low': (_("Toner low"),
00096                           _("Printer '%s' is low on toner.")),
00097             'toner-empty': (_("Toner empty"),
00098                             _("Printer '%s' has no toner left.")),
00099             'cover-open': (_("Cover open"),
00100                            _("The cover is open on printer '%s'.")),
00101             'door-open': (_("Door open"),
00102                           _("The door is open on printer '%s'.")),
00103             'media-low': (_("Paper low"),
00104                           _("Printer '%s' is low on paper.")),
00105             'media-empty': (_("Out of paper"),
00106                             _("Printer '%s' is out of paper.")),
00107             'marker-supply-low': (_("Ink low"),
00108                                   _("Printer '%s' is low on ink.")),
00109             'marker-supply-empty': (_("Ink empty"),
00110                                     _("Printer '%s' has no ink left.")),
00111             'offline': (_("Printer off-line"),
00112                         _("Printer '%s' is currently off-line.")),
00113             'connecting-to-device': (_("Not connected?"),
00114                                      _("Printer '%s' may not be connected.")),
00115             'other': (_("Printer error"),
00116                       _("There is a problem on printer '%s'.")),
00117 
00118             'cups-missing-filter': (_("Printer configuration error"),
00119                                     _("There is a missing print filter for "
00120                                       "printer '%s'.")),
00121             }
00122         try:
00123             (title, text) = messages[self.get_reason ()]
00124             try:
00125                 text = text % self.get_printer ()
00126             except TypeError:
00127                 # Probably an incorrect translation, missing a '%s'.
00128                 pass
00129         except KeyError:
00130             if self.get_level () == self.REPORT:
00131                 title = _("Printer report")
00132             elif self.get_level () == self.WARNING:
00133                 title = _("Printer warning")
00134             elif self.get_level () == self.ERROR:
00135                 title = _("Printer error")
00136 
00137             reason = self.get_reason ()
00138             if self._ppd:
00139                 try:
00140                     schemes = ["text", "http", "help", "file"]
00141                     localized_reason = ""
00142                     for scheme in schemes:
00143                         lreason = self._ppd.localizeIPPReason(self.reason,
00144                                                               scheme)
00145                         if lreason != None:
00146                             localized_reason = localized_reason + lreason + ", "
00147                     if localized_reason != "":
00148                         reason = localized_reason[:-2]
00149                 except RuntimeError:
00150                     pass
00151 
00152             text = _("Printer '%s': '%s'.") % (self.get_printer (), reason)
00153         return (title, text)

Here is the call graph for this function:

Definition at line 52 of file statereason.py.

00052 
00053     def get_level (self):
00054         if self.level != None:
00055             return self.level
00056 
00057         if (self.reason.endswith ("-report") or
00058             self.reason == "connecting-to-device"):
00059             self.level = self.REPORT
00060         elif self.reason.endswith ("-warning"):
00061             self.level = self.WARNING
00062         else:
00063             self.level = self.ERROR
00064 
00065         return self.level

Here is the caller graph for this function:

Definition at line 49 of file statereason.py.

00049 
00050     def get_printer (self):
00051         return self.printer

Here is the caller graph for this function:

Definition at line 66 of file statereason.py.

00066 
00067     def get_reason (self):
00068         if self.canonical_reason:
00069             return self.canonical_reason
00070 
00071         level = self.get_level ()
00072         reason = self.reason
00073         if level == self.WARNING and reason.endswith ("-warning"):
00074             reason = reason[:-8]
00075         elif level == self.ERROR and reason.endswith ("-error"):
00076             reason = reason[:-6]
00077         self.canonical_reason = reason
00078         return self.canonical_reason

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 154 of file statereason.py.

00154 
00155     def get_tuple (self):
00156         return (self.get_level (), self.get_printer (), self.get_reason ())

Here is the call graph for this function:


Member Data Documentation

Definition at line 42 of file statereason.py.

Definition at line 41 of file statereason.py.

Definition at line 29 of file statereason.py.

Definition at line 40 of file statereason.py.

Initial value:
{
        REPORT: "dialog-info",
        WARNING: "dialog-warning",
        ERROR: "dialog-error"
        }

Definition at line 31 of file statereason.py.

Definition at line 38 of file statereason.py.

Definition at line 39 of file statereason.py.

Definition at line 27 of file statereason.py.

Definition at line 28 of file statereason.py.


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