pymt.utils package

Submodules

pymt.utils.prefix module

pymt.utils.prefix.names_with_prefix(names, prefix)[source]

Find names that begin with a common prefix. In this case, names are a series .-separated words, much like module names.

Returns a list of all names that begin with prefix. The order of matched names is maintained.

>>> names_with_prefix(['foo.bar', 'foobar.baz'], 'foo')
['foo.bar']
>>> names_with_prefix(['foo.bar', 'foo.bar', 'foo.foo'], 'foo')
['foo.bar', 'foo.foo']
pymt.utils.prefix.prefix_is_empty(prefix)[source]

Check if a namespace prefix is empty.

A prefix is empty if it is None, just a “.” or an empty string.

Return True if empty, otherwise False.

pymt.utils.prefix.strip_prefix(name, prefix)[source]

Remove a prefix from a name, including any leading “.”s.

>>> strip_prefix('foo.bar', 'foo')
'bar'
>>> strip_prefix('foo.bar', '')
'foo.bar'

Module contents