Skip to content

Commit 860fd9b

Browse files
committed
Reformat Python files with black
1 parent d2c89b9 commit 860fd9b

3 files changed

Lines changed: 237 additions & 102 deletions

File tree

setup.py

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,20 @@
11
from setuptools import setup, find_packages
2+
23
# TODO: include package data (templates)
34
setup(
4-
name='syrup',
5-
version='0.0.2',
5+
name="syrup",
6+
version="0.0.2",
67
packages=find_packages(),
7-
package_data={
8-
'': ['templates/*']
9-
},
8+
package_data={"": ["templates/*"]},
109
install_requires=[
11-
'click',
12-
'requests',
13-
'Pillow',
14-
'jinja2',
10+
"click",
11+
"requests",
12+
"Pillow",
13+
"jinja2",
1514
],
16-
entry_points='''
15+
entry_points="""
1716
[console_scripts]
1817
syrup=syrup.__main__:cli
19-
''',
18+
""",
2019
zip_safe=True,
2120
)

syrup/__main__.py

Lines changed: 119 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -12,53 +12,132 @@
1212
NSISBuildInstaller,
1313
)
1414

15-
Version = namedtuple('Version', ['major', 'minor', 'build'])
16-
Version.__str__ = lambda self: "{self.major}.{self.minor}.{self.build}".format(self=self)
15+
Version = namedtuple("Version", ["major", "minor", "build"])
16+
Version.__str__ = lambda self: "{self.major}.{self.minor}.{self.build}".format(
17+
self=self
18+
)
19+
1720

1821
@click.group()
1922
@click.version_option()
2023
def cli():
2124
pass
2225

26+
2327
@cli.command()
24-
@click.option('--build-dir', default="build", type=click.Path(file_okay=False))
25-
@click.option('--artifact-dir', default="artifacts", type=click.Path(file_okay=False))
26-
@click.option('--clean-artifacts/--no-clean-artifacts', default=False)
28+
@click.option("--build-dir", default="build", type=click.Path(file_okay=False))
29+
@click.option("--artifact-dir", default="artifacts", type=click.Path(file_okay=False))
30+
@click.option("--clean-artifacts/--no-clean-artifacts", default=False)
2731
def clean(build_dir, artifact_dir, clean_artifacts, **kwargs):
2832
if clean_artifacts:
2933
cleanArtifacts(artifact_dir)
3034
cleanBuild(build_dir)
3135

36+
3237
def validate_version(ctx, param, value):
3338
try:
34-
return Version(*[int(x) if x else 0 for x in value.split('.')])
39+
return Version(*[int(x) if x else 0 for x in value.split(".")])
3540
except:
36-
raise click.BadParameter('version must be in major.minor.build format. (1.0.0)')
37-
38-
@cli.command()
39-
@click.option('--version', callback=validate_version, default="0.0.0", help="Version number of build (major.minor.build).")
40-
@click.option('--name', required=True, help="Application name.")
41-
@click.option('--company', required=True, help="Company name.")
42-
@click.option('--description', help="Application description.")
41+
raise click.BadParameter("version must be in major.minor.build format. (1.0.0)")
4342

44-
@click.option('--license', default=None, type=click.Path(exists=True, dir_okay=False), help="Path to license file (rtf or txt with CRLF line endings).")
45-
@click.option('--icon', default=None, type=click.Path(exists=True, dir_okay=False), help="Path to image to use as icon.")
46-
47-
@click.option('--clean/--no-clean', 'do_clean', default=True, help="Clean before building (default: true).")
48-
@click.option('--clean-artifacts/--no-clean-artifacts', default=False, help="Clean artifacts (default: false).")
49-
50-
@click.option('--build-dir', default="build", type=click.Path(file_okay=False), help="Path to build (temporary) directory.")
51-
@click.option('--artifact-dir', default="artifacts", type=click.Path(file_okay=False), help="Path to installer output directory.")
52-
@click.option('--src-dir', default="src", type=click.Path(file_okay=False, exists=True), help="Path to application files to create installer from.")
53-
@click.option('--executable', '-e', multiple=True, default=["*.exe"], help="Path of executables to create startmenu shortcuts to. Relative to src-dir. Can be passed multiple times. (default: *.exe)")
54-
@click.option('--postinstall', '-p', multiple=True, default=None, help="Commands to run post-install (at the end of installer)")
55-
56-
@click.option('--help-url', help="Help URL to display in 'Add/Remove Programs'. mailto: is allowed.")
57-
@click.option('--update-url', help="Update URL to display in 'Add/Remove Programs'. mailto: is allowed.")
58-
@click.option('--website-url', help="Website(about) URL to display in 'Add/Remove Programs'. mailto: is allowed.")
5943

44+
@cli.command()
45+
@click.option(
46+
"--version",
47+
callback=validate_version,
48+
default="0.0.0",
49+
help="Version number of build (major.minor.build).",
50+
)
51+
@click.option("--name", required=True, help="Application name.")
52+
@click.option("--company", required=True, help="Company name.")
53+
@click.option("--description", help="Application description.")
54+
@click.option(
55+
"--license",
56+
default=None,
57+
type=click.Path(exists=True, dir_okay=False),
58+
help="Path to license file (rtf or txt with CRLF line endings).",
59+
)
60+
@click.option(
61+
"--icon",
62+
default=None,
63+
type=click.Path(exists=True, dir_okay=False),
64+
help="Path to image to use as icon.",
65+
)
66+
@click.option(
67+
"--clean/--no-clean",
68+
"do_clean",
69+
default=True,
70+
help="Clean before building (default: true).",
71+
)
72+
@click.option(
73+
"--clean-artifacts/--no-clean-artifacts",
74+
default=False,
75+
help="Clean artifacts (default: false).",
76+
)
77+
@click.option(
78+
"--build-dir",
79+
default="build",
80+
type=click.Path(file_okay=False),
81+
help="Path to build (temporary) directory.",
82+
)
83+
@click.option(
84+
"--artifact-dir",
85+
default="artifacts",
86+
type=click.Path(file_okay=False),
87+
help="Path to installer output directory.",
88+
)
89+
@click.option(
90+
"--src-dir",
91+
default="src",
92+
type=click.Path(file_okay=False, exists=True),
93+
help="Path to application files to create installer from.",
94+
)
95+
@click.option(
96+
"--executable",
97+
"-e",
98+
multiple=True,
99+
default=["*.exe"],
100+
help="Path of executables to create startmenu shortcuts to. Relative to src-dir. Can be passed multiple times. (default: *.exe)",
101+
)
102+
@click.option(
103+
"--postinstall",
104+
"-p",
105+
multiple=True,
106+
default=None,
107+
help="Commands to run post-install (at the end of installer)",
108+
)
109+
@click.option(
110+
"--help-url",
111+
help="Help URL to display in 'Add/Remove Programs'. mailto: is allowed.",
112+
)
113+
@click.option(
114+
"--update-url",
115+
help="Update URL to display in 'Add/Remove Programs'. mailto: is allowed.",
116+
)
117+
@click.option(
118+
"--website-url",
119+
help="Website(about) URL to display in 'Add/Remove Programs'. mailto: is allowed.",
120+
)
60121
@click.pass_context
61-
def build(ctx, do_clean, version, name, company, description, license, icon, build_dir, artifact_dir, src_dir, clean_artifacts, help_url, update_url, website_url, executable, postinstall):
122+
def build(
123+
ctx,
124+
do_clean,
125+
version,
126+
name,
127+
company,
128+
description,
129+
license,
130+
icon,
131+
build_dir,
132+
artifact_dir,
133+
src_dir,
134+
clean_artifacts,
135+
help_url,
136+
update_url,
137+
website_url,
138+
executable,
139+
postinstall,
140+
):
62141
click.echo("Building {} v{}...".format(name, version))
63142
if do_clean:
64143
ctx.forward(clean)
@@ -71,19 +150,25 @@ def build(ctx, do_clean, version, name, company, description, license, icon, bui
71150
icon = makeIco(icon=icon, name=name, build_dir=build_dir)
72151

73152
nsi_script = compileNSISTemplate(
74-
build_dir=build_dir, artifact_dir=artifact_dir,
153+
build_dir=build_dir,
154+
artifact_dir=artifact_dir,
75155
executables=executable,
76156
version=version,
77-
icon=icon, license=license,
157+
icon=icon,
158+
license=license,
78159
icon_path=os.path.join(build_dir, icon) if icon else None,
79-
name=name, company=company,
160+
name=name,
161+
company=company,
80162
description=description,
81-
help_url=help_url, update_url=update_url, website_url=website_url,
163+
help_url=help_url,
164+
update_url=update_url,
165+
website_url=website_url,
82166
postinstall=postinstall,
83167
)
84168

85169
NSISBuildInstaller(nsi_script=nsi_script, artifact_dir=artifact_dir)
86170

171+
87172
if __name__ == "__main__":
88173
# pylint:disable=unexpected-keyword-arg
89-
cli(auto_envvar_prefix='SYRUP')
174+
cli(auto_envvar_prefix="SYRUP")

0 commit comments

Comments
 (0)