-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathColor.py
More file actions
28 lines (20 loc) · 812 Bytes
/
Color.py
File metadata and controls
28 lines (20 loc) · 812 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
class Color:
"""Color and only things related to the color itself."""
color_list = {} # Color-tracking dictionary
abbreviation_length = 3
def __init__(self, full_name: str, color_code: str, abbreviation: str = None):
"""
:param full_name: Full name of a color: "Yellow"
:param color_code: ANSI control code for this color
:param abbreviation: Short name of a color: "yel"
"""
# Assign parameters
self.color_name = full_name
self.abbreviation = abbreviation or full_name[:Color.abbreviation_length]
self.color_code = color_code
# Other fields
Color.color_list[full_name] = self
def __str__(self):
return self.color_name
def __repr__(self):
return "(Color) " + self.color_name