def _set_enum(self, target, value, bitarray):
<EOL>if isinstance(value, int):<EOL><INDENT>if target.find('<STR_LIT>', {'<STR_LIT:value>': value}) or self._get_rangeitem(target, value):<EOL><INDENT>raw_value = value<EOL><DEDENT>else:<EOL><INDENT>raise ValueError('<STR_LIT>' % (value))<EOL><DEDENT><DEDENT>else:<EOL><INDENT>value_item = target.find('<STR_LIT>', {'<STR_LIT:description>': value})<EOL>if value_item is None:<EOL><INDENT>raise ValueError('<STR_LIT>' % (value))<EOL><DEDENT>raw_value = int(value_item['<STR_LIT:value>'])<EOL><DEDENT>return self._set_raw(target, raw_value, bitarray)<EOL>
set given enum value (by string or integer value) to target field in bitarray