Skip to content

Commit

Permalink
✨ feat(constants): defines colors and symbols as constants
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
pallabpain committed Jun 19, 2023
1 parent 63b975e commit 32eab78
Show file tree
Hide file tree
Showing 3 changed files with 79 additions and 0 deletions.
18 changes: 18 additions & 0 deletions riocli/constants/__init__.py
Original file line number Diff line number Diff line change
@@ -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]
41 changes: 41 additions & 0 deletions riocli/constants/colors.py
Original file line number Diff line number Diff line change
@@ -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'
20 changes: 20 additions & 0 deletions riocli/constants/symbols.py
Original file line number Diff line number Diff line change
@@ -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 = '⧖'

0 comments on commit 32eab78

Please sign in to comment.