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


Python Ticket.resolution方法代码示例

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


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

示例1: _import_trackers

# 需要导入模块: from trac.ticket.model import Ticket [as 别名]
# 或者: from trac.ticket.model.Ticket import resolution [as 别名]
    def _import_trackers(self, meta, reset):
        types = set()
        components = set()
        priorities = set()
        resolutions = set()
        for tracker in meta["trackers"]:
            types.add(tracker["label"])
            v = tracker["vocabulary"]
            for x in v.get("Category", []):
                components.add(x)
            for x in v.get("priority", []):
                priorities.add(x)
            for x in v.get("Resolution", []):
                resolutions.add(x)

        if reset:

            @self.env.with_transaction()
            def do_reset_components(db):
                cursor = db.cursor()
                cursor.execute("DELETE FROM component")
                cursor.execute("DELETE FROM milestone")
                cursor.execute("DELETE FROM enum")
                cursor.execute("DELETE FROM version")
                cursor.execute("DELETE FROM ticket")
                cursor.execute("DELETE FROM ticket_change")

        @self.env.with_transaction()
        def do_reset_ticket_meta(db):
            cursor = db.cursor()
            for x in sorted(components):
                cursor.execute("INSERT INTO component (name, owner, description) VALUES (%s, 'admin', %s)", (x, x))
            for i, x in enumerate(sorted(types)):
                cursor.execute("INSERT INTO enum (type, name, value) VALUES ('ticket_type', %s, %s)", (x, i + 1))
            for i, x in enumerate(sorted(priorities)):
                cursor.execute("INSERT INTO enum (type, name, value) VALUES ('priority', %s, %s)", (x, i + 1))
            for i, x in enumerate(sorted(resolutions)):
                cursor.execute("INSERT INTO enum (type, name, value) VALUES ('resolution', %s, %s)", (x, i + 1))

        for tracker in meta["trackers"]:
            label = tracker["label"]
            for a in tracker["artifacts"]:
                owner = a.get("assigned_to", "")
                if owner == "Nobody" or owner == "No Change":
                    owner = ""

                ticket = Ticket(self.env)  # , a['id'])
                ticket.populate(
                    {
                        "summary": a.get("summary", ""),
                        "reporter": a.get("submitter", ""),
                        "description": a.get("description", ""),
                        "type": label,
                        "priority": a.get("priority", ""),
                        "component": a.get("Category", ""),
                        "owner": owner,
                        "status": a.get("status", ""),
                        "cc": "",
                        "keywords": "",
                    }
                )
                created = dateutil.parser.parse(a["date"])
                ticket.insert(created)

                changes = a["comments"]
                changes.extend(a["history"])
                lastcom = None
                for c in sorted(changes, key=lambda x: x["date"]):
                    modified = dateutil.parser.parse(c["date"])
                    if c["class"] == "COMMENT":
                        author = c.get("submitter", "")
                        comment = c.get("comment", "")
                        if lastcom != None and lastcom == modified:
                            modified += datetime.timedelta(0, 10)
                        lastcom = modified
                    elif c["class"] == "FIELDCHANGE":
                        author = c["by"]
                        comment = None
                        field = c["field"]
                        value = c["old"]  # WTF?
                        if field == "status":
                            ticket.status = value
                        elif field == "Resolution":
                            ticket.resolution = value
                        elif field == "assigned_to":
                            ticket.owner = value
                        elif field == "close_date":
                            continue
                    ticket.save_changes(author, comment, modified)

        return "OK"
开发者ID:nyuhuhuu,项目名称:trachacks,代码行数:93,代码来源:PlanetForgeImport.py


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