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)
36 raise ValueError("Not enough fields in " + `line`
)
37 function
, type, arg
, refcount
, comment
= parts
38 if refcount
== "null":
41 refcount
= int(refcount
)
45 # Get the entry, creating it if needed:
50 entry
= d
[function
] = Entry(function
)
52 # Update the entry with the new parameter or the result information.
55 entry
.args
.append((arg
, type, refcount
))
57 entry
.result_type
= type
58 entry
.result_refs
= refcount
63 def __init__(self
, name
):
67 self
.result_refs
= None
71 """Dump the data in the 'canonical' format, with functions in
76 for k
, entry
in items
:
81 s
= entry
.name
+ ":%s:%s:%s:"
82 if entry
.result_refs
is None:
86 print s
% (entry
.result_type
, "", r
)
87 for t
, n
, r
in entry
.args
:
98 if __name__
== "__main__":