Skip to content

Commit 15d74fb

Browse files
committed
Ignore IOErrors when checking for already installed files
1 parent 6467120 commit 15d74fb

File tree

1 file changed

+19
-10
lines changed

1 file changed

+19
-10
lines changed

core/helpers.py

Lines changed: 19 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -42,21 +42,30 @@ def get_text_files(directory):
4242
def detect_installed_file(current_file, test_files):
4343
"""Returns the file in <test_files> which is contained in
4444
<current_file>, or "Unknown"."""
45-
current = open(current_file).read()
46-
for f in test_files:
47-
tested = open(f).read()
48-
if tested in current:
49-
return f
45+
try:
46+
current = open(current_file).read()
47+
for f in test_files:
48+
tested = open(f).read()
49+
if tested in current:
50+
return f
51+
except IOError:
52+
pass
5053
return "Unknown"
5154

5255
def detect_installed_files(current_file, test_files):
5356
"""Returns a list of files in <test_files> that are contained in
5457
<current_file>."""
55-
current = open(current_file).read()
5658
installed = []
57-
for f in test_files:
58-
tested = open(f).read()
59-
if tested in current:
60-
installed.append(f)
59+
try:
60+
current = open(current_file).read()
61+
for f in test_files:
62+
try:
63+
tested = open(f).read()
64+
if tested in current:
65+
installed.append(f)
66+
except IOError:
67+
pass
68+
except IOError:
69+
pass
6170
return installed
6271

0 commit comments

Comments
 (0)