Ignore:
Timestamp:
Jan 10, 2012, 7:25:33 PM (12 years ago)
Author:
Jessica B. Hamrick <jhamrick@…>
Branches:
no-cups
Children:
b01b6d1
Parents:
ce2abc5
git-author:
Jessica B. Hamrick <jhamrick@…> (01/10/12 19:25:33)
git-committer:
Jessica B. Hamrick <jhamrick@…> (01/10/12 19:25:33)
Message:

Clean up core ipp code a bit

File:
1 edited

Legend:

Unmodified
Added
Removed
  • server/lib/gutenbach/ipp/core/value.py

    r793432f rffbe41d  
    4646
    4747        # make sure the arguments are valid
    48         if value is not None:
    49             assert tag is not None, \
    50                    "tag must not be null because " + \
    51                    "value is not null!"
     48        if value is not None and tag is None:
     49            raise ValueError("tag may not be None")
    5250
    5351        # initialize member variables
    54         self.tag = tag # one byte, the type of value
    55         self.value     = value     # non-binary value of self.value
     52        self.tag   = tag    # one byte, the type of value
     53        self.value = value  # non-binary value of self.value
    5654
    5755    def __cmp__(self, other):
     
    7674        """
    7775
    78         assert tag is not None, \
    79                "Cannot unpack values with unspecified value tag!"
    80         assert packed_value is not None, \
    81                "Cannot unpack null values!"
     76        if tag is None:
     77            raise ValueError("cannot unpack values with no value tag")
     78        if packed_value is None:
     79            raise ValueError("cannot unpack null values")
    8280
    8381        value = None
     
    172170
    173171        """
    174        
    175         assert self.tag is not None, \
    176                "cannot pack value with null value tag!"
    177         assert self.value is not None, \
    178                "cannot pack null value!"
     172
     173        if self.tag is None:
     174            raise ValueError("cannot pack value with null tag")
     175        if self.value is None:
     176            raise ValueError("cannot pack null value")
    179177
    180178        packed_value = None
     
    221219            # contains the units
    222220
    223             packed_value = truct.pack('>iib', *self.value)
     221            packed_value = struct.pack('>iib', *self.value)
    224222           
    225223        elif self.tag == OctetStringTags.RANGE_OF_INTEGER:
     
    291289        return self.packed_value_size + 1
    292290
    293     @property
    294     def pyobj(self):
    295         return (self.tag, self.value)
    296 
    297291    def __str__(self):
    298292        return str(self.value)
Note: See TracChangeset for help on using the changeset viewer.