components/policy/tools/template_writers/writers/doc_writer.py
def _PythonObjectToPlist(self, obj, indent=''):
    '''Converts a python object to an equivalent XML plist.

    Returns a list of lines.'''
    obj_type = type(obj)
    if obj_type == bool:
      return ['%s<%s/>' % (indent, 'true' if obj else 'false')]
    elif obj_type == int:
      return ['%s<integer>%s</integer>' % (indent, obj)]
    elif obj_type == str:
      return ['%s<string>%s</string>' % (indent, escape(obj))]
    elif obj_type == list:
      result = ['%s<array>' % indent]
      for item in obj:
        result += self._PythonObjectToPlist(item, indent + '  ')
      result.append('%s</array>' % indent)
      return result
    elif obj_type == dict:
      result = ['%s<dict>' % indent]
      for key in sorted(obj.keys()):
        result.append('%s<key>%s</key>' % (indent + '  ', key))
        result += self._PythonObjectToPlist(obj[key], indent + '  ')
      result.append('%s</dict>' % indent)
      return result
    else:
      raise Exception('Invalid object to convert: %s' % obj)
Converts a python object to an equivalent XML plist.

    Returns a list of lines.
Converts a python object to an equivalent XML plist.
Returns a list of lines.
Converts a python object to an equivalent XML plist . Returns a list of lines .
def _PythonObjectToPlist(self, obj, indent=''):
    obj_type = type(obj)
    if obj_type == bool:
      return ['%s<%s/>' % (indent, 'true' if obj else 'false')]
    elif obj_type == int:
      return ['%s<integer>%s</integer>' % (indent, obj)]
    elif obj_type == str:
      return ['%s<string>%s</string>' % (indent, escape(obj))]
    elif obj_type == list:
      result = ['%s<array>' % indent]
      for item in obj:
        result += self._PythonObjectToPlist(item, indent + '  ')
      result.append('%s</array>' % indent)
      return result
    elif obj_type == dict:
      result = ['%s<dict>' % indent]
      for key in sorted(obj.keys()):
        result.append('%s<key>%s</key>' % (indent + '  ', key))
        result += self._PythonObjectToPlist(obj[key], indent + '  ')
      result.append('%s</dict>' % indent)
      return result
    else:
      raise Exception('Invalid object to convert: %s' % obj)
def _PythonObjectToPlist ( self , obj , indent = '' ) : obj_type = type ( obj ) if obj_type == bool : return [ '%s<%s/>' % ( indent , 'true' if obj else 'false' ) ] elif obj_type == int : return [ '%s<integer>%s</integer>' % ( indent , obj ) ] elif obj_type == str : return [ '%s<string>%s</string>' % ( indent , escape ( obj ) ) ] elif obj_type == list : result = [ '%s<array>' % indent ] for item in obj : result += self . _PythonObjectToPlist ( item , indent + '  ' ) result . append ( '%s</array>' % indent ) return result elif obj_type == dict : result = [ '%s<dict>' % indent ] for key in sorted ( obj . keys ( ) ) : result . append ( '%s<key>%s</key>' % ( indent + '  ' , key ) ) result += self . _PythonObjectToPlist ( obj [ key ] , indent + '  ' ) result . append ( '%s</dict>' % indent ) return result else : raise Exception ( 'Invalid object to convert: %s' % obj )
Converts a python object to an equivalent XML plist.
Converts a python object to an equivalent XML plist .
'''Converts a python object to an equivalent XML plist.

    Returns a list of lines.'''
self
obj
indent