本文整理汇总了Python中unipath.FSPath.startswith方法的典型用法代码示例。如果您正苦于以下问题:Python FSPath.startswith方法的具体用法?Python FSPath.startswith怎么用?Python FSPath.startswith使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类unipath.FSPath
的用法示例。
在下文中一共展示了FSPath.startswith方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: create_chapters
# 需要导入模块: from unipath import FSPath [as 别名]
# 或者: from unipath.FSPath import startswith [as 别名]
def create_chapters(vers, release_date=None, comments_open=True):
"""
Create a bunch of ``Chapter`` objects for a given ``BookVersion``.
"""
c = pysvn.Client()
for record in c.ls(vers.svn_root):
name = Path(record["name"]).name
if name.ext != ".txt":
continue
parts = publish_html(c.cat(record["name"]))
title = re.sub(r"(?i)^(chapter|appendix)\s+[A-Z0-9]+:\s*", "", parts["title"])
if name.startswith("appendix"):
Chapter.objects.get_or_create(
type = "A",
number = ord(name.stem[-1]) - ord('A') + 1,
title = title,
version = vers,
defaults = dict(
release_date = release_date,
comments_open = comments_open,
)
)
elif name.startswith("chapter"):
Chapter.objects.get_or_create(
type = "C",
number = int(name.stem[-2:]),
title = title,
version = vers,
defaults = dict(
release_date = release_date,
comments_open = comments_open,
)
)