Helper function Extracts the extension from a file object
179535
function getFileExtension(file) {
    return file.name.substring(file.name.lastIndexOf('.')+1, file.name.length).toLowerCase()
}
735610
function(file) {
        var self = this;

        var ext;

        if (!self._options.keepExtension) {
            ext = self._options.extension || path.extname(file);
        }

        var fileName = path.basename(file, ext);

        if (self._options.format) {
            var formatRegex = self._options.format[0].split('/');
            formatRegex = new RegExp(formatRegex[1], formatRegex[2]);

            var replaceValue = self._options.format[1];

            fileName = fileName.replace(formatRegex, replaceValue);
        }

        var moduleConfig = {
            name: '',
            version: '1.0.0'
        };

        if (self._options.moduleConfig) {
            if (typeof self._options.moduleConfig === 'string') {
                var fileModuleConfig = path.resolve(self._options.moduleConfig);

                if (fs.existsSync(fileModuleConfig)) {
                    moduleConfig = require(fileModuleConfig);
                }
            } else {
                moduleConfig = self._options.moduleConfig;
            }
        }

        fileName = path.join(path.dirname(file), fileName);

        var moduleName = '';

        if (moduleConfig.name) {
            moduleName = moduleConfig.name + '@' + moduleConfig.version;
        }

        moduleName = path.join(moduleName, fileName.substring(self._options.moduleRoot.length));

        if (self._options.lowerCase) {
            moduleName = moduleName.toLowerCase();
        }

        return upath.toUnix(moduleName);
    }
476178
function getFileTypeReg(type) {
  var map = [], ext = her.config.get('project.fileType.' + type);
  if (type === 'text') {
    map = TEXT_FILE_EXTS;
  } else if (type === 'image') {
    map = IMAGE_FILE_EXTS;
  } else {
    throw new Error('invalid file type [' + type + ']');
  }
  if (ext && ext.length) {
    if (typeof ext === 'string') {
      ext = ext.split(/\s*,\s*/);
    }
    map = map.concat(ext);
  }
  map = map.join('|');
  return new RegExp('\\.(?:' + map + ')$', 'i');
}
1124837
function getFilenameWithoutExtension(filename) {
        var index = filename.lastIndexOf(".");
        return index === -1 ? filename : filename.slice(0, index);
    }
395649
private function _extract_file_extension()
    {

        if (empty($this->filename)) return false;

        if (!empty($this->mime_type)) {
            $array                = explode('/', $this->mime_type);
            $this->file_extension = array_pop($array);
        } else {
            if (strpos($this->filename, '.') !== false) {
                $array                = explode('/', $this->mime_type);
                $this->file_extension = array_pop($array);
            } else {
                $this->file_extension = 'unknown';
            }
        }

        return true;
    }
291922
private String extractExtension(String filename) {
    int startExtension = filename.indexOf('.');
    if (startExtension > 0) {
      return filename.substring(startExtension + 1);
    }
    return "";
  }
843223
def extract_classifier_and_extension(pkg_name, filename):
    
    basename, _, extension = filename.rpartition('.')
    if extension == 'gz' and filename.endswith('.tar.gz'):
        extension = 'tar.gz'
        basename = filename[:-7]
    if basename == pkg_name or basename[len(pkg_name)] != '-':
        return 'py2.py3-none-any', extension
    basename = basename[len(pkg_name)+1:]
    classifier_parts = basename.split('-')
    if len(classifier_parts) < 3:
        return 'py2.py3-none-any', extension
    if len(classifier_parts) == 3:
        _, _, classifier_parts[0] = classifier_parts[0].rpartition('.')
    return '-'.join(classifier_parts[-3:]), extension
306116
function findParsableFile(book, filename) {
    var fs = book.getContentFS();
    var ext = path.extname(filename);
    var basename = path.basename(filename, ext);
    var basedir = path.dirname(filename);

    // Ordered list of extensions to test
    var exts = parsers.extensions;

    return Promise.some(exts, function(ext) {
        var filepath = basename + ext;

        return fs.findFile(basedir, filepath)
        .then(function(found) {
            if (!found || book.isContentFileIgnored(found)) {
                return undefined;
            }

            return fs.statFile(found);
        });
    });
}
558751
private static String getFileExtension(final String filename) {

		String extension = "";
		int i = filename.lastIndexOf('.');
		int p = Math.max(filename.lastIndexOf('/'), filename.lastIndexOf('\\'));
		if (i > p)
			extension = filename.substring(i+1);

		return extension;
	}
1179533
def extract_filename(self):
    """"""
    globals_gdbval = self._gdbval['f_globals'].cast(GdbCache.DICT)
    global_dict = libpython.PyDictObjectPtr(globals_gdbval)
    for key, value in global_dict.iteritems():
      if str(key.proxyval(set())) == '__file__':
        return str(value.proxyval(set()))
56098
function getExtension(url) {
    var a = url.split('.');

    if (a.length === 1 || (a[0] === '' && a.length === 2))
      return '';
    return a.pop();
  }
1084194
def _get_relative_ext(of, sf):
    
    def half_finished_trim(orig, prefix):
        return (os.path.basename(prefix).count(".") > 0 and
                os.path.basename(orig).count(".") == os.path.basename(prefix).count("."))
    # Handle remote files
    if of.find(":") > 0:
        of = os.path.basename(of.split(":")[-1])
    if sf.find(":") > 0:
        sf = os.path.basename(sf.split(":")[-1])
    prefix = os.path.commonprefix([sf, of])
    while prefix.endswith(".") or (half_finished_trim(sf, prefix) and half_finished_trim(of, prefix)):
        prefix = prefix[:-1]
    exts_to_remove = of.replace(prefix, "")
    ext_to_add = sf.replace(prefix, "")
    # Return extensions relative to original
    if not exts_to_remove or exts_to_remove.startswith("."):
        return str("^" * exts_to_remove.count(".") + ext_to_add)
    else:
        raise ValueError("No cross platform way to reference complex extension: %s %s" % (sf, of))
915876
function parseFile(dir, filename) {
  const filePath = path.join(dir, filename);
  const fileStat = fs.statSync(filePath);
  const fileExt = path.extname(filename);

  return {
    path: filePath,
    stat: fileStat,
    ext: fileExt
  };
}
681487
function _extractFiles (dir, callback) {

			if ("undefined" === typeof dir) {
				throw new ReferenceError("missing \"directory\" argument");
			}
				else if ("string" !== typeof dir) {
					throw new TypeError("\"directory\" argument is not a string");
				}
				else if ("" === dir.trim()) {
					throw new Error("\"directory\" argument is empty");
				}
			else if ("undefined" === typeof callback) {
				throw new ReferenceError("missing \"callback\" argument");
			}
				else if ("function" !== typeof callback) {
					throw new TypeError("\"callback\" argument is not a function");
				}
			else {

				const _dir = dir.trim();

				isDirectoryProm(_dir).then((exists) => {
					return exists ? Promise.resolve() : Promise.reject(new Error("\"" + _dir + "\" is not a valid directory"));
				}).then(() => {

					readdir(_dir, (_err, files) => {
						return _err ? callback(_err) : _extractRealFiles(_dir, files, [], callback);
					});

				}).catch(callback);

			}

		}
235524
def format_from_extension(fname):
    
    _base, ext = os.path.splitext(fname)
    if not ext:
        return None
    try:
        format = known_extensions[ext.replace('.', '')]
    except KeyError:
        format = None
    return format
960726
def get_file_extension(filepath):
    
    _ext = os.path.splitext(filepath)[-1]
    if _ext:
        return _ext[1:] if _ext.startswith('.') else _ext

    return ''
610466
def _findExtnames(self, extname=None, exclude=None):
        
        #make a list of the available extension names for the object
        extensions=[]
        if extname is not None:
            if not isinstance(extname,list): extname=[extname]
            for extn in extname:
                extensions.append(extn.upper())
        else:
        #restore all the extensions data from the original file, be careful here
        #if you've altered data in memory you want to keep!
            for i in range(1,self._nextend+1,1):
                if hasattr(self._image[i],'_extension') and \
                    "IMAGE" in self._image[i]._extension:
                    if self._image[i].extname.upper() not in extensions:
                        extensions.append(self._image[i].extname)
        #remove this extension from the list
        if exclude is not None:
            exclude.upper()
            if exclude in extensions:
                newExt=[]
                for item in extensions:
                    if item != exclude:
                        newExt.append(item)
            extensions=newExt
            del newExt
        return extensions