- Timestamp:
- 05/15/05 11:17:29 (20 years ago)
- Files:
-
- 1 modified
Legend:
- Unmodified
- Added
- Removed
-
tea4cups/trunk/tea4cups
r634 r635 90 90 91 91 class IPPMessage : 92 """A class for IPP message files.""" 92 """A class for IPP message files. 93 94 Usage : 95 96 fp = open("/var/spool/cups/c00001", "rb") 97 message = IPPMessage(fp.read()) 98 fp.close() 99 print "IPP version : %s" % message.version 100 print "IPP operation Id : %s" % message.operation_id 101 print "IPP request Id : %s" % message.request_id 102 for attrtype in ("operation", "job", "printer", "unsupported") : 103 attrdict = getattr(message, "%s_attributes" % attrtype) 104 if attrdict : 105 print "%s attributes :" % attrtype.title() 106 for key in attrdict.keys() : 107 print " %s : %s" % (key, attrdict[key]) 108 """ 93 109 def __init__(self, data, debug=0) : 94 """Initializes an IPP Message object.""" 110 """Initializes and parses IPP Message object. 111 112 Parameters : 113 114 data : the IPP Message's content. 115 debug : a boolean value to output debug info on stderr. 116 """ 95 117 self.debug = debug 96 118 self.data = data … … 98 120 self.job_attributes = {} 99 121 self.printer_attributes = {} 122 self.unsupported_attributes = {} 100 123 self.tags = [ None ] * 256 # by default all tags reserved 101 124 … … 179 202 180 203 def job_attributes_tag(self) : 181 """Indicates that the parser enters into a n operation-attributes-tag group."""204 """Indicates that the parser enters into a job-attributes-tag group.""" 182 205 self.printInfo("Start of job_attributes_tag") 183 206 self._curdict = self.job_attributes … … 185 208 186 209 def printer_attributes_tag(self) : 187 """Indicates that the parser enters into a n operation-attributes-tag group."""210 """Indicates that the parser enters into a printer-attributes-tag group.""" 188 211 self.printInfo("Start of printer_attributes_tag") 189 212 self._curdict = self.printer_attributes 190 213 return self.parseTag() 191 214 215 def unsupported_attributes_tag(self) : 216 """Indicates that the parser enters into an unsupported-attributes-tag group.""" 217 self.printInfo("Start of unsupported_attributes_tag") 218 self._curdict = self.unsupported_attributes 219 return self.parseTag() 220 192 221 def parse(self) : 193 222 """Parses an IPP Message. 194 223 195 Implemented with RFC2910 as a reference. 196 NB : only a subset is actually implemented, but CUPS generated 197 message files are completely decoded. 224 NB : Only a subset of RFC2910 is implemented. 198 225 """ 199 226 self._curname = None … … 225 252 if len(value) == 1 : 226 253 attrdict[key] = value[0] 227 254 228 255 class FakeConfig : 229 256 """Fakes a configuration file parser."""