MCPcopy Create free account
hub / github.com/ddserver/ddserver / load

Method load

ddserver/utils/deps.py:80–105  ·  view source on GitHub ↗

Loads a export by the given name. The name must be a full specified identifier where the module name and the factory name are separated by a colon. The module containing the export is imported using the current context and the export is retrieved from the module.

(requirement)

Source from the content-addressed store, hash-verified

78
79 @staticmethod
80 def load(requirement):
81 ''' Loads a export by the given name.
82
83 The name must be a full specified identifier where the module name and
84 the factory name are separated by a colon. The module containing the
85 export is imported using the current context and the export is retrieved
86 from the module.
87 '''
88
89 module, export = requirement.split(':', 1)
90
91 # Import the module containing the export
92 module = __import__(name = module,
93 globals = globals(),
94 locals = locals(),
95 fromlist = [export],
96 level = 0)
97
98 # Get the export from the imported module
99 export = getattr(module, export)
100
101 # Check if the given name refers a exported factory
102 if not isinstance(export, Export):
103 raise TypeError('%s is not exported' % requirement)
104
105 return export
106
107
108

Callers 3

requireFunction · 0.80
wrapperFunction · 0.80
bFunction · 0.80

Calls

no outgoing calls

Tested by

no test coverage detected