本文整理汇总了Python中hyde.fs.Folder.child_folder方法的典型用法代码示例。如果您正苦于以下问题:Python Folder.child_folder方法的具体用法?Python Folder.child_folder怎么用?Python Folder.child_folder使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类hyde.fs.Folder
的用法示例。
在下文中一共展示了Folder.child_folder方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: _get_layout_folder
# 需要导入模块: from hyde.fs import Folder [as 别名]
# 或者: from hyde.fs.Folder import child_folder [as 别名]
def _get_layout_folder(root, layout_name='basic'):
"""
Finds the layout folder from the given root folder.
If it does not exist, return None
"""
layouts_folder = Folder(str(root)).child_folder(LAYOUTS)
layout_folder = layouts_folder.child_folder(layout_name)
return layout_folder if layout_folder.exists else None
示例2: Config
# 需要导入模块: from hyde.fs import Folder [as 别名]
# 或者: from hyde.fs.Folder import child_folder [as 别名]
class Config(Expando):
"""
Represents the hyde configuration file
"""
def __init__(self, sitepath, config_file=None, config_dict=None):
self.default_config = dict(
mode='production',
simple_copy = [],
content_root='content',
deploy_root='deploy',
media_root='media',
layout_root='layout',
media_url='/media',
base_url="/",
not_found='404.html',
plugins = [],
ignore = [ "*~", "*.bak", ".hg", ".git", ".svn"],
meta = {
"nodemeta": 'meta.yaml'
}
)
self.config_file = config_file
self.config_dict = config_dict
self.load_time = datetime.min
self.config_files = []
self.sitepath = Folder(sitepath)
super(Config, self).__init__(self.load())
@property
def last_modified(self):
return max((conf.last_modified for conf in self.config_files))
def needs_refresh(self):
if not self.config_files:
return True
return any((conf.has_changed_since(self.load_time)
for conf in self.config_files))
def load(self):
conf = dict(**self.default_config)
conf.update(self.read_config(self.config_file))
if self.config_dict:
conf.update(self.config_dict)
return conf
def reload(self):
if not self.config_file:
return
self.update(self.load())
def read_config(self, config_file):
"""
Reads the configuration file and updates this
object while allowing for inherited configurations.
"""
conf_file = self.sitepath.child(
config_file if
config_file else 'site.yaml')
conf = {}
if File(conf_file).exists:
self.config_files.append(File(conf_file))
logger.info("Reading site configuration from [%s]", conf_file)
with codecs.open(conf_file, 'r', 'utf-8') as stream:
conf = yaml.load(stream)
if 'extends' in conf:
parent = self.read_config(conf['extends'])
parent.update(conf)
conf = parent
self.load_time = datetime.now()
return conf
@property
def deploy_root_path(self):
"""
Derives the deploy root path from the site path
"""
return self.sitepath.child_folder(self.deploy_root)
@property
def content_root_path(self):
"""
Derives the content root path from the site path
"""
return self.sitepath.child_folder(self.content_root)
@property
def media_root_path(self):
"""
Derives the media root path from the content path
"""
return self.content_root_path.child_folder(self.media_root)
@property
def layout_root_path(self):
"""
Derives the layout root path from the site path
"""
#.........这里部分代码省略.........
示例3: Config
# 需要导入模块: from hyde.fs import Folder [as 别名]
# 或者: from hyde.fs.Folder import child_folder [as 别名]
class Config(Expando):
"""
Represents the hyde configuration file
"""
def __init__(self, sitepath, config_file=None, config_dict=None):
default_config = dict(
content_root='content',
deploy_root='deploy',
media_root='media',
layout_root='layout',
media_url='/media',
site_url='/',
not_found='404.html',
plugins = []
)
conf = dict(**default_config)
self.sitepath = Folder(sitepath)
conf.update(self.read_config(config_file))
if config_dict:
conf.update(config_dict)
super(Config, self).__init__(conf)
def read_config(self, config_file):
"""
Reads the configuration file and updates this
object while allowing for inherited configurations.
"""
conf_file = self.sitepath.child(
config_file if
config_file else 'site.yaml')
conf = {}
if File(conf_file).exists:
logger.info("Reading site configuration from [%s]", conf_file)
with codecs.open(conf_file, 'r', 'utf-8') as stream:
conf = yaml.load(stream)
if 'extends' in conf:
parent = self.read_config(conf['extends'])
parent.update(conf)
conf = parent
return conf
@property
def deploy_root_path(self):
"""
Derives the deploy root path from the site path
"""
return self.sitepath.child_folder(self.deploy_root)
@property
def content_root_path(self):
"""
Derives the content root path from the site path
"""
return self.sitepath.child_folder(self.content_root)
@property
def media_root_path(self):
"""
Derives the media root path from the site path
"""
return self.sitepath.child_folder(self.media_root)
@property
def layout_root_path(self):
"""
Derives the layout root path from the site path
"""
return self.sitepath.child_folder(self.layout_root)