API Reference¶
-
class
say.
Say
(**kwargs)¶ Say provides high-level printing functions. Instances are configurable and callable.
-
__call__
(*args, **kwargs)¶ Primary interface. say(something)
-
__init__
(**kwargs)¶ Make a Say instance with the given options.
-
blank_lines
(n, **kwargs)¶ Output N blank lines (“vertical separation”). Unlike other methods, this does not obey normal vertical separation rules, because it is about explicit vertical separation. If it obeyed vsep, it would usually gild the lily (double space).
-
but
(**kwargs)¶ Create a new instance whose options are chained to this instance’s options (and thence to self.__class__.options). kwargs become the cloned instance’s overlay options.
-
clone
(**kwargs)¶ Create a new instance whose options are chained to this instance’s options (and thence to self.__class__.options). kwargs become the cloned instance’s overlay options.
-
static
escape
(s)¶ Double { and } characters in a string to ‘escape’ them so
str.format
doesn’t treat them as template characters. NB This is NOT idempotent! Escaping more than once (when { or } are present ) = ERROR.
-
fork
(**kwargs)¶ Create a new instance whose options are chained to this instance’s class’s options, then this instance’s current values, then any difference values stated in kwwargs.
-
hr
(**kwargs)¶ Print a horizontal line. Like the HTML hr tag. Optionally specify the width, character repeated to make the line, and vertical separation.
Good options for the separator may be ‘-‘, ‘=’, or parts of the Unicode box drawing character set. http://en.wikipedia.org/wiki/Box-drawing_character
-
options
= Options(styles={}, files=[<open file '<stdout>', mode 'w'>], style=None, end='\n', silent=False, sep=' ', indent_str=' ', prefix='', indent=0, vsep=None, wrap=None, file=Transient, suffix='')¶
-
sep
(text='', **kwargs)¶ Print a short horizontal line, possibly with some text following, of the desired width. Useful as a separator for different parts of output.
-
set
(**kwargs)¶ Permanently change the reciver’s settings to those defined in the kwargs. An update-like function.
-
setfiles
(files)¶ Set the list of output files.
files
is a list. For each item, if it’s a real file likesys.stdout
, use it. If it’s a string, assume it’s a filename and open it for writing.
-
settings
(**kwargs)¶ Open a context manager for a with statement. Temporarily change settings for the duration of the with.
-
style
(*args, **kwargs)¶ Define a style.
-
title
(name, **kwargs)¶ Print a horizontal line with an embedded title.
-
verbatim
(*args, **kwargs)¶ Say, but without interpretation. Useful for just its text decoration features.
-
-
class
say.
Fmt
(**kwargs)¶ A type of Say that returns its result, rather than writes it to files.
-
__call__
(*args, **kwargs)¶ Primary interface. say(something)
-
__init__
(**kwargs)¶ Make a Say instance with the given options.
-
blank_lines
(n, **kwargs)¶ Output N blank lines (“vertical separation”). Unlike other methods, this does not obey normal vertical separation rules, because it is about explicit vertical separation. If it obeyed vsep, it would usually gild the lily (double space).
-
but
(**kwargs)¶ Create a new instance whose options are chained to this instance’s options (and thence to self.__class__.options). kwargs become the cloned instance’s overlay options.
-
clone
(**kwargs)¶ Create a new instance whose options are chained to this instance’s options (and thence to self.__class__.options). kwargs become the cloned instance’s overlay options.
-
static
escape
(s)¶ Double { and } characters in a string to ‘escape’ them so
str.format
doesn’t treat them as template characters. NB This is NOT idempotent! Escaping more than once (when { or } are present ) = ERROR.
-
fork
(**kwargs)¶ Create a new instance whose options are chained to this instance’s class’s options, then this instance’s current values, then any difference values stated in kwwargs.
-
hr
(**kwargs)¶ Print a horizontal line. Like the HTML hr tag. Optionally specify the width, character repeated to make the line, and vertical separation.
Good options for the separator may be ‘-‘, ‘=’, or parts of the Unicode box drawing character set. http://en.wikipedia.org/wiki/Box-drawing_character
-
options
= Options(files=Prohibited, styles={}, suffix='', sep=' ', indent_str=' ', prefix='', file=Transient, wrap=None, indent=0, style=None, end=None, silent=Prohibited, vsep=None)¶
-
sep
(text='', **kwargs)¶ Print a short horizontal line, possibly with some text following, of the desired width. Useful as a separator for different parts of output.
-
set
(**kwargs)¶ Permanently change the reciver’s settings to those defined in the kwargs. An update-like function.
-
setfiles
(files)¶ Set the list of output files.
files
is a list. For each item, if it’s a real file likesys.stdout
, use it. If it’s a string, assume it’s a filename and open it for writing.
-
settings
(**kwargs)¶ Open a context manager for a with statement. Temporarily change settings for the duration of the with.
-
style
(*args, **kwargs)¶ Define a style.
-
title
(name, **kwargs)¶ Print a horizontal line with an embedded title.
-
verbatim
(*args, **kwargs)¶ Say, but without interpretation. Useful for just its text decoration features.
-
-
class
say.
Text
(data=None, interpolate=True, dedent=True)¶ -
__init__
(data=None, interpolate=True, dedent=True)¶ x.__init__(…) initializes x; see help(type(x)) for signature
-
append
(line, callframe=None, interpolate=True)¶
-
copy
()¶ Make a copy.
-
extend
(lines, callframe=None, interpolate=True, dedent=True)¶
-
insert
(i, data, callframe=None, interpolate=True, dedent=True)¶
-
lines
¶
-
re_replace
(target, replacement)¶ Regular expression replacement. Target is either compiled re object or string that will be compiled into one. Replacement is either string or function that takes re match object as a parameter and returns replacement string.
-
read_from
(filepath, interpolate=True, dedent=True, encoding='utf-8')¶ Reads lines from the designated file, appending them to the end of the given Text. By default, interpolates and dedents any {} expressions.
-
render
()¶ Equivalent to
__str__
. For compatibility withTemplate
subclass.
-
replace
(target, replacement=None)¶ Replace all instances of the target string with the replacement string. Works in situ, contra str.replace().
-
text
¶
-
write
(contents)¶ Make it possible for Text objects to operate like file objects, and be written to.
-
write_to
(filepath, append=False, encoding='utf-8')¶ Write the Text instance’s contents to the given filepath. :param filepath: Filepath to write to. :param append: Whether to appened to the file (if it exists) or overwrite (default) :param encoding: How to encode the contents (default utf-8)
-