param data: dict of data from XML-RPC server, representing a bug.
        returns: AttrDict
429696
def _parse_bug(self, data):
        
        if 'id' in data:
            data['weburl'] = self.url.replace('xmlrpc.cgi', str(data['id']))
        bug = AttrDict(data)
        return bug
1095494
def data=(data)
      raise ArgumentError, 'No document data specified' if data.nil?

      @data = Nokogiri::XML.parse(data.to_s)
    end
114661
def serialize_unicode(self, data):
        
        try:
            return data.value
        except AttributeError:
            pass
        try:
            if isinstance(data, unicode):
                return data.encode(encoding='utf-8')
        except NameError:
            return str(data)
        else:
            return str(data)
282547
def AsDict(self, dt=True):
        
        data = {}

        if self.id:
            data['id'] = self.id
        if self.name:
            data['name'] = self.name
        if self.owner:
            data['owner'] = self.owner.AsDict()
        if self.url:
            data['url'] = self.url
        if self.thumbnail_url:
            data['thumbnail_url'] = self.thumbnail_url
        if self.description:
            data['description'] = self.description
        if self.type:
            data['type'] = self.type

        if dt:
            if self.created_at:
                data['created_at'] = self.created_at
            if self.updated_at:
                data['updated_at'] = self.updated_at
        else:
            if self.created_at:
                data['created_at'] = self.created_at_iso
            if self.updated_at:
                data['updated_at'] = self.updated_at_iso

        return data
1194249
def as_dict(self):
        
        data = get_dict_for_attrs(self, ['id', 'raw_id', 'short_id',
            'revision', 'date', 'message'])
        data['author'] = {'name': self.author_name, 'email': self.author_email}
        data['added'] = [node.path for node in self.added]
        data['changed'] = [node.path for node in self.changed]
        data['removed'] = [node.path for node in self.removed]
        return data
88601
def _xml_to_dict(self, element):
        
        return_dict = {}
        for el in element:
            return_dict[el.tag] = None
            children = el.getchildren()
            if children:
                return_dict[el.tag] = self._xml_to_dict(children)
            else:
                return_dict[el.tag] = el.text
        return return_dict
713746
def data_to_unicode(self, data):
        
        if isinstance(data, dict):
            return {self.to_unicode(k): self.to_unicode(v) for k, v in data.iteritems()}
        if isinstance(data, list):
            return [self.to_unicode(l) for l in data]
        else:
            return self.to_unicode(data)
931114
def _get_data_attr(data, attr):
    """"""
    if isinstance(data, dict):
        # `Data` object's id is hydrated as `__id` in expression engine
        data = data['__id']

    data_obj = Data.objects.get(id=data)

    return getattr(data_obj, attr)
110032
def to_python(self, data):
        
        if data is None:
            return ''
        if isinstance(data, unicode):
            data = data.encode(DEFAULT_ENCODING)
        else:
            data = str(data)
        return data
604238
def _client_data(self, client):
        
        data = {}
        if client:
            data['obj'] = client
            data['id'] = client.id
            data['url'] = client.absolute_url()
            data['name'] = to_utf8(client.getName())
        return data
620559
def parse(data):
    

    # convert to string
    data = data.decode("ascii")

    if len(data) == 2 and data == "A5":
        return AckMessage()

    # split into bytes
    raw = [data[i:i+2] for i in range(len(data)) if i % 2 == 0]

    if len(raw) != 7:
        return UnknownMessage(raw)

    if raw[1] == "B8":
        return StateMessage(raw)
    elif raw[3] == "12":
        return CommandMessage(raw)
    elif raw[3] == "14":
        return ScenarioTriggeredMessage(raw)
    elif raw[3] == "15":
        return RequestStatusMessage(raw)
    else:
        return UnknownMessage(raw)
486644
def format_payload(self, api_version, data):
        
        # Check if payload is for API v1 or API v2.
        if (api_version in (1, 2)):
            # Check if string type.
            if type(data) == str:
                # Convert to dictionary.
                logger.debug('Converting string to dict:\n%s' % data)
                # Remove possible starting question mark & ending ampersands.
                data = data.lstrip('?')
                data = data.rstrip('&')
                # Convert to dictionary.
                data = parse_qs(data)
                logger.debug('Converted:\n%s' % str(data))
        elif api_version in ('am', 'was', 'am2'):
            if type(data) == etree._Element:
                logger.debug('Converting lxml.builder.E to string')
                data = etree.tostring(data)
                logger.debug('Converted:\n%s' % data)
        return data
34891
def data(self):
        """"""
        d = {}
        self.token = ''
        try:
            d = self.viz.data
            self.token = d.get('token')
        except Exception as e:
            logging.exception(e)
            d['error'] = str(e)
        return {
            'datasource': self.datasource_name,
            'description': self.description,
            'description_markeddown': self.description_markeddown,
            'edit_url': self.edit_url,
            'form_data': self.form_data,
            'slice_id': self.id,
            'slice_name': self.slice_name,
            'slice_url': self.slice_url,
            'modified': self.modified(),
            'changed_on_humanized': self.changed_on_humanized,
            'changed_on': self.changed_on.isoformat(),
        }
399121
def as_dict(self):
        

        element_dict = dict()
        if hasattr(self, 'namespace'):
            element_dict['namespace'] = self.namespace
        if hasattr(self, 'name'):
            element_dict['name'] = self.name
        if hasattr(self, 'text'):
            element_dict['text'] = self.text

        attr_dict = dict()
        for attr in self.attrs:
            if hasattr(self, attr):
                attr_dict[attr] = getattr(self, attr)
        element_dict['attrs'] = attr_dict

        return element_dict
754588
def get_attrdict(self) -> OrderedNamespace:
        
        # noinspection PyUnresolvedReferences
        columns = self.__table__.columns.keys()
        values = (getattr(self, x) for x in columns)
        zipped = zip(columns, values)
        return OrderedNamespace(zipped)
101772
def json2xml(json_data, factory=ET.Element):

    
    if not isinstance(json_data, dict):
        json_data = json.loads(json_data)

    elem = internal_to_elem(json_data, factory)
    return ET.tostring(elem)
643954
def serialize(self, data):
        
        if data is None:
            return None
        elif isinstance(data, dict):
            return serializer.Serializer().serialize(data)
        else:
            raise Exception(_("Unable to serialize object of type = '%s'") %
                            type(data))