def vb_xpcom_to_attribute_dict(xpcom, interface_name=None, attributes=None, excluded_attributes=None, extra_attributes=None):
 if interface_name:
  m = re.search('XPCOM.+implementing {0}'.format(interface_name), str(xpcom))
  if (not m):
   log.warning('Interface %s is unknown and cannot be converted to dict', interface_name)
   return dict()
 interface_attributes = set((attributes or XPCOM_ATTRIBUTES.get(interface_name, [])))
 if extra_attributes:
  interface_attributes = interface_attributes.union(extra_attributes)
 if excluded_attributes:
  interface_attributes = interface_attributes.difference(excluded_attributes)
 attribute_tuples = []
 for attribute in interface_attributes:
  if isinstance(attribute, tuple):
   attribute_name = attribute[0]
   attribute_class = attribute[1]
   value = (attribute_name, getattr(xpcom, attribute_name, attribute_class()))
  else:
   value = (attribute, getattr(xpcom, attribute, ''))
  attribute_tuples.append(value)
 return dict(attribute_tuples)

def vb_xpcom_to_attribute_dict ( xpcom , interface_name = None , attributes = None , excluded_attributes = None , extra_attributes = None ) : if interface_name : m = re . search ( 'XPCOM.+implementing {0}' . format ( interface_name ) , str ( xpcom ) ) if ( not m ) : log . warning ( 'Interface %s is unknown and cannot be converted to dict' , interface_name ) return dict ( ) interface_attributes = set ( ( attributes or XPCOM_ATTRIBUTES . get ( interface_name , [ ] ) ) ) if extra_attributes : interface_attributes = interface_attributes . union ( extra_attributes ) if excluded_attributes : interface_attributes = interface_attributes . difference ( excluded_attributes ) attribute_tuples = [ ] for attribute in interface_attributes : if isinstance ( attribute , tuple ) : attribute_name = attribute [ 0 ] attribute_class = attribute [ 1 ] value = ( attribute_name , getattr ( xpcom , attribute_name , attribute_class ( ) ) ) else : value = ( attribute , getattr ( xpcom , attribute , '' ) ) attribute_tuples . append ( value ) return dict ( attribute_tuples )
attempts to build a dict from an xpcom object .