本文整理汇总了Python中mynt.fs.Directory.mk方法的典型用法代码示例。如果您正苦于以下问题:Python Directory.mk方法的具体用法?Python Directory.mk怎么用?Python Directory.mk使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类mynt.fs.Directory
的用法示例。
在下文中一共展示了Directory.mk方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: Mynt
# 需要导入模块: from mynt.fs import Directory [as 别名]
# 或者: from mynt.fs.Directory import mk [as 别名]
#.........这里部分代码省略.........
self.tags.clear()
for tag in tags:
self.tags[tag.pop('name')] = tag
else:
logger.debug('.. no posts found')
def _render(self):
self._process()
logger.info('>> Rendering')
self.renderer.register({
'archives': self.archives,
'posts': self.posts,
'tags': self.tags
})
logger.debug('.. posts')
for (newer_post, post, older_post) in zip([None] + self.posts[:-1], self.posts, self.posts[1:] + [None]):
try:
self.pages.append(Page(
self._get_path(post['url']),
self._pygmentize(self.renderer.render(post['layout'], {'older_post': older_post, 'post': post, 'newer_post': newer_post}))
))
except RendererException as e:
raise RendererException(e.message, '{0} in post \'{1}\''.format(post['layout'], post['title']))
logger.debug('.. pages')
for f in self.src:
if f.extension not in ('.html', '.htm', '.xml'):
continue
template = f.path.replace(self.src.path, '')
self.pages.append(Page(
normpath(self.dest.path, template),
self._pygmentize(self.renderer.render(template))
))
if self.config['tag_layout'] and self.tags:
logger.debug('.. tags')
for name, data in self.tags:
self.pages.append(Page(
self._get_path(data['url']),
self._pygmentize(self.renderer.render(self.config['tag_layout'], {'tag': data}))
))
if self.config['archive_layout'] and self.archives:
logger.debug('.. archives')
for year, data in self.archives:
self.pages.append(Page(
self._get_path(data['url']),
self._pygmentize(self.renderer.render(self.config['archive_layout'], {'archive': dict(year = year, **data)}))
))
def generate(self):
self._render()
logger.info('>> Generating')
assets_src = Directory(normpath(self.src.path, '_assets'))
assets_dest = Directory(normpath(self.dest.path, *self.config['assets_url'].split('/')))
if self.dest.exists:
if not self.opts['force']:
raise OptionException('Destination already exists.', 'the -f option must be used to force generation by deleting the destination')
self.dest.rm()
self.dest.mk()
for page in self.pages:
page.mk()
if assets_src.exists:
for asset in assets_src:
asset.cp(asset.path.replace(assets_src.path, assets_dest.path))
logger.info('Completed in {0:.3f}s'.format(time() - self._start))
@property
def parser(self):
if self._parser is None:
self._parser = self._get_parser()(self.config.get(self.config['parser'], {}))
return self._parser
@property
def renderer(self):
if self._renderer is None:
self._renderer = self._get_renderer()(self.src.path, self.config.get(self.config['renderer'], {}))
return self._renderer