Output
clo.output
Output handler
clo.output.Levels
Bases: Enum
An enumerator representing log levels.
clo.output.Levels.OFF
class-attribute
instance-attribute
OFF = 0
Disables all logging.
clo.output.Levels.FATAL
class-attribute
instance-attribute
FATAL = 1
Logs when an error causes the program to abort.
clo.output.Levels.ERROR
class-attribute
instance-attribute
ERROR = 2
Logs when the program has a non-fatal error.
clo.output.Levels.WARN
class-attribute
instance-attribute
WARN = 3
Logs when the program needs to warn the user of something.
clo.output.Levels.INFO
class-attribute
instance-attribute
INFO = 4
Logs general information.
clo.output.Levels.DEBUG
class-attribute
instance-attribute
DEBUG = 5
Logs verbose, debugging infromation.
clo.output.Levels.TRACE
class-attribute
instance-attribute
TRACE = 6
Logs egregiously verbos infromation.
clo.output.Log
A singleton class for outputting logs to stderr
.
clo.output.Log.FATAL
classmethod
FATAL(*values, sep=' ', end='\n', flush=False, code=10)
Output a FATAL
-level log.
PARAMETER | DESCRIPTION |
---|---|
sep |
A string inserted between values.
TYPE:
|
end |
A string appended after the last value.
TYPE:
|
flush |
Whether to forcibly flush the stream.
TYPE:
|
code |
If set, calls for exit with the code specified.
TYPE:
|
clo.output.Log.ERROR
classmethod
ERROR(*values, sep=' ', end='\n', flush=False, code=10)
Output an ERROR
-level log.
PARAMETER | DESCRIPTION |
---|---|
sep |
A string inserted between values.
TYPE:
|
end |
A string appended after the last value.
TYPE:
|
flush |
Whether to forcibly flush the stream.
TYPE:
|
code |
If set, calls for exit with the code specified.
TYPE:
|
clo.output.Log.WARN
classmethod
WARN(*values, sep=' ', end='\n', flush=False)
Output a WARN
-level log.
PARAMETER | DESCRIPTION |
---|---|
sep |
A string inserted between values.
TYPE:
|
end |
A string appended after the last value.
TYPE:
|
flush |
Whether to forcibly flush the stream.
TYPE:
|
clo.output.Log.INFO
classmethod
INFO(*values, sep=' ', end='\n', flush=False)
Output an INFO
-level log.
PARAMETER | DESCRIPTION |
---|---|
sep |
A string inserted between values.
TYPE:
|
end |
A string appended after the last value.
TYPE:
|
flush |
Whether to forcibly flush the stream.
TYPE:
|
clo.output.Log.DEBUG
classmethod
DEBUG(*values, sep=' ', end='\n', flush=False)
Output a DEBUG
-level log.
PARAMETER | DESCRIPTION |
---|---|
sep |
A string inserted between values.
TYPE:
|
end |
A string appended after the last value.
TYPE:
|
flush |
Whether to forcibly flush the stream.
TYPE:
|
clo.output.Log.TRACE
classmethod
TRACE(*values, sep=' ', end='\n', flush=False)
Output a TRACE
-level log.
PARAMETER | DESCRIPTION |
---|---|
sep |
A string inserted between values.
TYPE:
|
end |
A string appended after the last value.
TYPE:
|
flush |
Whether to forcibly flush the stream.
TYPE:
|
clo.output.ToJSON
ToJSON(obj)
Convert a serializable object into JSON.
PARAMETER | DESCRIPTION |
---|---|
obj |
Any serializable object.
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
str
|
A JSON-formatted document.
TYPE:
|
clo.output.ToCSV
ToCSV(records, file, sep=',')
Write a list of records to CSV.
PARAMETER | DESCRIPTION |
---|---|
records |
A list of records.
TYPE:
|
file |
The stream the output will be saved to.
TYPE:
|
sep |
The column separator.
TYPE:
|
clo.output.FromCSV
FromCSV(file, sep=',')
Convert CSV file contents into a list of records.
PARAMETER | DESCRIPTION |
---|---|
file |
The CSV-formatted input file.
TYPE:
|
sep |
The separator used in the file.
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
list[dict[str, Any]]
|
list[dict[str, Any]]: A list of records. |
clo.output.Columnize
Columnize(items, width=120, *, border=3, spacing=' ', end='\n')
Formats a set of subject/details pairs.
PARAMETER | DESCRIPTION |
---|---|
items |
The items to format.
TYPE:
|
border |
The size of spacing between the subject and details.
TYPE:
|
end |
A suffix to append to each pair-rendering.
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
str
|
The formatted text.
TYPE:
|