SOURCE CODE DOC¶
Entry Point¶
Package import¶
psprint¶
Prompt String-like Print
- psprint.DEFAULT_PRINT = pref long short text cont:[39m[49m[22m [39m[49m[22m<CUSTOM>[0m info:[32m[49m[22m INFORM i [39m[49m[22m<CUSTOM>[0m act:[33m[49m[22m ACTION @ [39m[49m[22m<CUSTOM>[0m list:[34m[49m[22m LIST · [39m[49m[22m<CUSTOM>[0m warn:[35m[49m[22m WARNING * [39m[49m[22m<CUSTOM>[0m err:[31m[49m[1m ERROR ! [31m[49m[2m<CUSTOM>[0m bug:[36m[49m[22m DEBUG # [36m[49m[2m<CUSTOM>[0m¶
PrintSpace object created by reading defaults from various psprintrc and psprint/style.yml files
- psprint.print(*args, mark=None, **kwargs)¶
psprint function for imports
- Return type
None
PrintSpace¶
- class psprint.printer.PrintSpace(config)[source]¶
Fancy Print class that also prints the type of message
- Parameters
config (
PathLike) – path to default configuration file (shipped)
- pref_max¶
int: maximum length of prefix string
- info_style; dict
pre-defined prefix styles
- info_index¶
list: keys of info_style mapped to int
- print_kwargs¶
dict : library of kwargs_accepted by print_function
- switches¶
dict: user-customizations: pad, short, bland, disabled
pad: bool: prefix is padded to start text at the same level short: bool: display short, 1 character- prefix bland: bool: do not show ANSI color/styles for prefix/text disabled: bool: behave like python default print_function
- edit_style(pref, index_int=None, mark=None, **kwargs)[source]¶
Edit loaded style
- Parameters
pref (
str) – str: prefix string long [length < 10 characters]index_int (
Optional[int]) – Index number that will call this InfoMarkmark (
Optional[str]) – Mark string that will call thisInfoMark**kwargs –
pref_s: str: prefix string short [1 character]
code:
color: {[0-15],[[l]krgybmcw],[[light] <color_name>]}
gloss: {[0-3],[rcdb],{reset,normal,dim,bright}}
for-
pref_color: color of of prefix
pref_gloss: gloss of prefix
pref_bgcol: background color of prefix
text_color: color of of text
text_gloss: gloss of text
text_bgcol: background color of text
- Returns
Summary of new (updated)
PrintSpace
- Return type
str
- psfmt(*args, mark=None, sep=None, **kwargs)[source]¶
Prefix String represenattion.
- Parameters
*args – passed to print_function for printing
mark (
Union[str,int,InfoMark,None]) –pre-declared InfoMark defaults:
cont or 0 or anything else: nothing
info or 1: [INFO]
act or 2: [ACTION]
list or 3: [LIST]
warn or 4: [WARNING]
error:or 5: [ERROR]
bug: or 6 [DEBUG]
Other marks defined in .psprintrc
sep (
Optional[str]) – If notNone, return *args joined by separator.**kwargs –
pref: str: prefix string long [length < 10 characters]
pref_s: str: prefix string short [1 character]
code:
color: {[0-15],[[l]krgybmcw],[[light] <color_name>]}
gloss: {[0-3],[rcdb],{reset,normal,dim,bright}}
for-
pref_color: color of of prefix
pref_gloss: gloss of prefix
pref_bgcol: background color of prefix
text_color: color of of text
text_gloss: gloss of text
text_bgcol: background color of text
pad: bool: prefix is padded to start text at the same level
short: bool: display short, 1 character- prefix
bland: bool: do not show ANSI color/styles for prefix/text
disabled: bool: behave like python default print_function
- Raises
BadMark – mark couldn’t be interpreted
- Return type
Union[List[str],str]- Returns
PSPRINT-like represented args. When these args is printed using standard print, PSPRINT-like output appears.
If a sep is provided, it is used to join args and return a string
- psprint(*args, mark=None, **kwargs)[source]¶
Prefix String PRINT
- Parameters
*args – passed to print_function for printing
mark (
Union[str,int,InfoMark,None]) –pre-declared InfoMark defaults:
cont or 0 or anything else: nothing
info or 1: [INFO]
act or 2: [ACTION]
list or 3: [LIST]
warn or 4: [WARNING]
error:or 5: [ERROR]
bug: or 6 [DEBUG]
Other marks defined in .psprintrc
**kwargs –
pref: str: prefix string long [length < 10 characters]
pref_s: str: prefix string short [1 character]
code:
color: {[0-15],[[l]krgybmcw],[[light] <color_name>]}
gloss: {[0-3],[rcdb],{reset,normal,dim,bright}}
for-
pref_color: color of of prefix
pref_gloss: gloss of prefix
pref_bgcol: background color of prefix
text_color: color of of text
text_gloss: gloss of text
text_bgcol: background color of text
pad: bool: prefix is padded to start text at the same level
short: bool: display short, 1 character- prefix
bland: bool: do not show ANSI color/styles for prefix/text
disabled: bool: behave like python default print_function
file: IO: passed to print function
sep: str: passed to print function
end: str: passed to print function
flush: bool: passed to print function
- Raises
BadMark – mark couldn’t be interpreted
- Return type
None
Base¶
InfoMark¶
Information Marker
- psprint.mark_types.DEFAULT_STYLE: Dict[str, int] = {'bgcol': 16, 'color': 16, 'gloss': 1}¶
Terminal-determined color, black background, normal gloss
- class psprint.mark_types.InfoMark(parent=None, pref_max=None, **kwargs)[source]¶
Prefix Mark information
- pref¶
PrintPref: Prefix text properties
- text¶
PrintText: Text properties
- Parameters
parent (
Optional[InfoMark]) – Inherit information from-pref_max (
Optional[int]) – pad prefix to reach length**kwargs –
pref: prefix string
pref_s: prefix short string
code:
color: {[0-15],[[l]krgybmcw],[[light] <color_name>]}
gloss: {[0-3],[rcdb],{reset,normal,dim,bright}}
for-
pref_color: color of of prefix
pref_gloss: gloss of prefix
pref_bgcol: background color of prefix
text_color: color of of text
text_gloss: gloss of text
text_bgcol: background color of text
TextTypes¶
Text Parts
- class psprint.text_types.AnsiEffect(parent=None, color=None, gloss=None, bgcol=None)[source]¶
Plain text object Text to be printed to (ANSI) terminal
- Parameters
color (
Optional[str]) – color of text [0-15]gloss (
Optional[str]) – gloss of text {0: bland, 1:normal ,2: dim, 3: bright}bgcol (
Optional[str]) – color of background [0-15]
- color¶
color of text
- gloss¶
gloss of text
- bgcol¶
background color
- property style: str¶
All style combined
- Return type
str
- class psprint.text_types.PrintPref(parent=None, pref=None, pref_max=0, **kwargs)[source]¶
Prefix that informs about Text
- Parameters
parent – template object for style
pref (
Optional[List[str]]) – prefix in [long, short] formatpref_max (
int) – pad with space to length**kwargs –
code:
color: {[0-15],[[l]krgybmcw],[[light] <color_name>]}
gloss: {[0-3],[rcdb],{reset,normal,dim,bright}}
for-
color: color of of prefix
gloss: gloss of prefix
bgcol: background color of prefix
pref – tuple: prefix long, short
brackets – tuple: bool long, short
pad – tuple: pad long, short
style – AnsiEffect: color/gloss style
- Raises
Errors¶
Error/Warnings¶
Errors and warnings
- exception psprint.errors.BadMark(mark, config)[source]¶
A
marksupplied inconfigcannot be parsed- Parameters
mark (
str) – passed markconfig (
str) – config file that defined the mark
- exception psprint.errors.BadPref(key, value)[source]¶
Prefix Style declared incorrectly
- Parameters
key – key
value – (Bad) value supplied
- exception psprint.errors.BadStyle(key, value)[source]¶
Style declared incorrectly
- Parameters
key – key
value – (Bad) value supplied