本文整理汇总了Python中aspen.configuration.Configurable.from_argv方法的典型用法代码示例。如果您正苦于以下问题:Python Configurable.from_argv方法的具体用法?Python Configurable.from_argv怎么用?Python Configurable.from_argv使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类aspen.configuration.Configurable
的用法示例。
在下文中一共展示了Configurable.from_argv方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: from_fs
# 需要导入模块: from aspen.configuration import Configurable [as 别名]
# 或者: from aspen.configuration.Configurable import from_argv [as 别名]
def from_fs(cls, fs):
"""Takes a path under ./fsfix using / as the path separator.
"""
fs = os.sep.join(fs.split('/'))
request = Request.from_wsgi(StubWSGIRequest(fs))
c = Configurable.from_argv(['fsfix'])
c.copy_configuration_to(request)
request.fs = fs
request.namespace = {}
request.website = Stub()
request.website.template_loader = Stub()
return request
示例2: from_fs
# 需要导入模块: from aspen.configuration import Configurable [as 别名]
# 或者: from aspen.configuration.Configurable import from_argv [as 别名]
def from_fs(cls, fs):
"""Takes a path under ./fsfix using / as the path separator.
"""
fs = os.sep.join(fs.split(os.sep))
request = Request.from_wsgi(StubWSGIRequest(fs))
website = Configurable.from_argv(['--root', 'fsfix'])
website.copy_configuration_to(request)
request.root = join(dirname(__file__), 'fsfix')
request.fs = fs
request.namespace = {}
request.website = website
request.website.template_loader = Stub()
return request
示例3: from_fs
# 需要导入模块: from aspen.configuration import Configurable [as 别名]
# 或者: from aspen.configuration.Configurable import from_argv [as 别名]
def from_fs(cls, fs, *a):
"""Takes a path under FSFIX using / as the path separator.
"""
fs = os.sep.join(fs.split(os.sep))
request = Request.from_wsgi(StubWSGIRequest(fs))
website = Configurable.from_argv([ '--www_root', FSFIX
, '--project_root', '.aspen'
] + list(a))
request.www_root = os.path.join(os.path.dirname(__file__), FSFIX)
request.fs = fs
request.context = {}
request.website = website
request._media_type = None
return request
示例4: test_cheese_example
# 需要导入模块: from aspen.configuration import Configurable [as 别名]
# 或者: from aspen.configuration.Configurable import from_argv [as 别名]
def test_cheese_example():
mk(('configure-aspen.py', """\
from aspen.renderers import Renderer, Factory
class Cheese(Renderer):
def render_content(self, context):
return self.compiled.replace("cheese", "CHEESE!!!!!!")
class CheeseFactory(Factory):
Renderer = Cheese
website.renderer_factories['excited-about-cheese'] = CheeseFactory(website)
"""))
website = Configurable.from_argv(["--project_root", FSFIX])
make_renderer = website.renderer_factories['excited-about-cheese']
render = make_renderer("", "I like cheese!") # test specline elsewhere
actual = render({})
assert actual == "I like CHEESE!!!!!!!", actual
示例5: __init__
# 需要导入模块: from aspen.configuration import Configurable [as 别名]
# 或者: from aspen.configuration.Configurable import from_argv [as 别名]
def __init__(self, path):
self.path = Path(path)
c = Configurable.from_argv(['fsfix'])
c.copy_configuration_to(self)
示例6: test_that_a_renderer_factory_is_instantiable
# 需要导入模块: from aspen.configuration import Configurable [as 别名]
# 或者: from aspen.configuration.Configurable import from_argv [as 别名]
def test_that_a_renderer_factory_is_instantiable():
actual = TornadoFactory(Configurable.from_argv([])).__class__
assert actual is TornadoFactory, actual
示例7: tornado_factory_factory
# 需要导入模块: from aspen.configuration import Configurable [as 别名]
# 或者: from aspen.configuration.Configurable import from_argv [as 别名]
def tornado_factory_factory(argv=None):
if argv is None:
argv = []
return TornadoFactory(Configurable.from_argv(argv))