How to use the twine.utils.get_repository_from_config function in twine

To help you get started, we’ve selected a few twine examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github pypa / twine / tests / test_utils.py View on Github external
def test_get_repository_config_missing(tmpdir):
    pypirc = os.path.join(str(tmpdir), ".pypirc")

    repository_url = "https://notexisting.python.org/pypi"
    exp = {
        "repository": repository_url,
        "username": None,
        "password": None,
    }
    assert utils.get_repository_from_config(pypirc, "foo", repository_url) == exp
    assert utils.get_repository_from_config(pypirc, "pypi", repository_url) == exp
    exp = {
        "repository": utils.DEFAULT_REPOSITORY,
        "username": None,
        "password": None,
    }
    assert utils.get_repository_from_config(pypirc, "pypi") == exp
github pypa / twine / tests / test_utils.py View on Github external
def test_get_repository_config_missing_config(tmpdir):
    """Raise an exception when a repository isn't defined in .pypirc."""
    pypirc = os.path.join(str(tmpdir), ".pypirc")
    with pytest.raises(exceptions.InvalidConfiguration):
        utils.get_repository_from_config(pypirc, "foobar")
github pypa / twine / tests / test_utils.py View on Github external
def test_get_repository_config_with_invalid_url(tmpdir, repo_url, message):
    """Raise an exception for a URL with an invalid/missing scheme and/or host."""
    pypirc = os.path.join(str(tmpdir), ".pypirc")

    with pytest.raises(
        exceptions.UnreachableRepositoryURLDetected, match=message,
    ):
        utils.get_repository_from_config(pypirc, "pypi", repo_url)
github pypa / twine / tests / test_utils.py View on Github external
def test_get_repository_config_missing(tmpdir):
    pypirc = os.path.join(str(tmpdir), ".pypirc")

    repository_url = "https://notexisting.python.org/pypi"
    exp = {
        "repository": repository_url,
        "username": None,
        "password": None,
    }
    assert utils.get_repository_from_config(pypirc, "foo", repository_url) == exp
    assert utils.get_repository_from_config(pypirc, "pypi", repository_url) == exp
    exp = {
        "repository": utils.DEFAULT_REPOSITORY,
        "username": None,
        "password": None,
    }
    assert utils.get_repository_from_config(pypirc, "pypi") == exp
github pypa / twine / tests / test_utils.py View on Github external
pypirc = os.path.join(str(tmpdir), ".pypirc")

    repository_url = "https://notexisting.python.org/pypi"
    exp = {
        "repository": repository_url,
        "username": None,
        "password": None,
    }
    assert utils.get_repository_from_config(pypirc, "foo", repository_url) == exp
    assert utils.get_repository_from_config(pypirc, "pypi", repository_url) == exp
    exp = {
        "repository": utils.DEFAULT_REPOSITORY,
        "username": None,
        "password": None,
    }
    assert utils.get_repository_from_config(pypirc, "pypi") == exp
github pypa / twine / twine / settings.py View on Github external
def _handle_repository_options(
        self, repository_name: str, repository_url: Optional[str]
    ) -> None:
        self.repository_config = utils.get_repository_from_config(
            self.config_file, repository_name, repository_url,
        )
        self.repository_config["repository"] = utils.normalize_repository_url(
            cast(str, self.repository_config["repository"]),
        )
github sdispater / poet / poet / publisher.py View on Github external
def __init__(self, output, repository,
                 username=None, password=None, config_file='~/.pypirc',
                 cert=None, client_cert=None, repository_url=None):
        self._output = output

        config = twine.utils.get_repository_from_config(
            config_file,
            repository,
            repository_url
        )
        config["repository"] = twine.utils.normalize_repository_url(
            config["repository"]
        )

        username = twine.utils.get_username(username, config)
        password = twine.utils.get_password(password, config)
        ca_cert = twine.utils.get_cacert(cert, config)
        client_cert = twine.utils.get_clientcert(client_cert, config)

        self._repository = Repository(
            output, config["repository"], username, password
        )