FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
Engineering_Python/WinDirSize.py at master · OnScale/Engineering_Python · GitHub
Uh oh!
There was an error while loading.
Please reload this page
.
OnScale
/
Engineering_Python
Public
Notifications
You must be signed in to change notification settings
Fork
1
Star
0
Code
Issues
0
Pull requests
1
Actions
Projects
Security and quality
0
Insights
Additional navigation options
Code
Issues
Pull requests
Actions
Projects
Security and quality
Insights
Expand file tree
Breadcrumbs
Engineering_Python
/
WinDirSize.py
Copy path
More file actions
More file actions
Latest commit
History
History
History
50 lines (40 loc) · 1.26 KB
Breadcrumbs
Engineering_Python
/
WinDirSize.py
Copy path
File metadata and controls
50 lines (40 loc) · 1.26 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
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
# -*- coding: utf-8 -*-
"""
Created on Thu Jul 30 14:44:02 2015
@author: admingh
"""
import
locale
import
os
locale
.
setlocale
(
locale
.
LC_ALL
,
""
)
def
get_size
(
state
,
root
,
names
):
paths
=
[
os
.
path
.
realpath
(
os
.
path
.
join
(
root
,
n
))
for
n
in
names
]
# handles dangling symlinks
state
[
0
]
+=
sum
(
os
.
stat
(
p
).
st_size
for
p
in
paths
if
os
.
path
.
exists
(
p
))
def
print_sizes
(
root
):
total
=
0
paths
=
[]
state
=
[
0
]
n_ind
=
s_ind
=
0
for
name
in
sorted
(
os
.
listdir
(
root
)):
path
=
os
.
path
.
join
(
root
,
name
)
if
not
os
.
path
.
isdir
(
path
):
continue
state
[
0
]
=
0
os
.
path
.
walk
(
path
,
get_size
,
state
)
total
+=
state
[
0
]
s_size
=
locale
.
format
(
'%8.0f'
,
state
[
0
],
3
)
n_ind
=
max
(
n_ind
,
len
(
name
),
5
)
s_ind
=
max
(
s_ind
,
len
(
s_size
))
paths
.
append
((
name
,
s_size
))
for
name
,
size
in
paths
:
print
name
.
ljust
(
n_ind
),
size
.
rjust
(
s_ind
),
'bytes'
s_total
=
locale
.
format
(
'%8.0f'
,
total
,
3
)
print
'
\n
total'
.
ljust
(
n_ind
),
s_total
.
rjust
(
s_ind
),
'bytes'
print_sizes
(
'.'
)
#import win32com.client as com
#
#folderPath = r"E:\WORK\Python\PythonScripts"
#fso = com.Dispatch("Scripting.FileSystemObject")
#folder = fso.GetFolder(folderPath)
#MB=1024*1024.0
#print "%.2f MB"%(folder.Size/MB)
Back
|
FazBrowse Home
|
New Git URL