Clean up init file in examples.

This commit is contained in:
Rowan Cockett
2016-01-23 16:37:11 -07:00
parent 91e37c5fa7
commit 84400650fa
+5 -4
View File
@@ -29,16 +29,17 @@ if __name__ == '__main__':
from SimPEG import Examples
# Create the examples dir in the docs folder.
docExamplesDir = os.path.sep.join(os.path.realpath(__file__).split(os.path.sep)[:-3] + ['docs', 'examples'])
fName = os.path.realpath(__file__)
docExamplesDir = os.path.sep.join(fName.split(os.path.sep)[:-3] + ['docs', 'examples'])
shutil.rmtree(docExamplesDir)
os.makedirs(docExamplesDir)
# Get all the python examples in this folder
thispath = os.path.sep.join(__file__.split(os.path.sep)[:-1])
thispath = os.path.sep.join(fName.split(os.path.sep)[:-1])
exfiles = [f[:-3] for f in os.listdir(thispath) if os.path.isfile(os.path.join(thispath, f)) and f.endswith('.py') and not f.startswith('_')]
# Add the imports to the top in the AUTOIMPORTS section
f = file(__file__, 'r')
f = file(fName, 'r')
inimports = False
out = ''
for line in f:
@@ -53,7 +54,7 @@ if __name__ == '__main__':
out += '\n##### AUTOIMPORTS #####\n'
f.close()
f = file(__file__, 'w')
f = file(fName, 'w')
f.write(out)
f.close()