View difference between Paste ID: xeyKi2Sx and pjAcZs8Z
SHOW: | | - or go back to the newest paste.
1-
import os
1+
, 1.101754605770111e-06
2-
import sys
2+
, 45.49366717785597
3-
3+
, 4.032342763617635
4-
def get_size(start_path = '.'):
4+
, 39.93321943562478
5-
    total_size = 0
5+
, 66.6471876706928
6-
    for dirpath, dirnames, filenames in os.walk(start_path):
6+
, 44.42955748178065
7-
        for f in filenames:
7+
, 40.76602909527719
8-
            fp = os.path.join(dirpath, f)
8+
, 38.40679931640625
9-
            total_size += os.path.getsize(fp)
9+
, 58.431023945100605
10-
10+
, 25.851066824048758
11-
    if total_size == 0 and os.path.isfile(start_path):
11+
, 65.02871671877801
12-
        total_size += os.path.getsize(start_path)
12+
, 8.288770914077759e-07
13-
13+
, 38.75344319269061
14-
    return total_size
14+
, 31.029634174890816
15-
15+
, 11.384204977191985
16-
def listContents(start_path = '.'):
16+
, 14.73015004210174
17-
    print('running on dir "' + start_path + '"')
17+
, 27.18648810312152
18-
    dirName = os.path.basename(os.path.abspath(start_path))
18+
, 41.36587429046631
19-
19+
, 41.810975436121225
20-
    contents = os.listdir(start_path)
20+
, 112.79941918700933
21-
    f = open('output_' + dirName + '.csv', 'w')
21+
, 105.71097385883331
22-
    for c in contents:
22+
, 122.89101929310709
23-
        str(c.encode('utf8'))
23+
, 45.835923979990184
24-
        f.write(', ')
24+
, 110.86683203838766
25-
        f.write(str(get_size(start_path + '/' + c) / 1024 / 1024/ 1024) + '\n')
25+
, 23.143787663429976
26-
    f.close();
26+
, 25.649807995185256
27-
27+
, 27.678043282590806
28-
if len(sys.argv) > 1:
28+
, 35.1484468979761
29-
    listContents(sys.argv[1])
29+
, 57.656713291071355
30-
else:
30+
, 0.0
31-
    listContents();
31+
, 20.754381491802633
32
, 40.081044897437096
33
, 80.45163483545184
34
, 83.13857948407531
35
, 125.60846426710486
36
, 35.30133497528732
37
, 1951.9792949752882
38
, 50.00762770976871
39
, 35.35590593330562