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


Python version.Version方法代码示例

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


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

示例1: get_last_release_versions

# 需要导入模块: from packaging import version [as 别名]
# 或者: from packaging.version import Version [as 别名]
def get_last_release_versions(repo: Repo) -> Tuple[Version, Version]:
    print("get latest release version")
    commit_to_tag = {tag.commit.hexsha: tag for tag in repo.tags}
    _, release_tag = sorted(
        [(tag.commit.committed_datetime, tag) for tag in repo.tags], reverse=True,
    )[0]
    for commit in release_tag.commit.iter_parents():
        if commit.hexsha in commit_to_tag:
            prev_release_tag = commit_to_tag[commit.hexsha]
            prev_version = Version(prev_release_tag.name)
            if not any(
                (
                    prev_version.is_devrelease,
                    prev_version.is_prerelease,
                    prev_version.is_postrelease,
                ),
            ):
                break
    else:
        raise RuntimeError("no previous release")
    release_version = Version(release_tag.name)
    print(f"\trelease {release_version} with previous {prev_version}")
    return prev_version, release_version 
开发者ID:tox-dev,项目名称:tox,代码行数:25,代码来源:notify.py

示例2: satisfies_version

# 需要导入模块: from packaging import version [as 别名]
# 或者: from packaging.version import Version [as 别名]
def satisfies_version(version, caret_range):
    assert caret_range.startswith('^'), 'Only supports caret ranges'
    extension_point_version = Version(version)
    extension_version = Version(caret_range[1:])
    next_extension_version = get_upper_bound_caret_version(
        extension_version)

    if extension_point_version < extension_version:
        raise PluginException(
            'Extension point is too old (%s), the extension requires '
            "'%s'" % (extension_point_version, extension_version))

    if extension_point_version >= next_extension_version:
        raise PluginException(
            'Extension point is newer (%s), than what the extension '
            "supports '%s'" % (extension_point_version, extension_version)) 
开发者ID:ros2,项目名称:ros2cli,代码行数:18,代码来源:plugin_system.py

示例3: estimate_tx

# 需要导入模块: from packaging import version [as 别名]
# 或者: from packaging.version import Version [as 别名]
def estimate_tx(self, safe_address: str, to: str, value: int, data: str, operation: int,
                    gas_token: Optional[str]) -> TransactionEstimationWithNonce:
        """
        :return: TransactionEstimation with costs and last used nonce of safe
        :raises: InvalidGasToken: If Gas Token is not valid
        """
        if not self._is_valid_gas_token(gas_token):
            raise InvalidGasToken(gas_token)

        last_used_nonce = self.get_last_used_nonce(safe_address)
        safe = Safe(safe_address, self.ethereum_client)
        safe_tx_gas = safe.estimate_tx_gas(to, value, data, operation)
        safe_tx_base_gas = safe.estimate_tx_base_gas(to, value, data, operation, gas_token, safe_tx_gas)

        # For Safe contracts v1.0.0 operational gas is not used (`base_gas` has all the related costs already)
        safe_version = safe.retrieve_version()
        if Version(safe_version) >= Version('1.0.0'):
            safe_tx_operational_gas = 0
        else:
            safe_tx_operational_gas = safe.estimate_tx_operational_gas(len(data) if data else 0)

        # Can throw RelayServiceException
        gas_price = self._estimate_tx_gas_price(gas_token)
        return TransactionEstimationWithNonce(safe_tx_gas, safe_tx_base_gas, safe_tx_base_gas, safe_tx_operational_gas,
                                              gas_price, gas_token or NULL_ADDRESS, last_used_nonce) 
开发者ID:gnosis,项目名称:safe-relay-service,代码行数:27,代码来源:transaction_service.py

示例4: update_metadata

# 需要导入模块: from packaging import version [as 别名]
# 或者: from packaging.version import Version [as 别名]
def update_metadata(self, metadata):
        # type: (Dict[str, Union[str, int, Version]]) -> None
        """
        Update the metadata on the current :class:`pythonfinder.models.python.PythonVersion`

        Given a parsed version dictionary from :func:`pythonfinder.utils.parse_python_version`,
        update the instance variables of the current version instance to reflect the newly
        supplied values.
        """

        for key in metadata:
            try:
                _ = getattr(self, key)
            except AttributeError:
                continue
            else:
                setattr(self, key, metadata[key]) 
开发者ID:sarugaku,项目名称:pythonfinder,代码行数:19,代码来源:python.py

示例5: parse

# 需要导入模块: from packaging import version [as 别名]
# 或者: from packaging.version import Version [as 别名]
def parse(cls, version):
        # type: (str) -> Dict[str, Union[str, int, Version]]
        """
        Parse a valid version string into a dictionary

        Raises:
            ValueError -- Unable to parse version string
            ValueError -- Not a valid python version
            TypeError -- NoneType or unparseable type passed in

        :param str version: A valid version string
        :return: A dictionary with metadata about the specified python version.
        :rtype: dict
        """

        if version is None:
            raise TypeError("Must pass a value to parse!")
        version_dict = parse_python_version(str(version))
        if not version_dict:
            raise ValueError("Not a valid python version: %r" % version)
        return version_dict 
开发者ID:sarugaku,项目名称:pythonfinder,代码行数:23,代码来源:python.py

示例6: test_python_versions

# 需要导入模块: from packaging import version [as 别名]
# 或者: from packaging.version import Version [as 别名]
def test_python_versions(monkeypatch, special_character_python):
    def mock_version(*args, **kwargs):
        version_output = "2.7.15+ (default, Jun 28 2018, 13:15:42)\n[GCC 7.2.0]"

        class FakeObj(object):
            def __init__(self, out):
                self.out = out

            def communicate(self):
                return self.out, ""

            def kill(self):
                pass

        c = FakeObj(version_output.split()[0])
        return c

    os.environ["PYTHONFINDER_IGNORE_UNSUPPORTED"] = str("1")
    with monkeypatch.context() as m:
        m.setattr("subprocess.Popen", mock_version)
        parsed = pythonfinder.models.python.PythonVersion.from_path(
            special_character_python.strpath
        )
        assert isinstance(parsed.version, Version) 
开发者ID:sarugaku,项目名称:pythonfinder,代码行数:26,代码来源:test_python.py

示例7: _checkversion

# 需要导入模块: from packaging import version [as 别名]
# 或者: from packaging.version import Version [as 别名]
def _checkversion(self) -> None:
        import pytest

        minver = self.inicfg.get("minversion", None)
        if minver:
            # Imported lazily to improve start-up time.
            from packaging.version import Version

            if not isinstance(minver, str):
                raise pytest.UsageError(
                    "%s: 'minversion' must be a single value" % self.inifile
                )

            if Version(minver) > Version(pytest.__version__):
                raise pytest.UsageError(
                    "%s: 'minversion' requires pytest-%s, actual pytest-%s'"
                    % (self.inifile, minver, pytest.__version__,)
                ) 
开发者ID:pytest-dev,项目名称:pytest,代码行数:20,代码来源:__init__.py

示例8: read_spec

# 需要导入模块: from packaging import version [as 别名]
# 或者: from packaging.version import Version [as 别名]
def read_spec(lines):
    candidates = {}
    latest = None
    for line in lines:
        if not line or line.startswith("#"):
            continue
        if not line.startswith(" "):
            name, version = splitstrip(line, 2)
            version = Version(version)
            latest = Candidate(name, version)
            candidates[latest] = set()
        else:
            if latest is None:
                raise RuntimeError(
                    "Spec has dependencies before first candidate"
                )
            name, specifier = splitstrip(line, 2)
            specifier = SpecifierSet(specifier)
            candidates[latest].add(Requirement(name, specifier))
    return candidates 
开发者ID:sarugaku,项目名称:resolvelib,代码行数:22,代码来源:reporter_demo.py

示例9: read_versioned_binary_mask

# 需要导入模块: from packaging import version [as 别名]
# 或者: from packaging.version import Version [as 别名]
def read_versioned_binary_mask(
            file_obj: BinaryIO,
    ) -> bm.BinaryMaskCollection:
        with tarfile.open(mode="r|gz", fileobj=file_obj) as tf:
            if tf.pax_headers is None:
                raise ValueError(
                    f"file does not appear to be a binary mask file (does not have headers)")
            if tf.pax_headers.get(AttrKeys.DOCTYPE, None) != DOCTYPE_STRING:
                raise ValueError(
                    f"file does not appear to be a binary mask file (missing or incorrect doctype)")
            if AttrKeys.VERSION not in tf.pax_headers:
                raise ValueError(f"file missing version data")

            requested_version = Version(tf.pax_headers[AttrKeys.VERSION])

            for version, implementation in BinaryMaskIO.ASCENDING_VERSIONS:
                if version == requested_version:
                    return implementation().read_binary_mask(tf)
            else:
                raise ValueError(f"No reader for version {requested_version}") 
开发者ID:spacetx,项目名称:starfish,代码行数:22,代码来源:_io.py

示例10: write_versioned_binary_mask

# 需要导入模块: from packaging import version [as 别名]
# 或者: from packaging.version import Version [as 别名]
def write_versioned_binary_mask(
            file_obj: BinaryIO,
            binary_mask: bm.BinaryMaskCollection,
            requested_version: Optional[Version] = None,
    ):
        if requested_version is None:
            implementation = BinaryMaskIO.ASCENDING_VERSIONS[-1][1]
        else:
            for version, implementing_class in BinaryMaskIO.ASCENDING_VERSIONS:
                if version == requested_version:
                    implementation = implementing_class
                    break
            else:
                raise ValueError(f"No writer for version {requested_version}")

        implementation().write_binary_mask(file_obj, binary_mask) 
开发者ID:spacetx,项目名称:starfish,代码行数:18,代码来源:_io.py

示例11: _fetch_redshift_column_attributes

# 需要导入模块: from packaging import version [as 别名]
# 或者: from packaging.version import Version [as 别名]
def _fetch_redshift_column_attributes(self, column):
        text = ""
        if sa_version >= Version('1.3.0'):
            info = column.dialect_options['redshift']
        else:
            if not hasattr(column, 'info'):
                return text
            info = column.info

        identity = info.get('identity')
        if identity:
            text += " IDENTITY({0},{1})".format(identity[0], identity[1])

        encode = info.get('encode')
        if encode:
            text += " ENCODE " + encode

        distkey = info.get('distkey')
        if distkey:
            text += " DISTKEY"

        sortkey = info.get('sortkey')
        if sortkey:
            text += " SORTKEY"
        return text 
开发者ID:sqlalchemy-redshift,项目名称:sqlalchemy-redshift,代码行数:27,代码来源:dialect.py

示例12: _get_column_info

# 需要导入模块: from packaging import version [as 别名]
# 或者: from packaging.version import Version [as 别名]
def _get_column_info(self, *args, **kwargs):
        kw = kwargs.copy()
        encode = kw.pop('encode', None)
        if sa_version < Version('1.2.0'):
            # SQLAlchemy 1.2.0 introduced the 'comment' param
            del kw['comment']
        if sa_version >= Version('1.3.16'):
            # SQLAlchemy 1.3.16 introduced generated columns,
            # not supported in redshift
            kw['generated'] = ''
        column_info = super(RedshiftDialect, self)._get_column_info(
            *args,
            **kw
        )
        if isinstance(column_info['type'], VARCHAR):
            if column_info['type'].length is None:
                column_info['type'] = NullType()
        if 'info' not in column_info:
            column_info['info'] = {}
        if encode and encode != 'none':
            column_info['info']['encode'] = encode
        return column_info 
开发者ID:sqlalchemy-redshift,项目名称:sqlalchemy-redshift,代码行数:24,代码来源:dialect.py

示例13: test_01logout_login

# 需要导入模块: from packaging import version [as 别名]
# 或者: from packaging.version import Version [as 别名]
def test_01logout_login(self):
        # This test if we properly regenerate the CSRF from the cookie when not restarting the program
        # can include changing login/vdom passwd on the same session
        # Check the  license validity/force a license update and wait in license call..
        if Version(fgt.get_version()) > Version('5.6'):
            try:
                self.assertTrue(fgt.license()['results']['vm']['status'] == "vm_valid" or "vm_eval")
            except KeyError:
                time.sleep(35)
        else:
            self.assertTrue(True, "not supported before 5.6")
            time.sleep(35)
        # do a logout then login again
        # TODO a expcetion check
        self.assertEqual(fgt.logout(), None)
        self.test_00login() 
开发者ID:fortinet-solutions-cse,项目名称:fortiosapi,代码行数:18,代码来源:test_fortiosapi_virsh.py

示例14: version

# 需要导入模块: from packaging import version [as 别名]
# 或者: from packaging.version import Version [as 别名]
def version(self):
        """Get Kubernetes version"""
        response = self.http_get('/version')
        if self.unhealthy(response.status_code):
            raise KubeHTTPException(response, 'fetching Kubernetes version')

        data = response.json()
        return Version('{}.{}'.format(data['major'], data['minor'])) 
开发者ID:deis,项目名称:controller,代码行数:10,代码来源:__init__.py

示例15: get_message_body

# 需要导入模块: from packaging import version [as 别名]
# 或者: from packaging.version import Version [as 别名]
def get_message_body(release_version: Version, prev_version: Version) -> str:
    is_major_release = release_version.release[0:2] != prev_version.release[0:2]
    if is_major_release:
        return textwrap.dedent(
            f"""
        The tox team is proud to announce the {release_version} feature release at https://pypi.org/project/tox/!

        tox aims to automate and standardize testing in Python. It is part of a larger vision of easing the packaging, testing and release process of Python software.

        Details about the changes can be found at https://tox.readthedocs.io/en/{release_version}/changelog.html
        For complete documentation, please visit: https://tox.readthedocs.io/en/{release_version}/

        As usual, you can upgrade from PyPI via:

            pip install --upgrade tox

        or - if you also want to get pre release versions:

            pip install -upgrade --pre tox

        We thank all present and past contributors to tox. Have a look at https://github.com/tox-dev/tox/blob/master/CONTRIBUTORS to see who contributed.

        Happy toxing,
        the tox-dev team
        """,  # noqa
        )
    else:
        return textwrap.dedent(
            f"""
                The tox team is proud to announce the {release_version} bug fix release at https://pypi.org/project/tox/!

                tox aims to automate and standardize testing in Python. It is part of a larger vision of easing the packaging, testing and release process of Python software.

                For details about the fix(es),please check the CHANGELOG: https://tox.readthedocs.io/en/{release_version}/changelog.html

                We thank all present and past contributors to tox. Have a look at https://github.com/tox-dev/tox/blob/master/CONTRIBUTORS to see who contributed.

                Happy toxing,
                the tox-dev team
                """,  # noqa
        ) 
开发者ID:tox-dev,项目名称:tox,代码行数:43,代码来源:notify.py


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