How to use the twine.utils.get_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_empty_userpass(tmpdir):
    """Suppress prompts if empty username and password are provided in .pypirc."""
    pypirc = os.path.join(str(tmpdir), ".pypirc")

    with open(pypirc, "w") as fp:
        fp.write(
            textwrap.dedent(
                """
            [pypi]
            username=
            password=
        """
            )
        )

    config = utils.get_config(pypirc)
    pypi = config["pypi"]

    assert pypi["username"] == pypi["password"] == ""
github pypa / twine / tests / test_utils.py View on Github external
def test_get_config_override_pypi_url(tmpdir):
    pypirc = os.path.join(str(tmpdir), ".pypirc")

    with open(pypirc, "w") as fp:
        fp.write(
            textwrap.dedent(
                """
            [pypi]
            repository = http://pypiproxy
        """
            )
        )

    assert utils.get_config(pypirc)["pypi"]["repository"] == "http://pypiproxy"
github pypa / twine / tests / test_utils.py View on Github external
def test_get_config_missing(tmpdir):
    pypirc = os.path.join(str(tmpdir), ".pypirc")

    assert utils.get_config(pypirc) == {
        "pypi": {
            "repository": utils.DEFAULT_REPOSITORY,
            "username": None,
            "password": None,
        },
        "testpypi": {
            "repository": utils.TEST_REPOSITORY,
            "username": None,
            "password": None,
        },
github pypa / twine / tests / test_utils.py View on Github external
def test_get_config_deprecated_pypirc():
    tests_dir = os.path.dirname(os.path.abspath(__file__))
    deprecated_pypirc_path = os.path.join(tests_dir, "fixtures", "deprecated-pypirc")

    assert utils.get_config(deprecated_pypirc_path) == {
        "pypi": {
            "repository": utils.DEFAULT_REPOSITORY,
            "username": "testusername",
            "password": "testpassword",
        },
        "testpypi": {
            "repository": utils.TEST_REPOSITORY,
            "username": "testusername",
            "password": "testpassword",
        },
github guildai / guildai / guild / package_main.py View on Github external
def _pypirc_section_for_repo(repo):
    from twine import utils
    config = utils.get_config()
    for section in config:
        if config[section].get("repository") == repo:
            return section
    return None
github docker / compose / script / release / release / pypi.py View on Github external
def check_pypirc():
    try:
        config = get_config()
    except Error as e:
        raise ScriptError('Failed to parse .pypirc file: {}'.format(e))

    if config is None:
        raise ScriptError('Failed to parse .pypirc file')

    if 'pypi' not in config:
        raise ScriptError('Missing [pypi] section in .pypirc file')

    if not (config['pypi'].get('username') and config['pypi'].get('password')):
        raise ScriptError('Missing login/password pair for pypi repo')