squabble.util module

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

squabble.util.strip_rst_directives(string)[source]

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')
'hello\nworld'
squabble.util.format_type_name(type_name)[source]

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)
'pg_catalog.timetz'