Format the path =============== d:/aaa.txt ==> d:\\aaa.txt ./bb.txt ==> {base}\\bb.txt cc.txt ==> {base}\\cc.txt
484027
function (base, p) {
		var r = "";
		if (p[1] === ":" || p[0] === "/") {
			r = path.normalize(p);
		} else {
			r = path.join(base, p);
		}
		return r;
	}
1121682
def __format_path(self, path):
        
        # Unicode strings are converted back to strings, because it seems
        # that inotify_add_watch from ctypes does not work well when
        # it receives an ctypes.create_unicode_buffer instance as argument.
        # Therefore even wd are indexed with bytes string and not with
        # unicode paths.
        if isinstance(path, unicode):
            path = path.encode(sys.getfilesystemencoding())
        return os.path.normpath(path)
83942
def format_file_path(filepath):
    """"""

    try:
        is_windows_network_mount = WINDOWS_NETWORK_MOUNT_PATTERN.match(filepath)
        filepath = os.path.realpath(os.path.abspath(filepath))
        filepath = re.sub(BACKSLASH_REPLACE_PATTERN, '/', filepath)
        is_windows_drive = WINDOWS_DRIVE_PATTERN.match(filepath)
        if is_windows_drive:
            filepath = filepath.capitalize()
        if is_windows_network_mount:
            # Add back a / to the front, since the previous modifications
            # will have replaced any double slashes with single
            filepath = '/' + filepath
    except:
        pass
    return filepath
646769
def format_key_for_backend(self, key, remove_slash_prefix=False, trailing_slash=False):
        """"""
        path = self.prefix + key
        if trailing_slash:
            if not path or path[-1] != "/":
                path += "/"
        else:
            path = path.rstrip("/")
        if remove_slash_prefix:  # Azure defines slashes in the beginning as "dirs" for listing purposes
            path = path.lstrip("/")
        return path
1368373
private String normalizePath(String path) {
		// remove double slashes & backslashes
		path = path.replace("//", "/");
		path = path.replace("\\", "/");

		return path;
	}
36050
def shorten_path(location, bold=False):
    """"""
    original = location
    short = os.sep.join(
        [s[0] if len(s) > (len("2long4")) else s for s in location.split(os.sep)]
    )
    short = short.split(os.sep)
    short[-1] = original.split(os.sep)[-1]
    if bold:
        short[-1] = str(crayons.normal(short[-1], bold=True))
    return os.sep.join(short)
425150
function formatPathname(urlobj)
{
	var pathname = joinDirs(urlobj.extra.directory, urlobj.extra.directoryLeadingSlash);
	
	if (urlobj.extra.filename !== null)
	{
		pathname += urlobj.extra.filename;
	}
	
	return pathname;
}
1010646
def pyfile_path(path):
    
    if "/" in path:
        parts = path.split("/")
        join_term = "/"
    elif "\\" in path:
        parts =path.split("\\")
        join_term = "\\"
    parts.reverse()
    base = parts[:parts.index('rdfframework')]
    base.reverse()
    return join_term.join(base)
766785
function formatAsElegantPath(path, sep) {
    const chalk = require('chalk');
    const packages = path.split(sep);
    const lastIndex = packages.length - 1;

    // prettier-ignore
    const result = packages
        .map((item) => item.trim())
        .map((item, index) => {
            return index === lastIndex
                ? chalk.red.bold(item)
                : item;
        })
        .join(' -> ');
    return result;
}
138392
function strip(path) {
    var cur;
    var next;
    var str = '';

    for (var i = 0; i < path.length; i++) {
        cur = path.charAt(i);

        if (i !== path.length - 1) {
            next = path.charAt(i + 1);
        }

        if (cur === '/' && (next === '/' || (next === '?' && i > 0))) {
            continue;
        }

        str += cur;
    }

    return (str);
}
851457
function (path) {
                var absolute = path.charAt(0) === '/', trailingSlash = path.slice(0 - 1) === '/';
                path = normalizeArray(splitPathToArray(path), !absolute).join('/');
                if (!path && !absolute) {
                    path = '.';
                }
                if (path && trailingSlash) {
                    path += '/';
                }
                return (absolute ? '/' : '') + path;
            }
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
271150
function format() {
  var args = Array.prototype.slice.call(arguments);
  var pathname = [];
  var parsedUrl = {};
  var pathName = '';
  var options;

  // Looking for paths and options
  args.forEach(function (arg, key) {

    // Find a path
    if(_.isString(arg)) {

      // First may contains the host
      if(key === 0) {
        parsedUrl = url.parse(arg);

        if (parsedUrl.pathname[0] && parsedUrl.pathname[0][0] === '/') {
          pathName = '/';
        }

        pathname.push.apply(pathname, parsedUrl.pathname.split('/'));

        return;
      }

      pathname.push.apply(pathname, arg.split('/'));
    }

    // Find the option
    else if (_.isObject(arg)) {
      options = arg;
    }
  });

  options = options || {};

  // Path params
  options.param = options.param || {};

  pathname = pathname.map(function (path) {
    if(path.charAt(0) === ':' && options.param[path.substring(1)]) {
      return options.param[path.substring(1)];
    }

    return path;
  });

  pathName += path.join.apply(path, pathname);
  parsedUrl.pathname = pathName;

  // Merge with options
  parsedUrl = _.merge(parsedUrl, options);

  return url.format(parsedUrl);
}
884103
public static final String formatPath(String path) {
		if (path == null) {
			return "";
		}
		path = path.trim();
		if (path.isEmpty()) {
			return path;
		}
		if (!path.startsWith("/")) {
			path = '/' + path;
		}
		while (path.endsWith("/")) {
			path = path.substring(0, path.length() - 1);
		}
		return path;
	}
839089
def _formatFilepaths(self):
        
        likedir=self['output']['likedir']
        self.likefile  = join(likedir,self['output']['likefile'])
        self.mergefile = join(likedir,self['output']['mergefile'])
        self.roifile   = join(likedir,self['output']['roifile'])

        searchdir=self['output']['searchdir']
        self.labelfile  = join(searchdir,self['output']['labelfile'])
        self.objectfile = join(searchdir,self['output']['objectfile'])
        self.assocfile  = join(searchdir,self['output']['assocfile'])
        self.candfile   = join(searchdir,self['output']['candfile'])

        mcmcdir=self['output']['mcmcdir']
        self.mcmcfile   = join(mcmcdir,self['output']['mcmcfile'])
673205
private String getBasePath(String path1, String path2) {

        StringBuffer base = new StringBuffer();
        path1 = path1.replace('\\', '/');
        path2 = path2.replace('\\', '/');

        String[] parts1 = path1.split("/");
        String[] parts2 = path2.split("/");

        for (int i = 0; i < parts1.length; i++) {
            if (i >= parts2.length) {
                break;
            }
            if (parts1[i].equals(parts2[i])) {
                base.append(parts1[i] + "/");
            }
        }

        return base.toString();
    }
790503
function relativePath(file, pattern) {
    var length = file.length,
        x;

    pattern = path.normalize(pattern);
    file = path.normalize(file);

    for (x = 0; x < length; x += 1) {
        if (file[x] !== pattern[x]) {
            return file.substr(x);
        }
    }

    return path.basename(file);
}