# HG changeset patch # User Paul Boddie # Date 1105306485 -3600 # Node ID 055b402634bca134f5eb9c9c50c72c674cd6814c # Parent 89cf6f5868da20bd8e2aa201e068e95becbccdf1 Added a method to provide the "unqualified Python name" of methods. This is useful when generating wrappers of existing Python classes where the additional type information usually included in "Python names" is not present in the wrapped method names. diff -r 89cf6f5868da -r 055b402634bc classfile.py --- a/classfile.py Sun Jan 09 01:36:06 2005 +0100 +++ b/classfile.py Sun Jan 09 22:34:45 2005 +0100 @@ -63,14 +63,19 @@ array_sep = "_array_" # was "[]" base_seps = ("_", "_") # was "<" and ">" - def get_python_name(self): + def get_unqualified_python_name(self): name = self.get_name() if str(name) == "": - name = "__init__" + return "__init__" elif str(name) == "": return "__clinit__" else: - name = str(name) + return str(name) + + def get_python_name(self): + name = self.get_unqualified_python_name() + if name == "__clinit__": + return name return name + self.symbol_sep + self._get_descriptor_as_name() def _get_descriptor_as_name(self): @@ -621,7 +626,8 @@ if __name__ == "__main__": import sys - f = open(sys.argv[1]) + f = open(sys.argv[1], "rb") c = ClassFile(f.read()) + f.close() # vim: tabstop=4 expandtab shiftwidth=4