Skip to content

Commit 61a3f8c

Browse files
committed
Ensure only resources that exist get copied
1 parent cf37510 commit 61a3f8c

File tree

1 file changed

+16
-8
lines changed

1 file changed

+16
-8
lines changed

EulerPy/problem.py

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -58,16 +58,24 @@ def copy_resources(self):
5858

5959
resourcesDir = os.path.join(os.getcwd(), 'resources', '')
6060

61+
copiedResources = []
62+
6163
for resource in self.resources:
6264
src = os.path.join(dataDir, 'resources', resource)
63-
shutil.copy(src, resourcesDir)
64-
65-
msg = "Copied {0} to {1}.".format(', '.join(
66-
'"%s"' % resource for resource in self.resources),
67-
os.path.relpath(resourcesDir, os.pardir)
68-
)
69-
70-
click.secho(msg, fg='green')
65+
try:
66+
shutil.copy(src, resourcesDir)
67+
except IOError:
68+
pass
69+
else:
70+
copiedResources.append(resource)
71+
72+
if copiedResources:
73+
msg = "Copied {0} to {1}.".format(
74+
', '.join(copiedResources),
75+
os.path.relpath(resourcesDir, os.pardir)
76+
)
77+
78+
click.secho(msg, fg='green')
7179

7280

7381
@property

0 commit comments

Comments
 (0)