Releases: jshwi/object-colors
v2.3.1
v2.3.0
v2.2.0
v2.1.0
v2.0.1
v2.0.0
Added
- Adds
colorama
forWindows
systems - Overrides
__repr__
- Adds string formatter to
get
- Adds
populate
for all elements - Raises
TypeError
if setting invalid attribute name - Raises
IndexError
if setting of rangeint
attributes - Raises
TypeError
if setting invalid attribute type - Raises
ValueError
if setting invalid attributestr
value - Overrides
__len__
- Allows empty
get
orprint
without raising anIndexError
Changed
- Renames:
text
->fore
,background
->back
- Renames:
purple
->magenta
- Moves:
_get_processed
->__setattr__
- Improves compiled ANSI string and default types
Deprecated
populate_colors
is deprecated in favour ofpopulate("fore")
Removed
- Removes multicolor feature
- Removes
pop
method - Removes functionality to pass single {1,2,3} digit number as {1,2,3} arg(s)
Fixed
- Fixes
print
method to mirror builtin - Removes default black background for none
- Adds all effects
- Objects can be properly added with
__setattr__
Multicolor
New Methods
- multicolor():
- All colors present in class with randomly color string
- set_str():
- Set a new subclass with an ansi escaped string
- get_object():
- separate an ansi escaped string into an object containing ansi code and bare string
- get_list():
- separate an ansi escaped string into a list containing ansi code and bare string
Add keyword colours
Return string coloured by chosen keywords
The colour of the class will be the colour of the keyword while the rest of the string will remain as it was
Includes option to scatter the search (instead of only words) and option to ignore cases
color = Color(populate=True)
str_ = "String of substrings to colour"
colored_keys = color.red.get_key(str_, "String", scatter=False, ignore_case=False)
These few lines of code would be returned with the substring "String" highlighted in red
Add populate arg
Colors("colors") is not intuitive
Colors(populate=True) will populate all colors into class now
Add populate colors
When called with the "colors" string argument the new instance will be populated with an instance for every color.
When combined with the bold object this further simplifies the use of this module.
example:
c = Color("colors")
c.red.print("not bold")
c.red.bold.print("bold")
c.yellow.print("not bold")
c.yellow.bold.print("bold")
etc...