Пример #1
0
 def xml(self, indent=""):
     """This methods renders an XML representation of this parameter, along with
     its selected value, and feedback on validation errors"""
     xml = indent + "<" + self.__class__.__name__
     xml += ' id="' + self.id + '"'
     xml += ' name="' + xmlescape(self.name) + '"'
     xml += ' description="' + xmlescape(self.description) + '"'
     if self.paramflag:
         xml += ' flag="' + self.paramflag + '"'
     if self.multi:
         xml += ' multi="true"'
     for key, value in self.kwargs.items():
         if key != 'choices' and key != 'default' and key != 'flag' and key != 'paramflag':
             if isinstance(value, bool):
                 xml += ' ' + key + '="' + str(int(value)) + '"'
             elif isinstance(value, list):
                 xml += ' ' + key + '="' + ",".join(value) + '"'
             else:
                 xml += ' ' + key + '="' + xmlescape(value) + '"'
     if self.error:
         xml += ' error="' + self.error + '"'
     xml += ">"
     for key, value in self.choices:
         if self.value == key or (isinstance(self.value, list)
                                  and key in self.value):
             xml += " <choice id=\"" + key + "\" selected=\"1\">" + xmlescape(
                 value) + "</choice>"
         else:
             xml += " <choice id=\"" + key + "\">" + xmlescape(
                 value) + "</choice>"
     xml += "</" + self.__class__.__name__ + ">"
     return xml
Пример #2
0
 def xml(self, indent = ""):
     """This methods renders an XML representation of this parameter, along with 
     its selected value, and feedback on validation errors"""
     xml = indent + "<" + self.__class__.__name__
     xml += ' id="'+self.id + '"'
     xml += ' name="'+xmlescape(self.name) + '"'
     xml += ' description="'+xmlescape(self.description) + '"'
     if self.paramflag:
         xml += ' flag="'+self.paramflag + '"'        
     if self.multi:
         xml += ' multi="true"'
     for key, value in self.kwargs.items():    
         if key != 'choices' and key != 'default' and key != 'flag' and key != 'paramflag':
             if isinstance(value, bool):
                 xml += ' ' + key + '="' + str(int(value))+ '"'                    
             elif isinstance(value, list):
                 xml += ' ' + key + '="'+",".join(value)+ '"'        
             else:
                 xml += ' ' + key + '="'+xmlescape(value)+ '"'
     if self.error:
          xml += ' error="'+self.error + '"'               
     xml += ">"
     for key, value in self.choices:
         if self.value == key or (isinstance(self.value ,list) and key in self.value):
             xml += " <choice id=\""+key+"\" selected=\"1\">" + xmlescape(value) + "</choice>"        
         else:
             xml += " <choice id=\""+key+"\">" + xmlescape(value) + "</choice>"
     xml += "</" + self.__class__.__name__ + ">"
     return xml
Пример #3
0
 def xml(self, indent=""):
     """This methods renders an XML representation of this parameter, along with
     its selected value, and feedback on validation errors"""
     xml = indent + "<" + self.__class__.__name__
     xml += ' id="' + self.id + '"'
     xml += ' name="' + xmlescape(self.name) + '"'
     xml += ' description="' + xmlescape(self.description) + '"'
     if self.paramflag:
         xml += ' flag="' + self.paramflag + '"'
     for key, v in self.kwargs.items():
         if key not in ('value', 'error', 'name', 'description', 'flag',
                        'paramflag', 'validator'):
             if isinstance(v, bool):
                 xml += ' ' + key + '="' + str(int(v)) + '"'
             elif isinstance(v, list):
                 xml += ' ' + key + '="' + xmlescape(",".join(v)) + '"'
             elif isinstance(v, str) or (sys.version < '3'
                                         and isinstance(v, unicode)):  #pylint: disable=undefined-variable
                 xml += ' ' + key + '="' + xmlescape(v) + '"'
             else:
                 xml += ' ' + key + '="' + xmlescape(str(v)) + '"'
     if self.hasvalue:
         if sys.version < '3':
             xml += ' value="' + xmlescape(unicode(self.value)) + '"'  #pylint: disable=undefined-variable
         else:
             xml += ' value="' + xmlescape(str(self.value)) + '"'
     if self.error:
         xml += ' error="' + xmlescape(self.error) + '"'
     xml += " />"
     return xml
Пример #4
0
 def xml(self, indent = ""):
     """This methods renders an XML representation of this parameter, along with
     its selected value, and feedback on validation errors"""
     xml = indent + "<" + self.__class__.__name__
     xml += ' id="'+self.id + '"'
     xml += ' name="'+xmlescape(self.name) + '"'
     xml += ' description="'+xmlescape(self.description) + '"'
     if self.paramflag:
         xml += ' flag="'+self.paramflag + '"'
     for key, v in self.kwargs.items():
         if key not in ('value','error','name','description','flag','paramflag', 'validator'):
             if isinstance(v, bool):
                 xml += ' ' + key + '="' + str(int(v))+ '"'
             elif isinstance(v, list):
                 xml += ' ' + key + '="'+xmlescape(",".join(v))+ '"'
             elif isinstance(v, str)  or ( sys.version < '3' and isinstance(v, unicode)): #pylint: disable=undefined-variable
                 xml += ' ' + key + '="'+xmlescape(v)+ '"'
             else:
                 xml += ' ' + key + '="'+xmlescape(str(v))+ '"'
     if self.hasvalue:
         if sys.version < '3':
             xml += ' value="'+xmlescape(unicode(self.value)) + '"' #pylint: disable=undefined-variable
         else:
             xml += ' value="'+xmlescape(str(self.value)) + '"'
     if self.error:
         xml += ' error="'+xmlescape(self.error) + '"'
     xml += " />"
     return xml