Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Z
ZODB
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
nexedi
ZODB
Commits
c09bd60b
Commit
c09bd60b
authored
May 03, 2002
by
Guido van Rossum
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add summary printing, proper command line option parsing, and a -v
option.
parent
9203aa1c
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
33 additions
and
7 deletions
+33
-7
src/scripts/space.py
src/scripts/space.py
+33
-7
No files found.
src/scripts/space.py
View file @
c09bd60b
...
...
@@ -14,23 +14,49 @@ from ZODB.FileStorage import FileStorage
from
ZODB.utils
import
U64
from
ZODB.fsdump
import
get_pickle_metadata
def
main
(
path
):
def
run
(
path
,
v
=
0
):
fs
=
FileStorage
(
path
,
read_only
=
1
)
# break into the file implementation
if
hasattr
(
fs
.
_index
,
'iterkeys'
):
iter
=
fs
.
_index
.
iterkeys
()
else
:
iter
=
fs
.
_index
.
keys
()
totals
=
{}
for
oid
in
iter
:
data
,
serialno
=
fs
.
load
(
oid
,
''
)
mod
,
klass
=
get_pickle_metadata
(
data
)
print
"%8s %5d %s.%s"
%
(
U64
(
oid
),
len
(
data
),
mod
,
klass
)
key
=
"%s.%s"
%
(
mod
,
klass
)
bytes
,
count
=
totals
.
get
(
key
,
(
0
,
0
))
bytes
+=
len
(
data
)
count
+=
1
totals
[
key
]
=
bytes
,
count
if
v
:
print
"%8s %5d %s"
%
(
U64
(
oid
),
len
(
data
),
key
)
L
=
totals
.
items
()
L
.
sort
(
lambda
a
,
b
:
cmp
(
b
,
a
))
L
.
reverse
()
print
"Totals per object class:"
for
key
,
(
bytes
,
count
)
in
L
:
print
"%8d %8d %s"
%
(
count
,
bytes
,
key
)
if
__name__
==
"__main__"
:
def
main
()
:
import
sys
import
getopt
try
:
path
,
=
sys
.
argv
[
1
:]
except
ValueError
:
print
__doc__
opts
,
args
=
getopt
.
getopt
(
sys
.
argv
[
1
:],
"v"
)
except
getopt
.
error
,
msg
:
print
msg
print
"usage: space.py [-v] Data.fs"
sys
.
exit
(
2
)
if
len
(
args
)
!=
1
:
print
"usage: space.py [-v] Data.fs"
sys
.
exit
(
2
)
main
(
path
)
v
=
0
for
o
,
a
in
opts
:
if
o
==
"-v"
:
v
+=
1
path
=
args
[
0
]
run
(
path
,
v
)
if
__name__
==
"__main__"
:
main
()
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment