Skip to content

Commit e706163

Browse files
aylwardthewtex
authored andcommitted
STYLE: Reformatting CreateTarball.py to match lint
1 parent 37da5d6 commit e706163

File tree

1 file changed

+30
-26
lines changed

1 file changed

+30
-26
lines changed

Utilities/CreateTarball.py

Lines changed: 30 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -17,26 +17,26 @@
1717

1818

1919
if len(sys.argv) != 3:
20-
print('usage: ' + sys.argv[0] + ' <example_name> <SPHINX_DESTINATION>')
20+
print("usage: " + sys.argv[0] + " <example_name> <SPHINX_DESTINATION>")
2121
sys.exit(1)
2222

2323
# Collect our directories.
2424
cwd = os.getcwd()
2525
example_name = sys.argv[1]
2626
example_dir = os.path.join(cwd, example_name)
27-
example_idx = example_dir.index('SphinxExamples') + 15
28-
html_output_dir = os.path.join(sys.argv[2], 'html', example_dir[example_idx:])
27+
example_idx = example_dir.index("SphinxExamples") + 15
28+
html_output_dir = os.path.join(sys.argv[2], "html", example_dir[example_idx:])
2929

3030
if not os.path.exists( html_output_dir ):
3131
os.makedirs( html_output_dir )
3232

3333
# Copy files to support web editting to the html output.
3434
files_to_copy_to_html_output = []
35-
files_to_copy_to_html_output.append(os.path.join(example_dir, 'CMakeLists.txt'))
36-
files_to_copy_to_html_output.extend(glob.glob(os.path.join(example_dir, '*.cxx')))
37-
files_to_copy_to_html_output.extend(glob.glob(os.path.join(example_dir, '*.html')))
38-
files_to_copy_to_html_output.extend(glob.glob(os.path.join(example_dir, '*.py')))
39-
files_to_copy_to_html_output.extend(glob.glob(os.path.join(example_dir, '*.rst')))
35+
files_to_copy_to_html_output.append(os.path.join(example_dir, "CMakeLists.txt"))
36+
files_to_copy_to_html_output.extend(glob.glob(os.path.join(example_dir, "*.cxx")))
37+
files_to_copy_to_html_output.extend(glob.glob(os.path.join(example_dir, "*.html")))
38+
files_to_copy_to_html_output.extend(glob.glob(os.path.join(example_dir, "*.py")))
39+
files_to_copy_to_html_output.extend(glob.glob(os.path.join(example_dir, "*.rst")))
4040
for path in files_to_copy_to_html_output:
4141
shutil.copy2(path, html_output_dir)
4242

@@ -45,53 +45,57 @@
4545
files_for_tarball = files_to_copy_to_html_output
4646

4747
# Add a directory to build the project.
48-
build_dir = os.path.join(example_dir, 'build')
48+
build_dir = os.path.join(example_dir, "build")
4949
if not os.path.exists(build_dir):
5050
os.mkdir(build_dir)
5151
files_for_tarball.append(build_dir)
5252

5353
# Substitude CMAKE_CURRENT_BINARY_DIR for CMAKE_CURRENT_SOURCE_DIR in the
5454
# tarball CMakeLists.txt. This so the input images can be found.
55-
tarball_cmakelist = os.path.join(example_dir, 'CMakeLists.txt.tarball')
56-
with open(tarball_cmakelist, 'w') as new_list_file:
57-
with open(os.path.join(example_dir, 'CMakeLists.txt'), 'r') as old_list_file:
55+
tarball_cmakelist = os.path.join(example_dir, "CMakeLists.txt.tarball")
56+
with open(tarball_cmakelist, "w") as new_list_file:
57+
with open(os.path.join(example_dir, "CMakeLists.txt"), "r") as old_list_file:
5858
for line in old_list_file:
59-
newline = line.replace('CMAKE_CURRENT_BINARY_DIR', 'CMAKE_CURRENT_SOURCE_DIR')
59+
newline = line.replace(
60+
"CMAKE_CURRENT_BINARY_DIR", "CMAKE_CURRENT_SOURCE_DIR"
61+
)
6062
new_list_file.write(newline)
6163
files_for_tarball = files_for_tarball[1:]
6264
files_for_tarball.append(tarball_cmakelist)
6365

64-
inputs = glob.glob(os.path.join(example_dir, '*.sha512'))
66+
inputs = glob.glob(os.path.join(example_dir, "*.sha512"))
6567
for path in inputs:
6668
files_for_tarball.append(path[:-7])
6769

6870
# Remove duplicates.
6971
files_for_tarball = set(files_for_tarball)
7072

71-
with tarfile.open(os.path.join(html_output_dir, example_name + '.tar.gz'), \
72-
'w:gz', dereference=True) as tarfile:
73+
with tarfile.open(
74+
os.path.join(html_output_dir, example_name + ".tar.gz"), "w:gz", dereference=True
75+
) as tarfile:
7376
example_dir_idx = example_dir.index(example_name)
7477
def strip_path(tarinfo):
75-
tarinfo.name = tarinfo.name[example_dir_idx-1:]
78+
tarinfo.name = tarinfo.name[example_dir_idx - 1 :]
7679
# Put the inputs and outputs into the build directory because the test
7780
# will not be able to find them otherwise.
7881
basename = os.path.basename(tarinfo.name)
79-
if basename == 'CMakeLists.txt.tarball':
80-
head, tail = os.path.split(tarinfo.name)
81-
tarinfo.name = os.path.join(head, 'CMakeLists.txt')
82+
if basename == "CMakeLists.txt.tarball":
83+
head, tail = os.path.split(tarinfo.name)
84+
tarinfo.name = os.path.join(head, "CMakeLists.txt")
8285
return tarinfo
8386
for path in files_for_tarball:
8487
tarfile.add(path, filter=strip_path)
8588

86-
with zipfile.ZipFile(os.path.join(html_output_dir, example_name + '.zip'), \
87-
'w') as zipfile:
89+
with zipfile.ZipFile(
90+
os.path.join(html_output_dir, example_name + ".zip"), "w"
91+
) as zipfile:
8892
example_dir_idx = example_dir.index(example_name)
8993
for path in files_for_tarball:
90-
arcname = path[example_dir_idx-1:]
94+
arcname = path[example_dir_idx - 1 :]
9195
# Put the inputs and outputs into the build directory because the test
9296
# will not be able to find them otherwise.
9397
basename = os.path.basename(arcname)
94-
if basename == 'CMakeLists.txt.tarball':
95-
head, tail = os.path.split(arcname)
96-
arcname = os.path.join(head, 'CMakeLists.txt')
98+
if basename == "CMakeLists.txt.tarball":
99+
head, tail = os.path.split(arcname)
100+
arcname = os.path.join(head, "CMakeLists.txt")
97101
zipfile.write(path, arcname)

0 commit comments

Comments
 (0)