alligator.utils

alligator.utils.determine_module(func)

Given a function, returns the Python dotted path of the module it comes from.

Ex:

from random import choice
determine_module(choice) # Returns 'random'
Parameters:func (function) – The callable
Returns:Dotted path string
alligator.utils.determine_name(func)

Given a function, returns the name of the function.

Ex:

from random import choice
determine_name(choice) # Returns 'choice'
Parameters:func (function) – The callable
Returns:Name string
alligator.utils.import_attr(module_name, attr_name)

Given a dotted Python path & an attribute name, imports the module & returns the attribute.

If not found, raises UnknownCallableError.

Ex:

choice = import_attr('random', 'choice')
Parameters:
  • module_name (string) – The dotted Python path
  • attr_name (string) – The attribute name
Returns:

attribute

alligator.utils.import_module(module_name)

Given a dotted Python path, imports & returns the module.

If not found, raises UnknownModuleError.

Ex:

mod = import_module('random')
Parameters:module_name (string) – The dotted Python path
Returns:module