Raise warning.

        Parameters
        ----------
        filepath : path-like
            Given filepath.
        expected : string
            Expected file suffix.
2812
def warn(filepath, expected):
        
        filepath = pathlib.Path(filepath)
        message = "file {0} has type {1} (expected {2})".format(
            filepath, filepath.suffix, expected
        )
        warnings.warn(message, WrongFileTypeWarning)
960726
def get_file_extension(filepath):
    
    _ext = os.path.splitext(filepath)[-1]
    if _ext:
        return _ext[1:] if _ext.startswith('.') else _ext

    return ''
311054
def getNameFromPath(filePath):
    
    if len(filePath) == 0:
        raise ValueError("Cannot have empty path for name")
    fileName = os.path.split(os.path.normpath(filePath))[1]
    # We need to handle things like .fa.gz, so we can't use
    # os.path.splitext
    ret = fileName.split(".")[0]
    assert ret != ""
    return ret
307012
def parse_file_path(filepath):
    # type: (pathlib.Path) -> Tuple[str, str, str]
    
    if not isinstance(filepath, pathlib.Path):
        filepath = pathlib.Path(filepath)
    dirname = '/'.join(filepath.parts[:len(filepath.parts) - 1])
    if len(dirname) == 0:
        dirname = None
    if len(filepath.parts) > 0:
        fname = filepath.parts[-1]
    else:
        fname = None
    fname, snapshot = blobxfer.util.parse_fileshare_or_file_snapshot_parameter(
        fname)
    return (dirname, fname, snapshot)
600825
def get_file_suffix(self, path, prefix):
        
        parent = self._ensure_folder_path(path)

        file_list = self.drive.ListFile({
            'q': "'{}' in parents and trashed=false and title contains '{}'".format(
                parent['id'], prefix)}).GetList()
        try:
            number_of_files = len(file_list)
        except:
            number_of_files = 0
        return '{0:04}'.format(number_of_files)
1251161
private boolean validateFilePath(String filePath) {
        if (filePath == null || filePath.isEmpty()) {
            throw new IllegalArgumentException("filePath must be a valid filePath within the file system.");
        }

        // Check if the filename exists as a File -- use an absolute file to ensure we have
        // a parent: even if that parent is ${user.dir} ...
        File loc = new File(filePath).getAbsoluteFile();

        return (loc.exists() || loc.getParentFile().exists());
    }
98844
def get_file_suffix(self, path, prefix):
        
        try:
            number_of_files = len(glob.glob(os.path.join(path, prefix) + '*'))
        except:
            number_of_files = 0
        return '{0:04}'.format(number_of_files)
504500
public static String getFileName(String filePath) {
		if (filePath == null) {
			return filePath;
		}
		int index = filePath.lastIndexOf(File.separator);
		if (index == -1) {
			return filePath;
		}
		return filePath.substring(index + 1);
	}
895086
def relative_path(self, filepath, basepath=None):
        
        if basepath is None:
            basepath = self.basedir
        if not basepath:
            return filepath
        if filepath.startswith(basepath):
            rel = filepath[len(basepath):]
        if rel and rel[0] == os.sep:
            rel = rel[1:]
        return rel
557741
function (filePath) {
        var name = path.relative(this.opts.cwd, filePath);

        name = path.join(path.dirname(name), path.basename(name, this.opts.extension));

        return name;
    }
510631
def read_file(cls, filepath):
        
        with open(filepath, mode='rb') as f:
            contents = f.read()
        return cls.decode(contents)
7563
def identify_sep(filepath):
    
    ext = os.path.splitext(filepath)[1].lower()
    allowed_exts = ['.csv', '.txt', '.tsv']
    assert ext in ['.csv', '.txt'], "Unexpected file extension {}. \
                                    Supported extensions {}\n filename: {}".format(
                                    ext, allowed_exts, os.path.basename(filepath))
    maybe_seps = ['|',
                  ';',
                  ',',
                  '\t',
                  ':']

    with open(filepath,'r') as fp:
        header = fp.__next__()

    count_seps_header = {sep: _count(sep, header) for sep in maybe_seps}
    count_seps_header = {sep: count for sep,
                         count in count_seps_header.items() if count > 0}

    if count_seps_header:
        return max(count_seps_header.__iter__(),
                   key=(lambda key: count_seps_header[key]))
    else:
        raise Exception("Couldn't identify the sep from the header... here's the information:\n HEADER: {}\n SEPS SEARCHED: {}".format(header, maybe_seps))
786723
public static String getFilenameFromString(String filePath) {
        String newPath = filePath;

        int forwardInd = filePath.lastIndexOf("/");
        int backInd = filePath.lastIndexOf("\\");

        if (forwardInd > backInd) {
            newPath = filePath.substring(forwardInd + 1);
        } else {
            newPath = filePath.substring(backInd + 1);
        }

        // still original if no occurance of "/" or "\"
        return newPath;
    }
705436
def add_filepath(self, filepath, fullpath, copy=False):
        

        # Ignore directories
        if os.path.isdir(fullpath):
            return False

        # Ignore anything matching the ignore patterns
        for pattern in self.ignore:
            if fnmatch.fnmatch(os.path.basename(fullpath), pattern):
                return False

        if filepath not in self.data:
            self.data[filepath] = {}

        self.data[filepath]['fullpath'] = fullpath
        if 'hashes' not in self.data[filepath]:
            self.data[filepath]['hashes'] = {hash: None for hash in all_hashes}

        if copy:
            self.data[filepath]['copy'] = copy

        if hasattr(self, 'existing_filepaths'):
            if filepath in self.existing_filepaths:
                self.existing_filepaths.remove(filepath)

        return True
297450
def inflect(self, filename):
        
        suffix = ("/" if os.path.isdir(filename) else " ")
        return self._escape(filename) + suffix
1103063
def _get_fullpath(self, filepath):
        
        if filepath[0] == '/':
            return filepath
        return os.path.join(self._base_path, filepath)
54517
public static String getPathFromString(String filePath) {
        String newPath = filePath;

        int forwardInd = filePath.lastIndexOf("/");
        int backInd = filePath.lastIndexOf("\\");

        if (forwardInd > backInd) {
            newPath = filePath.substring(0, forwardInd + 1);
        } else {
            newPath = filePath.substring(0, backInd + 1);
        }

        // still original if no occurance of "/" or "\"
        return newPath;
    }