Changeset 2416 for pykota/trunk
- Timestamp:
- 09/03/05 00:38:54 (19 years ago)
- Files:
-
- 1 modified
Legend:
- Unmodified
- Added
- Removed
-
pykota/trunk/pykota/ipp.py
r2415 r2416 161 161 if not self.parsed : 162 162 return "" 163 buffer = []164 buffer.append("IPP version : %s.%s" % self.version)165 buffer.append("IPP operation Id : 0x%04x" % self.operation_id)166 buffer.append("IPP request Id : 0x%08x" % self.request_id)163 mybuffer = [] 164 mybuffer.append("IPP version : %s.%s" % self.version) 165 mybuffer.append("IPP operation Id : 0x%04x" % self.operation_id) 166 mybuffer.append("IPP request Id : 0x%08x" % self.request_id) 167 167 for attrtype in self.attributes_types : 168 168 attrdict = getattr(self, "%s_attributes" % attrtype) 169 169 if attrdict : 170 buffer.append("%s attributes :" % attrtype.title())170 mybuffer.append("%s attributes :" % attrtype.title()) 171 171 for key in attrdict.keys() : 172 buffer.append(" %s : %s" % (key, attrdict[key]))172 mybuffer.append(" %s : %s" % (key, attrdict[key])) 173 173 if self.data : 174 buffer.append("IPP datas : %s" % repr(message.data))175 return "\n".join( buffer)174 mybuffer.append("IPP datas : %s" % repr(message.data)) 175 return "\n".join(mybuffer) 176 176 177 177 def dump(self) : … … 180 180 Returns the message as a string of text. 181 181 """ 182 buffer = []182 mybuffer = [] 183 183 if None not in (self.version, self.operation_id, self.request_id) : 184 buffer.append(chr(self.version[0]) + chr(self.version[1]))185 buffer.append(pack(">H", self.operation_id))186 buffer.append(pack(">I", self.request_id))184 mybuffer.append(chr(self.version[0]) + chr(self.version[1])) 185 mybuffer.append(pack(">H", self.operation_id)) 186 mybuffer.append(pack(">I", self.request_id)) 187 187 for attrtype in self.attributes_types : 188 188 tagprinted = 0 189 189 for (attrname, value) in getattr(self, "%s_attributes" % attrtype).items() : 190 190 if not tagprinted : 191 buffer.append(chr(self.dictags["%s-attributes-tag" % attrtype]))191 mybuffer.append(chr(self.dictags["%s-attributes-tag" % attrtype])) 192 192 tagprinted = 1 193 193 if type(value) != type([]) : 194 194 value = [ value ] 195 195 for (vtype, val) in value : 196 buffer.append(chr(self.dictags[vtype]))197 buffer.append(pack(">H", len(attrname)))198 buffer.append(attrname)196 mybuffer.append(chr(self.dictags[vtype])) 197 mybuffer.append(pack(">H", len(attrname))) 198 mybuffer.append(attrname) 199 199 if vtype in ("integer", "enum") : 200 buffer.append(pack(">H", 4))201 buffer.append(pack(">I", val))200 mybuffer.append(pack(">H", 4)) 201 mybuffer.append(pack(">I", val)) 202 202 elif vtype == "boolean" : 203 buffer.append(pack(">H", 1))204 buffer.append(chr(val))203 mybuffer.append(pack(">H", 1)) 204 mybuffer.append(chr(val)) 205 205 else : 206 buffer.append(pack(">H", len(val)))207 buffer.append(val)208 buffer.append(chr(self.dictags["end-of-attributes-tag"]))209 buffer.append(self.data)210 return "".join( buffer)206 mybuffer.append(pack(">H", len(val))) 207 mybuffer.append(val) 208 mybuffer.append(chr(self.dictags["end-of-attributes-tag"])) 209 mybuffer.append(self.data) 210 return "".join(mybuffer) 211 211 212 212 def parse(self) :