Skip to content

Commit fd0ddc0

Browse files
committed
Fix file formatting
1 parent 3489e16 commit fd0ddc0

File tree

1 file changed

+12
-11
lines changed

1 file changed

+12
-11
lines changed

binary-search/download_imdb.py

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -16,34 +16,35 @@
1616
def main():
1717
"""Script entry point."""
1818

19-
print('Fetching data from IMDb...')
19+
print("Fetching data from IMDb...")
2020

21-
with open('names.txt', 'w') as destination:
21+
with open("names.txt", "w") as destination:
2222
destination.writelines(names())
2323

24-
with open('names.txt') as source, \
25-
open('sorted_names.txt', 'w') as destination:
24+
with open("names.txt") as source, open(
25+
"sorted_names.txt", "w"
26+
) as destination:
2627
destination.writelines(sorted(source.readlines()))
2728

2829
print('Created "names.txt" and "sorted_names.txt"')
2930

3031

3132
def names():
3233
"""Return a generator of names with a trailing newline."""
33-
url = 'https://datasets.imdbws.com/name.basics.tsv.gz'
34+
url = "https://datasets.imdbws.com/name.basics.tsv.gz"
3435
with urllib.request.urlopen(url) as response:
35-
with tempfile.NamedTemporaryFile(mode='w+b') as archive:
36+
with tempfile.NamedTemporaryFile(mode="w+b") as archive:
3637
shutil.copyfileobj(response, archive)
3738
archive.seek(0)
38-
with gzip.open(archive, mode='rt') as source:
39+
with gzip.open(archive, mode="rt") as source:
3940
next(source) # Skip the header
4041
for line in source:
41-
full_name = line.split('\t')[1]
42-
yield f'{full_name}\n'
42+
full_name = line.split("\t")[1]
43+
yield f"{full_name}\n"
4344

4445

45-
if __name__ == '__main__':
46+
if __name__ == "__main__":
4647
try:
4748
main()
4849
except KeyboardInterrupt:
49-
print('Aborted')
50+
print("Aborted")

0 commit comments

Comments
 (0)