User:Bugman/subsystems: Difference between revisions

Jump to navigation Jump to search
→‎Script: Newest version of the script.
m (→‎All subsystems: Changed the order.)
(→‎Script: Newest version of the script.)
Line 328: Line 328:
         # XML start.
         # XML start.
         if self.xml:
         if self.xml:
            print("<?xml version=\"1.0\"?>")
             print("<subsystems>")
             print("<subsystems>")


Line 356: Line 357:
                 # Subsystems.
                 # Subsystems.
                 for subsystem in subsystem_list:
                 for subsystem in subsystem_list:
                     print("    %s" % (subsystem))
                     for line in repr(subsystem).split("\n"):
                        print("    %s" % (line))


                 # End.
                 # End.
Line 447: Line 449:
         @rtype:    str
         @rtype:    str
         """
         """
        # The subsystem name.
        string = "<%s" % self.name


         # The inheritance chain.
         # The inheritance chain.
        inheritance = ""
         if self.base_class:
         if self.base_class:
             if self.xml:
             inheritance += "%s" % self.base_class.name
                string += " from=\""
            else:
                string += " : "
            string += "%s" % self.base_class.name
             if self.base_class.base_class:
             if self.base_class.base_class:
                 string += " : %s" % self.base_class.base_class.name
                 inheritance += " : %s" % self.base_class.base_class.name
                 if self.base_class.base_class.base_class:
                 if self.base_class.base_class.base_class:
                     string += " : %s" % self.base_class.base_class.base_class.name
                     inheritance += " : %s" % self.base_class.base_class.base_class.name
                     if self.base_class.base_class.base_class.base_class:
                     if self.base_class.base_class.base_class.base_class:
                         string += " : %s" % self.base_class.base_class.base_class.base_class.name
                         inheritance += " : %s" % self.base_class.base_class.base_class.base_class.name
                         if self.base_class.base_class.base_class.base_class.base_class:
                         if self.base_class.base_class.base_class.base_class.base_class:
                             string += " : %s" % self.base_class.base_class.base_class.base_class.base_class.name
                             inheritance += " : %s" % self.base_class.base_class.base_class.base_class.base_class.name
            if self.xml:
 
                string += "\""
        # XML representation.
        if self.xml:
            return self.__repr_xml__(inheritance)
 
        # The subsystem name and inheritance chain.
        string = "<%s : %s" % (self.name, inheritance)


         # Add the declaration file name.
         # Add the declaration file name.
         if self.xml:
         string += " declared in \"%s\"" % self.declaration_file
            string += " declaration="
        else:
            string += " in "
        string += "\"%s\"" % self.declaration_file


         # Add the implementation file name.
         # Add the implementation file name.
         if self.implementation_file:
         if self.implementation_file:
             if self.xml:
             string += ", implemented in \"%s\"" % self.implementation_file
                string += " implementation="
            else:
                string += ", "
            string += "\"%s\"" % self.implementation_file


         # Closure.
         # Closure.
        if self.xml:
            string += "/"
         string += ">"
         string += ">"


         # Return the representation.
         # Return the representation.
        return string
    def __repr_xml__(self, inheritance=""):
        """Create a XML representation of the object.
        @keyword inheritance:  The string representation of the inheritance chain.
        @type inheritance:      str
        @return:                The XML representation.
        @rtype:                str
        """
        # Start.
        string = "<%s>\n" % self.name
        # The inheritance chain.
        string += "  <inheritance>%s</inheritance>\n" % inheritance
        # Add the declaration file name.
        string += "  <declaration>%s</declaration>\n" % self.declaration_file
        # Add the implementation file name.
        if self.implementation_file:
            string += "  <implementation>%s</implementation>\n" % self.implementation_file
        # End.
        string += "</%s>" % self.name
        # Return the string.
         return string
         return string


Navigation menu