|
| 1 | +#!/usr/bin/env python |
1 | 2 |
|
2 | | -# |
3 | | -# Cleans up by deleting object files, executable, and _output directory. |
4 | | -# Use after run_examples to clean up stuff not needed on webpages. |
| 3 | +r""" |
| 4 | +Cleans up by deleting object files, executable, and _output directory. |
| 5 | +""" |
5 | 6 |
|
6 | 7 | import os,sys,glob |
7 | 8 | import shutil |
8 | 9 |
|
9 | | -examples_dir = os.path.abspath('./examples') |
10 | | -print "Will remove all _output, _plots, and build directories from ",examples_dir |
11 | | -ans = raw_input("Ok? ") |
12 | | -if ans.lower() not in ['y','yes']: |
13 | | - print "Aborting." |
14 | | - sys.exit() |
| 10 | +if __name__ == "__main__": |
15 | 11 |
|
16 | | -os.chdir(examples_dir) |
17 | | -exdirlist = [] |
18 | | -for (dirpath, subdirs, files) in os.walk('.'): |
19 | | - currentdir = os.path.abspath(os.getcwd()) |
20 | | - os.chdir(os.path.abspath(dirpath)) |
21 | | - |
22 | | - print 'In directory ',dirpath |
23 | | - |
24 | | - if os.path.isdir('_output'): |
25 | | - shutil.rmtree('./_output') |
26 | | - if os.path.isdir('_plots'): |
27 | | - shutil.rmtree('./_plots') |
28 | | - if os.path.isdir('build'): |
29 | | - shutil.rmtree('./build') |
| 12 | + examples_dir = os.path.abspath('./examples') |
| 13 | + print "Will remove all _output, _plots, and build directories from ",examples_dir |
| 14 | + ans = raw_input("Ok? ") |
| 15 | + if ans.lower() not in ['y','yes']: |
| 16 | + print "Aborting." |
| 17 | + sys.exit() |
| 18 | + |
| 19 | + os.chdir(examples_dir) |
| 20 | + exdirlist = [] |
| 21 | + for (dirpath, subdirs, files) in os.walk('.'): |
| 22 | + currentdir = os.path.abspath(os.getcwd()) |
| 23 | + os.chdir(os.path.abspath(dirpath)) |
| 24 | + |
| 25 | + print 'In directory ',dirpath |
30 | 26 |
|
31 | | - os.chdir(currentdir) |
| 27 | + if os.path.isdir('_output'): |
| 28 | + shutil.rmtree('./_output') |
| 29 | + if os.path.isdir('_plots'): |
| 30 | + shutil.rmtree('./_plots') |
| 31 | + if os.path.isdir('build'): |
| 32 | + shutil.rmtree('./build') |
| 33 | + |
| 34 | + os.chdir(currentdir) |
32 | 35 |
|
0 commit comments