• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

zopefoundation / ZODB / 5706069709

pending completion
5706069709

push

github

web-flow
Drop support for Python < 3.7 (#386)

* Bumped version for breaking release.

* Drop support for Python 2.7, 3.5, 3.6.

---------

Co-authored-by: Jens Vagelpohl <jens@plyp.com>

2877 of 4050 branches covered (71.04%)

554 of 554 new or added lines in 89 files covered. (100.0%)

13324 of 15914 relevant lines covered (83.73%)

0.84 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

0.0
/src/ZODB/scripts/space.py
1
#!/usr/bin/env python
2
"""Report on the space used by objects in a storage.
×
3

4
usage: space.py data.fs
5

6
The current implementation only supports FileStorage.
7

8
Current limitations / simplifications: Ignores revisions and versions.
9
"""
10

11
from ZODB.FileStorage import FileStorage
×
12
from ZODB.utils import U64
×
13
from ZODB.utils import get_pickle_metadata
×
14
from ZODB.utils import load_current
×
15

16

17
def run(path, v=0):
×
18
    fs = FileStorage(path, read_only=1)
×
19
    # break into the file implementation
20
    if hasattr(fs._index, 'iterkeys'):
×
21
        iter = fs._index.keys()
×
22
    else:
23
        iter = fs._index.keys()
×
24
    totals = {}
×
25
    for oid in iter:
×
26
        data, serialno = load_current(fs, oid)
×
27
        mod, klass = get_pickle_metadata(data)
×
28
        key = "{}.{}".format(mod, klass)
×
29
        bytes, count = totals.get(key, (0, 0))
×
30
        bytes += len(data)
×
31
        count += 1
×
32
        totals[key] = bytes, count
×
33
        if v:
×
34
            print("%8s %5d %s" % (U64(oid), len(data), key))
×
35
    L = totals.items()
×
36
    L.sort(key=lambda x: x[1])
×
37
    L.reverse()
×
38
    print("Totals per object class:")
×
39
    for key, (bytes, count) in L:
×
40
        print("%8d %8d %s" % (count, bytes, key))
×
41

42

43
def main():
×
44
    import getopt
×
45
    import sys
×
46
    try:
×
47
        opts, args = getopt.getopt(sys.argv[1:], "v")
×
48
    except getopt.error as msg:
×
49
        print(msg)
×
50
        print("usage: space.py [-v] Data.fs")
×
51
        sys.exit(2)
×
52
    if len(args) != 1:
×
53
        print("usage: space.py [-v] Data.fs")
×
54
        sys.exit(2)
×
55
    v = 0
×
56
    for o, a in opts:
×
57
        if o == "-v":
×
58
            v += 1
×
59
    path = args[0]
×
60
    run(path, v)
×
61

62

63
if __name__ == "__main__":
×
64
    main()
×
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc