1 """Support functions for loading the reference count data file."""
2 __version__
= '$Revision$'
8 # Determine the expected location of the reference count file:
10 p
= os
.path
.dirname(__file__
)
12 p
= os
.path
.dirname(sys
.argv
[0])
13 p
= os
.path
.normpath(os
.path
.join(os
.getcwd(), p
, os
.pardir
,
14 "api", "refcounts.dat"))
19 def load(path
=DEFAULT_PATH
):
20 return loadfile(open(path
))
30 if line
[:1] in ("", "#"):
31 # blank lines and comments
33 parts
= line
.split(":", 4)
35 raise ValueError("Not enough fields in " + `line`
)
36 function
, type, arg
, refcount
, comment
= parts
37 if refcount
== "null":
40 refcount
= int(refcount
)
44 # Get the entry, creating it if needed:
49 entry
= d
[function
] = Entry(function
)
51 # Update the entry with the new parameter or the result information.
54 entry
.args
.append((arg
, type, refcount
))
56 entry
.result_type
= type
57 entry
.result_refs
= refcount
62 def __init__(self
, name
):
66 self
.result_refs
= None
70 """Dump the data in the 'canonical' format, with functions in
75 for k
, entry
in items
:
80 s
= entry
.name
+ ":%s:%s:%s:"
81 if entry
.result_refs
is None:
85 print s
% (entry
.result_type
, "", r
)
86 for t
, n
, r
in entry
.args
:
97 if __name__
== "__main__":