本文整理汇总了Python中itools.uri.Path.get_name方法的典型用法代码示例。如果您正苦于以下问题:Python Path.get_name方法的具体用法?Python Path.get_name怎么用?Python Path.get_name使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类itools.uri.Path
的用法示例。
在下文中一共展示了Path.get_name方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: update_links
# 需要导入模块: from itools.uri import Path [as 别名]
# 或者: from itools.uri.Path import get_name [as 别名]
def update_links(self, source, target):
source = Path(source)
site_root = self.get_site_root()
# Tags
tags_base = site_root.get_abspath().resolve2("tags")
if tags_base.get_prefix(source) == tags_base:
tags = list(self.get_property("tags"))
source_name = source.get_name()
target_name = Path(target).get_name()
for tag in tags:
if tag == source_name:
# Hit
index = tags.index(source_name)
tags[index] = target_name
self.set_property("tags", tags)
get_context().database.change_resource(self)
示例2: update_links
# 需要导入模块: from itools.uri import Path [as 别名]
# 或者: from itools.uri.Path import get_name [as 别名]
def update_links(self, source, target):
source = Path(source)
site_root = self.get_site_root()
available_languages = site_root.get_property('website_languages')
# Tags
tags_base = site_root.get_abspath().resolve2('tags')
if tags_base.get_prefix(source) == tags_base:
tags = list(self.get_property('tags'))
source_name = source.get_name()
target_name = Path(target).get_name()
for tag in tags:
if tag == source_name:
# Hit
index = tags.index(source_name)
tags[index] = target_name
self.set_property('tags', tags)
# Thumbnail
base = self.get_canonical_path()
resources_new2old = get_context().database.resources_new2old
base = str(base)
old_base = resources_new2old.get(base, base)
old_base = Path(old_base)
new_base = Path(base)
for lang in available_languages:
path = self.get_property('thumbnail', lang)
if not path:
continue
ref = get_reference(path)
if ref.scheme:
continue
path = old_base.resolve2(path)
if path == source:
# Hit
self.set_property('thumbnail', new_base.get_pathto(target),
lang)
get_context().database.change_resource(self)
示例3: get_basename
# 需要导入模块: from itools.uri import Path [as 别名]
# 或者: from itools.uri.Path import get_name [as 别名]
def get_basename(path):
if type(path) is not Path:
path = Path(path)
return path.get_name()