mirror of
https://github.com/pre-commit/pre-commit-hooks.git
synced 2026-04-13 14:24:18 +00:00
[pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
This commit is contained in:
parent
72ad6dc953
commit
f4cd1ba0d6
813 changed files with 66015 additions and 58839 deletions
|
|
@ -3,6 +3,8 @@
|
|||
Provides the PyPIRCCommand class, the base class for the command classes
|
||||
that uses .pypirc in the distutils.command package.
|
||||
"""
|
||||
from __future__ import annotations
|
||||
|
||||
import os
|
||||
from configparser import RawConfigParser
|
||||
|
||||
|
|
@ -18,6 +20,7 @@ username:%s
|
|||
password:%s
|
||||
"""
|
||||
|
||||
|
||||
class PyPIRCCommand(Command):
|
||||
"""Base command that knows how to handle the .pypirc file
|
||||
"""
|
||||
|
|
@ -27,11 +30,16 @@ class PyPIRCCommand(Command):
|
|||
realm = None
|
||||
|
||||
user_options = [
|
||||
('repository=', 'r',
|
||||
"url of repository [default: %s]" % \
|
||||
DEFAULT_REPOSITORY),
|
||||
('show-response', None,
|
||||
'display full response text from server')]
|
||||
(
|
||||
'repository=', 'r',
|
||||
'url of repository [default: %s]' %
|
||||
DEFAULT_REPOSITORY,
|
||||
),
|
||||
(
|
||||
'show-response', None,
|
||||
'display full response text from server',
|
||||
),
|
||||
]
|
||||
|
||||
boolean_options = ['show-response']
|
||||
|
||||
|
|
@ -58,9 +66,11 @@ class PyPIRCCommand(Command):
|
|||
if 'distutils' in sections:
|
||||
# let's get the list of servers
|
||||
index_servers = config.get('distutils', 'index-servers')
|
||||
_servers = [server.strip() for server in
|
||||
index_servers.split('\n')
|
||||
if server.strip() != '']
|
||||
_servers = [
|
||||
server.strip() for server in
|
||||
index_servers.split('\n')
|
||||
if server.strip() != ''
|
||||
]
|
||||
if _servers == []:
|
||||
# nothing set, let's try to get the default pypi
|
||||
if 'pypi' in sections:
|
||||
|
|
@ -74,10 +84,14 @@ class PyPIRCCommand(Command):
|
|||
current['username'] = config.get(server, 'username')
|
||||
|
||||
# optional params
|
||||
for key, default in (('repository',
|
||||
self.DEFAULT_REPOSITORY),
|
||||
('realm', self.DEFAULT_REALM),
|
||||
('password', None)):
|
||||
for key, default in (
|
||||
(
|
||||
'repository',
|
||||
self.DEFAULT_REPOSITORY,
|
||||
),
|
||||
('realm', self.DEFAULT_REALM),
|
||||
('password', None),
|
||||
):
|
||||
if config.has_option(server, key):
|
||||
current[key] = config.get(server, key)
|
||||
else:
|
||||
|
|
@ -86,13 +100,17 @@ class PyPIRCCommand(Command):
|
|||
# work around people having "repository" for the "pypi"
|
||||
# section of their config set to the HTTP (rather than
|
||||
# HTTPS) URL
|
||||
if (server == 'pypi' and
|
||||
repository in (self.DEFAULT_REPOSITORY, 'pypi')):
|
||||
if (
|
||||
server == 'pypi' and
|
||||
repository in (self.DEFAULT_REPOSITORY, 'pypi')
|
||||
):
|
||||
current['repository'] = self.DEFAULT_REPOSITORY
|
||||
return current
|
||||
|
||||
if (current['server'] == repository or
|
||||
current['repository'] == repository):
|
||||
if (
|
||||
current['server'] == repository or
|
||||
current['repository'] == repository
|
||||
):
|
||||
return current
|
||||
elif 'server-login' in sections:
|
||||
# old format
|
||||
|
|
@ -101,11 +119,13 @@ class PyPIRCCommand(Command):
|
|||
repository = config.get(server, 'repository')
|
||||
else:
|
||||
repository = self.DEFAULT_REPOSITORY
|
||||
return {'username': config.get(server, 'username'),
|
||||
'password': config.get(server, 'password'),
|
||||
'repository': repository,
|
||||
'server': server,
|
||||
'realm': self.DEFAULT_REALM}
|
||||
return {
|
||||
'username': config.get(server, 'username'),
|
||||
'password': config.get(server, 'password'),
|
||||
'repository': repository,
|
||||
'server': server,
|
||||
'realm': self.DEFAULT_REALM,
|
||||
}
|
||||
|
||||
return {}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue