本文整理汇总了Python中r2.config.paths.get_built_statics_path函数的典型用法代码示例。如果您正苦于以下问题:Python get_built_statics_path函数的具体用法?Python get_built_statics_path怎么用?Python get_built_statics_path使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了get_built_statics_path函数的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: get_source
def get_source(self, use_built_statics=False):
if use_built_statics:
# we are in the build system so we have already copied all files
# into the static build directory
built_statics_path = get_built_statics_path()
path = os.path.join(built_statics_path, "static", "js", self.name)
else:
# we are in request so we need to check the pylons static_files
# path and the static paths for all plugins
path = locate_static_file(os.path.join("static", "js", self.name))
with open(path) as f:
return f.read()
开发者ID:zeantsoi,项目名称:reddit,代码行数:13,代码来源:js.py
示例2: get_content
def get_content(self, use_built_statics=False):
name, style = os.path.splitext(self.name)
if use_built_statics:
built_statics_path = get_built_statics_path()
path = os.path.join(built_statics_path, 'static', 'js', self.name)
else:
path = locate_static_file(os.path.join('static', 'js', self.name))
with open(path) as f:
return [{
"name": name,
"style": style.lstrip('.'),
"template": f.read(),
}]
开发者ID:zeantsoi,项目名称:reddit,代码行数:15,代码来源:js.py
示例3: load_environment
def load_environment(global_conf={}, app_conf={}, setup_globals=True):
r2_path = get_r2_path()
root_path = os.path.join(r2_path, "r2")
paths = {
"root": root_path,
"controllers": os.path.join(root_path, "controllers"),
"templates": [os.path.join(root_path, "templates")],
}
if ConfigValue.bool(global_conf.get("uncompressedJS")):
paths["static_files"] = get_raw_statics_path()
else:
paths["static_files"] = get_built_statics_path()
config = PylonsConfig()
config.init_app(global_conf, app_conf, package="r2", paths=paths)
# don't put action arguments onto c automatically
config["pylons.c_attach_args"] = False
# when accessing non-existent attributes on c, return "" instead of dying
config["pylons.strict_tmpl_context"] = False
g = Globals(config, global_conf, app_conf, paths)
config["pylons.app_globals"] = g
if setup_globals:
config["r2.import_private"] = ConfigValue.bool(global_conf["import_private"])
g.setup()
g.plugins.declare_queues(g.queues)
g.plugins.load_plugins(config)
config["r2.plugins"] = g.plugins
g.startup_timer.intermediate("plugins")
config["pylons.h"] = r2.lib.helpers
config["routes.map"] = make_map(config)
# override the default response options
config["pylons.response_options"]["headers"] = {}
# when mako loads a previously compiled template file from its cache, it
# doesn't check that the original template path matches the current path.
# in the event that a new plugin defines a template overriding a reddit
# template, unless the mtime newer, mako doesn't update the compiled
# template. as a workaround, this makes mako store compiled templates with
# the original path in the filename, forcing it to update with the path.
if "cache_dir" in app_conf:
module_directory = os.path.join(app_conf["cache_dir"], "templates")
def mako_module_path(filename, uri):
filename = filename.lstrip("/").replace("/", "-")
path = os.path.join(module_directory, filename + ".py")
return os.path.abspath(path)
else:
# disable caching templates since we don't know where they should go.
module_directory = mako_module_path = None
# set up the templating system
config["pylons.app_globals"].mako_lookup = TemplateLookup(
directories=paths["templates"],
error_handler=handle_mako_error,
module_directory=module_directory,
input_encoding="utf-8",
default_filters=["conditional_websafe"],
filesystem_checks=getattr(g, "reload_templates", False),
imports=[
"from r2.lib.filters import websafe, unsafe, conditional_websafe",
"from pylons import request",
"from pylons import tmpl_context as c",
"from pylons import app_globals as g",
"from pylons.i18n import _, ungettext",
],
modulename_callable=mako_module_path,
)
if setup_globals:
g.setup_complete()
return config
开发者ID:Shilohtd,项目名称:reddit,代码行数:83,代码来源:environment.py
示例4: destination_path
def destination_path(self):
built_statics_path = get_built_statics_path()
return os.path.join(built_statics_path, "static", self.name)
开发者ID:zeantsoi,项目名称:reddit,代码行数:3,代码来源:js.py
示例5: dependencies
def dependencies(self):
built_statics_path = get_built_statics_path()
path = os.path.join(built_statics_path, "static", "js", self.name)
return [path]
开发者ID:zeantsoi,项目名称:reddit,代码行数:4,代码来源:js.py
注:本文中的r2.config.paths.get_built_statics_path函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论