Changeset 635 for tea4cups

Show
Ignore:
Timestamp:
05/15/05 11:17:29 (19 years ago)
Author:
jerome
Message:

Added support for IPP unsupported attributes :-)

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • tea4cups/trunk/tea4cups

    r634 r635  
    9090 
    9191class 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    """ 
    93109    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        """ 
    95117        self.debug = debug 
    96118        self.data = data 
     
    98120        self.job_attributes = {} 
    99121        self.printer_attributes = {} 
     122        self.unsupported_attributes = {} 
    100123        self.tags = [ None ] * 256      # by default all tags reserved 
    101124         
     
    179202         
    180203    def job_attributes_tag(self) :  
    181         """Indicates that the parser enters into an operation-attributes-tag group.""" 
     204        """Indicates that the parser enters into a job-attributes-tag group.""" 
    182205        self.printInfo("Start of job_attributes_tag") 
    183206        self._curdict = self.job_attributes 
     
    185208         
    186209    def printer_attributes_tag(self) :  
    187         """Indicates that the parser enters into an operation-attributes-tag group.""" 
     210        """Indicates that the parser enters into a printer-attributes-tag group.""" 
    188211        self.printInfo("Start of printer_attributes_tag") 
    189212        self._curdict = self.printer_attributes 
    190213        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         
    192221    def parse(self) : 
    193222        """Parses an IPP Message. 
    194223         
    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. 
    198225        """ 
    199226        self._curname = None 
     
    225252                if len(value) == 1 : 
    226253                    attrdict[key] = value[0] 
    227              
     254                     
    228255class FakeConfig :     
    229256    """Fakes a configuration file parser."""