MCPcopy Create free account
hub / github.com/csound/csound / _FindDelegateAtPath

Method _FindDelegateAtPath

Emscripten/examples/httpd.py:60–89  ·  view source on GitHub ↗
(self, dirname)

Source from the content-addressed store, hash-verified

58
59class PluggableHTTPRequestHandler(SimpleHTTPServer.SimpleHTTPRequestHandler):
60 def _FindDelegateAtPath(self, dirname):
61 # First check the cache...
62 logging.debug('Looking for cached delegate in %s...' % dirname)
63 handler_script = os.path.join(dirname, 'handler.py')
64
65 if dirname in self.server.delegate_map:
66 result = self.server.delegate_map[dirname]
67 if result is None:
68 logging.debug('Found None.')
69 else:
70 logging.debug('Found delegate.')
71 return result
72
73 # Don't have one yet, look for one.
74 delegate = None
75 logging.debug('Testing file %s for existence...' % handler_script)
76 if os.path.exists(handler_script):
77 logging.debug(
78 'File %s exists, looking for HTTPRequestHandlerDelegate.' %
79 handler_script)
80
81 module = imp.load_source('handler', handler_script)
82 delegate_class = getattr(module, 'HTTPRequestHandlerDelegate', None)
83 delegate = delegate_class()
84 if not delegate:
85 logging.warn(
86 'Unable to find symbol HTTPRequestHandlerDelegate in module %s.' %
87 handler_script)
88
89 return delegate
90
91 def _FindDelegateForURLRecurse(self, cur_dir, abs_root):
92 delegate = self._FindDelegateAtPath(cur_dir)

Callers 1

Calls 3

debugMethod · 0.80
joinMethod · 0.45
warnMethod · 0.45

Tested by

no test coverage detected