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


Python Git.rm_tessera方法代码示例

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


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

示例1: Tesserae

# 需要导入模块: from git import Git [as 别名]
# 或者: from git.Git import rm_tessera [as 别名]

#.........这里部分代码省略.........
    @check_tessera_id
    def show(self, tessera_id):
        """
            Shows a specific tessera by passing the tessera_id parameter.
        """
        t = Tessera(tessera_id, os.path.join(self.tesseraepath, tessera_id))
        print(t.raw_tessera_file_content)
        return True

    @verify_tessera_path
    def ls(self, order_by, order_type, filter_types):
        """
            Lists all tesserae and show basic information.
        """
        tesserae = self._get_all_tesserae()

        if not tesserae:
            print("no tesserae created yet. Use git tessera create 'title' to create a new tessera")
            return True

        rows = [(t.short_id, t.title, ", ".join(t.keywords.get("status", ["unknown"])), ", ".join(t.keywords.get("type", ["unknown"])), t.keywords.get("priority", ["0"])[0], t.metadata.get("author", ["unknown"]), t.metadata.get("updated"))
                for t in tesserae if not filter_types or filter_types.intersection(t.keywords.get("type"))]

        if not rows:
            print("no tesserae found which matched your query")
            return True

        if order_by:
            order_by = order_by.lower()
            headers = [x.lower() for x in Tesserae.LS_HEADER]
            try:
                index = headers.index(order_by)
            except ValueError:
                raise TesseraError("cannot order by '%s' because this columns does not exist. Available colums are: '%s'" % (order_by, headers))

            rows = sorted(rows, key=lambda r: float(r[index]) if r[index].isdigit() else r[index], reverse=order_type == "desc")

        rows.insert(0, Tesserae.LS_HEADER)
        widths = [max(map(len, column)) for column in zip(*rows)]
        for n, r in enumerate(rows):
            print("  ".join(data.ljust(width) for data, width in zip(r, widths)))
            if n == 0:
                print("=" * (sum(widths) + 2 * len(widths)))
        return True

    @verify_tessera_path
    def create(self, title):
        """
            Creates a new tessera.
        """
        tessera = Tessera.create(self.tesseraepath, title)

        if not Editor.open(tessera.tessera_file, TesseraConfig(self._configpath)):
            tessera.remove()
            return False

        if not self._git.add_tessera(tessera):
            print("error: cannot commit new tessera")
            tessera.remove()
            return False

        print("Created new tessera with id %s" % tessera.id)
        return True

    @verify_tessera_path
    @check_tessera_id
    def remove(self, tessera_id):
        """
            Removes a tessera by it's id.
        """
        tessera = Tessera(tessera_id, os.path.join(self.tesseraepath, tessera_id))
        tessera.remove()

        if not self._git.rm_tessera(tessera):
            print("error: cannot remove tessera")
            return False

        print("Removed tessera with id '%s'" % tessera.id)
        return True

    @verify_tessera_path
    @check_tessera_id
    def edit(self, tessera_id):
        """
            Edits a tessera by it's id.
        """
        tessera = Tessera(tessera_id, os.path.join(self.tesseraepath, tessera_id))

        if not Editor.open(tessera.tessera_file, TesseraConfig(self._configpath)):
            print("error: cannot updated tessera")
            return False

        tessera.update()

        if not self._git.update_tessera(tessera):
            print("error: cannot commit updated tessera")
            return False

        print("Updated tessera with id %s" % tessera.id)
        return True
开发者ID:timofurrer,项目名称:git-tessera,代码行数:104,代码来源:tesserae.py


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