-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfilesize.py
35 lines (30 loc) · 950 Bytes
/
filesize.py
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
import os
import re
def getFileSizes(dirname):
filepaths = []
for basename in os.listdir(dirname):
filename = os.path.join(dirname, basename)
if os.path.isfile(filename):
filepaths.append(filename)
# Re-populate list with filename, size tuples
for i in range(len(filepaths)):
filepaths[i] = (filepaths[i], os.path.getsize(filepaths[i]))
print (filepaths[i][0][2:] + "\t" + str(filepaths[i][1]))
def scrapeTimes(file, regex):
rslt = list()
name = ""
time = ""
i=0;
for line in open(file):
a=re.findall(regex,line)
if(a):
if(i%2):
time = a[0][i%2]
tup = (name,time)
rslt.append(tup)
else:
name = a[0][i%2]
i= i+1
return rslt
times = scrapeTimes("./ETDC/timesComp", r'\*\* File compressed: ([\w+.]+) \*\*|Time \(USER\)--> ([\d\.]+)')
print(times)