當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。