Skip to content
This repository was archived by the owner on Nov 21, 2018. It is now read-only.

Commit a816dfa

Browse files
committed
Merge pull request #4 from frewsxcv/cleanup
Minor cleanup/refactoring
2 parents bfd4ef5 + 26f254b commit a816dfa

File tree

2 files changed

+26
-29
lines changed

2 files changed

+26
-29
lines changed

fetch-inputs.py

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,10 @@
1616
print "channel: " + str(channel)
1717
print
1818

19-
if channel == None:
19+
if channel is None:
2020
print "specify --channel"
2121
sys.exit(1)
22-
if target == None:
22+
if target is None:
2323
print "specify --target"
2424
sys.exit(1)
2525

@@ -56,7 +56,7 @@
5656
rust_artifacts = []
5757
for line in open(os.path.join(TEMP_DIR, rust_manifest_name)):
5858
if target in line and ".tar.gz" in line:
59-
rust_artifacts += [line.rstrip()]
59+
rust_artifacts.append(line.rstrip())
6060
assert len(rust_artifacts) > 0
6161
print "rust artifacts: " + str(rust_artifacts)
6262

@@ -68,7 +68,7 @@
6868
for line in open(os.path.join(TEMP_DIR, rust_manifest_name)):
6969
if "-src" in line:
7070
rust_source = line.rstrip()
71-
assert rust_source != None
71+
assert rust_source is not None
7272
print "rust source: " + rust_source
7373

7474
# Download the source
@@ -99,7 +99,7 @@
9999
assert len(version) > 0
100100
break
101101

102-
assert version != None
102+
assert version is not None
103103

104104
# Search the cargo snap database for this version
105105
for line in open("cargo-revs.txt"):
@@ -108,15 +108,14 @@
108108
assert len(cargo_archive_date) > 0
109109
break
110110

111-
assert cargo_archive_date != None
111+
assert cargo_archive_date is not None
112112

113113
print "cargo date: " + str(cargo_archive_date)
114114

115115
# Download cargo manifest
116-
if cargo_archive_date == None:
117-
remote_cargo_dir = SERVER_ADDRESS + "/" + CARGO_DIST_FOLDER
118-
else:
119-
remote_cargo_dir = SERVER_ADDRESS + "/" + CARGO_DIST_FOLDER + "/" + cargo_archive_date
116+
remote_cargo_dir = SERVER_ADDRESS + "/" + CARGO_DIST_FOLDER
117+
if cargo_archive_date is not None:
118+
remote_cargo_dir += "/" + cargo_archive_date
120119

121120
cargo_manifest_name = "channel-cargo-nightly"
122121
remote_cargo_manifest = remote_cargo_dir + "/" + cargo_manifest_name
@@ -134,7 +133,7 @@
134133
cargo_artifacts = []
135134
for line in open(os.path.join(TEMP_DIR, cargo_manifest_name)):
136135
if target in line:
137-
cargo_artifacts += [line.rstrip()]
136+
cargo_artifacts.append(line.rstrip())
138137
assert len(cargo_artifacts) > 0
139138
print "cargo artifacts: " + str(cargo_artifacts)
140139

package-rust.py

Lines changed: 16 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
print "msi: " + str(make_msi)
2727
print
2828

29-
if target == None:
29+
if target is None:
3030
print "specify --target"
3131
sys.exit(1)
3232

@@ -53,7 +53,7 @@ def run(args):
5353
# The names of the packages that need to be combined via rust-installer
5454
components = [RUSTC_PACKAGE_NAME, "cargo", "rust-docs"]
5555
if "pc-windows-gnu" in target:
56-
components += ["rust-mingw"]
56+
components.append("rust-mingw")
5757

5858
# Now find the names of the tarballs that belong to those components
5959
inputs = []
@@ -77,7 +77,7 @@ def run(args):
7777
if not component_installer:
7878
print "unable to find installer for component " + component + ", target " + target
7979
sys.exit(1)
80-
inputs += [INPUT_DIR + "/" + component_installer]
80+
inputs.append(INPUT_DIR + "/" + component_installer)
8181

8282
# Extract the version from the filename
8383
if component == RUSTC_PACKAGE_NAME:
@@ -93,9 +93,9 @@ def run(args):
9393
mingw_installer = component_installer
9494

9595

96-
assert version != None
97-
assert rustc_installer != None
98-
assert source_tarball != None
96+
assert version is not None
97+
assert rustc_installer is not None
98+
assert source_tarball is not None
9999

100100
# Set up the overlay of license info
101101
run(["tar", "xzf", INPUT_DIR + "/" + rustc_installer, "-C", TEMP_DIR, ])
@@ -123,15 +123,13 @@ def run(args):
123123
"--legacy-manifest-dirs=rustlib,cargo",
124124
"--input-tarballs=" + tarball_list,
125125
"--non-installed-overlay=" + overlay_dir
126-
])
126+
])
127127

128128
# Everything below here is used for producing non-rust-installer packaging
129129

130130
# Create the LICENSE.txt file used in some GUI installers
131131
license_file = TEMP_DIR + "/LICENSE.txt"
132-
cmd = "cat " + \
133-
rustc_dir + "/COPYRIGHT " + rustc_dir + "/LICENSE-APACHE " + rustc_dir + "/LICENSE-MIT " + \
134-
"> " + license_file
132+
cmd = "cat {0}/COPYRIGHT {0}/LICENSE-APACHE {0}/LICENSE-MIT > {1}".format(rustc_dir, license_file)
135133
run(["sh", "-c", cmd])
136134

137135
# Fish out the following Makefile variables from the source code or rebuild them somehow.
@@ -147,19 +145,19 @@ def run(args):
147145
source_dir = os.path.join(TEMP_DIR, source_tarball.replace("-src.tar.gz", ""))
148146

149147
for line in open(source_dir + "/mk/main.mk"):
150-
if "CFG_RELEASE_NUM" in line and CFG_RELEASE_NUM == None:
148+
if "CFG_RELEASE_NUM" in line and CFG_RELEASE_NUM is None:
151149
CFG_RELEASE_NUM = line.split("=")[1].strip()
152150
assert len(CFG_RELEASE_NUM) > 0
153-
if "CFG_BETA_CYCLE" in line and CFG_BETA_CYCLE == None:
151+
if "CFG_BETA_CYCLE" in line and CFG_BETA_CYCLE is None:
154152
CFG_BETA_CYCLE = line.split("=")[1].strip()
155153
# NB: This can be an empty string
156154

157-
assert CFG_RELEASE_NUM != None
155+
assert CFG_RELEASE_NUM is not None
158156

159157
# FIXME Temporary hack
160-
if CFG_BETA_CYCLE == None:
158+
if CFG_BETA_CYCLE is None:
161159
CFG_BETA_CYCLE = ""
162-
assert CFG_BETA_CYCLE != None
160+
assert CFG_BETA_CYCLE is not None
163161

164162
# Guess the channel from the source tarball
165163
channel = None
@@ -216,9 +214,9 @@ def run(args):
216214

217215
if make_exe:
218216
print "creating .exe"
219-
assert docs_installer != None
220-
assert mingw_installer != None
221-
assert cargo_installer != None
217+
assert docs_installer is not None
218+
assert mingw_installer is not None
219+
assert cargo_installer is not None
222220
exe_temp_dir = TEMP_DIR + "/exe"
223221
os.mkdir(exe_temp_dir)
224222
run(["tar", "xzf", INPUT_DIR + "/" + rustc_installer, "-C", exe_temp_dir])

0 commit comments

Comments
 (0)