def klass(self, klass): self.__klass = Klass(klass) self.__klass(self)
klasses = [] filenames = [f for f in listdir('.') if filepat.match(f)] for filename in filenames: f = [file for file in open(filename)] classes = [classpat.match(line) for line in f if classpat.match(line)] operations = [operpat.match(line) for line in f if operpat.match(line)] attributes = [attrpat.match(line) for line in f if attrpat.match(line)] if len(classes) > 1: print 'This script only supports one class per file.' print 'File %s contains more than one class.' % filename print len(classes) name, parents = classes[0].groups() parents = parents.strip() temp = Klass(name) for parent in parents.split(', '): parent = parent.strip().split(' ')[-1] temp.add_parent(parent) for match in operations: g = match.groups() temp.add_operation(g[1], g[2], g[3]) for match in attributes: g = match.groups() temp.add_attribute(g[0], g[1]) klasses.append(temp) prepstring = 'digraph %s {\n\tfontsize = %s\n\trankdir = BT\n\t%s\n\n\t' % (graphname, fontsize, printfriendly) +\ 'node [\n\t\tfontsize = %s\n\t\tshape = "record"\n\t]\n\n\t' % fontsize +\ 'edge [\n\t\tpenwidth = %s\n\t\tarrowhead = "empty"\n\t]\n\n' % penwidth endstring = '}'