Load attribute values from Plex XML response.
345457
def _loadData(self, data):
        
        self._data = data
        self._token = logfilter.add_secret(data.attrib.get('authenticationToken'))
        self._webhooks = []
        self.authenticationToken = self._token
        self.certificateVersion = data.attrib.get('certificateVersion')
        self.cloudSyncDevice = data.attrib.get('cloudSyncDevice')
        self.email = data.attrib.get('email')
        self.guest = utils.cast(bool, data.attrib.get('guest'))
        self.home = utils.cast(bool, data.attrib.get('home'))
        self.homeSize = utils.cast(int, data.attrib.get('homeSize'))
        self.id = data.attrib.get('id')
        self.locale = data.attrib.get('locale')
        self.mailing_list_status = data.attrib.get('mailing_list_status')
        self.maxHomeSize = utils.cast(int, data.attrib.get('maxHomeSize'))
        self.queueEmail = data.attrib.get('queueEmail')
        self.queueUid = data.attrib.get('queueUid')
        self.restricted = utils.cast(bool, data.attrib.get('restricted'))
        self.scrobbleTypes = data.attrib.get('scrobbleTypes')
        self.secure = utils.cast(bool, data.attrib.get('secure'))
        self.thumb = data.attrib.get('thumb')
        self.title = data.attrib.get('title')
        self.username = data.attrib.get('username')
        self.uuid = data.attrib.get('uuid')
        subscription = data.find('subscription')

        self.subscriptionActive = utils.cast(bool, subscription.attrib.get('active'))
        self.subscriptionStatus = subscription.attrib.get('status')
        self.subscriptionPlan = subscription.attrib.get('plan')

        self.subscriptionFeatures = []
        for feature in subscription.iter('feature'):
            self.subscriptionFeatures.append(feature.attrib.get('id'))

        roles = data.find('roles')
        self.roles = []
        if roles:
            for role in roles.iter('role'):
                self.roles.append(role.attrib.get('id'))

        entitlements = data.find('entitlements')
        self.entitlements = []
        for entitlement in entitlements.iter('entitlement'):
            self.entitlements.append(entitlement.attrib.get('id'))

        # TODO: Fetch missing MyPlexAccount attributes
        self.profile_settings = None
        self.services = None
        self.joined_at = None
392138
def load_stream(filename):
    """"""
    rawfile = pkg_resources.resource_stream(__name__, filename)
    if six.PY2:
        return rawfile
    return io.TextIOWrapper(rawfile, 'utf-8')
361362
def load_dict(self, dct):
        """"""
        for k, v in dct.items():
            setattr(self, k, v)
311793
private void readResourceExtendedAttributes(Project.Resources.Resource xml, Resource mpx)
   {
      for (Project.Resources.Resource.ExtendedAttribute attrib : xml.getExtendedAttribute())
      {
         int xmlFieldID = Integer.parseInt(attrib.getFieldID()) & 0x0000FFFF;
         ResourceField mpxFieldID = MPPResourceField.getInstance(xmlFieldID);
         TimeUnit durationFormat = DatatypeConverter.parseDurationTimeUnits(attrib.getDurationFormat(), null);
         DatatypeConverter.parseExtendedAttribute(m_projectFile, mpx, attrib.getValue(), mpxFieldID, durationFormat);
      }
   }
828627
def load_attributes_from_response(response)
      if (response['Transfer-Encoding'] == 'chunked' || (!response['Content-Length'].blank? && response['Content-Length'] != "0")) && !response.body.nil? && response.body.strip.size > 0
        load( self.class.format.decode(response.body)[self.class.element_name] )
        #fix double nested items .. active resource SUCKS soooo bad
        if self.respond_to?(:items)
          new_items = []
          self.items.each { |item| new_items << item.attributes.first[1] }
          self.items = new_items
        end
        @persisted = true
      end
    end
898189
def load_xml(self, filepath):
        """"""
        from os import path
        import xml.etree.ElementTree as ET
        #Make sure the file exists and then import it as XML and read the values out.
        uxpath = path.expanduser(filepath)
        if path.isfile(uxpath):
            tree = ET.parse(uxpath)
            vms("Parsing global settings from {}.".format(uxpath))
            root = tree.getroot()

            for child in root:
                if child.tag == "var":
                    self._vardict[child.attrib["name"]] = child.attrib["value"]
1005197
def to_xml(self):
        
        root = ET.Element("entry")
        for x in self.xml_tags:
            if getattr(self, x):
                if x in ['episodes', 'scores', 'status', 'dates', 'storage', 'rewatched', 'flags', 'tags']:
                    if x == 'episodes':
                        if self.episodes.current:
                            temp = ET.SubElement(root, 'episode')
                            temp.text = str(self.episodes.current)
                    elif x == 'scores':
                        if self.scores.user:
                            temp = ET.SubElement(root, 'score')
                            temp.text = str(self.scores.user)
                    elif x == 'status':
                        if self.status.user:
                            temp = ET.SubElement(root, 'status')
                            temp.text = str(self.status.user)
                    elif x == 'dates':
                        if self.dates.user.start:
                            start = ET.SubElement(root, 'date_start')
                            start.text = format_date(self.dates.user.start)
                        if self.dates.user.end:
                            end = ET.SubElement(root, 'date_finish')
                            end.text = format_date(self.dates.user.end)
                    elif x == 'storage':
                        if self.storage.type:
                            stype = ET.SubElement(root, 'storage_type')
                            stype.text = str(self.storage.type)
                        if self.storage.value:
                            sval = ET.SubElement(root, 'storage_value')
                            sval.text = str(self.storage.value)
                    elif x == 'rewatched':
                        if self.rewatched.times:
                            rt = ET.SubElement(root, 'times_rewatched')
                            rt.text = str(self.rewatched.times)
                        if self.rewatched.value:
                            rv = ET.SubElement(root, 'rewatch_value')
                            rv.text = str(self.rewatched.value)
                    elif x == 'flags':
                        if self.flags.discussion:
                            df = ET.SubElement(root, 'enable_discussion')
                            df.text = '1' if self.flags.discussion else '0'
                        if self.flags.rewatching:
                            rf = ET.SubElement(root, 'enable_rewatching')
                            rf.text = '1' if self.flags.rewatching else '0'
                    else:
                        if self.tags:
                            temp = ET.SubElement(root, 'tags')
                            temp.text = ','.join(self.tags)
                else:
                    temp = ET.SubElement(root, x)
                    temp.text = str(getattr(self, x))
        return '<?xml version="1.0" encoding="UTF-8"?>{}'.format(ET.tostring(root, encoding="unicode"))
444180
def output_xml(data, code, headers=None):
    """"""
    resp = make_response(dumps({'response' :data}), code)
    resp.headers.extend(headers or {})
    return resp
620541
def loads(inputStr):
    """"""
    inCat = json.loads(inputStr)
    assert CATALOGUE_TYPE in _values(inCat[CATALOGUE_METADATA], ISCONTENTTYPE_RELATION)
    # Manually copy mandatory fields, to check that they are they, and exclude other garbage
    desc = _values(inCat[CATALOGUE_METADATA], DESCRIPTION_RELATION)[0]  # TODO: We are ASSUMING just one description, which may not be true
    outCat = Hypercat(desc)
    for i in inCat[ITEMS]:
        href = i[HREF]
        contentType = _values(i[ITEM_METADATA], ISCONTENTTYPE_RELATION) [0]
        desc = _values(i[ITEM_METADATA], DESCRIPTION_RELATION) [0]
        if contentType == CATALOGUE_TYPE:
            r = Hypercat(desc)
        else:
            r = Resource(desc, contentType)
        outCat.addItem(r, href)

    return outCat
1371006
def _parse(data, obj_name, attr_map):
    """"""
    parsed_xml = minidom.parseString(data)
    parsed_objects = []
    for obj in parsed_xml.getElementsByTagName(obj_name):
        parsed_obj = {}
        for (py_name, xml_name) in attr_map.items():
            parsed_obj[py_name] = _get_minidom_tag_value(obj, xml_name)
        parsed_objects.append(parsed_obj)
    return parsed_objects
1016546
def _parse_properties(response, result_class):
    '''
    
    '''

    if response is None or response.headers is None:
        return None

    props = result_class()
    for key, value in response.headers:
        info = GET_PROPERTIES_ATTRIBUTE_MAP.get(key)
        if info:
            if info[0] is None:
                setattr(props, info[1], info[2](value))
            else:
                attr = getattr(props, info[0])
                setattr(attr, info[1], info[2](value))

    return props
208957
def get_attributes                                                         
      url = URI.parse('http://www.blip.tv/')   
      res = Net::HTTP.start(url.host, url.port) {|http|      
       http.get("http://www.blip.tv/file/#{@id.to_s}?skin=api")
      }                                                                                
      
      hash = Hash.from_xml(res.body)
      
      if hash["response"]["status"] != "OK"
        raise VideoResponseError.new(hash["response"]["notice"])
      end
      
      if hash["response"]["payload"]["asset"].is_a?(Array) 
        return hash["response"]["payload"]["asset"][0] # there may be several assets. In that case, read the first one
      else
        return hash["response"]["payload"]["asset"]
      end
    end
327830
def trips_process_xml():
    """"""
    if request.method == 'OPTIONS':
        return {}
    response = request.body.read().decode('utf-8')
    body = json.loads(response)
    xml_str = body.get('xml_str')
    tp = trips.process_xml(xml_str)
    return _stmts_from_proc(tp)
609254
public static Object loadXMLInfo(String filename) throws JAXBException {
        Object obj = null;
        JAXBContext jaxbContext = JAXBContext.newInstance(CLINVAR_CONTEXT_v53);
        Unmarshaller unmarshaller = jaxbContext.createUnmarshaller();
        obj = unmarshaller.unmarshal(new File(filename));
        return obj;
    }
486801
def _get_el_attributes(lxml_el, ns=None, nsmap=None):
    
    attrs = {}
    for attr, val in lxml_el.items():
        attr = _to_colon_ns(attr, default_ns=ns, nsmap=nsmap)
        attrs[attr] = val
    return attrs
821960
def from_attributes(cls, server, dbname, username, dbclass, port=None, query_band=None,
                        initial_sql=None, authentication=''):
        """"""

        root = ET.Element('connection', authentication=authentication)
        xml = cls(root)
        xml.server = server
        xml.dbname = dbname
        xml.username = username
        xml.dbclass = dbclass
        xml.port = port
        xml.query_band = query_band
        xml.initial_sql = initial_sql

        return xml
844737
def xmltreefromfile(filename):
    """"""
    try:
        return ElementTree.parse(filename, ElementTree.XMLParser(collect_ids=False))
    except TypeError:
        return ElementTree.parse(filename, ElementTree.XMLParser())