workflow.py 文件源码

python
阅读 32 收藏 0 点赞 0 评论 0

项目:Gank-Alfred-Workflow 作者: hujiaweibujidao 项目源码 文件源码
def version(self):
        """Return the version of the workflow

        .. versionadded:: 1.9.10

        Get the version from the ``update_settings`` dict passed on
        instantiation or the ``version`` file located in the workflow's
        root directory. Return ``None`` if neither exist or
        :class:`ValueError` if the version number is invalid (i.e. not
        semantic).

        :returns: Version of the workflow (not Alfred-Workflow)
        :rtype: :class:`~workflow.update.Version` object

        """

        if self._version is UNSET:

            version = None
            # First check `update_settings`
            if self._update_settings:
                version = self._update_settings.get('version')

            # Fallback to `version` file
            if not version:
                filepath = self.workflowfile('version')

                if os.path.exists(filepath):
                    with open(filepath, 'rb') as fileobj:
                        version = fileobj.read()

            if version:
                from update import Version
                version = Version(version)

            self._version = version

        return self._version

    # Workflow utility methods -----------------------------------------
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号