Skip to content

Commit

Permalink
Deprecate the classes 'Enum' and 'BitwiseEnum' from
Browse files Browse the repository at this point in the history
Mythtv.utility.enum.py.

Since python3, these classes are fully compatible to the class
'IntEnum' from the module enum in python3.

Use this statement: 'from enum import IntEnum' instead.
See https://docs.python.org/3/library/enum.html for
various ways to initialize an enum as well.

After the release of MythTV v32, the whole file utility/enum.py will
be deleted.

Refs #422
  • Loading branch information
rcrdnalor committed Dec 20, 2021
1 parent d4cf227 commit fb1f828
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion mythtv/bindings/python/MythTV/utility/enum.py
Expand Up @@ -6,12 +6,19 @@
# operation.
#------------------------------

# Important Note: The classes provided by this module are considered deprecated and will be
# removed after the release of MythTV v32!
# Please use the class 'IntEnum' from the module 'enum' provided by python3.

from builtins import int
from warnings import warn

class EnumValue( object ):
_next = 0
_storage = []
def __init__(self, name, value=None, friendly_name=None):
warn("Class 'EnumValue' will be removed after MythTV v32 release, "
"use 'IntEnum' from the module 'enum' provided by python3", DeprecationWarning, 2)
self.name = self.friendly = name
if friendly_name:
self.friendly = friendly_name
Expand Down Expand Up @@ -56,7 +63,10 @@ class BaseEnum( object, metaclass=EnumType ):
def __init__(self, mode):
self.mode = mode

def __int__(self): return self.mode
def __int__(self):
warn("Class 'BaseEnum' and it descendants will be removed after MythTV v32 release, "
"use 'IntEnum' from the module 'enum' provided by python3", DeprecationWarning, 2)
return self.mode
def __eq__(self, other): return (self.mode == int(other))
def __ne__(self, other): return (self.mode != int(other))

Expand Down

0 comments on commit fb1f828

Please sign in to comment.