Esempio n. 1
0
    def parse(self, filename):
        tree = ElemTree.parse(filename)
        root = tree.getroot()

        resultlist = []

        for classinfo in root.findall("classes"):

            result = Documentation()
            result.name = classinfo.attrib["name"]

            # Yes, the description is in an attrib called description in a node called description
            descriptionnode = classinfo.find("description")
            if descriptionnode is not None:
                result.description = descriptionnode.get("description")

            for propertyinfo in classinfo.findall("deviceProperties"):
                name = propertyinfo.attrib["name"]
                description = propertyinfo.attrib["description"]
                type = self.__get_type(propertyinfo)
                defaultnode = propertyinfo.find("DefaultPropValue")
                default = defaultnode.text if defaultnode is not None else "-"
                result.addproperty(name, description, type, default)

            for commandinfo in classinfo.findall("commands"):
                name = commandinfo.attrib["name"]
                description = commandinfo.attrib["description"]
                argin = commandinfo.find("argin")
                parameter_description = argin.get("description")
                parameter_type = self.__get_type(argin)
                argout = commandinfo.find("argout")
                result_description = argout.get("description")
                result_type = self.__get_type(argout)

                result.addcommand(name, description, parameter_type, parameter_description, result_type, result_description)

            for attributeinfo in classinfo.findall("attributes"):
                name = attributeinfo.get("name")
                description = attributeinfo.find("properties").get("description")
                type = self.__get_type(attributeinfo, "dataType")
                result.addattribute(name, description, type)

            resultlist.append(result)

        return resultlist
 def parse(self, device_url):
     device = DeviceProxy(device_url)
     result = Documentation()
     result.name = device.info().dev_class
     result.description = device.description()
     # FIXME: perhaps need to query the database about the propertiess
     propertyNames = device.get_property_list('*')
     for propertyName in propertyNames:
         result.addproperty(propertyName, 'TODO description', 'TODO type name', 'TODO default')
     attributeInfos = device.attribute_list_query()
     for attributeInfo in attributeInfos:
         result.addattribute(attributeInfo.name, attributeInfo.description, self.translate(attributeInfo.data_type, attributeInfo.data_format))
     commandInfos = device.command_list_query()
     for commandInfo in commandInfos:
         result.addcommand(
             commandInfo.cmd_name,
             'TODO command description',
             self.translate_command_argument(commandInfo.in_type),
             commandInfo.in_type_desc,
             self.translate_command_argument(commandInfo.out_type),
             commandInfo.out_type_desc)
     return [result]