libbe.ui.util.user

Tools for getting, setting, creating, and parsing the user’s ID.

IDs will look like ‘John Doe <jdoe@example.com>’. Note that the libbe.storage.vcs.arch enforces IDs with this format.

Do not confuse the user IDs discussed in this module, which refer to humans, with the “user IDs” discussed in libbe.util.id, which are human-readable tags refering to objects.

libbe.ui.util.user.create_user_id(name, email=None)

Create a user ID string from given name and email strings.

See also

parse_user_id
inverse

Examples

>>> create_user_id("John Doe", "jdoe@example.com")
'John Doe <jdoe@example.com>'
>>> create_user_id("John Doe")
'John Doe'
libbe.ui.util.user.get_fallback_email()

Return an email address extracted from environmental variables.

libbe.ui.util.user.get_fallback_username()

Return a username extracted from environmental variables.

libbe.ui.util.user.get_user_id(storage=None)

Return a user ID, checking a list of possible sources.

The source order is:

  1. Global BE configuration [1] (default section, setting ‘user’).
  2. storage.get_user_id, if that function is defined.
  3. get_fallback_username() and get_fallback_email().
[1]See libbe.storage.util.config.

Notes

Sometimes the storage will keep track of the user ID (e.g. most VCSs, see libbe.storage.vcs.base.VCS.get_user_id()). If so, we prefer that ID to the fallback, since the user has likely configured it directly.

libbe.ui.util.user.parse_user_id(value)

Parse a user ID string into name and email strings.

See also

create_user_id
inverse

Examples

>>> parse_user_id("John Doe <jdoe@example.com>")
('John Doe', 'jdoe@example.com')
>>> parse_user_id("John Doe")
('John Doe', None)
>>> parse_user_id("John Doe <jdoe@example.com><what?>")
('John Doe', 'jdoe@example.com')
libbe.ui.util.user.set_user_id(user_id)

Set the user ID in a user’s BE configuration.

Previous topic

libbe.ui.util.pager

Next topic

libbe.util

This Page