From 964e248b38e4c5e5fe5081b31a078a71a7a3abe8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?M=C3=A1rton=20Csord=C3=A1s?= Date: Wed, 28 Apr 2021 11:50:24 +0200 Subject: [PATCH] [refactor] Use Python3 enums --- analyzer/codechecker_analyzer/analyzers/config_handler.py | 6 ++---- analyzer/codechecker_analyzer/buildlog/log_parser.py | 3 ++- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/analyzer/codechecker_analyzer/analyzers/config_handler.py b/analyzer/codechecker_analyzer/analyzers/config_handler.py index ab0f7b3fc1..07f4b2dda2 100644 --- a/analyzer/codechecker_analyzer/analyzers/config_handler.py +++ b/analyzer/codechecker_analyzer/analyzers/config_handler.py @@ -11,6 +11,7 @@ from abc import ABCMeta +from enum import Enum from operator import itemgetter import collections import platform @@ -32,13 +33,10 @@ # disabled on the command-line, or belongs to a profile explicitly disabled # on the command-line, then it is considered to have a CheckerState of # disabled. -# TODO: Use enum when upgrading to Python3. -class CheckerState(object): +class CheckerState(Enum): default = 0 disabled = 1 enabled = 2 - STATES = {'default', 'disabled', 'enabled'} - NAMES = {0: 'default', 1: 'disabled', 2: 'enabled'} class AnalyzerConfigHandler(object, metaclass=ABCMeta): diff --git a/analyzer/codechecker_analyzer/buildlog/log_parser.py b/analyzer/codechecker_analyzer/buildlog/log_parser.py index 865a26edbc..07830a8667 100644 --- a/analyzer/codechecker_analyzer/buildlog/log_parser.py +++ b/analyzer/codechecker_analyzer/buildlog/log_parser.py @@ -10,6 +10,7 @@ from collections import defaultdict # pylint: disable=no-name-in-module from distutils.spawn import find_executable +from enum import Enum import glob import json @@ -1200,7 +1201,7 @@ def default(self, o): return json.JSONEncoder.default(self, o) -class CompileActionUniqueingType(object): +class CompileActionUniqueingType(Enum): NONE = 0 # Full Action text SOURCE_ALPHA = 1 # Based on source file, uniqueing by # on alphanumerically first target