Skip to content

Commit 48896eb

Browse files
committed
✨ apply black style
1 parent b75b90a commit 48896eb

File tree

1 file changed

+74
-76
lines changed

1 file changed

+74
-76
lines changed

templates/setup.py.jj2

Lines changed: 74 additions & 76 deletions
Original file line numberDiff line numberDiff line change
@@ -10,17 +10,17 @@
1010
{% block header %}
1111
# Template by pypi-mobans
1212
{% endblock %}
13-
import os
14-
import sys
1513
import codecs
1614
import locale
15+
import os
1716
import platform
17+
import sys
1818
from shutil import rmtree
1919
{% if external_module_library %}
2020
from distutils.core import setup, Extension
2121
{% else %}
2222

23-
from setuptools import Command, setup, find_packages
23+
from setuptools import Command, find_packages, setup
2424

2525
{%endif%}
2626
{%block compat_block%}
@@ -34,46 +34,46 @@ PY33 = sys.version_info < (3, 4)
3434
# This work around is only if a project supports Python < 3.4
3535
{% if PY33 %}
3636
try:
37-
codecs.lookup('mbcs')
37+
codecs.lookup("mbcs")
3838
except LookupError:
39-
ascii = codecs.lookup('ascii')
40-
func = lambda name, enc=ascii: {True: enc}.get(name=='mbcs')
39+
ascii = codecs.lookup("ascii")
40+
func = lambda name, enc=ascii: {True: enc}.get(name=="mbcs")
4141
codecs.register(func)
4242
{% endif %}
4343

4444
# Work around for locale not being set
4545
try:
4646
lc = locale.getlocale()
4747
pf = platform.system()
48-
if pf != 'Windows' and lc == (None, None):
49-
locale.setlocale(locale.LC_ALL, 'C.UTF-8')
48+
if pf != "Windows" and lc == (None, None):
49+
locale.setlocale(locale.LC_ALL, "C.UTF-8")
5050
except (ValueError, UnicodeError, locale.Error):
51-
locale.setlocale(locale.LC_ALL, 'en_US.UTF-8')
51+
locale.setlocale(locale.LC_ALL, "en_US.UTF-8")
5252

53-
NAME = '{{name}}'
54-
AUTHOR = '{{author}}'
55-
VERSION = '{{current_version}}'
56-
EMAIL = '{{contact}}'
57-
LICENSE = '{{license}}'
53+
NAME = "{{name}}"
54+
AUTHOR = "{{author}}"
55+
VERSION = "{{current_version}}"
56+
EMAIL = "{{contact}}"
57+
LICENSE = "{{license}}"
5858
{% if MAINTAINER %}
59-
MAINTAINER = '{{maintainer}}'
60-
MAINTAINER_CONTACT = '{{maintainer_contact}}'
59+
MAINTAINER = "{{maintainer}}"
60+
MAINTAINER_CONTACT = "{{maintainer_contact}}"
6161
{% endif %}
6262
{% if command_line_interface or entry_points %}
6363
ENTRY_POINTS = {
6464
{% if not entry_points or 'console_scripts' not in entry_points %}
65-
'console_scripts': [
66-
'{{command_line_interface}} = {{ entry_point }}'
65+
"console_scripts": [
66+
"{{command_line_interface}} = {{ entry_point }}"
6767
],
6868
{% endif %}
6969
{% if entry_points %}
7070
{% for group_name, items in entry_points.items() %}
71-
'{{group_name}}': [
72-
{% if group_name == 'console_scripts' and command_line_interface %}
73-
'{{command_line_interface}} = {{ entry_point }}',
71+
"{{group_name}}": [
72+
{% if group_name == "console_scripts" and command_line_interface %}
73+
"{{command_line_interface}} = {{ entry_point }}",
7474
{% endif %}
7575
{% for item in items %}
76-
'{{item}}',
76+
"{{item}}",
7777
{% endfor %}
7878
],
7979
{% endfor %}
@@ -82,64 +82,64 @@ ENTRY_POINTS = {
8282
{% endif %}
8383
DESCRIPTION = (
8484
{% for line in description | split_length(70) %}
85-
'{{ line }}'{{ ' +' if not loop.last}}
85+
"{{ line }}"{{ " +" if not loop.last}}
8686
{% endfor %}
8787
)
88-
URL = 'https://{{scm_host}}/{{organisation}}/{{name}}'
89-
DOWNLOAD_URL = '%s/archive/{{release}}.tar.gz' % URL
90-
FILES = ['README.rst',{%block morefiles %}{%endblock%} 'CHANGELOG.rst']
88+
URL = "https://{{scm_host}}/{{organisation}}/{{name}}"
89+
DOWNLOAD_URL = "%s/archive/{{release}}.tar.gz" % URL
90+
FILES = ["README.rst",{%block morefiles %}{%endblock%} "CHANGELOG.rst"]
9191
{% if self.additional_keywords %}
9292
{% set additional_keywords = self.additional_keywords() %}
93-
{% if additional_keywords and not additional_keywords.rstrip().endswith(',') %}
94-
{% set additional_keywords = additional_keywords.rstrip() + ',\n' %}
93+
{% if additional_keywords and not additional_keywords.rstrip().endswith(",") %}
94+
{% set additional_keywords = additional_keywords.rstrip() + ",\n" %}
9595
{% endif %}
9696
{% endif %}
9797
KEYWORDS = [
98-
'python',
98+
"python",
9999
{% for keyword in keywords %}
100-
'{{keyword}}',
100+
"{{keyword}}",
101101
{% endfor %}
102102
{%block additional_keywords -%}
103103
{%endblock%}
104104
]
105105

106106
CLASSIFIERS = [
107-
'Topic :: Software Development :: Libraries',
108-
'Programming Language :: Python',
109-
'Intended Audience :: Developers',
110-
{% if min_python_version <= ['2', '6'] %}
111-
'Programming Language :: Python :: 2.6',
107+
"Topic :: Software Development :: Libraries",
108+
"Programming Language :: Python",
109+
"Intended Audience :: Developers",
110+
{% if min_python_version <= ["2", "6"] %}
111+
"Programming Language :: Python :: 2.6",
112112
{%- endif %}
113113

114-
{% if min_python_version <= ['2', '7'] %}
115-
'Programming Language :: Python :: 2.7',
114+
{% if min_python_version <= ["2", "7"] %}
115+
"Programming Language :: Python :: 2.7",
116116
{%- endif %}
117117

118-
{%- if min_python_version[0] == '3' %}
119-
'Programming Language :: Python :: 3 :: Only',
118+
{%- if min_python_version[0] == "3" %}
119+
"Programming Language :: Python :: 3 :: Only",
120120
{%- endif %}
121121

122-
{% if min_python_version <= ['3','3'] %}
123-
'Programming Language :: Python :: 3.3',
122+
{% if min_python_version <= ["3","3"] %}
123+
"Programming Language :: Python :: 3.3",
124124
{%- endif %}
125125

126-
{% if min_python_version <= ['3','4'] %}
127-
'Programming Language :: Python :: 3.4',
126+
{% if min_python_version <= ["3","4"] %}
127+
"Programming Language :: Python :: 3.4",
128128
{%- endif %}
129129

130-
{% if min_python_version <= ['3','5'] %}
131-
'Programming Language :: Python :: 3.5',
130+
{% if min_python_version <= ["3","5"] %}
131+
"Programming Language :: Python :: 3.5",
132132
{%- endif %}
133133

134-
{% if min_python_version <= ['3','6'] %}
135-
'Programming Language :: Python :: 3.6',
134+
{% if min_python_version <= ["3","6"] %}
135+
"Programming Language :: Python :: 3.6",
136136
{% endif %}
137137
{%block additional_classifiers%}
138138
{%endblock %}
139139
]
140140

141141
{%macro handle_complex_dependency(complex_one) -%}
142-
{%set dependency, condition = complex_one.split(';')%}
142+
{%set dependency, condition = complex_one.split(";")%}
143143
{% if condition == 'python_version<"3"'%}
144144
if PY2:
145145
{% endif %}
@@ -164,12 +164,12 @@ INSTALL_REQUIRES = [
164164
{% if '#' in egg_name: %}
165165
{% set egg_name = egg_name.split('#')[0].strip() %}
166166
{% endif %}
167-
'{{[repo_link, egg_name] | join('#egg=')}}',
167+
"{{[repo_link, egg_name] | join('#egg=')}}",
168168
{% elif '#' in dependency: %}
169169
{% set dependency = dependency.split('#')[0].strip() %}
170-
'{{dependency}}',
170+
"{{dependency}}",
171171
{% else %}
172-
'{{dependency}}',
172+
"{{dependency}}",
173173
{% endif %}
174174
{% endif %}
175175
{% endfor %}
@@ -189,18 +189,18 @@ PYMODULE = Extension(
189189
'{{name}}',
190190
sources=[
191191
{% for source in sources: %}
192-
'{{source}}',
192+
"{{source}}",
193193
{% endfor %}
194194
],
195195
libraries=INSTALL_REQUIRES
196196
)
197197
{% else %}
198-
PACKAGES = find_packages(exclude=['ez_setup', 'examples', 'tests'])
198+
PACKAGES = find_packages(exclude=["ez_setup", "examples", "tests"])
199199
{% if extra_dependencies or dependencies: %}
200200
EXTRAS_REQUIRE = {
201201
{% for dependency in extra_dependencies: %}
202202
{% for key, value in dependency.items(): %}
203-
'{{key}}': {{value}},
203+
"{{key}}": {{value}},
204204
{% endfor %}
205205
{% endfor %}
206206
}
@@ -210,16 +210,14 @@ EXTRAS_REQUIRE = {}
210210
{% endif %}
211211
# You do not need to read beyond this line
212212
{% if nowheel %}
213-
PUBLISH_COMMAND = '{0} setup.py sdist upload -r pypi'.format(
214-
sys.executable)
213+
PUBLISH_COMMAND = "{0} setup.py sdist upload -r pypi".format(sys.executable)
215214
{% else %}
216-
PUBLISH_COMMAND = '{0} setup.py sdist bdist_wheel upload -r pypi'.format(
217-
sys.executable)
215+
PUBLISH_COMMAND = "{0} setup.py sdist bdist_wheel upload -r pypi".format(sys.executable)
218216
{% endif %}
219-
GS_COMMAND = ('gs {{name}} v{{release}} ' +
217+
GS_COMMAND = ("gs {{name}} v{{release}} " +
220218
"Find {{release}} in changelog for more details")
221-
NO_GS_MESSAGE = ('Automatic github release is disabled. ' +
222-
'Please install gease to enable it.')
219+
NO_GS_MESSAGE = ("Automatic github release is disabled. " +
220+
"Please install gease to enable it.")
223221
UPLOAD_FAILED_MSG = (
224222
'Upload failed. please run "%s" yourself.' % PUBLISH_COMMAND)
225223
HERE = os.path.abspath(os.path.dirname(__file__))
@@ -228,13 +226,13 @@ HERE = os.path.abspath(os.path.dirname(__file__))
228226
class PublishCommand(Command):
229227
"""Support setup.py upload."""
230228

231-
description = 'Build and publish the package on github and pypi'
229+
description = "Build and publish the package on github and pypi"
232230
user_options = []
233231

234232
@staticmethod
235233
def status(s):
236234
"""Prints things in bold."""
237-
print('\033[1m{0}\033[0m'.format(s))
235+
print("\033[1m{0}\033[0m".format(s))
238236

239237
def initialize_options(self):
240238
pass
@@ -244,14 +242,14 @@ class PublishCommand(Command):
244242

245243
def run(self):
246244
try:
247-
self.status('Removing previous builds...')
248-
rmtree(os.path.join(HERE, 'dist'))
249-
rmtree(os.path.join(HERE, 'build'))
250-
rmtree(os.path.join(HERE, '{{name|replace('-', '_')}}.egg-info'))
245+
self.status("Removing previous builds...")
246+
rmtree(os.path.join(HERE, "dist"))
247+
rmtree(os.path.join(HERE, "build"))
248+
rmtree(os.path.join(HERE, "{{name|replace('-', '_')}}.egg-info"))
251249
except OSError:
252250
pass
253251

254-
self.status('Building Source and Wheel (universal) distribution...')
252+
self.status("Building Source and Wheel (universal) distribution...")
255253
run_status = True
256254
if has_gease():
257255
run_status = os.system(GS_COMMAND) == 0
@@ -265,7 +263,7 @@ class PublishCommand(Command):
265263

266264

267265
SETUP_COMMANDS.update({
268-
'publish': PublishCommand
266+
"publish": PublishCommand
269267
})
270268

271269

@@ -294,7 +292,7 @@ def read_files(*files):
294292
def read(afile):
295293
"""Read a file into setup"""
296294
the_relative_file = os.path.join(HERE, afile)
297-
with codecs.open(the_relative_file, 'r', 'utf-8') as opened_file:
295+
with codecs.open(the_relative_file, "r", "utf-8") as opened_file:
298296
content = filter_out_test_code(opened_file)
299297
content = "".join(list(content))
300298
return content
@@ -303,11 +301,11 @@ def read(afile):
303301
def filter_out_test_code(file_handle):
304302
found_test_code = False
305303
for line in file_handle.readlines():
306-
if line.startswith('.. testcode:'):
304+
if line.startswith(".. testcode:"):
307305
found_test_code = True
308306
continue
309307
if found_test_code is True:
310-
if line.startswith(' '):
308+
if line.startswith(" "):
311309
continue
312310
else:
313311
empty_line = line.strip()
@@ -317,16 +315,16 @@ def filter_out_test_code(file_handle):
317315
found_test_code = False
318316
yield line
319317
else:
320-
for keyword in ['|version|', '|today|']:
318+
for keyword in ["|version|", "|today|"]:
321319
if keyword in line:
322320
break
323321
else:
324322
yield line
325323

326324

327-
if __name__ == '__main__':
325+
if __name__ == "__main__":
328326
setup(
329-
{% if 'tests' is exists %}
327+
{% if "tests" is exists %}
330328
test_suite="tests",
331329
{% endif %}
332330
name=NAME,
@@ -347,7 +345,7 @@ if __name__ == '__main__':
347345
ext_modules=[PYMODULE],
348346
{% else %}
349347
extras_require=EXTRAS_REQUIRE,
350-
tests_require=['nose'],
348+
tests_require=["nose"],
351349
install_requires=INSTALL_REQUIRES,
352350
packages=PACKAGES,
353351
include_package_data=True,

0 commit comments

Comments
 (0)