Changeset 3099
- Timestamp:
- 07/08/08 15:10:21 (5 years ago)
- Location:
- branch/UMPA/umpa
- Files:
-
- 2 modified
-
protocols/IP.py (modified) (3 diffs)
-
utils/__init__.py (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
branch/UMPA/umpa/protocols/IP.py
r3088 r3099 22 22 import base 23 23 from utils.my_exceptions import UMPAAttributeException 24 from utils import get_item_by_name 24 25 25 26 class HVersion(base.Field): … … 114 115 '''Set value of the field.''' 115 116 if self._is_valid(attr): 116 self._fields[valid_fields.index(attr)].set(val)117 get_item_by_name(self._fields, self.valid_fields, attr).set(val) 117 118 else: 118 119 raise UMPAAttributeException, attr + ' not allowed' … … 121 122 '''Return value of the field.''' 122 123 if self._is_valid(attr): 123 return self._fields[valid_fields.index(attr)].get() 124 return get_item_by_name(self._fields, self.valid_fields, 125 attr).get() 124 126 else: 125 127 raise UMPAAttributeException, attr + ' not allowed' -
branch/UMPA/umpa/utils/__init__.py
r3082 r3099 28 28 29 29 def dict_from_sequence(seq): 30 '''Return sa dictionary based on a sequence.'''30 '''Return a dictionary based on a sequence.''' 31 31 return dict(_pairwise(seq)) 32 33 def get_item_by_name(seq, seq_with_name, name): 34 '''Return an item from the sequence based on the another sequence 35 and position of the name there. 36 ''' 37 return seq[seq_with_name.index(name)]
