Parses an addon name from the given addon.xml filename.
965758
def get_addon_name(addonxml):
    ''''''
    xml = parse(addonxml)
    addon_node = xml.getElementsByTagName('addon')[0]
    return addon_node.getAttribute('name')
372918
def parse(self, filename_or_file, initialize=True):
        
        if isinstance(filename_or_file, (str, unicode)):
            filename = filename_or_file
        else:
            filename = filename_or_file.name
        try:
            domtree = minidom.parse(filename_or_file)
        except xml.parsers.expat.ExpatError, e:
            args = [e.args[0]]
            if isinstance(filename, unicode):
                filename = filename.encode(sys.getdefaultencoding(), "replace")
            args.insert(0, '\n  File "%s"\n   ' % filename)
            raise ManifestXMLParseError(" ".join([str(arg) for arg in args]))
        if initialize:
            self.__init__()
        self.filename = filename
        self.load_dom(domtree, False)
662924
def parse_atom_file(filename: str) -> AtomFeed:
    """"""
    root = parse_xml(filename).getroot()
    return _parse_atom(root)
851026
def parse_application_name(setup_filename):
        
        with open(setup_filename, 'rt') as setup_file:
            fst = RedBaron(setup_file.read())
            for node in fst:
                if (
                    node.type == 'atomtrailers' and
                    str(node.name) == 'setup'
                ):
                    for call in node.call:
                        if str(call.name) == 'name':
                            value = call.value
                            if hasattr(value, 'to_python'):
                                value = value.to_python()
                            name = str(value)
                            break
                    if name:
                        break
        return name
1046362
def _parse(self, source, name, filename):
        """"""
        return Parser(self, source, name, encode_filename(filename)).parse()
524841
function readManifest(addonPath) {
  var manifest;

  if (addonPath.slice(-4) === '.xpi') {
    manifest = checkedCall(fs.readFile, addonPath).then(function(buff) {
      var zip = new AdmZip(buff);
      if (!zip.getEntry('install.rdf')) {
        throw new AddonFormatError(
            'Could not find install.rdf in ' + addonPath);
      }
      var done = promise.defer();
      zip.readAsTextAsync('install.rdf', done.fulfill);
      return done.promise;
    });
  } else {
    manifest = checkedCall(fs.stat, addonPath).then(function(stats) {
      if (!stats.isDirectory()) {
        throw Error(
            'Add-on path is niether a xpi nor a directory: ' + addonPath);
      }
      return checkedCall(fs.readFile, path.join(addonPath, 'install.rdf'));
    });
  }

  return manifest.then(function(content) {
    return checkedCall(xml.parseString, content);
  });
}
603244
def htmlParseFile(filename, encoding):
    
    ret = libxml2mod.htmlParseFile(filename, encoding)
    if ret is None:raise parserError('htmlParseFile() failed')
    return xmlDoc(_obj=ret)
542353
def fromFile(filename):
        
        xdata = None
        ydata = None

        # try parsing an XML file
        try:
            xdata = ElementTree.parse(filename).getroot()
        except StandardError:
            xdata = None

        if xdata is None:
            # try parsing a yaml file
            if yaml:
                with open(filename, 'r') as f:
                    text = f.read()

                try:
                    ydata = yaml.load(text)
                except StandardError:
                    return None
            else:
                log.warning('Could not process yaml builder!')

        # load a yaml definition
        if type(ydata) == dict:
            typ = ydata.get('type')
            module = ydata.get('module')
            builder = Builder.plugin(typ, module)
            if builder:
                return builder.fromYaml(ydata, os.path.dirname(filename))
            else:
                log.warning('Could not find builder: {0}'.format(typ))

        # load an xml definition
        elif xdata is not None:
            typ = xdata.get('type')
            module = xdata.get('module')
            builder = Builder.plugin(typ, module)
            if builder:
                return builder.fromXml(xdata, os.path.dirname(filename))
            else:
                log.warning('Could not find builder: {0}'.format(typ))

        return None
538366
def parseEntity(filename):
    
    ret = libxml2mod.xmlParseEntity(filename)
    if ret is None:raise parserError('xmlParseEntity() failed')
    return xmlDoc(_obj=ret)
597237
private Document parseExtensionFile(String serviceName) {

		String extensionFileName = serviceName + "-Extensions.xml";

    	if (isIddAsResource()) {
    		InputStream is = resourceLoader.getResourceAsStream(extensionFileName);
    		if (is != null) {
    			return XmlUtil.parse(is, resolver);
    		}
    		else {
    			return null;
    		}
    	}
    	else {
    		File extensionsFile = new File( new File(getBaseDir(), RESOURCES_DIR), extensionFileName);
    		if (extensionsFile.exists()) {
        		return XmlUtil.parse(extensionsFile, resolver);
    		}
    		else {
    			return null;
    		}
    	}
    }
391106
private CmsModule getModuleForFileName(String fileName) {

        String moduleName = fileName;
        if (fileName.endsWith(SUFFIX)) {
            moduleName = fileName.substring(0, fileName.length() - SUFFIX.length());
        }
        CmsModule result = OpenCms.getModuleManager().getModule(moduleName);
        return result;
    }
475096
def load_plugin_from_addonxml(cls, mode, url):
        '''
        '''
        cwd = os.getcwd()
        sys.path.insert(0, cwd)
        module_name = get_addon_module_name(os.path.join(cwd, 'addon.xml'))
        addon = __import__(module_name)

        # Find the first instance of xbmcswift2.Plugin
        try:
            plugin = (attr_value for attr_value in vars(addon).values()
                      if isinstance(attr_value, Plugin)).next()
        except StopIteration:
            sys.exit('Could\'t find a Plugin instance in %s.py' % module_name)

        return cls(plugin, mode, url)
921603
def identify_names(filename):
    """"""
    node, _ = parse_source_file(filename)
    if node is None:
        return {}

    # Get matches from the code (AST)
    finder = NameFinder()
    finder.visit(node)
    names = list(finder.get_mapping())
    names += extract_object_names_from_docs(filename)

    example_code_obj = collections.OrderedDict()
    for name, full_name in names:
        if name in example_code_obj:
            continue  # if someone puts it in the docstring and code
        # name is as written in file (e.g. np.asarray)
        # full_name includes resolved import path (e.g. numpy.asarray)
        splitted = full_name.rsplit('.', 1)
        if len(splitted) == 1:
            # module without attribute. This is not useful for
            # backreferences
            continue

        module, attribute = splitted
        # get shortened module name
        module_short = get_short_module_name(module, attribute)
        cobj = {'name': attribute, 'module': module,
                'module_short': module_short}
        example_code_obj[name] = cobj
    return example_code_obj
645776
def parse_xml_file(self, fileobj, id_generator=None):
        """"""
        root = etree.parse(fileobj).getroot()
        usage_id = self._usage_id_from_node(root, None, id_generator)
        return usage_id
699525
function plugin_parser(xmlPath) {
    this.path = xmlPath;
    this.doc = xml.parseElementtreeSync(xmlPath);
    this.platforms = this.doc.findall('platform').map(function(p) {
        return p.attrib.name;
    });
}
1040547
def _parse_from_file(self, filepath, fname,
                         dependencies, recursive, greedy):
        """"""
        #Now that we have the file contents, we can parse them using the parsers
        string = self.tramp.read(filepath)
        pmodules = self.modulep.parse(string, self, filepath=filepath)
        file_mtime = self._get_mod_mtime(filepath)

        for module in pmodules:
            module.change_time = file_mtime
            self.modules[module.name.lower()] = module
            self._modulefiles[fname].append(module.name.lower())

        pprograms = self.modulep.parse(string, self, False)
        for program in pprograms:
            program.change_time = file_mtime
            self.programs[program.name.lower()] = program
            self._programfiles[fname].append(program.name.lower())

        #There may be xml files for the docstrings that also need to be parsed.
        self._parse_docstrings(filepath)
        
        return (pmodules, pprograms)
935443
def _parse_repo(self, xml):
        
        self.name = get_attrib(xml, "name", "repo")
        self.username = get_attrib(xml, "user", "repo")
        self.apikey = get_attrib(xml, "apikey", "repo")
        self.organization = get_attrib(xml, "organization")
        self.staging = get_attrib(xml, "staging", "repo")