Return an instance of the language class that fname is suited for.

    Searches through the module langs for the class that matches up
    with fname.  If is_ext is True then fname will be taken to be
    the extension for a language.
8820
def language(fname, is_ext=False):
    

    global _langmapping

    # Normalize the fname so that it looks like an extension.
    if is_ext:
        fname = '.' + fname
    _, ext = os.path.splitext(fname)

    return _langmapping[ext]()
1175333
public function getFallbackPageExtensions($file_ext = null)
    {
        if (empty($this->page_extensions)) {
            if (!$file_ext) {
                $file_ext = CONTENT_EXT;
            }

            if ($this->enabled()) {
                $valid_lang_extensions = [];
                foreach ($this->languages as $lang) {
                    $valid_lang_extensions[] = '.' . $lang . $file_ext;
                }

                if ($this->active) {
                    $active_extension = '.' . $this->active . $file_ext;
                    $key = \array_search($active_extension, $valid_lang_extensions, true);

                    // Default behavior is to find any language other than active
                    if ($this->config->get('system.languages.pages_fallback_only')) {
                        $slice = \array_slice($valid_lang_extensions, 0, $key+1);
                        $valid_lang_extensions = array_reverse($slice);
                    } else {
                        unset($valid_lang_extensions[$key]);
                        array_unshift($valid_lang_extensions, $active_extension);
                    }
                }
                $valid_lang_extensions[] = $file_ext;
                $this->page_extensions = $valid_lang_extensions;
            } else {
                $this->page_extensions = (array)$file_ext;
            }
        }

        return $this->page_extensions;
    }
1053363
def cli(filename, direct, language):
    # TODO: Flesh this description out
    
    file_extension = filename.split(".")[-1]
    if file_extension not in extensions.keys():
        error = "{} is not currently supported in Pyterp.\n Pyterp currently only supports" \
                "the following types: {}".format(file_extension, extensions.items())
        raise RuntimeError(error)

    if direct is not None and language is None:
        raise click.BadOptionUsage('--language',
                                   "When running a program directly from string, you must specify the langauge "
                                   "with the --language option: Valid options include [bf]")
    """
    TODO: Figure out how to best load each interpreter based on extension. Maybe a factory?
    """
    interpreter = pyterp.Brainfuck(filename=filename, direct_input=direct)
    interpreter.run()
1190038
def join_ext(name, extension):
    
    if extension[0] == EXT:
        ret = name + extension
    else:
        ret = name + EXT + extension
    return ret
1129179
def lookup_class(fully_qualified_name):
    
    module_name, class_name = str(fully_qualified_name).rsplit(".", 1)
    module = __import__(module_name, globals(), locals(), [class_name], 0)
    Class = getattr(module, class_name)

    if not inspect.isclass(Class):
        raise TypeError(
            "%s is not of type class: %s" % (class_name, type(Class)))

    return Class
1192338
def get_translation(self, language_code, related_name=None):
        
        meta = self._parler_meta._get_extension_by_related_name(related_name)
        return self._get_translated_model(language_code, meta=meta)
1118832
def match_extension(f):
    ''''''
    (root,ext) = os.path.splitext(f)
    return ext.lower() in extensions
1315968
def get_language(self):
        
        locale = self.get_locale()
        language = locale
        if '_' in locale:
            language = locale[0:locale.index('_')]
        return language
143397
def load_fn_matches_ext(file_path, file_type):
    
    correct_ext = False
    curr_ext = os.path.splitext(file_path)[1]
    exts = [curr_ext, file_type]
    try:
        # special case: if file type is excel, both extensions are valid.
        if ".xlsx" in exts and ".xls" in exts:
            correct_ext = True
        elif curr_ext == file_type:
            correct_ext = True
        else:
            print("Use '{}' to load this file: {}".format(FILE_TYPE_MAP[curr_ext]["load_fn"],
                                                          os.path.basename(file_path)))
    except Exception as e:
        logger_misc.debug("load_fn_matches_ext: {}".format(e))

    return correct_ext
1329743
def search(cls, name, lookup=[]):
        
        if os.path.isfile(name): return name
        for spath in lookup:
            fname = os.path.join(spath, name)
            if os.path.isfile(fname):
                return fname
            for ext in cls.extensions:
                if os.path.isfile('%s.%s' % (fname, ext)):
                    return '%s.%s' % (fname, ext)
72272
function findTypeForExtend(types, extend) {
  var orig = types.find(ea => ea.name === extend.name && ea.type !== "extend");
  if (!orig) throw new Error("Cannot find original for extension " + JSON.stringify(extend, null, 2));
  return orig;
}
884009
function get_name($class, $function, $name = null)
    {
        $result = false;
        if (isset(Eresus_CMS::getLegacyKernel()->conf['extensions']))
        {
            if (isset(Eresus_CMS::getLegacyKernel()->conf['extensions'][$class]))
            {
                if (isset(Eresus_CMS::getLegacyKernel()->conf['extensions'][$class][$function]))
                {
                    $items = Eresus_CMS::getLegacyKernel()->conf['extensions'][$class][$function];
                    reset($items);
                    $result = isset($items[$name]) ? $name : key($items);
                }
            }
        }

        return $result;
    }
608612
private function buildLanguagePath($extension, $language)
    {
        $returnValue = (string) '';

        
        $returnValue = dirname(__FILE__) . '/../../' . $extension . '/' . self::DEF_OUTPUT_DIR . '/' . $language;
        

        return (string) $returnValue;
    }
1092030
def get_language(self, name):
        

        for language in self.__languages:
            if language.name == name:
                LOGGER.debug("> Language '{0}': '{1}'.".format(name, language))
                return language
595980
def find_lexer_class(name):
    
    if name in _lexer_cache:
        return _lexer_cache[name]
    # lookup builtin lexers
    for module_name, lname, aliases, _, _ in itervalues(LEXERS):
        if name == lname:
            _load_lexers(module_name)
            return _lexer_cache[name]
    # continue with lexers from setuptools entrypoints
    for cls in find_plugin_lexers():
        if cls.name == name:
            return cls
1311130
def search(cls, name, lookup=None):
        

        for spath in lookup:
            spath = os.path.abspath(spath) + os.sep
            fname = os.path.abspath(os.path.join(spath, name))
            if not fname.startswith(spath): continue
            if os.path.isfile(fname): return fname
            for ext in cls.extensions:
                if os.path.isfile('%s.%s' % (fname, ext)):
                    return '%s.%s' % (fname, ext)
588603
def get_language(language_name):
    

    langs = list(pkg_resources.iter_entry_points(group=LANG_EP,
                                                 name=language_name))

    if not langs:
        raise TextXError('Language "{}" is not registered.'
                         .format(language_name))

    if len(langs) > 1:
        # Multiple languages defined with the same name
        raise TextXError('Language "{}" registered multiple times:\n{}'
                         .format(language_name,
                                 "\n".join([l.dist for l in langs])))

    return langs[0].load()()