squabble.util module

Odds and ends pieces that don’t fit elsewhere, but aren’t important enough to have their own modules.


Strip reStructuredText directives out of a block of text.

Lines containing a directive will be stripped out entirely

>>> strip_rst_directives('hello\n.. code-block:: foo\nworld')

Return a simple stringified version of a pglast.node.TypeName node.

Note that this won’t be suitable for printing, and ignores type modifiers (e.g. NUMERIC(3,4) => NUMERIC).

>>> import pglast
>>> sql = 'CREATE TABLE _ (y time with time zone);'
>>> node = pglast.Node(pglast.parse_sql(sql))
>>> col_def = node[0]['stmt']['tableElts'][0]
>>> format_type_name(col_def.typeName)