2 sphinxcontrib.autohttp.common
3 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
5 The common functions for web framework reflection.
7 :copyright: Copyright 2011 by Hong Minhee
8 :license: BSD, see LICENSE
for details.
12from six.moves import builtins
13from six.moves import reduce
15def import_object(import_name):
16 module_name, expr = import_name.split(':', 1)
17 mod = __import__(module_name)
18 mod = reduce(getattr, module_name.split(
'.')[1:], mod)
20 if not isinstance(globals, dict):
21 globals = globals.__dict__
22 return eval(expr, globals, mod.__dict__)
26 method = method.lower().strip()
27 if isinstance(content, six.string_types):
28 content = content.splitlines()
30 paths = [path]
if isinstance(path, six.string_types)
else path
32 yield '.. http:{method}:: {path}'.format(**locals())
def http_directive(method, path, content)