Changeset c269bc7 for server/lib/ippattributegroup.py
- Timestamp:
- Mar 7, 2011, 7:47:42 PM (14 years ago)
- Branches:
- no-cups
- Children:
- fa0d0ef
- Parents:
- 5cfb358
- git-author:
- Jessica B. Hamrick <jhamrick@…> (03/07/11 19:47:42)
- git-committer:
- Jessica B. Hamrick <jhamrick@…> (03/07/11 19:47:42)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
server/lib/ippattributegroup.py
rebf327d rc269bc7 13 13 """ 14 14 15 def __init__(self, attribute_group_tag , attributes=[]):15 def __init__(self, attribute_group_tag=None, attributes=[]): 16 16 """ 17 Initialize an AttributeGroup. 17 Initialize an AttributeGroup. An AttributeGroup can be 18 initialized in three ways: 19 20 AttributeGroup() 21 AttributeGroup(attribute_group_tag) 22 AttributeGroup(attribute_group_tag, attributes) 18 23 19 24 Arguments: … … 22 27 attribute group 23 28 24 attributes -- (optional)a list of attributes29 attributes -- a list of attributes 25 30 """ 26 31 27 # make sure attribute_group_tag isn't empty 28 assert attribute_group_tag is not None 32 if attribute_group_tag is not None: 33 assert isinstance(attribute_group_tag, char), \ 34 "attribute_group_tag must be a character!" 35 29 36 30 # make sure attributes is a list or tuple of Attributes 31 assert isinstance(attributes, (list, tuple)) 32 for a in attributes: assert isinstance(a, Attribute) 37 if len(attributes) > 0: 38 for a in attributes: 39 assert isinstance(a, Attribute), \ 40 "attribute must be of type Attribute!" 33 41 34 42 self.attribute_group_tag = attribute_group_tag … … 36 44 37 45 def getAttribute(self, name): 46 """ 47 Returns a list of attributes which have name 'name'. 48 """ 49 38 50 return filter(lambda x: x.name == name, self.attributes) 39 51 40 def toBinaryData(self): 52 def getTag(self): 53 """ 54 Return the attribute group tag. 55 """ 56 57 return self.attribute_group_tag 58 59 def getAttributes(self): 60 """ 61 Return the list of attributes in this attribue group. 62 """ 63 64 return self.attributes 65 66 def setAttributes(self, attributes): 67 """ 68 Sets the attributes for the attribute group. 69 """ 70 71 for a in attributes: 72 assert isinstance(a, Attribute), \ 73 "attribute must be of type Attribute!" 74 75 self.attributes = attributes 76 77 def addAttribute(self, attribute): 78 """ 79 Adds an attribute to the list of attributes for the attribute 80 group. 81 """ 82 83 assert isinstance(attribute, Attribute), \ 84 "attribute must be of type Attribute!" 85 86 self.attributes.append(attribute) 87 88 def setTag(self, tag): 89 """ 90 Sets the attribute group tag. 91 """ 92 93 assert isinstance(tag, char), \ 94 "attribute tag must be a character!" 95 96 self.attribute_group_tag = tag 97 98 def pack(self): 41 99 """ 42 100 Convert the AttributeGroup to binary.
Note: See TracChangeset
for help on using the changeset viewer.