6,566
edits
(→Script: Yet another script update.) |
(→Script: Another version.) |
||
Line 58: | Line 58: | ||
# Add some problematic non-parsable classes. | # Add some problematic non-parsable classes. | ||
self.subsystems[1].append(Subsystem("FGAISim", base_class=Subsystem("FGInterface", base_class=Subsystem("SGSubsystem")), declaration_file="src/FDM/SP/AISim.hpp", xml=self.xml)) | self.subsystems[1].append(Subsystem("FGAISim", base_class=Subsystem("FGInterface", base_class=Subsystem("SGSubsystem")), declaration_file="src/FDM/SP/AISim.hpp", xml=self.xml)) | ||
# Find all SGSubsystem and SGSubsystemGroup derived classes. | # Find all SGSubsystem and SGSubsystemGroup derived classes. | ||
paths = [SIMGEAR_PATH, FLIGHTGEAR_PATH] | paths = [SIMGEAR_PATH, FLIGHTGEAR_PATH] | ||
for path in paths: | |||
for | self.find_primary(path=path, text="classes", primary=self.subsystems[0], base_name="SGSubsystem", base=subsystem_base, skip=["SGSubsystemGroup"]) | ||
self.find_primary(path= | self.find_primary(path=path, text="groups", primary=self.groups[0], base_name="SGSubsystemGroup", base=group_base) | ||
self.find_primary(path= | |||
self.find_secondary(path= | self.find_secondary(path=path, text="classes", primary=self.subsystems[0], secondary=self.subsystems[1]) | ||
self.find_secondary(path= | self.find_secondary(path=path, text="groups", primary=self.groups[0], secondary=self.groups[1]) | ||
self.find_tertiary(path= | self.find_tertiary(path=path, text="classes", secondary=self.subsystems[1], tertiary=self.subsystems[2]) | ||
self.find_tertiary(path= | self.find_tertiary(path=path, text="groups", secondary=self.groups[1], tertiary=self.groups[2]) | ||
self.find_quaternary(path= | self.find_quaternary(path=path, text="classes", tertiary=self.subsystems[2], quaternary=self.subsystems[3]) | ||
self.find_quaternary(path= | self.find_quaternary(path=path, text="groups", tertiary=self.groups[2], quaternary=self.groups[3]) | ||
# Find the subsystem and subsystem group implementation files. | # Find the subsystem and subsystem group implementation files. | ||
Line 84: | Line 79: | ||
# Final summary. | # Final summary. | ||
self.summarise() | self.summarise() | ||
Line 145: | Line 136: | ||
# Search. | # Search. | ||
for cmd in cmds: | for cmd in cmds: | ||
pipe = Popen(cmd, shell=True, stdout=PIPE) | pipe = Popen(cmd, shell=True, stdout=PIPE) | ||
lines = pipe.stdout.readlines() | lines = pipe.stdout.readlines() | ||
Line 162: | Line 152: | ||
# Search. | # Search. | ||
for cmd in cmds: | for cmd in cmds: | ||
pipe = Popen(cmd, shell=True, stdout=PIPE) | pipe = Popen(cmd, shell=True, stdout=PIPE) | ||
Line 187: | Line 176: | ||
def find_primary(self, path=None, text=None, primary=None, base_name=None, base=None, skip=[] | def find_primary(self, path=None, text=None, primary=None, base_name=None, base=None, skip=[]): | ||
"""Find all primary subsystems and groups | """Find all primary subsystems and groups | ||
Line 202: | Line 191: | ||
@keyword skip: A list of class names to skip. | @keyword skip: A list of class names to skip. | ||
@type skip: list of str | @type skip: list of str | ||
""" | """ | ||
# Printout. | # Printout. | ||
sys.stderr.write("Finding all primary %s in: %s\n" % (text, path)) | |||
# Find all subsystems or groups. | # Find all subsystems or groups. | ||
for file_name, class_name in self.grep(path=path, base_name=base_name): | for file_name, class_name in self.grep(path=path, base_name=base_name): | ||
Line 215: | Line 204: | ||
# Sort the subsystems by name. | # Sort the subsystems by name. | ||
primary.sort(key=operator.attrgetter('name')) | primary.sort(key=operator.attrgetter('name')) | ||
def find_secondary(self, path=None, text=None, primary=None, secondary=None | def find_secondary(self, path=None, text=None, primary=None, secondary=None): | ||
"""Find all secondary subsystems and groups | """Find all secondary subsystems and groups | ||
Line 240: | Line 217: | ||
@keyword secondary: The secondary list of subsystems or groups. | @keyword secondary: The secondary list of subsystems or groups. | ||
@type secondary: list of Subsystem instances | @type secondary: list of Subsystem instances | ||
""" | """ | ||
# Printout. | |||
sys.stderr.write("Finding all secondary %s in: %s\n" % (text, path)) | |||
# Loop over all primary subsystems. | # Loop over all primary subsystems. | ||
Line 252: | Line 230: | ||
secondary.sort(key=operator.attrgetter('name')) | secondary.sort(key=operator.attrgetter('name')) | ||
def find_tertiary(self, path=None, text=None, secondary=None, tertiary=None): | |||
def find_tertiary(self, path=None, text=None, secondary=None, tertiary=None | |||
"""Find all tertiary subsystems and groups | """Find all tertiary subsystems and groups | ||
Line 276: | Line 242: | ||
@keyword tertiary: The tertiary list of subsystems or groups. | @keyword tertiary: The tertiary list of subsystems or groups. | ||
@type tertiary: list of Subsystem instances | @type tertiary: list of Subsystem instances | ||
""" | """ | ||
# Printout. | |||
sys.stderr.write("Finding all tertiary %s in: %s\n" % (text, path)) | |||
# Loop over all secondary subsystems. | # Loop over all secondary subsystems. | ||
Line 287: | Line 254: | ||
# Sort all subsystems by name. | # Sort all subsystems by name. | ||
tertiary.sort(key=operator.attrgetter('name')) | tertiary.sort(key=operator.attrgetter('name')) | ||
def find_quaternary(self, path=None, text=None, tertiary=None, quaternary=None | def find_quaternary(self, path=None, text=None, tertiary=None, quaternary=None): | ||
"""Find all | """Find all quaternary subsystems and groups | ||
@keyword path: The path to the repository to search through. | @keyword path: The path to the repository to search through. | ||
Line 312: | Line 267: | ||
@keyword quaternary: The quaternary list of subsystems or groups. | @keyword quaternary: The quaternary list of subsystems or groups. | ||
@type quaternary: list of Subsystem instances | @type quaternary: list of Subsystem instances | ||
""" | """ | ||
# Printout. | |||
sys.stderr.write("Finding all quaternary %s in: %s\n" % (text, path)) | |||
# Loop over all tertiary subsystems. | # Loop over all tertiary subsystems. | ||
Line 323: | Line 279: | ||
# Sort all subsystems by name. | # Sort all subsystems by name. | ||
quaternary.sort(key=operator.attrgetter('name')) | quaternary.sort(key=operator.attrgetter('name')) | ||
Line 363: | Line 307: | ||
# Cannot handle this line! | # Cannot handle this line! | ||
if not search("class ", line): | if not search("class ", line): | ||
sys.stderr.write(" | sys.stderr.write("Skipping: %s\n" % repr(line[:-1])) | ||
continue | continue | ||
Line 381: | Line 325: | ||
def summarise(self): | def summarise(self): | ||
"""Print out a summary of all found subsystems and subsystem groups.""" | """Print out a summary of all found subsystems and subsystem groups.""" | ||
# XML start. | |||
if self.xml: | |||
print("<subsystems>") | |||
# Subsystem and group printouts. | |||
labels = ["primary", "secondary", "tertiary", "quaternary"] | |||
labels2 = ["Primary", "Secondary", "Tertiary", "Quaternary"] | |||
classes = ["subsystems", "groups"] | |||
for i in range(len(self.subsystems)): | |||
for j in range(len(classes)): | |||
if classes[j] == "subsystems": | |||
subsystem_list = self.subsystems[i] | |||
else: | |||
subsystem_list = self.groups[i] | |||
# Nothing in the list. | |||
if not len(subsystem_list): | |||
continue | |||
# Count all. | |||
counts = self.count(subsystem_list) | |||
# Start. | |||
if self.xml: | |||
print(" <%s_%s count=\"%i\">" % (labels[i], classes[j], counts[j])) | |||
else: | |||
print("\n%s %s (%i):" % (labels2[i], classes[j], counts[j])) | |||
# Subsystems. | |||
for subsystem in subsystem_list: | |||
print(" %s" % (subsystem)) | |||
# End. | |||
if self.xml: | |||
print(" </%s_%s>" % (labels[i], classes[j])) | |||
# Counts. | # Counts. | ||
Line 406: | Line 386: | ||
simgear_total = subsystem_classes_simgear + subsystem_groups_simgear | simgear_total = subsystem_classes_simgear + subsystem_groups_simgear | ||
flightgear_total = subsystem_classes_flightgear + subsystem_groups_flightgear | flightgear_total = subsystem_classes_flightgear + subsystem_groups_flightgear | ||
if self.xml: | if self.xml: | ||
print(" <counts>") | print(" <counts>") | ||
Line 430: | Line 408: | ||
print("Counts: %i subsystem groups (%i flightgear, %i simgear)." % (subsystem_groups, subsystem_groups_flightgear, subsystem_groups_simgear)) | print("Counts: %i subsystem groups (%i flightgear, %i simgear)." % (subsystem_groups, subsystem_groups_flightgear, subsystem_groups_simgear)) | ||
print("Counts: %i subsystem classes and groups (%i flightgear, %i simgear)." % (subsystem_total, flightgear_total, simgear_total)) | print("Counts: %i subsystem classes and groups (%i flightgear, %i simgear)." % (subsystem_total, flightgear_total, simgear_total)) | ||
# XML end. | |||
if self.xml: | |||
print("</subsystems>") | |||