Strip leading directory name from the given path
168343
def _strip_leading_dirname(self, path):
        ''''''
        return os.path.sep.join(path.split(os.path.sep)[1:])
959288
function(filepath) {
    var pieces = _.last(filepath.split('/')).split('.');
    var name   = _(pieces).without(_.last(pieces)).join('.'); // strips file extension
    if (name.charAt(0) === '_') {
      name = name.substr(1, name.length); // strips leading _ character
    }
    return name;
  }
598748
def trim_path(path, length=30):
    
    s = path.replace('\\', '/').split('/')
    t = -1
    for i in range(len(s)-1, -1, -1):
        t = len(s[i]) + t + 1
        if t > length-4:
            break
    return '.../' + '/'.join(s[i+1:])
610830
static String stripLeadingSlash(String path) {
        if (path.endsWith("/")) {
            return path.substring(0, path.length() - 1);
        } else {
            return path;
        }
    }
115917
def dirname(self, path):
        """"""
        if self.is_ssh(path):
            remotepath = self._get_remote(path)
            remotedir = os.path.dirname(remotepath)
            return self._get_tramp_path(remotedir)
        else:
            return os.path.dirname(path)
471453
def clean_py_files(path):
    

    for dirname, subdirlist, filelist in os.walk(path):

        for f in filelist:
            if f.endswith('py'):
                os.remove(os.path.join(dirname, f))
178627
function (path) {
                //There has to be an easier way to do this.
                var i, part, ary,
                    firstChar = path.charAt(0);

                if (firstChar !== '/' &&
                        firstChar !== '\\' &&
                        path.indexOf(':') === -1) {
                    //A relative path. Use the current working directory.
                    path = xpcUtil.cwd() + '/' + path;
                }

                ary = path.replace(/\\/g, '/').split('/');

                for (i = 0; i < ary.length; i += 1) {
                    part = ary[i];
                    if (part === '.') {
                        ary.splice(i, 1);
                        i -= 1;
                    } else if (part === '..') {
                        ary.splice(i - 1, 2);
                        i -= 2;
                    }
                }
                return ary.join('/');
            }
572860
def clean_tmpdir(path):
    """"""
    if os.path.exists(path) and \
       os.path.isdir(path):
        rmtree(path)
433582
def filter_paths(pathnames, patterns=None, ignore_patterns=None):
    """"""
    result = []
    if patterns is None:
        patterns = ['*']
    if ignore_patterns is None:
        ignore_patterns = []
    for pathname in pathnames:
        if match_patterns(pathname, patterns) and not match_patterns(pathname, ignore_patterns):
            result.append(pathname)
    return result
697137
def get_name_from_path(full_path, root_path):
    """"""
    relative_image_path = os.path.relpath(full_path, root_path)
    return "_".join(relative_image_path.split('.')[:-1]).replace('/', '_')\
        .replace(';', '').replace(':', '')
1085244
def generic_filename(path):
    '''
    
    '''

    for sep in common_path_separators:
        if sep in path:
            _, path = path.rsplit(sep, 1)
    return path
942267
function getFileName(path) {
		var re = /([\w\.\-]+)$/i;
		var m = re.exec(path);
		return m ? m[1] : '';
	}
138171
def clean_path(root, path, subdir=False):
    '''
    
    '''
    if not os.path.isabs(root):
        return ''
    if not os.path.isabs(path):
        path = os.path.join(root, path)
    path = os.path.normpath(path)
    if subdir:
        if path.startswith(root):
            return path
    else:
        if os.path.dirname(path) == os.path.normpath(root):
            return path
    return ''
1131487
def replace_d(self, path, arg_name=None):
        
        root, dir = os.path.split(path)
        pattern = re.compile(r'(\[\[)([A-Za-z_]+)(\]\])')
        for (o, var_name, c) in re.findall(pattern, dir):
            dir = self.handle_args(dir, var_name, arg_name, isfilename=True)
        os.rename(path, os.path.join(root, dir))
1324798
def parsePathname(self, pathname):
        
        if os.path.isdir(pathname):
            for root, dirs, files in os.walk(pathname):
                dirs.sort()
                files.sort()
                for fn in files:
                    # ignore emacsish junk
                    if fn.endswith('.py') and not fn.startswith('.#'):
                        self.parseFile(os.path.join(root, fn))
        elif pathname.endswith('.importcache'):
            self.readCache(pathname)
        else:
            self.parseFile(pathname)
1142076
private static String getTrimmedPath(String path) {
        String result = path;
        if (result.endsWith("/")) {
            result = result.substring(0, result.length() - 1);
        }
        return result;
    }
1243817
def strip_chroot_from(path)
    return path unless (chrooted? and path and path.start_with?(chroot_path))
    path[chroot_path.length..-1]
  end