From 32eab78c305ae754d19ba84f8c870aa0cc144ff8 Mon Sep 17 00:00:00 2001 From: Pallab Pain Date: Thu, 25 May 2023 19:27:53 +0530 Subject: [PATCH] =?UTF-8?q?=E2=9C=A8=20feat(constants):=20defines=20colors?= =?UTF-8?q?=20and=20symbols=20as=20constants?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This commit introduces the constants module. There are redundant uses of many strings and symbols in the entire code base and this module puts them all in one place such that all existing and future code can refer these. --- riocli/constants/__init__.py | 18 ++++++++++++++++ riocli/constants/colors.py | 41 ++++++++++++++++++++++++++++++++++++ riocli/constants/symbols.py | 20 ++++++++++++++++++ 3 files changed, 79 insertions(+) create mode 100644 riocli/constants/__init__.py create mode 100644 riocli/constants/colors.py create mode 100644 riocli/constants/symbols.py diff --git a/riocli/constants/__init__.py b/riocli/constants/__init__.py new file mode 100644 index 00000000..67fb31a4 --- /dev/null +++ b/riocli/constants/__init__.py @@ -0,0 +1,18 @@ +# Copyright 2023 Rapyuta Robotics +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +from riocli.constants.colors import Colors +from riocli.constants.symbols import Symbols + +__all__ = [Colors, Symbols] diff --git a/riocli/constants/colors.py b/riocli/constants/colors.py new file mode 100644 index 00000000..e2be344e --- /dev/null +++ b/riocli/constants/colors.py @@ -0,0 +1,41 @@ +# Copyright 2023 Rapyuta Robotics +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +from enum import Enum + + +class Colors(str, Enum): + """ + Colors is a str enum based on the colors supported by click. + https://github.com/pallets/click/blob/main/examples/colors/colors.py + """ + def __str__(self): + return str(self.value).lower() + + BLACK = 'black' + RED = 'red' + GREEN = 'green' + YELLOW = 'yellow' + BLUE = 'blue' + MAGENTA = 'magenta' + CYAN = 'cyan' + WHITE = 'white' + BRIGHT_BLACK = 'bright_black' + BRIGHT_RED = 'bright_red' + BRIGHT_GREEN = 'bright_green' + BRIGHT_YELLOW = 'bright_yellow' + BRIGHT_BLUE = 'bright_blue' + BRIGHT_MAGENTA = 'bright_magenta' + BRIGHT_CYAN = 'bright_cyan' + BRIGHT_WHITE = 'bright_white' diff --git a/riocli/constants/symbols.py b/riocli/constants/symbols.py new file mode 100644 index 00000000..ad21d817 --- /dev/null +++ b/riocli/constants/symbols.py @@ -0,0 +1,20 @@ +# Copyright 2023 Rapyuta Robotics +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +class Symbols: + INFO = '🛈' + ERROR = '✘' + SUCCESS = '✔' + WARNING = '⚠' + WAITING = '⧖'