forked from npad/sidestream
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmkSample.py
More file actions
executable file
·48 lines (40 loc) · 1.23 KB
/
Copy pathmkSample.py
File metadata and controls
executable file
·48 lines (40 loc) · 1.23 KB
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
#! /usr/bin/python
"""
Make up a bunch of files with assorted content of varying sizes, named per their size.
"""
import os
def sizename(name):
"""
Rename a file to indicate it's size, preserving the path and extention
"""
try:
dir=name[0:name.rindex("/")]+"/"
except ValueError:
dir=""
ext=name[name.rfind("."):]
newname=dir+str(os.path.getsize(name))+ext
os.rename(name, newname) # errors fall through
print "Created", newname
text = """
%06d
This paragraph is rather unremarkable, except that it is exactly
512 bytes long, including carriage returns and line feeds.
ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz 0123456789
ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz 0123456789
ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz 0123456789
ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz 0123456789
ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz 0123456789
ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz
"""
def writetext(count):
f=file("temp.txt", "w")
for i in range(count):
f.write(text%i)
f.close()
sizename("temp.txt")
# main
# files of size 2^n from 512B to 1 MB
sz = 1
for n in range(12):
writetext(sz)
sz=sz<<1