Return the root of the directory corresponding to the desired environment,
    or None if the environment was not found.
11202
def _env_root(repo, saltenv):
    '''
    
    '''
    # If 'base' is desired, look for the trunk
    if saltenv == 'base':
        trunk = os.path.join(repo['repo'], repo['trunk'])
        if os.path.isdir(trunk):
            return trunk
        else:
            return None

    # Check branches
    branches = os.path.join(repo['repo'], repo['branches'])
    if os.path.isdir(branches) and saltenv in os.listdir(branches):
        return os.path.join(branches, saltenv)

    # Check tags
    tags = os.path.join(repo['repo'], repo['tags'])
    if os.path.isdir(tags) and saltenv in os.listdir(tags):
        return os.path.join(tags, saltenv)

    return None
1193383
def path_for(self, *args):
        """"""
        if args and args[0].startswith(os.path.sep):
            return os.path.join(*args)
        return os.path.join(self._root_path or os.getcwd(), *args)
11269
def cwd():
    """"""
    cwd = os.environ.get("BE_CWD")
    if cwd and not os.path.isdir(cwd):
        sys.stderr.write("ERROR: %s is not a directory" % cwd)
        sys.exit(lib.USER_ERROR)
    return cwd or os.getcwd().replace("\\", "/")
510067
def _get_parent(self):
        """"""
        _dir = os.path.dirname(self.path)
        if is_repo(_dir):
            return Local(_dir)
        else:
            return None
757167
def find_root(self):
        
        cmd = self
        while cmd.parent:
            cmd = cmd.parent
        return cmd
1103188
def path(self):
    """"""
    if self._root_dir is None:
      # This env variable is for testing purpose.
      override_buildroot = os.environ.get('PANTS_BUILDROOT_OVERRIDE', None)
      if override_buildroot:
        self._root_dir = override_buildroot
      else:
        self._root_dir = os.path.realpath(self.find_buildroot())
      if PY2:
        self._root_dir = self._root_dir.decode('utf-8')
    return self._root_dir
41772
def make_relative_to_root(path):
  """"""
  return os.path.normpath(path.format(pex_root=ENV.PEX_ROOT))
1322
def get_root_folder():
    
    locations = {
     'linux':{'hme':'/home/duncan/', 'core_folder':'/home/duncan/dev/src/python/AIKIF'},
     'win32':{'hme':'T:\\user\\',    'core_folder':'T:\\user\\dev\\src\\python\\AIKIF'},
     'cygwin':{'hme':os.getcwd() + os.sep,    'core_folder':os.getcwd()},
     'darwin':{'hme':os.getcwd() + os.sep,    'core_folder':os.getcwd()}
    }
    hme = locations[sys.platform]['hme']
    core_folder = locations[sys.platform]['core_folder']

    if not os.path.exists(core_folder):
        hme = os.getcwd()        
        core_folder = os.getcwd()
        print('config.py : running on CI build (or you need to modify the paths in config.py)')
    return hme, core_folder
663424
def get_system_root_directory():
    
    root = os.path.dirname(__file__)
    root = os.path.dirname(root)
    root = os.path.abspath(root)
    return root
56234
def __get_rc_handle(self, root_dir):
        
        rc_path = os.path.join(root_dir, '.rc')
        env_path = os.path.join(root_dir, '.env')
        fh = open(rc_path, "w+")
        # .rc will always source .env
        fh.write(source_template % (env_path, env_path))
        return (rc_path, fh)
669860
def check_root(self):
        '''
        
        '''
        # No need to pass an environment to self.root() here since per-saltenv
        # configuration is a gitfs-only feature and check_root() is not used
        # for gitfs.
        root_dir = salt.utils.path.join(self.cachedir, self.root()).rstrip(os.sep)
        if os.path.isdir(root_dir):
            return root_dir
        log.error(
            'Root path \'%s\' not present in %s remote \'%s\', '
            'skipping.', self.root(), self.role, self.id
        )
        return None
912933
def get_parent_folder(self):
        
        if self.root:
            return None
        if self.parent:
            return self.parent

        if self.parent_id:
            self.parent = self.get_folder(folder_id=self.parent_id)
        return self.parent
964654
def _get_userdir(user=None):
    """"""

    if user is not None and not isinstance(user, fsnative):
        raise TypeError

    if is_win:
        if "HOME" in environ:
            path = environ["HOME"]
        elif "USERPROFILE" in environ:
            path = environ["USERPROFILE"]
        elif "HOMEPATH" in environ and "HOMEDRIVE" in environ:
            path = os.path.join(environ["HOMEDRIVE"], environ["HOMEPATH"])
        else:
            return

        if user is None:
            return path
        else:
            return os.path.join(os.path.dirname(path), user)
    else:
        import pwd

        if user is None:
            if "HOME" in environ:
                return environ["HOME"]
            else:
                try:
                    return path2fsn(pwd.getpwuid(os.getuid()).pw_dir)
                except KeyError:
                    return
        else:
            try:
                return path2fsn(pwd.getpwnam(user).pw_dir)
            except KeyError:
                return
41001
def root_dir(self):
        
        if self.cfg.script:
            return os.path.dirname(self.cfg.script)
773758
def find_vcs_root(path, dirs=(".git",)):
    """"""
    prev, path = None, os.path.abspath(path)
    while prev != path:
        if any(os.path.exists(os.path.join(path, d)) for d in dirs):
            return path
        prev, path = path, os.path.abspath(os.path.join(path, os.pardir))
    return None
676053
def get_parent_dir(name):
    """"""
    parent_dir = os.path.dirname(os.path.dirname(name))
    if parent_dir:
        return parent_dir
    return os.path.abspath('.')
246039
def get_pwd
      return Dir.pwd if ENV['PWD'].nil?
      env_stat = File.stat(ENV['PWD'])
      pwd_stat = File.stat(Dir.pwd)
      if env_stat.ino == pwd_stat.ino && env_stat.dev == pwd_stat.dev
        ENV['PWD']
      else
        Dir.pwd
      end
    end