-
Notifications
You must be signed in to change notification settings - Fork 7
Expand file tree
/
Copy pathclean.py
More file actions
executable file
·25 lines (21 loc) · 780 Bytes
/
clean.py
File metadata and controls
executable file
·25 lines (21 loc) · 780 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
#!/usr/bin/env python
import os
def delete_if_exists(path):
if os.path.exists(path):
os.system("rm -r " + path)
folders = [x for x in os.listdir("case/") if os.path.isdir("case/" + x)]
for f in folders:
if "processor" in f: # in the case of parallel runs.
delete_if_exists("case/" + f)
continue
dotsep = f.split(".")
isfloat = len(dotsep) > 1 and all([x.isdigit() for x in dotsep])
esep = f.split("e-")
issci = len(esep) > 1 and all([x.isdigit() for x in esep])
isnum = f.isdigit() or isfloat or issci
if isnum and float(f) != 0:
delete_if_exists("case/" + f)
delete_if_exists("mesh/main.msh")
delete_if_exists("case/constant/polyMesh")
delete_if_exists("case/postProcessing")
delete_if_exists("case/view.foam")