2828
2929
3030class AllowStyle (Enum ):
31- """Values for ``cmd2.ansi.allow_style``"""
31+ """Values for ``cmd2.ansi.allow_style``. """
3232
3333 ALWAYS = 'Always' # Always output ANSI style sequences
3434 NEVER = 'Never' # Remove ANSI style sequences from all output
3535 TERMINAL = 'Terminal' # Remove ANSI style sequences if the output is not going to the terminal
3636
3737 def __str__ (self ) -> str :
38- """Return value instead of enum name for printing in cmd2's set command"""
38+ """Return value instead of enum name for printing in cmd2's set command. """
3939 return str (self .value )
4040
4141 def __repr__ (self ) -> str :
42- """Return quoted value instead of enum description for printing in cmd2's set command"""
42+ """Return quoted value instead of enum description for printing in cmd2's set command. """
4343 return repr (self .value )
4444
4545
@@ -124,7 +124,7 @@ def widest_line(text: str) -> int:
124124
125125
126126def style_aware_write (fileobj : IO [str ], msg : str ) -> None :
127- """Write a string to a fileobject and strip its ANSI style sequences if required by allow_style setting
127+ """Write a string to a fileobject and strip its ANSI style sequences if required by allow_style setting.
128128
129129 :param fileobj: the file object being written to
130130 :param msg: the string being written
@@ -183,63 +183,63 @@ def clear_line(clear_type: int = 2) -> str:
183183# Base classes which are not intended to be used directly
184184####################################################################################
185185class AnsiSequence :
186- """Base class to create ANSI sequence strings"""
186+ """Base class to create ANSI sequence strings. """
187187
188188 def __add__ (self , other : Any ) -> str :
189189 """Support building an ANSI sequence string when self is the left operand
190- e.g. Fg.LIGHT_MAGENTA + "hello"
190+ e.g. Fg.LIGHT_MAGENTA + "hello".
191191 """
192192 return str (self ) + str (other )
193193
194194 def __radd__ (self , other : Any ) -> str :
195195 """Support building an ANSI sequence string when self is the right operand
196- e.g. "hello" + Fg.RESET
196+ e.g. "hello" + Fg.RESET.
197197 """
198198 return str (other ) + str (self )
199199
200200
201201class FgColor (AnsiSequence ):
202- """Base class for ANSI Sequences which set foreground text color"""
202+ """Base class for ANSI Sequences which set foreground text color. """
203203
204204
205205class BgColor (AnsiSequence ):
206- """Base class for ANSI Sequences which set background text color"""
206+ """Base class for ANSI Sequences which set background text color. """
207207
208208
209209####################################################################################
210210# Implementations intended for direct use
211211####################################################################################
212212class Cursor :
213- """Create ANSI sequences to alter the cursor position"""
213+ """Create ANSI sequences to alter the cursor position. """
214214
215215 @staticmethod
216216 def UP (count : int = 1 ) -> str :
217- """Move the cursor up a specified amount of lines (Defaults to 1)"""
217+ """Move the cursor up a specified amount of lines (Defaults to 1). """
218218 return f"{ CSI } { count } A"
219219
220220 @staticmethod
221221 def DOWN (count : int = 1 ) -> str :
222- """Move the cursor down a specified amount of lines (Defaults to 1)"""
222+ """Move the cursor down a specified amount of lines (Defaults to 1). """
223223 return f"{ CSI } { count } B"
224224
225225 @staticmethod
226226 def FORWARD (count : int = 1 ) -> str :
227- """Move the cursor forward a specified amount of lines (Defaults to 1)"""
227+ """Move the cursor forward a specified amount of lines (Defaults to 1). """
228228 return f"{ CSI } { count } C"
229229
230230 @staticmethod
231231 def BACK (count : int = 1 ) -> str :
232- """Move the cursor back a specified amount of lines (Defaults to 1)"""
232+ """Move the cursor back a specified amount of lines (Defaults to 1). """
233233 return f"{ CSI } { count } D"
234234
235235 @staticmethod
236236 def SET_POS (x : int , y : int ) -> str :
237- """Set the cursor position to coordinates which are 1-based"""
237+ """Set the cursor position to coordinates which are 1-based. """
238238 return f"{ CSI } { y } ;{ x } H"
239239
240240
241241class TextStyle (AnsiSequence , Enum ):
242- """Create text style ANSI sequences"""
242+ """Create text style ANSI sequences. """
243243
244244 # Resets all styles and colors of text
245245 RESET_ALL = 0
@@ -264,7 +264,7 @@ class TextStyle(AnsiSequence, Enum):
264264 def __str__ (self ) -> str :
265265 """Return ANSI text style sequence instead of enum name
266266 This is helpful when using a TextStyle in an f-string or format() call
267- e.g. my_str = f"{TextStyle.UNDERLINE_ENABLE}hello{TextStyle.UNDERLINE_DISABLE}"
267+ e.g. my_str = f"{TextStyle.UNDERLINE_ENABLE}hello{TextStyle.UNDERLINE_DISABLE}".
268268 """
269269 return f"{ CSI } { self .value } m"
270270
@@ -297,7 +297,7 @@ class Fg(FgColor, Enum):
297297 def __str__ (self ) -> str :
298298 """Return ANSI color sequence instead of enum name
299299 This is helpful when using an Fg in an f-string or format() call
300- e.g. my_str = f"{Fg.BLUE}hello{Fg.RESET}"
300+ e.g. my_str = f"{Fg.BLUE}hello{Fg.RESET}".
301301 """
302302 return f"{ CSI } { self .value } m"
303303
@@ -330,7 +330,7 @@ class Bg(BgColor, Enum):
330330 def __str__ (self ) -> str :
331331 """Return ANSI color sequence instead of enum name
332332 This is helpful when using a Bg in an f-string or format() call
333- e.g. my_str = f"{Bg.BLACK}hello{Bg.RESET}"
333+ e.g. my_str = f"{Bg.BLACK}hello{Bg.RESET}".
334334 """
335335 return f"{ CSI } { self .value } m"
336336
@@ -601,7 +601,7 @@ class EightBitFg(FgColor, Enum):
601601 def __str__ (self ) -> str :
602602 """Return ANSI color sequence instead of enum name
603603 This is helpful when using an EightBitFg in an f-string or format() call
604- e.g. my_str = f"{EightBitFg.SLATE_BLUE_1}hello{Fg.RESET}"
604+ e.g. my_str = f"{EightBitFg.SLATE_BLUE_1}hello{Fg.RESET}".
605605 """
606606 return f"{ CSI } 38;5;{ self .value } m"
607607
@@ -872,7 +872,7 @@ class EightBitBg(BgColor, Enum):
872872 def __str__ (self ) -> str :
873873 """Return ANSI color sequence instead of enum name
874874 This is helpful when using an EightBitBg in an f-string or format() call
875- e.g. my_str = f"{EightBitBg.KHAKI_3}hello{Bg.RESET}"
875+ e.g. my_str = f"{EightBitBg.KHAKI_3}hello{Bg.RESET}".
876876 """
877877 return f"{ CSI } 48;5;{ self .value } m"
878878
@@ -883,7 +883,7 @@ class RgbFg(FgColor):
883883 """
884884
885885 def __init__ (self , r : int , g : int , b : int ) -> None :
886- """RgbFg initializer
886+ """RgbFg initializer.
887887
888888 :param r: integer from 0-255 for the red component of the color
889889 :param g: integer from 0-255 for the green component of the color
@@ -898,7 +898,7 @@ def __init__(self, r: int, g: int, b: int) -> None:
898898 def __str__ (self ) -> str :
899899 """Return ANSI color sequence instead of enum name
900900 This is helpful when using an RgbFg in an f-string or format() call
901- e.g. my_str = f"{RgbFg(0, 55, 100)}hello{Fg.RESET}"
901+ e.g. my_str = f"{RgbFg(0, 55, 100)}hello{Fg.RESET}".
902902 """
903903 return self ._sequence
904904
@@ -909,7 +909,7 @@ class RgbBg(BgColor):
909909 """
910910
911911 def __init__ (self , r : int , g : int , b : int ) -> None :
912- """RgbBg initializer
912+ """RgbBg initializer.
913913
914914 :param r: integer from 0-255 for the red component of the color
915915 :param g: integer from 0-255 for the green component of the color
@@ -924,7 +924,7 @@ def __init__(self, r: int, g: int, b: int) -> None:
924924 def __str__ (self ) -> str :
925925 """Return ANSI color sequence instead of enum name
926926 This is helpful when using an RgbBg in an f-string or format() call
927- e.g. my_str = f"{RgbBg(100, 255, 27)}hello{Bg.RESET}"
927+ e.g. my_str = f"{RgbBg(100, 255, 27)}hello{Bg.RESET}".
928928 """
929929 return self ._sequence
930930
0 commit comments