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 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53
|
#!/usr/bin/python
import sys
import os
if len(sys.argv) != 4:
print 'Usage: %s directory with depth' % sys.argv[0]
sys.exit(1)
root, width, depth = sys.argv[1:]
width = int(width)
depth = int(depth)
assert not os.path.exists(root), 'Need new directory'
name = 'some_page_%i_%i'
content = '''\
Content-Type: text/x-zim-wiki
Wiki-Format: zim 0.26
====== Some Page ======
//Some test data//
Foooo Bar!
TODO: insert random links here
'''
content += ('la la laaa'*20 + '\n') * 10
def populate_level(path, j):
path += os.path.sep
os.mkdir(path)
d = 1
for i in range(width):
myname = name % (j, i)
file = path + myname + '.txt'
print '>', file
fh = open(file, 'w')
fh.write(content)
fh.close()
if j < depth:
d += populate_level(path + myname, j+1)
return d
d = populate_level(root, 0)
f = d * width
print 'Total %i files %i directories' % (f, d)
print 'Done'
|