本文整理汇总了Python中unipath.FSPath.components方法的典型用法代码示例。如果您正苦于以下问题:Python FSPath.components方法的具体用法?Python FSPath.components怎么用?Python FSPath.components使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类unipath.FSPath
的用法示例。
在下文中一共展示了FSPath.components方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: do_build
# 需要导入模块: from unipath import FSPath [as 别名]
# 或者: from unipath.FSPath import components [as 别名]
def do_build(self, arguments):
# If no course arguments are given, build all the courses.
if arguments['<course>']:
try:
courses = [self.library.courses[c] for c in arguments['<course>']]
except KeyError:
raise CLIError("No such course:", c)
else:
courses = self.library.courses.values()
for course in courses:
self.out.write(u'Building %s\n' % course.title)
# Make the dest directory.
dest = self.library.build_path.child(course.slug)
if dest.exists():
dest.rmtree()
dest.mkdir(parents=True)
# Create the sphinx support directories (_static, _templates) by
# merging directories from the internal chucks-support directory
# and from the library's theme if it exists. This has to happen
# before building the handounts and Sphinx docs because both those
# steps uses these components.
for subdir in ('_static', '_templates'):
chucksdir = self.support_path.child(subdir)
themedir = self.library.theme_path.child(subdir)
sources = [d for d in (chucksdir, themedir) if d.exists()]
if not dest.child(subdir).exists():
dest.child(subdir).mkdir()
fileutils.merge_trees(sources, dest.child(subdir))
# Write out an auth.json for the deployment step. This should
# probably actually become part of the deployment step at some point.
if hasattr(course, 'auth'):
json.dump(course.auth, open(dest.child('auth.json'), 'w'))
# Handouts have to go first: Sphinx links to the handouts.
self._build_handouts(course)
self._build_sphinx(course)
# Copy over any extra files to be downloaded. FIXME: This is a nasty
# hack. Inject these into toc.html as download links?
for fname in getattr(course, 'downloads', []):
p = Path(fname)
if p.isabsolute():
src = p
else:
src = self.library.path.child(*p.components())
shutil.copy(src, dest.child('html'))
示例2: _fget
# 需要导入模块: from unipath import FSPath [as 别名]
# 或者: from unipath.FSPath import components [as 别名]
def _fget(self):
d = Path(getattr(self, config_name, default))
return self.path.child(*d.components())