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)
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)
def get_basename(path): if type(path) is not Path: path = Path(path) return path.get_name()