6.18. foundations.namespace

namespace.py

Platform:
Windows, Linux, Mac Os X.
Description:
Provides simple strings namespace manipulation objects.

Others:

6.18.1. Module Attributes

foundations.namespace.LOGGER
foundations.namespace.NAMESPACE_SPLITTER

6.18.2. Functions

foundations.namespace.setNamespace(namespace, attribute, namespaceSplitter=u'|')[source]

Sets given namespace to given attribute.

Usage:

>>> setNamespace("parent", "child")
u'parent|child'
Parameters:
  • namespace (unicode) – Namespace.
  • attribute (unicode) – Attribute.
  • namespaceSplitter (unicode) – Namespace splitter character.
Returns:

Namespaced attribute.

Return type:

unicode

foundations.namespace.getNamespace(attribute, namespaceSplitter=u'|', rootOnly=False)[source]

Returns given attribute foundations.namespace.

Usage:

>>> getNamespace("grandParent|parent|child")
u'grandParent|parent'
>>> getNamespace("grandParent|parent|child", rootOnly=True)
u'grandParent'
Parameters:
  • attribute (unicode) – Attribute.
  • namespaceSplitter (unicode) – Namespace splitter character.
  • rootOnly (bool) – Return only root foundations.namespace.
Returns:

Attribute foundations.namespace.

Return type:

unicode

foundations.namespace.removeNamespace(attribute, namespaceSplitter=u'|', rootOnly=False)[source]

Returns attribute with stripped foundations.namespace.

Usage:

>>> removeNamespace("grandParent|parent|child")
u'child'
>>> removeNamespace("grandParent|parent|child", rootOnly=True)
u'parent|child'
Parameters:
  • attribute (unicode) – Attribute.
  • namespaceSplitter (unicode) – Namespace splitter character.
  • rootOnly (bool) – Remove only root foundations.namespace.
Returns:

Attribute without foundations.namespace.

Return type:

unicode

foundations.namespace.getRoot(attribute, namespaceSplitter=u'|')[source]

Returns given attribute root.

Usage:

>>> getRoot("grandParent|parent|child")
u'grandParent'
Parameters:
  • attribute (unicode) – Attribute.
  • namespaceSplitter (unicode) – Namespace splitter character.
Returns:

Attribute foundations.namespace.

Return type:

unicode

foundations.namespace.getLeaf(attribute, namespaceSplitter=u'|')[source]

Returns given attribute leaf.

Usage:

>>> getLeaf("grandParent|parent|child")
u'child'
Parameters:
  • attribute (unicode) – Attribute.
  • namespaceSplitter (unicode) – Namespace splitter character.
Returns:

Attribute foundations.namespace.

Return type:

unicode