Expand any '~', '.', '*' variables in filepath.

    See also: pugnlp.futil.expand_path

    >>> len(expand_filepath('~')) > 3
    True
327814
def expand_filepath(filepath):
    
    return os.path.abspath(os.path.expandvars(os.path.expanduser(filepath)))
1338239
def expand_defaults(self, client=False, getenv=True, getshell=True):
        
        if not isinstance(self._default, six.string_types):
            self.expanded_default = self._default
        else:
            self.expanded_default = coerce(self.type, expand_defaults(
                self._default, client, getenv, getshell))
230990
def replace_ext(file_path, ext):
        '''  '''
        if not file_path:
            raise Exception("File path cannot be empty")
        dirname = os.path.dirname(file_path)
        filename = FileHelper.getfilename(file_path)
        if ext:
            filename = filename + '.' + ext
        return os.path.join(dirname, filename)
1199599
def add_suffix(file_path, suffix='modified', sep='_', ext=None):
    """"""
    return _add_suffix(file_path, suffix, sep, ext)
201434
def clean_path(p):
    
    p = os.path.expanduser(p)
    p = os.path.expandvars(p)
    p = os.path.abspath(p)
    return p
376832
def match(self, filepath):
        
        # no extension?
        if filepath.find(".") == -1:
            return False

        # match extension
        return filepath.lower().split(".")[-1] in self.__extensions
37598
def fully_expanded_path(self):
        
        return os.path.abspath(
            os.path.normpath(
                os.path.normcase(
                    os.path.expandvars(
                        os.path.expanduser(self.path)))))
1099622
def expand_source_paths(paths):
    
    for src_path in paths:
        # only track the source path if we can find it to avoid double-reloads
        # when the source and the compiled path change because on some
        # platforms they are not changed at the same time
        if src_path.endswith(('.pyc', '.pyo')):
            py_path = get_py_path(src_path)
            if os.path.exists(py_path):
                src_path = py_path
        yield src_path
960726
def get_file_extension(filepath):
    
    _ext = os.path.splitext(filepath)[-1]
    if _ext:
        return _ext[1:] if _ext.startswith('.') else _ext

    return ''
901319
def expand_magic_path(aPath,aBasePath=nil)
			aBasePath ||= Dir.pwd
			path = aPath
			if path.begins_with?('...')
				rel_part = path.split3(/\.\.\.[\/\\]/)[2]
				return find_upwards(aBasePath,rel_part)
			end
			path_combine(aBasePath,aPath)
		end
867630
function expand(input, options, next) {
  var cwd = options.cwd
  var paths = []
  var actual = 0
  var expected = 0
  var failed

  input.forEach(each)

  if (!expected) {
    search(paths, options, done)
  }

  function each(file) {
    if (string(file)) {
      if (magic(file)) {
        expected++
        glob(file, {cwd: cwd}, one)
      } else {
        /* `relative` to make the paths canonical. */
        file = relative(cwd, resolve(cwd, file)) || '.'
        paths.push(file)
      }
    } else {
      file.cwd = cwd
      file.path = relative(cwd, file.path)
      file.history = [file.path]
      paths.push(file)
    }
  }

  function one(error, files) {
    /* istanbul ignore if - glob errors are unusual. */
    if (failed) {
      return
    }

    /* istanbul ignore if - glob errors are unusual. */
    if (error) {
      failed = true
      done(error)
    } else {
      actual++
      paths = paths.concat(files)

      if (actual === expected) {
        search(paths, options, done)
      }
    }
  }

  function done(error, files) {
    /* istanbul ignore if - `search` currently does not give errors. */
    if (error) {
      next(error)
    } else {
      next(null, {input: paths, output: files})
    }
  }
}
621062
def make_readable_path(path):
    """"""
    home = os.path.expanduser("~")
    if path.startswith(home):
        path = "~" + path[len(home):]

    return path
1270691
def prepend_path_variable_command(variable, paths):
    
    assert isinstance(variable, basestring)
    assert is_iterable_typed(paths, basestring)
    return path_variable_setting_command(
        variable, paths + [expand_variable(variable)])
60718
def expanduser(path):
    """"""
    if path[:1] != '~':
        return path
    i, n = 1, len(path)
    while i < n and path[i] not in '/\\':
        i = i + 1

    if 'HOME' in os.environ:
        userhome = os.environ['HOME']
    elif 'USERPROFILE' in os.environ:
        userhome = os.environ['USERPROFILE']
    elif not 'HOMEPATH' in os.environ:
        return path
    else:
        try:
            drive = os.environ['HOMEDRIVE']
        except KeyError:
            drive = ''
        userhome = join(drive, os.environ['HOMEPATH'])

    if i != 1:  # ~user
        userhome = join(dirname(userhome), path[1:i])

    return userhome + path[i:]
578941
def expand(directory: str) -> str:
    """"""
    temp1 = os.path.expanduser(directory)
    return os.path.expandvars(temp1)
499312
def expand_filenames(self, filenames):
        
        results = []
        for filename in filenames:
            result = filename
            if "$" in filename:
                template = Template(filename)
                result = template.substitute(**self.environment)
                logging.debug(
                    "Expanding {} to {}.".format(filename, result))
            if any([pattern in result for pattern in "*[]?"]):
                expanded = glob.glob(result)
                if len(expanded) > 0:
                    result = expanded
                else:
                    result = "NONEXISTENT"
            if isinstance(result, list):
                results.extend(result)
            else:
                results.append(result)
        return sorted(list(set(results)))
761558
def format_path(p, quote_spaces=False):
    """"""
    if b'\n' in p:
        p = re.sub(b'\n', b'\\n', p)
        quote = True
    else:
        quote = p[0] == b'"' or (quote_spaces and b' ' in p)
    if quote:
        extra = GIT_FAST_IMPORT_NEEDS_EXTRA_SPACE_AFTER_QUOTE and b' ' or b''
        p = b'"' + p + b'"' + extra
    return p