当前位置: 首页>>代码示例>>Python>>正文


Python TagEngine.remove_tags方法代码示例

本文整理汇总了Python中tractags.api.TagEngine.remove_tags方法的典型用法代码示例。如果您正苦于以下问题:Python TagEngine.remove_tags方法的具体用法?Python TagEngine.remove_tags怎么用?Python TagEngine.remove_tags使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在tractags.api.TagEngine的用法示例。


在下文中一共展示了TagEngine.remove_tags方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: download_deleted

# 需要导入模块: from tractags.api import TagEngine [as 别名]
# 或者: from tractags.api.TagEngine import remove_tags [as 别名]
    def download_deleted(self, download):
        tags = TagEngine(self.env).tagspace.downloads

        # Prepare tag names.
        self._resolve_ids(download)
        tag_names = [download['author'], download['component'],
          download['version'], download['architecture'],
          download['platform'], download['type']]
        if download['tags']:
            tag_names.extend(download['tags'].split(' '))

        # Add tags to download.
        self.log.debug(tag_names)
        tags.remove_tags(None, download['id'], list(sets.Set(tag_names)))
开发者ID:nyuhuhuu,项目名称:trachacks,代码行数:16,代码来源:tags.py

示例2: screenshot_deleted

# 需要导入模块: from tractags.api import TagEngine [as 别名]
# 或者: from tractags.api.TagEngine import remove_tags [as 别名]
 def screenshot_deleted(self, screenshot):
     # Add tags to screenshot.
     tags = TagEngine(self.env).tagspace.screenshots
     tag_names = self._get_tags(screenshot)
     tags.remove_tags(None, screenshot['id'], list(sets.Set(tag_names)))
开发者ID:nyuhuhuu,项目名称:trachacks,代码行数:7,代码来源:tags.py

示例3: _do_actions

# 需要导入模块: from tractags.api import TagEngine [as 别名]
# 或者: from tractags.api.TagEngine import remove_tags [as 别名]

#.........这里部分代码省略.........
                if is_tags:
                    tags = TagEngine(self.env).tagspace.screenshots
                    tag_names = new_components
                    tag_names.extend(new_versions)
                    tag_names.extend([new_name, screenshot["author"]])
                    if new_tags:
                        tag_names.extend(new_tags.split(" "))
                    tags.replace_tags(req, screenshot["id"], tag_names)

                # Edit screenshot.
                self.api.edit_screenshot(
                    cursor, screenshot["id"], new_name, new_description, new_tags, new_components, new_versions
                )

            elif mode == "delete":
                req.perm.assert_permission("SCREENSHOTS_ADMIN")

                # Get screenshots
                screenshots = self.api.get_screenshots(cursor, component["name"], version["name"])
                index = self._get_screenshot_index(screenshots, self.id) or 0
                screenshot = self.api.get_screenshot(cursor, self.id)

                # Delete screenshot.
                try:
                    self.api.delete_screenshot(cursor, self.id)
                    path = os.path.join(self.path, str(self.id))
                    os.remove(os.path.join(path, screenshot["large_file"]))
                    os.remove(os.path.join(path, screenshot["medium_file"]))
                    os.remove(os.path.join(path, screenshot["small_file"]))
                    os.rmdir(path)
                except:
                    pass

                # Delete screenshot tags.
                if is_tags:
                    tags = TagEngine(self.env).tagspace.screenshots
                    tag_names = screenshot["components"]
                    tag_names.extend(screenshot["versions"])
                    tag_names.extend([screenshot["name"], screenshot["author"]])
                    if screenshot["tags"]:
                        tag_names.extend(screenshot["tags"].split(" "))
                    tags.remove_tags(req, screenshot["id"], tag_names)

                # Set new screenshot id.
                if index > 1:
                    self.id = screenshots[index - 1]["id"]
                else:
                    self.id = screenshots[0]["id"]

            elif mode == "display":
                req.perm.assert_permission("SCREENSHOTS_VIEW")

                # Get screenshots of selected version and component.
                screenshots = self.api.get_screenshots(cursor, component["name"], version["name"])
                index = self._get_screenshot_index(screenshots, self.id) or 0

                # Prepare displayed screenshots.
                lenght = len(screenshots)
                previous = []
                current = []
                next = []
                if lenght > 0:
                    current.append(screenshots[index])
                if (index + 1) < lenght:
                    next.append(screenshots[index + 1])
                else:
                    next.append(no_screenshot)
                if (index + 2) < lenght:
                    next.append(screenshots[index + 2])
                else:
                    next.append(no_screenshot)
                if (index - 1) > 0:
                    previous.append(screenshots[index - 2])
                else:
                    previous.append(no_screenshot)
                if (index) > 0:
                    previous.append(screenshots[index - 1])
                else:
                    previous.append(no_screenshot)

                # Fill HDF structure
                req.hdf["screenshots.index"] = index + 1
                req.hdf["screenshots.count"] = len(screenshots)
                req.hdf["screenshots.previous"] = previous
                req.hdf["screenshots.current"] = current
                req.hdf["screenshots.next"] = next

                return "screenshots.cs", None

            elif mode == "add-display":
                req.perm.assert_permission("SCREENSHOTS_ADMIN")

                # Get screenshot
                screenshot = self.api.get_screenshot(cursor, self.id)
                self.log.debug("screenshot: %s" % (screenshot,))

                # Fill HDF structure
                req.hdf["screenshots.current"] = [screenshot]

                return "screenshot-add.cs", None
开发者ID:nyuhuhuu,项目名称:trachacks,代码行数:104,代码来源:core.py


注:本文中的tractags.api.TagEngine.remove_tags方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。