mirror of
https://github.com/samba-team/samba.git
synced 2025-01-11 05:18:09 +03:00
netcmd: models: EnumField now also supports IntFlag
Signed-off-by: Rob van der Linde <rob@catalyst.net.nz> Reviewed-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz> Reviewed-by: Andrew Bartlett <abartlet@samba.org>
This commit is contained in:
parent
3c8d449ad3
commit
4595a1dae3
@ -20,7 +20,7 @@
|
|||||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
#
|
#
|
||||||
|
|
||||||
from enum import IntEnum
|
from enum import IntEnum, IntFlag
|
||||||
|
|
||||||
import io
|
import io
|
||||||
from abc import ABCMeta, abstractmethod
|
from abc import ABCMeta, abstractmethod
|
||||||
@ -181,7 +181,7 @@ class EnumField(Field):
|
|||||||
|
|
||||||
Has a special case for IntEnum as the constructor only accepts int.
|
Has a special case for IntEnum as the constructor only accepts int.
|
||||||
"""
|
"""
|
||||||
if issubclass(self.enum, IntEnum):
|
if issubclass(self.enum, (IntEnum, IntFlag)):
|
||||||
return self.enum(int(str(value)))
|
return self.enum(int(str(value)))
|
||||||
else:
|
else:
|
||||||
return self.enum(str(value))
|
return self.enum(str(value))
|
||||||
|
Loading…
Reference in New Issue
Block a user