Find a file in a folder (case incensitive) Return the real filename
546321
function findFile(root, filename) {
    return Q.nfcall(fs.readdir, root)
    .then(function(files) {
        return _.find(files, function(file) {
            return (file.toLowerCase() == filename.toLowerCase());
        });
    });
}
1160895
def find_files(args):
    '''
    
    '''
    files_or_dirs = args or ['.']
    filenames = []
    for f in files_or_dirs:
        if path.isdir(f):
            filenames.extend(glob.glob(path.join(f, '**', '*_spec.py'), recursive=True))
        elif path.isfile(f):
            filenames.append(f)
        else:
            raise FileNotFoundError('could not spec file {}'.format(repr(f)))
    return filenames
581369
def get_file_string(filepath):
    """"""
    with open(os.path.abspath(filepath)) as f:
        return f.read()
509668
protected synchronized String getFileName(Map result, String fileType) {
        String exname = getExName(result);
        String crid;
        if (getValueOr(result, "seasonal_dome_applied", "N").equals("Y")) {
            crid = "SN";
        } else {
            crid = getCrid(result);
        }
        if (exname.length() == 10) {
            if (crid.equals("XX") || crid.equals("FA")) {
                crid = exname.substring(exname.length() - 2, exname.length());
            }
        }

        String ret;
        if (exToFileMap.containsKey(exname + "_" + crid)) {
            return exToFileMap.get(exname + "_" + crid) + fileType;
        } else {
            ret = exname;
            if (ret.equals("")) {
                ret = "TEMP0001";
            } else {
                try {
                    if (ret.endsWith(crid)) {
                        ret = ret.substring(0, ret.length() - crid.length());
                    }
                    // If the exname is too long
                    if (ret.length() > 8) {
                        ret = ret.substring(0, 8);
                    }
                    // If the exname do not follow the Dssat rule
                    if (!ret.matches("[\\w ]{1,6}\\d{2}$")) {
                        if (ret.length() > 6) {
                            ret = ret.substring(0, 6);
                        }
                        ret += "01";
                    }
                } catch (Exception e) {
                    ret = "TEMP0001";
                }
            }

            // Special handling for batch
            if (exname.matches(".+_\\d+_b\\S+(__\\d+)?$")) {
                int idx = exname.lastIndexOf("_b") + 2;
                ret += "B" + exname.substring(idx).replaceAll("__\\d+$", "");
            }

            // Find a non-repeated file name
            int count;
            while (fileNameSet.contains(ret + "." + crid)) {
                try {
                    count = Integer.parseInt(ret.substring(ret.length() - 2, ret.length()));
                    count++;
                } catch (Exception e) {
                    count = 1;
                }
                ret = ret.replaceAll("\\w{2}$", String.format("%02d", count));
            }
        }

        exToFileMap.put(exname + "_" + crid, ret + "." + crid);
        fileNameSet.add(ret + "." + crid);

        return ret + "." + crid + fileType;
    }
1189041
def _search(mapping, filename):
    """"""
    result = mapping.get(filename)
    if result is not None:
        return result
    name, ext = os.path.splitext(filename)
    result = mapping.get(ext)
    if result is not None:
        for pattern, result2 in result:
            if fnmatch(filename, pattern):
                return result2
    return None
212401
def filename_match(fsearch, filename, width, height):
    '''
    
    '''
    fsearch = clean_path(fsearch)
    filename = clean_path(filename)
    if fsearch == filename:
        return True

    if fsearch.find('@') == -1:
        return False
    basename, fileext = os.path.splitext(fsearch)
    nickname, extinfo = basename.split('@', 1)
    if extinfo == 'auto':
        valid_names = {}.fromkeys([
            nickname+'@{}x{}'.format(width, height)+fileext,
            nickname+'@{}x{}'.format(height, width)+fileext,
            nickname+'.{}x{}'.format(width, height)+fileext,
            nickname+'.{}x{}'.format(height, width)+fileext,
        ])
        if filename in valid_names:
            return True
    # if extinfo.find('x') != -1:
    #     cw, ch = extinfo.split('x', 1)
    #     if cw*width == ch*height or cw*height == ch*width:
    #         return True
    return False
740971
def _find_file(filename):
    
    import os
    if os.path.exists(filename):
        path = filename
    else:
        path = os.path.dirname(__file__)
        path = os.path.join(path, 'data', filename)

    if not os.path.exists(path):
        raise ValueError("cannot locate file '%s'" %filename)

    return path
1081854
def __getFilenameSuffix(self, filename):
        """"""
        if filename and isinstance(filename, string_types):
            if self.__isValidTGZ(filename):
                return ".tar.gz"
            elif filename.endswith(".zip"):
                return ".zip"
1341440
function getBetterFileName(dataUrlType, itemName, format) {
  let name = itemName;
  const extension = "." + format;
  // Only add the extension if it's not already there.
  if (name.indexOf(extension) !== name.length - extension.length) {
    name = name + extension;
  }
  // For local files, the file already exists on the user's computer with the original name, so give it a modified name.
  if (dataUrlType === "local") {
    name = "processed " + name;
  }
  return name;
}
710864
def get_filename(disposition):
    
    if disposition:
        params = [param.strip() for param in disposition.split(';')[1:]]
        for param in params:
            if '=' in param:
                name, value = param.split('=', 1)
                if name == 'filename':
                    return value.strip('"')
601279
def parseFilename(self, filename):
        """"""
        match = self.filename_regex.match(filename)
        if match is None:
            # TODO?: Raise exception?
            '''print("Filename", filename, "unrecognized!")'''
            return None
        lat = int(match.group(2))
        lon = int(match.group(4))
        if match.group(1) == "S":
            lat = -lat
        if match.group(3) == "W":
            lon = -lon
        return lat, lon
894653
def getfullfilename(file_path):
        ''' 
        '''
        warnings.warn("getfullfilename() is deprecated and will be removed in near future. Use chirptext.io.write_file() instead", DeprecationWarning)
        if file_path:
            return os.path.basename(file_path)
        else:
            return ''
24443
def get_filename(self):
        '''  '''
        if self.filename is None or not os.path.exists(self.filename):
            tf = tempfile.mktemp() + self._default_file_extension
            self.save(tf)
            yield tf
            os.remove(tf)
        else:
            yield self.filename
619571
def get_file_name(url):
  """"""
  return os.path.basename(urllib.parse.urlparse(url).path) or 'unknown_name'
602881
function getFilePath(sourcePath, filename, subDir) {
    if (subDir === void 0) { subDir = ''; }
    var filePath = filename
        .replace(path.resolve(sourcePath), '')
        .replace(path.basename(filename), '');
    if (subDir) {
        filePath = filePath.replace(subDir + path.sep, '');
    }
    if (/^[\/\\]/.test(filePath)) {
        filePath = filePath.substr(1);
    }
    return filePath.replace(/\\/g, '/');
}
19498
def get_filename(self, index):
        """"""
        if index:
            path = self.fsmodel.filePath(self.proxymodel.mapToSource(index))
            return osp.normpath(to_text_string(path))
1106319
def get_file_name(query):
	
	match = re.search(r'\S*\.[\d\w]{1,4}', query)
	if(match):
		filename = match.group()
		return filename
	else:
		start = match.start()
		end = match.end()
		spaces = re.finditer(r' ', query)
		space_index = []
		for space in spaces:
			space_index.append(space.start())
		space_index.pop()
		for i in space_index:
			filename = query[i+1:end]
			if(os.path.isfile(filename)):
				return filename
		return None