本文整理汇总了Python中mynt.fs.Directory.cp方法的典型用法代码示例。如果您正苦于以下问题:Python Directory.cp方法的具体用法?Python Directory.cp怎么用?Python Directory.cp使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类mynt.fs.Directory
的用法示例。
在下文中一共展示了Directory.cp方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: _generate
# 需要导入模块: from mynt.fs import Directory [as 别名]
# 或者: from mynt.fs.Directory import cp [as 别名]
def _generate(self):
self._initialize()
self._parse()
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('/')))
figures_src = Directory(normpath(self.src.path, '_figures'))
figures_dest = Directory(normpath(self.dest.path, *self.config['figures_url'].split('/')))
if self.dest.exists:
if self.opts['force']:
self.dest.empty()
else:
self.dest.rm()
else:
self.dest.mk()
for page in self.pages:
page.mk()
assets_src.cp(assets_dest.path)
figures_src.cp(figures_dest.path)
for pattern in self.config['include']:
for path in iglob(normpath(self.src.path, pattern)):
dest = path.replace(self.src.path, self.dest.path)
if op.isdir(path):
Directory(path).cp(dest, False)
elif op.isfile(path):
File(path).cp(dest)
示例2: _generate
# 需要导入模块: from mynt.fs import Directory [as 别名]
# 或者: from mynt.fs.Directory import cp [as 别名]
def _generate(self):
logger.debug('>> Initializing\n.. src: %s\n.. dest: %s', self.src.path, self.dest.path)
self._update_config()
if self.config['locale']:
try:
locale.setlocale(locale.LC_ALL, (self.config['locale'], 'utf-8'))
except locale.Error:
raise ConfigException('Locale not available.', 'run `locale -a` to see available locales')
self.renderer.register({'site': self.config})
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 self.opts['force']:
self.dest.empty()
else:
self.dest.rm()
else:
self.dest.mk()
for page in self.pages:
page.mk()
assets_src.cp(assets_dest.path)
for pattern in self.config['include']:
for path in iglob(normpath(self.src.path, pattern)):
dest = path.replace(self.src.path, self.dest.path)
if op.isdir(path):
Directory(path).cp(dest, False)
elif op.isfile(path):
File(path).cp(dest)
logger.info('Completed in %.3fs', time() - self._start)
示例3: Mynt
# 需要导入模块: from mynt.fs import Directory [as 别名]
# 或者: from mynt.fs.Directory import cp [as 别名]
#.........这里部分代码省略.........
def _render(self):
logger.info('>> Rendering')
self.writer.register(self.data)
for i, page in enumerate(self.pages):
self.pages[i] = self.writer.render(*page)
def _generate(self):
self._initialize()
self._parse()
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('/')))
figures_src = Directory(normpath(self.src.path, '_figures'))
figures_dest = Directory(normpath(self.dest.path, *self.config['figures_url'].split('/')))
if self.dest.exists:
if self.opts['force']:
self.dest.empty()
else:
self.dest.rm()
else:
self.dest.mk()
for page in self.pages:
page.mk()
assets_src.cp(assets_dest.path)
figures_src.cp(figures_dest.path)
for pattern in self.config['include']:
for path in iglob(normpath(self.src.path, pattern)):
dest = path.replace(self.src.path, self.dest.path)
if op.isdir(path):
Directory(path).cp(dest, False)
elif op.isfile(path):
File(path).cp(dest)
def _regenerate(self):
self._reader = None
self._writer = None
self.config = None
self.posts = None
self.containers = None
self.data.clear()
self.pages = None
self._generate()
def generate(self):
Timer.start()
self.src = Directory(self.opts['src'])
self.dest = Directory(self.opts['dest'])
if not self.src.exists:
raise OptionException('Source must exist.')
示例4: Mynt
# 需要导入模块: from mynt.fs import Directory [as 别名]
# 或者: from mynt.fs.Directory import cp [as 别名]
#.........这里部分代码省略.........
))
def _generate(self):
logger.debug('>> Initializing\n.. src: %s\n.. dest: %s', self.src.path, self.dest.path)
self._update_config()
if self.config['locale']:
try:
locale.setlocale(locale.LC_ALL, (self.config['locale'], 'utf-8'))
except locale.Error:
raise ConfigException('Locale not available.', 'run `locale -a` to see available locales')
self.renderer.register({'site': self.config})
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 self.opts['force']:
self.dest.empty()
else:
self.dest.rm()
else:
self.dest.mk()
for page in self.pages:
page.mk()
assets_src.cp(assets_dest.path)
for pattern in self.config['include']:
for path in iglob(normpath(self.src.path, pattern)):
dest = path.replace(self.src.path, self.dest.path)
if op.isdir(path):
Directory(path).cp(dest, False)
elif op.isfile(path):
File(path).cp(dest)
logger.info('Completed in %.3fs', time() - self._start)
def _regenerate(self):
self._parser = None
self._renderer = None
self._start = time()
self.archives = OrderedDict()
self.config = {}
self.pages = []
self.posts = []
self.tags = OrderedDict()
self._generate()
logger.info('Regenerated in %.3fs', time() - self._start)
def generate(self):
self.src = Directory(self.opts['src'])
self.dest = Directory(self.opts['dest'])
示例5: Mynt
# 需要导入模块: from mynt.fs import Directory [as 别名]
# 或者: from mynt.fs.Directory import cp [as 别名]
#.........这里部分代码省略.........
))
def _generate(self):
logger.debug('>> Initializing\n.. src: {0}\n.. dest: {1}'.format(self.src.path, self.dest.path))
self._update_config()
for opt in ('base_url',):
if opt in self.opts:
self.config[opt] = self.opts[opt]
self.renderer.register({'site': self.config})
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 self.opts['force']:
self.dest.empty()
else:
self.dest.rm()
else:
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))
# cbr - v0.8 - 2013-01-25
robots_src = File(normpath(self.src.path, 'robots.txt' ))
favicon_src = File(normpath(self.src.path, 'favicon.ico' ))
if robots_src.exists:
logger.debug('.. found: {0}'.format(robots_src.path))
robots_src_dest = robots_src.path.replace(robots_src.path, self.dest.path)
robots_src.cp(robots_src_dest + '/robots.txt')
else:
logger.debug('.. no robots file found: {0}'.format(robots_src.path))
# cbr - v0.8 - 2013-01-25
if favicon_src.exists:
logger.debug('.. found: {0}'.format(favicon_src.path))
favicon_file_dest = favicon_src.path.replace(favicon_src.path, self.dest.path)
favicon_src.cp(favicon_file_dest + '/favicon.ico')
else:
logger.debug('.. no favicon found at: {0}'.format(favicon_src.path))
logger.info('Completed in {0:.3f}s'.format(time() - self._start))
def _regenerate(self):
logger.setLevel(logging.ERROR)
self._parser = None
self._renderer = None
self._start = time()
self.archives = OrderedDict()