mirror of
https://github.com/python/cpython.git
synced 2025-07-19 17:25:54 +00:00

svn+ssh://pythondev@svn.python.org/python/trunk ........ r63208 | georg.brandl | 2008-05-13 15:04:54 -0400 (Tue, 13 May 2008) | 2 lines #2831: add start argument to enumerate(). Patch by Scott Dial and me. ........ r63209 | marc-andre.lemburg | 2008-05-13 15:10:45 -0400 (Tue, 13 May 2008) | 3 lines Remove leftovers from reverted setuptools checkin (they were added in r45525). ........ r63211 | georg.brandl | 2008-05-13 17:32:03 -0400 (Tue, 13 May 2008) | 2 lines Fix a refleak in the _warnings module. ........ r63212 | andrew.kuchling | 2008-05-13 20:46:41 -0400 (Tue, 13 May 2008) | 1 line List all the removes and renamed modules ........ r63214 | brett.cannon | 2008-05-13 21:09:40 -0400 (Tue, 13 May 2008) | 2 lines Rewrap some lines in test_py3kwarn. ........ r63219 | georg.brandl | 2008-05-14 02:34:15 -0400 (Wed, 14 May 2008) | 2 lines Add NEWS entry for #2831. ........ r63220 | neal.norwitz | 2008-05-14 02:47:56 -0400 (Wed, 14 May 2008) | 3 lines Fix "refleak" by restoring the tearDown method removed by accident (AFAICT) in r62788. ........ r63221 | georg.brandl | 2008-05-14 03:18:22 -0400 (Wed, 14 May 2008) | 2 lines Fix another "refleak" by clearing the filters after test. ........ r63222 | neal.norwitz | 2008-05-14 03:21:42 -0400 (Wed, 14 May 2008) | 5 lines Install the json package and tests as well as the lib2to3 tests so the tests work when run from an install directory. They are currently skipped on the daily runs (not from the buildbots) for checking refleaks, etc. ........ r63256 | andrew.kuchling | 2008-05-14 21:10:24 -0400 (Wed, 14 May 2008) | 1 line Note some removals and a rename ........ r63311 | brett.cannon | 2008-05-15 00:36:53 -0400 (Thu, 15 May 2008) | 2 lines Add a snippet for the deprecation directive for docs. ........ r63313 | gregory.p.smith | 2008-05-15 00:56:18 -0400 (Thu, 15 May 2008) | 5 lines disable the crashing test. I will also file a bug. This crash does not appear to be a new bug, its just that the test coverage went up recently exposing it. (I verified that by testing this test code on an older Modules/_bsddb.c) ........ r63320 | georg.brandl | 2008-05-15 11:08:32 -0400 (Thu, 15 May 2008) | 2 lines #2863: add gen.__name__ and add this name to generator repr(). ........ r63324 | andrew.kuchling | 2008-05-15 16:07:39 -0400 (Thu, 15 May 2008) | 1 line Import class from distutils.cmd, not .core, to avoid circular import ........ r63327 | alexandre.vassalotti | 2008-05-15 16:31:42 -0400 (Thu, 15 May 2008) | 2 lines Fixed typo in a doctest of test_genexps. ........ r63332 | benjamin.peterson | 2008-05-15 18:34:33 -0400 (Thu, 15 May 2008) | 2 lines add Mac modules to the list of deprecated ones ........ r63333 | benjamin.peterson | 2008-05-15 18:41:16 -0400 (Thu, 15 May 2008) | 2 lines fix typos in whatsnew ........ r63348 | benjamin.peterson | 2008-05-15 22:24:49 -0400 (Thu, 15 May 2008) | 2 lines make test_platform a bit more assertive (We'll see what the buildbots say.) ........
124 lines
4.2 KiB
Python
124 lines
4.2 KiB
Python
"""distutils.pypirc
|
|
|
|
Provides the PyPIRCCommand class, the base class for the command classes
|
|
that uses .pypirc in the distutils.command package.
|
|
"""
|
|
import os
|
|
import sys
|
|
from configparser import ConfigParser
|
|
|
|
from distutils.cmd import Command
|
|
|
|
DEFAULT_PYPIRC = """\
|
|
[pypirc]
|
|
servers =
|
|
pypi
|
|
|
|
[pypi]
|
|
username:%s
|
|
password:%s
|
|
"""
|
|
|
|
class PyPIRCCommand(Command):
|
|
"""Base command that knows how to handle the .pypirc file
|
|
"""
|
|
DEFAULT_REPOSITORY = 'http://pypi.python.org/pypi'
|
|
DEFAULT_REALM = 'pypi'
|
|
repository = None
|
|
realm = None
|
|
|
|
user_options = [
|
|
('repository=', 'r',
|
|
"url of repository [default: %s]" % \
|
|
DEFAULT_REPOSITORY),
|
|
('show-response', None,
|
|
'display full response text from server')]
|
|
|
|
boolean_options = ['show-response']
|
|
|
|
def _get_rc_file(self):
|
|
"""Returns rc file path."""
|
|
return os.path.join(os.path.expanduser('~'), '.pypirc')
|
|
|
|
def _store_pypirc(self, username, password):
|
|
"""Creates a default .pypirc file."""
|
|
rc = self._get_rc_file()
|
|
f = open(rc, 'w')
|
|
try:
|
|
f.write(DEFAULT_PYPIRC % (username, password))
|
|
finally:
|
|
f.close()
|
|
try:
|
|
os.chmod(rc, 0o600)
|
|
except OSError:
|
|
# should do something better here
|
|
pass
|
|
|
|
def _read_pypirc(self):
|
|
"""Reads the .pypirc file."""
|
|
rc = self._get_rc_file()
|
|
if os.path.exists(rc):
|
|
print('Using PyPI login from %s' % rc)
|
|
repository = self.repository or self.DEFAULT_REPOSITORY
|
|
realm = self.realm or self.DEFAULT_REALM
|
|
|
|
config = ConfigParser()
|
|
config.read(rc)
|
|
sections = config.sections()
|
|
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() != '']
|
|
if _servers == []:
|
|
# nothing set, let's try to get the default pypi
|
|
if 'pypi' in sections:
|
|
_servers = ['pypi']
|
|
else:
|
|
# the file is not properly defined, returning
|
|
# an empty dict
|
|
return {}
|
|
for server in _servers:
|
|
current = {'server': server}
|
|
current['username'] = config.get(server, 'username')
|
|
current['password'] = config.get(server, 'password')
|
|
|
|
# optional params
|
|
for key, default in (('repository',
|
|
self.DEFAULT_REPOSITORY),
|
|
('realm', self.DEFAULT_REALM)):
|
|
if config.has_option(server, key):
|
|
current[key] = config.get(server, key)
|
|
else:
|
|
current[key] = default
|
|
if (current['server'] == repository or
|
|
current['repository'] == repository):
|
|
return current
|
|
elif 'server-login' in sections:
|
|
# old format
|
|
server = 'server-login'
|
|
if config.has_option(server, 'repository'):
|
|
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 {}
|
|
|
|
def initialize_options(self):
|
|
"""Initialize options."""
|
|
self.repository = None
|
|
self.realm = None
|
|
self.show_response = 0
|
|
|
|
def finalize_options(self):
|
|
"""Finalizes options."""
|
|
if self.repository is None:
|
|
self.repository = self.DEFAULT_REPOSITORY
|
|
if self.realm is None:
|
|
self.realm = self.DEFAULT_REALM
|