1 """Support functions for loading the reference count data file."""
2 __version__
= '$Revision$'
9 # Determine the expected location of the reference count file:
11 p
= os
.path
.dirname(__file__
)
14 p
= os
.path
.normpath(os
.path
.join(os
.getcwd(), p
, os
.pardir
,
15 "api", "refcounts.dat"))
20 def load(path
=DEFAULT_PATH
):
21 return loadfile(open(path
))
30 line
= string
.strip(line
)
31 if line
[:1] in ("", "#"):
32 # blank lines and comments
34 parts
= string
.split(line
, ":", 4)
35 function
, type, arg
, refcount
, comment
= parts
36 if refcount
== "null":
39 refcount
= int(refcount
)
43 # Get the entry, creating it if needed:
48 entry
= d
[function
] = Entry(function
)
50 # Update the entry with the new parameter or the result information.
53 entry
.args
.append((arg
, type, refcount
))
55 entry
.result_type
= type
56 entry
.result_refs
= refcount
61 def __init__(self
, name
):
65 self
.result_refs
= None
69 """Dump the data in the 'canonical' format, with functions in
74 for k
, entry
in items
:
79 s
= entry
.name
+ ":%s:%s:%s:"
80 if entry
.result_refs
is None:
84 print s
% (entry
.result_type
, "", r
)
85 for t
, n
, r
in entry
.args
:
96 if __name__
== "__main__":