marrow/package/loader.py
def load(target:str, namespace:str=None, default=nodefault, executable:bool=False, separators:Sequence[str]=('.', ':'),
		protect:bool=True):
	"""This helper function loads an object identified by a dotted-notation string.
	
	For example::
	
		# Load class Foo from example.objects
		load('example.objects:Foo')
		
		# Load the result of the class method ``new`` of the Foo object
		load('example.objects:Foo.new', executable=True)
	
	If a plugin namespace is provided simple name references are allowed.  For example::
	
		# Load the plugin named 'routing' from the 'web.dispatch' namespace
		load('routing', 'web.dispatch')
	
	The ``executable``, ``protect``, and first tuple element of ``separators`` are passed to the traverse function.
	Providing a namespace does not prevent full object lookup (dot-colon notation) from working.
	"""
	
	assert check_argument_types()
	
	if namespace and ':' not in target:
		allowable = dict((i.name,  i) for i in iter_entry_points(namespace))
		
		if target not in allowable:
			raise LookupError('Unknown plugin "' + target + '"; found: ' + ', '.join(allowable))
		
		return allowable[target].load()
	
	parts, _, target = target.partition(separators[1])
	
	try:
		obj = __import__(parts)
	except ImportError:
		if default is not nodefault:
			return default
		
		raise
	
	return traverse(
			obj,
			separators[0].join(parts.split(separators[0])[1:] + target.split(separators[0])),
			default = default,
			executable = executable,
			protect = protect
		) if target else obj
def load(target:str, namespace:str=None, default=nodefault, executable:bool=False, separators:Sequence[str]=('.', ':'),
		protect:bool=True):
	"""This helper function loads an object identified by a dotted-notation string.
	
	For example::
	
		# Load class Foo from example.objects
		load('example.objects:Foo')
		
		# Load the result of the class method ``new`` of the Foo object
		load('example.objects:Foo.new', executable=True)
	
	If a plugin namespace is provided simple name references are allowed.  For example::
	
		# Load the plugin named 'routing' from the 'web.dispatch' namespace
		load('routing', 'web.dispatch')
	
	The ``executable``, ``protect``, and first tuple element of ``separators`` are passed to the traverse function.
	Providing a namespace does not prevent full object lookup (dot-colon notation) from working.
	"""
	
	assert check_argument_types()
	
	if namespace and ':' not in target:
		allowable = dict((i.name,  i) for i in iter_entry_points(namespace))
		
		if target not in allowable:
			raise LookupError('Unknown plugin "' + target + '"; found: ' + ', '.join(allowable))
		
		return allowable[target].load()
	
	parts, _, target = target.partition(separators[1])
	
	try:
		obj = __import__(parts)
	except ImportError:
		if default is not nodefault:
			return default
		
		raise
	
	return traverse(
			obj,
			separators[0].join(parts.split(separators[0])[1:] + target.split(separators[0])),
			default = default,
			executable = executable,
			protect = protect
		) if target else obj
def load ( target : str , namespace : str = None , default = nodefault , executable : bool = False , separators : Sequence [ str ] = ( '.' , ':' ) , protect : bool = True ) : assert check_argument_types ( ) if namespace and ':' not in target : allowable = dict ( ( i . name , i ) for i in iter_entry_points ( namespace ) ) if target not in allowable : raise LookupError ( 'Unknown plugin "' + target + '"; found: ' + ', ' . join ( allowable ) ) return allowable [ target ] . load ( ) parts , _ , target = target . partition ( separators [ 1 ] ) try : obj = __import__ ( parts ) except ImportError : if default is not nodefault : return default raise return traverse ( obj , separators [ 0 ] . join ( parts . split ( separators [ 0 ] ) [ 1 : ] + target . split ( separators [ 0 ] ) ) , default = default , executable = executable , protect = protect ) if target else obj
This helper function loads an object identified by a dotted-notation string.
	
	For example::
	
		# Load class Foo from example.objects
		load('example.objects:Foo')
		
		# Load the result of the class method ``new`` of the Foo object
		load('example.objects:Foo.new', executable=True)
	
	If a plugin namespace is provided simple name references are allowed.  For example::
	
		# Load the plugin named 'routing' from the 'web.dispatch' namespace
		load('routing', 'web.dispatch')
	
	The ``executable``, ``protect``, and first tuple element of ``separators`` are passed to the traverse function.
	Providing a namespace does not prevent full object lookup (dot-colon notation) from working.
This helper function loads an object identified by a dotted - notation string . For example :: # Load class Foo from example . objects load ( example . objects : Foo ) # Load the result of the class method new of the Foo object load ( example . objects : Foo . new executable = True ) If a plugin namespace is provided simple name references are allowed . For example :: # Load the plugin named routing from the web . dispatch namespace load ( routing web . dispatch ) The executable protect and first tuple element of separators are passed to the traverse function . Providing a namespace does not prevent full object lookup ( dot - colon notation ) from working .