dql.output module

Formatting and displaying output

class dql.output.BaseFormat(results, ostream, width='auto', pagesize='auto', lossy_json_float=True)[source]

Bases: object

Base class for formatters

display()[source]

Write results to an output stream

format_field(field)[source]

Format a single Dynamo value

pagesize[source]

The number of results to display at a time

post_write()[source]

Called once after writing all records

pre_write()[source]

Called once before writing the very first record

wait()[source]

Block for user input

width[source]

The display width

write(result)[source]

Write a single result and stick it in an output stream

class dql.output.ColumnFormat(*args, **kwargs)[source]

Bases: dql.output.BaseFormat

A layout that puts item attributes in columns

post_write()[source]

Called once after writing all records

pre_write()[source]

Called once before writing the very first record

wait()[source]

Block for user input

write(result)[source]

Write a single result and stick it in an output stream

class dql.output.ExpandedFormat(results, ostream, width='auto', pagesize='auto', lossy_json_float=True)[source]

Bases: dql.output.BaseFormat

A layout that puts item attributes on separate lines

pagesize[source]

The number of results to display at a time

write(result)[source]

Write a single result and stick it in an output stream

class dql.output.JsonFormat(results, ostream, width='auto', pagesize='auto', lossy_json_float=True)[source]

Bases: dql.output.BaseFormat

display()[source]

Write results to an output stream

write(result)[source]

Write a single result and stick it in an output stream

class dql.output.SmartBuffer(buf)[source]

Bases: object

A buffer that wraps another buffer and encodes unicode strings.

flush()[source]

flush the buffer

write(arg)[source]

Write a string or bytes object to the buffer

class dql.output.SmartFormat(results, ostream, *args, **kwargs)[source]

Bases: object

A layout that chooses column/expanded format intelligently

display()[source]

Write results to an output stream

dql.output.delta_to_str(rd)[source]

Convert a relativedelta to a human-readable string

dql.output.format_json(json_object, indent, default)[source]

Pretty-format json data

dql.output.less_display()[source]

Use smoke and mirrors to acquire ‘less’ for pretty paging

dql.output.make_list(obj)[source]

Turn an object into a list if it isn’t already

dql.output.serialize_json_var(obj)[source]

Serialize custom types to JSON

dql.output.serialize_json_var_lossy_float(obj)[source]

Serialize custom types to JSON

dql.output.stdout_display()[source]

Print results straight to stdout

dql.output.truncate(string, length, ellipsis='…')[source]

Truncate a string to a length, ending with ‘…’ if it overflows

dql.output.wrap(string, length, indent)[source]

Wrap a string at a line length