Return the expected result of an os.walk on the linkdir, based on the
        mountpoint value.
970987
def linkdir_walk(self):
        '''
        
        '''
        try:
            # Use cached linkdir_walk if we've already run this
            return self._linkdir_walk
        except AttributeError:
            self._linkdir_walk = []
            try:
                parts = self._mountpoint.split('/')
            except AttributeError:
                log.error(
                    '%s class is missing a \'_mountpoint\' attribute',
                    self.__class__.__name__
                )
            else:
                for idx, item in enumerate(parts[:-1]):
                    try:
                        dirs = [parts[idx + 1]]
                    except IndexError:
                        dirs = []
                    self._linkdir_walk.append((
                        salt.utils.path.join(self.linkdir, *parts[:idx + 1]),
                        dirs,
                        []
                    ))
                try:
                    # The linkdir itself goes at the beginning
                    self._linkdir_walk.insert(0, (self.linkdir, [parts[0]], []))
                except IndexError:
                    pass
            return self._linkdir_walk
723164
def p(self, path):
        
        if path.startswith("/"):
            path = path[1:]
        p = os.path.join(self.mount_point, path)
        logger.debug("path = %s", p)
        return p
96998
def mount(device, mountpoint, options=None, persist=False, filesystem="ext3"):
    """"""
    cmd_args = ['mount']
    if options is not None:
        cmd_args.extend(['-o', options])
    cmd_args.extend([device, mountpoint])
    try:
        subprocess.check_output(cmd_args)
    except subprocess.CalledProcessError as e:
        log('Error mounting {} at {}\n{}'.format(device, mountpoint, e.output))
        return False

    if persist:
        return fstab_add(device, mountpoint, filesystem, options=options)
    return True
569916
def walk_dir(dir_path, walk_after, recurse=None, archive_mtime=None):
    """"""
    if recurse is None:
        recurse = Settings.recurse

    result_set = set()
    if not recurse:
        return result_set

    for root, _, filenames in os.walk(dir_path):
        for filename in filenames:
            filename_full = os.path.join(root, filename)
            try:
                results = walk_file(filename_full, walk_after, recurse,
                                    archive_mtime)
                result_set = result_set.union(results)
            except Exception:
                print("Error with file: {}".format(filename_full))
                raise

    return result_set
168598
def _islinklike(dir_path):
    '''
    
    '''
    dir_path = ph.path(dir_path)
    if platform.system() == 'Windows':
        if dir_path.isjunction():
            return True
    elif dir_path.islink():
        return True
    return False
45723
def _build_mountpoint(self, volume):
        
        self.add_volume(self._build_volume(volume))
        return {
            'sourceVolume': self.path_to_name(volume.get('host')),
            'containerPath': volume.get('container')
        }
702469
def _os_walk(directory, recurse=True, **kwargs):
    
    if recurse:
        for root, dirs, files in os.walk(directory, **kwargs):
            yield root, dirs, files
    else:
        files = []
        for filename in os.listdir(directory):
            if os.path.isfile(os.path.join(directory, filename)):
                files.append(filename)
        yield directory, [], files
1253393
def chdir(self, dir, change_os_dir=0):
        
        curr=self._cwd
        try:
            if dir is not None:
                self._cwd = dir
                if change_os_dir:
                    os.chdir(dir.get_abspath())
        except OSError:
            self._cwd = curr
            raise
638322
def detect_mountpoint(self):
        

        if self.info.get('lastmountpoint'):
            return self.info.get('lastmountpoint')
        if not self.mountpoint:
            return None

        result = None
        paths = os.listdir(self.mountpoint)
        if 'grub' in paths:
            result = '/boot'
        elif 'usr' in paths and 'var' in paths and 'root' in paths:
            result = '/'
        elif 'bin' in paths and 'lib' in paths and 'local' in paths and 'src' in paths and 'usr' not in paths:
            result = '/usr'
        elif 'bin' in paths and 'lib' in paths and 'local' not in paths and 'src' in paths and 'usr' not in paths:
            result = '/usr/local'
        elif 'lib' in paths and 'local' in paths and 'tmp' in paths and 'var' not in paths:
            result = '/var'
        # elif sum(['bin' in paths, 'boot' in paths, 'cdrom' in paths, 'dev' in paths, 'etc' in paths, 'home' in paths,
        #          'lib' in paths, 'lib64' in paths, 'media' in paths, 'mnt' in paths, 'opt' in paths,
        #          'proc' in paths, 'root' in paths, 'sbin' in paths, 'srv' in paths, 'sys' in paths, 'tmp' in paths,
        #          'usr' in paths, 'var' in paths]) > 11:
        #    result = '/'

        if result:
            self.info['lastmountpoint'] = result
            if not self.info.get('label'):
                self.info['label'] = self.info['lastmountpoint']
            logger.info("Detected mountpoint as {0} based on files in volume".format(self.info['lastmountpoint']))

        return result
1264335
def sorted_walk(dir):
    
    for base, dirs, files in os.walk(dir):
        dirs.sort()
        files.sort()
        yield base, dirs, files
644460
def mkdir(self, tid, mode):

        

        pt = self.PathType.get(tid)

        if pt is self.PathType.invalid or pt is self.PathType.file:
            raise FuseOSError(errno.EPERM)

        if self.__exists(tid):
            raise FuseOSError(errno.EEXIST)

        try:
            dir_ent = YTActions(tid[0])
            dir_ent.updateResults()
        except ConnectionError:
            raise FuseOSError(errno.ENETDOWN)

        self.searches[tid[0]] = dir_ent # now adding directory entry is legit, nothing failed.

        return 0
665199
def TargetDirectory(ID, season, relative=False, **kwargs):
    '''
    

    '''

    if season is None:
        return None
    if relative:
        path = ''
    else:
        path = EVEREST_DAT
    return os.path.join(path, 'k2', 'c%02d' % season,
                        ('%09d' % ID)[:4] + '00000',
                        ('%09d' % ID)[4:])
460711
def mount_point(cls, file_path):
		
		mount = None

		for mp in cls.mounts():
			mp_path = mp.path()
			if file_path.startswith(mp_path) is True:
				if mount is None or len(mount.path()) <= len(mp_path):
					mount = mp

		return mount
977011
def mount(self):
        """"""
        if not self.is_mounted():
            # OS X mounting is handled automagically in /Volumes:
            # DO NOT mkdir there!
            # For Linux, ensure the mountpoint exists.
            if not is_osx():
                if not os.path.exists(self.connection["mount_point"]):
                    os.mkdir(self.connection["mount_point"])
            self._mount()
580888
def get_dev_at_mountpoint(mntpoint):
        
        results = util.subp(['findmnt', '-o', 'SOURCE', mntpoint])
        if results.return_code != 0:
            raise MountError('No device mounted at %s' % mntpoint)

        stdout = results.stdout.decode(sys.getdefaultencoding())
        return stdout.replace('SOURCE\n', '').strip().split('\n')[-1]
209184
def is_dir_url(link):
    # type: (Link) -> bool
    
    link_path = url_to_path(link.url_without_fragment)
    return os.path.isdir(link_path)
401527
def _is_target_a_directory(link, rel_target):
	
	target = os.path.join(os.path.dirname(link), rel_target)
	return os.path.isdir(target)