Skip to content

Commit 1e50596

Browse files
committed
Format using black
1 parent 5d960c2 commit 1e50596

File tree

17 files changed

+1533
-1393
lines changed

17 files changed

+1533
-1393
lines changed

bootstrap.py

Lines changed: 60 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727

2828
tmpeggs = tempfile.mkdtemp()
2929

30-
usage = '''\
30+
usage = """\
3131
[DESIRED PYTHON FOR BUILDOUT] bootstrap.py [options]
3232
3333
Bootstraps a buildout-based project.
@@ -37,25 +37,34 @@
3737
3838
Note that by using --find-links to point to local resources, you can keep
3939
this script from going over the network.
40-
'''
40+
"""
4141

4242
parser = OptionParser(usage=usage)
4343
parser.add_option("-v", "--version", help="use a specific zc.buildout version")
4444

45-
parser.add_option("-t", "--accept-buildout-test-releases",
46-
dest='accept_buildout_test_releases',
47-
action="store_true", default=False,
48-
help=("Normally, if you do not specify a --version, the "
49-
"bootstrap script and buildout gets the newest "
50-
"*final* versions of zc.buildout and its recipes and "
51-
"extensions for you. If you use this flag, "
52-
"bootstrap and buildout will get the newest releases "
53-
"even if they are alphas or betas."))
54-
parser.add_option("-c", "--config-file",
55-
help=("Specify the path to the buildout configuration "
56-
"file to be used."))
57-
parser.add_option("-f", "--find-links",
58-
help=("Specify a URL to search for buildout releases"))
45+
parser.add_option(
46+
"-t",
47+
"--accept-buildout-test-releases",
48+
dest="accept_buildout_test_releases",
49+
action="store_true",
50+
default=False,
51+
help=(
52+
"Normally, if you do not specify a --version, the "
53+
"bootstrap script and buildout gets the newest "
54+
"*final* versions of zc.buildout and its recipes and "
55+
"extensions for you. If you use this flag, "
56+
"bootstrap and buildout will get the newest releases "
57+
"even if they are alphas or betas."
58+
),
59+
)
60+
parser.add_option(
61+
"-c",
62+
"--config-file",
63+
help=("Specify the path to the buildout configuration " "file to be used."),
64+
)
65+
parser.add_option(
66+
"-f", "--find-links", help=("Specify a URL to search for buildout releases")
67+
)
5968

6069

6170
options, args = parser.parse_args()
@@ -76,14 +85,17 @@
7685
from urllib2 import urlopen
7786

7887
# XXX use a more permanent ez_setup.py URL when available.
79-
exec(urlopen('https://bitbucket.org/pypa/setuptools/raw/0.7.2/ez_setup.py'
80-
).read(), ez)
88+
exec(
89+
urlopen("https://bitbucket.org/pypa/setuptools/raw/0.7.2/ez_setup.py").read(),
90+
ez,
91+
)
8192
setup_args = dict(to_dir=tmpeggs, download_delay=0)
82-
ez['use_setuptools'](**setup_args)
93+
ez["use_setuptools"](**setup_args)
8394

8495
if to_reload:
8596
reload(pkg_resources)
8697
import pkg_resources
98+
8799
# This does not (always?) update the default working set. We will
88100
# do it.
89101
for path in sys.path:
@@ -95,36 +107,43 @@
95107

96108
ws = pkg_resources.working_set
97109

98-
cmd = [sys.executable, '-c',
99-
'from setuptools.command.easy_install import main; main()',
100-
'-mZqNxd', tmpeggs]
110+
cmd = [
111+
sys.executable,
112+
"-c",
113+
"from setuptools.command.easy_install import main; main()",
114+
"-mZqNxd",
115+
tmpeggs,
116+
]
101117

102118
find_links = os.environ.get(
103-
'bootstrap-testing-find-links',
104-
options.find_links or
105-
('http://downloads.buildout.org/'
106-
if options.accept_buildout_test_releases else None)
107-
)
119+
"bootstrap-testing-find-links",
120+
options.find_links
121+
or (
122+
"http://downloads.buildout.org/"
123+
if options.accept_buildout_test_releases
124+
else None
125+
),
126+
)
108127
if find_links:
109-
cmd.extend(['-f', find_links])
128+
cmd.extend(["-f", find_links])
110129

111-
setuptools_path = ws.find(
112-
pkg_resources.Requirement.parse('setuptools')).location
130+
setuptools_path = ws.find(pkg_resources.Requirement.parse("setuptools")).location
113131

114-
requirement = 'zc.buildout'
132+
requirement = "zc.buildout"
115133
version = options.version
116134
if version is None and not options.accept_buildout_test_releases:
117135
# Figure out the most recent final version of zc.buildout.
118136
import setuptools.package_index
119-
_final_parts = '*final-', '*final'
137+
138+
_final_parts = "*final-", "*final"
120139

121140
def _final_version(parsed_version):
122141
for part in parsed_version:
123-
if (part[:1] == '*') and (part not in _final_parts):
142+
if (part[:1] == "*") and (part not in _final_parts):
124143
return False
125144
return True
126-
index = setuptools.package_index.PackageIndex(
127-
search_path=[setuptools_path])
145+
146+
index = setuptools.package_index.PackageIndex(search_path=[setuptools_path])
128147
if find_links:
129148
index.add_find_links((find_links,))
130149
req = pkg_resources.Requirement.parse(requirement)
@@ -143,14 +162,13 @@ def _final_version(parsed_version):
143162
best.sort()
144163
version = best[-1].version
145164
if version:
146-
requirement = '=='.join((requirement, version))
165+
requirement = "==".join((requirement, version))
147166
cmd.append(requirement)
148167

149168
import subprocess
169+
150170
if subprocess.call(cmd, env=dict(os.environ, PYTHONPATH=setuptools_path)) != 0:
151-
raise Exception(
152-
"Failed to execute command:\n%s",
153-
repr(cmd)[1:-1])
171+
raise Exception("Failed to execute command:\n%s", repr(cmd)[1:-1])
154172

155173
######################################################################
156174
# Import and run buildout
@@ -159,12 +177,12 @@ def _final_version(parsed_version):
159177
ws.require(requirement)
160178
import zc.buildout.buildout
161179

162-
if not [a for a in args if '=' not in a]:
163-
args.append('bootstrap')
180+
if not [a for a in args if "=" not in a]:
181+
args.append("bootstrap")
164182

165183
# if -c was provided, we push it back into args for buildout' main function
166184
if options.config_file is not None:
167-
args[0:0] = ['-c', options.config_file]
185+
args[0:0] = ["-c", options.config_file]
168186

169187
zc.buildout.buildout.main(args)
170188
shutil.rmtree(tmpeggs)

0 commit comments

Comments
 (0)