summaryrefslogtreecommitdiffstats
path: root/mark.py
diff options
context:
space:
mode:
authorjwansek <eddie.atten.ea29@gmail.com>2022-01-22 20:42:03 +0000
committerjwansek <eddie.atten.ea29@gmail.com>2022-01-22 20:42:03 +0000
commit3313a936debe04c733b3003858724de17cfcd7de (patch)
treedd354a53d9d982571bd4d959319b5cea717a57a2 /mark.py
parent4e218b3c10fe61f5bc9a83183bd584927e37b1ec (diff)
downloadSmarker-3313a936debe04c733b3003858724de17cfcd7de.tar.gz
Smarker-3313a936debe04c733b3003858724de17cfcd7de.zip
added automatically removing generated files
Diffstat (limited to 'mark.py')
-rw-r--r--mark.py17
1 files changed, 12 insertions, 5 deletions
diff --git a/mark.py b/mark.py
index 2630be1..835ac03 100644
--- a/mark.py
+++ b/mark.py
@@ -27,15 +27,22 @@ class FileDependencies:
pass
def __exit__(self, type, value, traceback):
+ stuff_to_remove = []
try:
- for file_dep in self.assessment_struct["dependencies"]["files"]:
- if os.path.isfile(os.path.split(file_dep)[-1]):
- os.remove(os.path.split(file_dep)[-1])
- else:
- shutil.rmtree(os.path.split(file_dep)[-1])
+ stuff_to_remove += [os.path.split(f)[-1] for f in self.assessment_struct["dependencies"]["files"]]
+ except KeyError:
+ pass
+ try:
+ stuff_to_remove += self.assessment_struct["produced_files"]
except KeyError:
pass
+ for file_dep in stuff_to_remove:
+ if os.path.isfile(file_dep):
+ os.remove(file_dep)
+ else:
+ shutil.rmtree(file_dep)
+
def main(**kwargs):
student_no = os.path.splitext(os.path.split(args["submission"])[-1])[0]