Load sources from an XML file.
427299
def _create_diffuse_src_from_xml(self, config, src_type='FileFunction'):
        
        diffuse_xmls = config.get('diffuse_xml')
        srcs_out = []
        for diffuse_xml in diffuse_xmls:
            srcs_out += self.load_xml(diffuse_xml, coordsys=config.get('coordsys', 'CEL'))
        return srcs_out
947149
def loadXml(self, xdata, filepath=''):
        
        # build options
        opts = {'platform': sys.platform}

        mkpath = lambda x: _mkpath(filepath, x, **opts)

        # lookup environment variables
        xenv = xdata.find('environment')
        if xenv is not None:
            env = {}
            log.info('loading environment...')
            for xkey in xenv:
                text = xkey.text
                if text:
                    env[xkey.tag] = os.path.expandvars(text)
                else:
                    env[xkey.tag] = ''

            self.setEnvironment(env)

        # lookup general settings
        xsettings = xdata.find('settings')
        if xsettings is not None:
            for xsetting in xsettings:
                key = xsetting.tag
                val = xsetting.text
                attr = '_' + key
                if hasattr(self, attr):
                    setattr(self, attr, val)

        # lookup options
        xoptions = xdata.find('options')
        if xoptions is not None:
            options = 0
            for xopt in xoptions:
                key = xopt.tag
                value = xopt.text

                if value.lower() == 'true':
                    try:
                        options |= Builder.Options[key]
                    except KeyError:
                        continue

            self._options = options

        # lookup path options
        xpaths = xdata.find('paths')
        if xpaths is not None:
            for xpath in xpaths:
                key = xpath.tag
                path = xpath.text

                if key.endswith('Paths'):
                    path = map(mkpath, path.split(';'))
                else:
                    path = mkpath(path)

                setattr(self, '_' + key, path)

        # lookup executable options
        xexe = xdata.find('executable')
        if xexe is not None:
            exe_tags = {'runtime': '_runtime',
                        'exe': '_executableName',
                        'cli': '_executableCliName',
                        'product': '_productName'}

            for tag, prop in exe_tags.items():
                xtag = xexe.find(tag)
                if xtag is not None:
                    value = xtag.text
                    if value.startswith('.'):
                        value = mkpath(value)

                    setattr(self, prop, value)

            # load exclude options
            xexcludes = xexe.find('excludes')
            if xexcludes is not None:
                excludes = []
                for xexclude in xexcludes:
                    excludes.append(xexclude.text)
                self.setExecutableExcludes(excludes)

            # load build data
            xexedata = xexe.find('data')
            if xexedata is not None:
                data = []
                for xentry in xexedata:
                    if xentry.tag == 'tree':
                        path = xentry.get('path', '')
                        if path:
                            path = mkpath(path)
                        else:
                            path = self.sourcePath()

                        prefix = xentry.get('prefix', os.path.basename(path))
                        excludes = xentry.get('excludes', '').split(';')

                        if excludes:
                            data.append(('tree', (path, prefix, excludes)))
                    else:
                        for xitem in xentry:
                            data.append((xentry.tag, xitem.attrs))

                self.setExecutableData(data)

            # load hidden imports
            xhiddenimports = xexe.find('hiddenimports')
            if xhiddenimports is not None:
                imports = []
                for ximport in xhiddenimports:
                    imports.append(ximport.text)
                self.setHiddenImports(imports)

            # load options
            xopts = xexe.find('options')
            if xopts is not None:
                for xopt in xopts:
                    if xopt.text.startswith('.'):
                        value = mkpath(xopt.text)
                    else:
                        value = xopt.text
                    self._executableOptions[xopt.tag] = value

        # lookup installer options
        xinstall = xdata.find('installer')
        if xinstall is not None:
            install_tags = {'name': '_installName'}

            for tag, prop in install_tags.items():
                xtag = xinstall.find(tag)
                if xtag is not None:
                    value = xtag.text
                    if value.startswith('.'):
                        value = mkpath(value)
                    setattr(self, prop, value)

            xopts = xinstall.find('options')
            if xopts is not None:
                for xopt in xopts:
                    if xopt.text.startswith('.'):
                        value = mkpath(xopt.text)
                    else:
                        value = xopt.text

                    self._installerOptions[xopt.tag] = value

            xdirectories = xinstall.find('additional_directories')
            if xdirectories is not None:
                for xdir in xdirectories:
                    self._installDirectories[xdir.get('path')] = xdir.get('source', '')
911200
def XML(content, source=None):
    
    try:
        tree = ET.XML(content)
    except ET.ParseError as err:
        x_parse_error(err, content, source)
    return tree
1166727
def _load(self, graph, source):
        """"""
        try:
            return graph.load(source)
        except:
            pass
        try:
            return graph.load(source, format='n3')
        except:
            pass
        try:
            return graph.load(source, format='nt')
        except:
            raise Exception("Could not load {} as either RDF/XML, N3 or NTriples".format(source))
93575
private static Document _loadDocument(InputStream is) throws SAXException, IOException {
	InputSource source = new InputSource(is);

	return XMLUtil.parse(source, null, false);
    }
861671
def get_from_sources(self, index, doc_type, document_id):
        """"""
        return self.sources.get(index, {}).get(doc_type, {}).get(document_id, {})
363155
def load_addon_strings(addon, filename):
    ''''''
    def get_strings(fn):
        xml = parse(fn)
        strings = dict((tag.getAttribute('id'), tag.firstChild.data) for tag in xml.getElementsByTagName('string'))
        #strings = {}
        #for tag in xml.getElementsByTagName('string'):
            #strings[tag.getAttribute('id')] = tag.firstChild.data
        return strings
    addon._strings = get_strings(filename)
800540
def create_from_xmlfile(cls, xmlfile, extdir=None):
        
        root = ElementTree.ElementTree(file=xmlfile).getroot()
        srcs = root.findall('source')
        if len(srcs) == 0:
            raise Exception('No sources found.')
        return cls.create_from_xml(srcs[0], extdir=extdir)
20795
def _loadOneSource(self, sourceFName):
        
        sourceLines = open(sourceFName).readlines()
        del sourceLines[0]
        if len(sourceLines[0].split("\t"))==2:
            self._loadTwoPartSource(sourceFName, sourceLines)
        elif len(sourceLines[0].split("\t"))==3:
            self._loadThreePartSource(sourceFName, sourceLines)
        else:
            raise Error, "%s does not appear to be a source authority file"
90030
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)
            root = tree.getroot()
            if "symlink" in root.attrib:
                self._vardict["symlink"] = root.attrib.lower() == "true"
                
            for child in root:
                if child.tag == "codes":
                    self._load_codes(child)
                elif child.tag == "mappings":
                    self._load_mapping(child)
                elif child.tag == "ssh":
                    self._load_ssh(child)
                elif child.tag == "isense":
                    self._load_isense(child)
                elif child.tag == "libraries":
                    self._load_includes(child)
                elif child.tag == "compilers":
                    self._vardict["compilers"] = child.text
481144
def load_xml(self, xmlfile, **kwargs):
        """"""

        extdir = kwargs.get('extdir', self.extdir)
        coordsys = kwargs.get('coordsys', 'CEL')
        if not os.path.isfile(xmlfile):
            xmlfile = os.path.join(fermipy.PACKAGE_DATA, 'catalogs', xmlfile)

        root = ElementTree.ElementTree(file=xmlfile).getroot()

        diffuse_srcs = []
        srcs = []
        ra, dec = [], []

        for s in root.findall('source'):
            src = Source.create_from_xml(s, extdir=extdir)
            if src.diffuse:
                diffuse_srcs += [src]
            else:
                srcs += [src]
                ra += [src['RAJ2000']]
                dec += [src['DEJ2000']]

        src_skydir = SkyCoord(ra=np.array(ra) * u.deg,
                              dec=np.array(dec) * u.deg)
        radec = np.vstack((src_skydir.ra.deg, src_skydir.dec.deg)).T
        glonlat = np.vstack((src_skydir.galactic.l.deg,
                             src_skydir.galactic.b.deg)).T

        offset = self.skydir.separation(src_skydir).deg
        offset_cel = wcs_utils.sky_to_offset(self.skydir,
                                             radec[:, 0], radec[:, 1], 'CEL')
        offset_gal = wcs_utils.sky_to_offset(self.skydir,
                                             glonlat[:, 0], glonlat[:, 1], 'GAL')

        m0 = get_skydir_distance_mask(src_skydir, self.skydir,
                                      self.config['src_radius'])
        m1 = get_skydir_distance_mask(src_skydir, self.skydir,
                                      self.config['src_radius_roi'],
                                      square=True, coordsys=coordsys)
        m = (m0 & m1)
        srcs = np.array(srcs)[m]
        for i, s in enumerate(srcs):
            s.data['offset'] = offset[m][i]
            s.data['offset_ra'] = offset_cel[:, 0][m][i]
            s.data['offset_dec'] = offset_cel[:, 1][m][i]
            s.data['offset_glon'] = offset_gal[:, 0][m][i]
            s.data['offset_glat'] = offset_gal[:, 1][m][i]
            self.load_source(s, False,
                             merge_sources=self.config['merge_sources'])

        for i, s in enumerate(diffuse_srcs):
            self.load_source(s, False,
                             merge_sources=self.config['merge_sources'])

        self._build_src_index()
        return srcs
1291865
def fromxml(node, file=None):
        """"""
        if not isinstance(node,ElementTree._Element): #pylint: disable=protected-access
            node = parsexmlstring(node)
        if node.tag == 'CLAMMetaData':
            dataformat = node.attrib['format']

            formatclass = None
            for C in CUSTOM_FORMATS: #CUSTOM_FORMATS will be injected by clamservice.py
                if C.__name__ == dataformat:
                    formatclass = C
                    break
            if formatclass is None and dataformat in vars(clam.common.formats) and issubclass(vars(clam.common.formats)[dataformat], CLAMMetaData):
                formatclass = vars(clam.common.formats)[dataformat]
            if formatclass is None:
                raise Exception("Format class " + dataformat + " not found!")

            data = {}
            if 'inputtemplate' in node.attrib:
                data['inputtemplate'] = node.attrib['inputtemplate']
            if 'inputtemplatelabel' in node.attrib:
                data['inputtemplatelabel'] = node.attrib['inputtemplatelabel']



            for subnode in node:
                if subnode.tag == 'meta':
                    key = subnode.attrib['id']
                    value = subnode.text
                    data[key] = value
                elif subnode.tag == 'provenance':
                    data['provenance'] = CLAMProvenanceData.fromxml(subnode)
            return formatclass(file, **data)
        else:
            raise Exception("Invalid CLAM Metadata!")
605268
def load_xml(self, filepath):
        
        # Parse the XML file
        vot = vo.parse_single_table(filepath)
        self.raw = np.array([list(i) for i in vot.array]).T

        # Parse the filter metadata
        for p in [str(p).split() for p in vot.params]:

            # Extract the key/value pairs
            key = p[1].split('"')[1]
            val = p[-1].split('"')[1]

            # Do some formatting
            flt1 = p[2].split('"')[1] == 'float'
            flt2 = p[3].split('"')[1] == 'float'
            if flt1 or flt2:
                val = float(val)

            else:
                val = val.replace('b&apos;', '')\
                         .replace('&apos', '')\
                         .replace('&amp;', '&')\
                         .strip(';')

            # Set the attribute
            if key != 'Description':
                setattr(self, key, val)

        # Create some attributes
        self.path = filepath
        self.pixels_per_bin = self.raw.shape[-1]
        self.n_bins = 1
1267319
def _fetch_xml(self, url):
        """"""
        with contextlib.closing(urlopen(url)) as f:
            return xml.etree.ElementTree.parse(f).getroot()
787355
private static Document loadXML(InputSource source, boolean useNamespace) {
		try {
			org.w3c.dom.Document doc = getDocumentBuilder(null, useNamespace).parse(source);
			return new DocumentImpl(doc);
		} catch (Exception e) {
			throw new DomException(e);
		} finally {
			close(source);
		}
	}
279914
def _load_resource(self, source_r, abs_path=False):
        

        r = self.doc.resource(source_r.name)

        r.url = self.resource_root.join(r.url).inner
884363
def loadXMLGenericData(filename):  # not tested
    """"""
    reader = vtk.vtkXMLGenericDataObjectReader()
    reader.SetFileName(filename)
    reader.Update()
    return Actor(reader.GetOutput())