Return the real wanted path (relative to the INGInious root) or None if the path is not valid/allowed
178330
def verify_path(self, courseid, taskid, path, new_path=False):
        
        task_fs = self.task_factory.get_task_fs(courseid, taskid)
        # verify that the dir exists
        if not task_fs.exists():
            return None

        # all path given to this part of the application must start with a "/", let's remove it
        if not path.startswith("/"):
            return None
        path = path[1:len(path)]

        if ".." in path:
            return None

        if task_fs.exists(path) == new_path:
            return None

        # do not allow touching the task.* file
        if os.path.splitext(path)[0] == "task" and os.path.splitext(path)[1][1:] in \
                self.task_factory.get_available_task_file_extensions():
            return None

        # do not allow hidden dir/files
        if path != ".":
            for i in path.split(os.path.sep):
                if i.startswith("."):
                    return None
        return path
93037
def _to_relative_path(self, path):
        """"""
        if not osp.isabs(path):
            return path
        if self.repo.bare:
            raise InvalidGitRepositoryError("require non-bare repository")
        if not path.startswith(self.repo.working_tree_dir):
            raise ValueError("Absolute path %r is not in git repository at %r" % (path, self.repo.working_tree_dir))
        return os.path.relpath(path, self.repo.working_tree_dir)
1040190
def GetRealPath(filename):
  
  if os.path.isabs(filename):                # already absolute
    return filename

  if filename.startswith('./') or  filename.startswith('../'): # relative
    return os.path.abspath(filename)

  path = os.getenv('PATH', '')
  for directory in path.split(':'):
    tryname = os.path.join(directory, filename)
    if os.path.exists(tryname):
      if not os.path.isabs(directory):  # relative directory
        return os.path.abspath(tryname)
      return tryname
  if os.path.exists(filename):
    return os.path.abspath(filename)
  return None
167128
def safeRmTree(rootPath):
        
        shutil.rmtree(rootPath, True)

        return not os.path.exists(rootPath)
443483
def pretty_relpath(path, start):
    '''
    
    '''
    relpath = os.path.relpath(path, start)
    if relpath.startswith('..'):
        return path
    return relpath
119925
def existing_subpath(root_path, valid_subpaths, tiebreaker='first',
                     verbose=VERYVERBOSE):
    
    # Find the oxford_style groundtruth directory
    for subpath in valid_subpaths:
        path  = join(root_path, subpath)
        if checkpath(path, verbose=verbose):
            if tiebreaker == 'first':
                return path
    raise AssertionError('none of the following subpaths exist: %r' %
                         (valid_subpaths,))
981205
def relpath(self, path):
        
        return os.path.relpath(path, start=self.path)
308071
def root_dir(relpath)
      r = relpath.match(%r(^[/]?.+?[/$]))
      return relpath if r.nil?
      r[0] || relpath
    end
31787
def find(self, path, all=False):
        '''
        
        '''
        found = os.path.join(settings.STATIC_ROOT, path)
        if all:
            return [found]
        else:
            return found
215098
def archive_path(self, real_path):
        
        if (not self.path_prefix):
            return(real_path)
        else:
            return(os.path.relpath(real_path, self.path_prefix))
41772
def make_relative_to_root(path):
  """"""
  return os.path.normpath(path.format(pex_root=ENV.PEX_ROOT))
588962
def __root_path(self):
        
        if self.root_path is not None:
            if os.path.isdir(self.root_path):
                sys.path.append(self.root_path)
                return
            raise RuntimeError('EverNode requires a valid root path.'
                               ' Directory: %s does not exist'
                               % (self.root_path))
1018045
def path(self, path):
        
        if os.path.isabs(path):
            return path
        return os.path.join(self.location, path)
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
1278378
def resource_path(relative):
    """"""
    if hasattr(sys, "_MEIPASS"):
        return os.path.join(sys._MEIPASS, relative)
    return os.path.join(relative)
889395
def GetRootFileEntry(self):
    
    path_spec = fake_path_spec.FakePathSpec(location=self.LOCATION_ROOT)
    return self.GetFileEntryByPathSpec(path_spec)
1290092
def path(self, which=None):
        
        if which == 'clone':
            return '{0}/{1}'.format(
                super(Role, self).path(which='self'),
                which
            )
        return super(Role, self).path(which)