Add @unique decorator to all enumerations
Currently, there are no enumerations using the enum module which reuse values/need aliases. Add the @unique decorator to all enum classes as a safety net for future modifications.
This commit is contained in:
parent
5cc92efcb6
commit
8df8486def
|
@ -23,7 +23,7 @@
|
|||
## along with Gajim. If not, see <http://www.gnu.org/licenses/>.
|
||||
##
|
||||
|
||||
from enum import IntEnum
|
||||
from enum import IntEnum, unique
|
||||
|
||||
from gi.repository import Gtk
|
||||
import gtkgui_helpers
|
||||
|
@ -32,6 +32,7 @@ from gi.repository import Pango
|
|||
|
||||
from common import gajim
|
||||
|
||||
@unique
|
||||
class Column(IntEnum):
|
||||
PREFERENCE_NAME = 0
|
||||
VALUE = 1
|
||||
|
|
|
@ -35,8 +35,9 @@
|
|||
import re
|
||||
from common import defs
|
||||
from gi.repository import GLib
|
||||
from enum import IntEnum
|
||||
from enum import IntEnum, unique
|
||||
|
||||
@unique
|
||||
class Option(IntEnum):
|
||||
TYPE = 0
|
||||
VAL = 1
|
||||
|
|
|
@ -26,8 +26,9 @@ import os
|
|||
import sys
|
||||
import tempfile
|
||||
from common import defs
|
||||
from enum import Enum
|
||||
from enum import Enum, unique
|
||||
|
||||
@unique
|
||||
class Type(Enum):
|
||||
CONFIG = 0
|
||||
CACHE = 1
|
||||
|
|
|
@ -23,7 +23,7 @@ import hashlib
|
|||
import logging
|
||||
import os
|
||||
import threading
|
||||
from enum import IntEnum
|
||||
from enum import IntEnum, unique
|
||||
import nbxmpp
|
||||
from common import gajim
|
||||
from common import configpaths
|
||||
|
@ -39,6 +39,7 @@ from common.jingle_ftstates import (
|
|||
log = logging.getLogger('gajim.c.jingle_ft')
|
||||
|
||||
|
||||
@unique
|
||||
class State(IntEnum):
|
||||
NOT_STARTED = 0
|
||||
INITIALIZED = 1
|
||||
|
|
|
@ -29,7 +29,7 @@ Handles Jingle sessions (XEP 0166)
|
|||
# * timeout
|
||||
|
||||
import logging
|
||||
from enum import Enum
|
||||
from enum import Enum, unique
|
||||
import nbxmpp
|
||||
from common import gajim
|
||||
from common.jingle_transport import get_jingle_transport, JingleTransportIBB
|
||||
|
@ -43,6 +43,7 @@ from common.connection_handlers_events import (
|
|||
log = logging.getLogger("gajim.c.jingle_session")
|
||||
|
||||
# FIXME: Move it to JingleSession.States?
|
||||
@unique
|
||||
class JingleStates(Enum):
|
||||
"""
|
||||
States in which jingle session may exist
|
||||
|
|
|
@ -19,7 +19,7 @@ Handles Jingle Transports (currently only ICE-UDP)
|
|||
|
||||
import logging
|
||||
import socket
|
||||
from enum import IntEnum
|
||||
from enum import IntEnum, unique
|
||||
import nbxmpp
|
||||
from common import gajim
|
||||
|
||||
|
@ -34,6 +34,7 @@ def get_jingle_transport(node):
|
|||
return transports[namespace](node)
|
||||
|
||||
|
||||
@unique
|
||||
class TransportType(IntEnum):
|
||||
"""
|
||||
Possible types of a JingleTransport
|
||||
|
|
|
@ -36,7 +36,7 @@ import json
|
|||
from gzip import GzipFile
|
||||
from io import BytesIO
|
||||
from gi.repository import GLib
|
||||
from enum import IntEnum
|
||||
from enum import IntEnum, unique
|
||||
|
||||
from common import exceptions
|
||||
from common import gajim
|
||||
|
@ -51,10 +51,12 @@ CACHE_DB_PATH = gajim.gajimpaths['CACHE_DB']
|
|||
import logging
|
||||
log = logging.getLogger('gajim.c.logger')
|
||||
|
||||
@unique
|
||||
class JIDConstant(IntEnum):
|
||||
NORMAL_TYPE = 0
|
||||
ROOM_TYPE = 1
|
||||
|
||||
@unique
|
||||
class KindConstant(IntEnum):
|
||||
STATUS = 0
|
||||
GCSTATUS = 1
|
||||
|
@ -65,6 +67,7 @@ class KindConstant(IntEnum):
|
|||
CHAT_MSG_SENT = 6
|
||||
ERROR = 7
|
||||
|
||||
@unique
|
||||
class ShowConstant(IntEnum):
|
||||
ONLINE = 0
|
||||
CHAT = 1
|
||||
|
@ -73,6 +76,7 @@ class ShowConstant(IntEnum):
|
|||
DND = 4
|
||||
OFFLINE = 5
|
||||
|
||||
@unique
|
||||
class TypeConstant(IntEnum):
|
||||
AIM = 0
|
||||
GG = 1
|
||||
|
@ -90,6 +94,7 @@ class TypeConstant(IntEnum):
|
|||
MRIM = 13
|
||||
NO_TRANSPORT = 14
|
||||
|
||||
@unique
|
||||
class SubscriptionConstant(IntEnum):
|
||||
NONE = 0
|
||||
TO = 1
|
||||
|
|
|
@ -17,8 +17,9 @@
|
|||
## along with Gajim. If not, see <http://www.gnu.org/licenses/>.
|
||||
##
|
||||
|
||||
from enum import IntEnum
|
||||
from enum import IntEnum, unique
|
||||
|
||||
@unique
|
||||
class Constant(IntEnum):
|
||||
NAME = 0
|
||||
DOMAIN = 1
|
||||
|
@ -26,6 +27,7 @@ class Constant(IntEnum):
|
|||
BARE_NAME = 3
|
||||
TXT = 4
|
||||
|
||||
@unique
|
||||
class ConstantRI(IntEnum):
|
||||
INTERFACE = 0
|
||||
PROTOCOL = 1
|
||||
|
|
|
@ -29,7 +29,7 @@ from gi.repository import Pango
|
|||
import os
|
||||
import time
|
||||
|
||||
from enum import IntEnum
|
||||
from enum import IntEnum, unique
|
||||
|
||||
import gtkgui_helpers
|
||||
import tooltips
|
||||
|
@ -44,6 +44,7 @@ from nbxmpp.protocol import NS_JINGLE_FILE_TRANSFER
|
|||
import logging
|
||||
log = logging.getLogger('gajim.filetransfer_window')
|
||||
|
||||
@unique
|
||||
class Column(IntEnum):
|
||||
IMAGE = 0
|
||||
LABELS = 1
|
||||
|
|
|
@ -46,7 +46,7 @@ import cell_renderer_image
|
|||
import dataforms_widget
|
||||
import nbxmpp
|
||||
|
||||
from enum import IntEnum
|
||||
from enum import IntEnum, unique
|
||||
|
||||
from common import events
|
||||
from common import gajim
|
||||
|
@ -65,6 +65,7 @@ from common.connection_handlers_events import GcMessageOutgoingEvent
|
|||
import logging
|
||||
log = logging.getLogger('gajim.groupchat_control')
|
||||
|
||||
@unique
|
||||
class Column(IntEnum):
|
||||
IMG = 0 # image to show state (online, new message etc)
|
||||
NICK = 1 # contact nickame or ROLE name
|
||||
|
|
|
@ -77,8 +77,9 @@ from common.logger import LOG_DB_PATH, JIDConstant, KindConstant
|
|||
from common import helpers
|
||||
import dialogs
|
||||
|
||||
from enum import IntEnum
|
||||
from enum import IntEnum, unique
|
||||
|
||||
@unique
|
||||
class Column(IntEnum):
|
||||
UNIXTIME = 2
|
||||
MESSAGE = 3
|
||||
|
|
|
@ -31,7 +31,7 @@ from gi.repository import GLib
|
|||
import time
|
||||
import calendar
|
||||
|
||||
from enum import IntEnum
|
||||
from enum import IntEnum, unique
|
||||
|
||||
import gtkgui_helpers
|
||||
import conversation_textview
|
||||
|
@ -43,6 +43,7 @@ from common import exceptions
|
|||
|
||||
from common.logger import ShowConstant, KindConstant
|
||||
|
||||
@unique
|
||||
class InfoColumn(IntEnum):
|
||||
'''Completion dict'''
|
||||
JID = 0
|
||||
|
@ -50,6 +51,7 @@ class InfoColumn(IntEnum):
|
|||
NAME = 2
|
||||
COMPLETION = 3
|
||||
|
||||
@unique
|
||||
class Column(IntEnum):
|
||||
LOG_JID = 0
|
||||
CONTACT_NAME = 1
|
||||
|
|
|
@ -32,7 +32,7 @@ from gi.repository import GdkPixbuf
|
|||
from gi.repository import GLib, Gdk
|
||||
import os
|
||||
|
||||
from enum import IntEnum
|
||||
from enum import IntEnum, unique
|
||||
|
||||
import gtkgui_helpers
|
||||
from dialogs import WarningDialog, YesNoDialog, ArchiveChooserDialog
|
||||
|
@ -43,6 +43,7 @@ from plugins.helpers import GajimPluginActivateException
|
|||
from plugins.plugins_i18n import _
|
||||
from common.exceptions import PluginsystemError
|
||||
|
||||
@unique
|
||||
class Column(IntEnum):
|
||||
PLUGIN = 0
|
||||
NAME = 1
|
||||
|
|
|
@ -43,7 +43,7 @@ import os
|
|||
import time
|
||||
import locale
|
||||
|
||||
from enum import IntEnum
|
||||
from enum import IntEnum, unique
|
||||
|
||||
import common.sleepy
|
||||
import history_window
|
||||
|
@ -69,6 +69,7 @@ from message_window import MessageWindowMgr
|
|||
from nbxmpp.protocol import NS_FILE, NS_ROSTERX, NS_CONFERENCE
|
||||
|
||||
|
||||
@unique
|
||||
class Column(IntEnum):
|
||||
IMG = 0 # image to show state (online, new message etc)
|
||||
NAME = 1 # cellrenderer text that holds contact nickame
|
||||
|
|
Loading…
Reference in New Issue