marrow/package/lazy.py
def lazyload(reference: str, *args, **kw):
	"""Lazily load and cache an object reference upon dereferencing.
	
	Assign the result of calling this function with either an object reference passed in positionally:
	
		class MyClass:
			debug = lazyload('logging:debug')
	
	Or the attribute path to traverse (using `marrow.package.loader:traverse`) prefixed by a period.
	
		class AnotherClass:
			target = 'logging:info'
			log = lazyload('.target')
	
	Additional arguments are passed to the eventual call to `load()`.
	"""
	
	assert check_argument_types()
	
	def lazily_load_reference(self):
		ref = reference
		
		if ref.startswith('.'):
			ref = traverse(self, ref[1:])
		
		return load(ref, *args, **kw)
	
	return lazy(lazily_load_reference)
def lazyload(reference: str, *args, **kw):
	"""Lazily load and cache an object reference upon dereferencing.
	
	Assign the result of calling this function with either an object reference passed in positionally:
	
		class MyClass:
			debug = lazyload('logging:debug')
	
	Or the attribute path to traverse (using `marrow.package.loader:traverse`) prefixed by a period.
	
		class AnotherClass:
			target = 'logging:info'
			log = lazyload('.target')
	
	Additional arguments are passed to the eventual call to `load()`.
	"""
	
	assert check_argument_types()
	
	def lazily_load_reference(self):
		ref = reference
		
		if ref.startswith('.'):
			ref = traverse(self, ref[1:])
		
		return load(ref, *args, **kw)
	
	return lazy(lazily_load_reference)
def lazyload ( reference : str , * args , * * kw ) : assert check_argument_types ( ) def lazily_load_reference ( self ) : ref = reference if ref . startswith ( '.' ) : ref = traverse ( self , ref [ 1 : ] ) return load ( ref , * args , * * kw ) return lazy ( lazily_load_reference )
Lazily load and cache an object reference upon dereferencing.
	
	Assign the result of calling this function with either an object reference passed in positionally:
	
		class MyClass:
			debug = lazyload('logging:debug')
	
	Or the attribute path to traverse (using `marrow.package.loader:traverse`) prefixed by a period.
	
		class AnotherClass:
			target = 'logging:info'
			log = lazyload('.target')
	
	Additional arguments are passed to the eventual call to `load()`.
Lazily load and cache an object reference upon dereferencing . Assign the result of calling this function with either an object reference passed in positionally : class MyClass : debug = lazyload ( logging : debug ) Or the attribute path to traverse ( using marrow . package . loader : traverse ) prefixed by a period . class AnotherClass : target = logging : info log = lazyload ( . target ) Additional arguments are passed to the eventual call to load () .