platform specific default root path.
343366
def arduino_default_path():
    """"""
    if sys.platform == 'darwin':
        s = path('/Applications/Arduino.app/Contents/Resources/Java')
    elif sys.platform == 'win32':
        s = None
    else:
        s = path('/usr/share/arduino/')
    return s
1262785
def get_root_path(self, path):
        """"""
        # Look at the directories present in the current working directory. In
        # case a .svn directory is present, we know we are in the root directory
        # of a Subversion repository (for Subversion 1.7.x). In case no
        # repository specific folder is found, and the current directory has a
        # parent directory, look if a repository specific directory can be found
        # in the parent directory.
        while path != '/':
            if '.svn' in os.listdir(path):
                return path
            path = os.path.abspath(os.path.join(path, os.pardir))

        # No Subversion repository found.
        return None
1016590
def prepend_root_dir(opts, path_options):
    '''
    
    '''
    root_dir = os.path.abspath(opts['root_dir'])
    def_root_dir = salt.syspaths.ROOT_DIR.rstrip(os.sep)
    for path_option in path_options:
        if path_option in opts:
            path = opts[path_option]
            tmp_path_def_root_dir = None
            tmp_path_root_dir = None
            # When running testsuite, salt.syspaths.ROOT_DIR is often empty
            if path == def_root_dir or path.startswith(def_root_dir + os.sep):
                # Remove the default root dir prefix
                tmp_path_def_root_dir = path[len(def_root_dir):]
            if root_dir and (path == root_dir or
                             path.startswith(root_dir + os.sep)):
                # Remove the root dir prefix
                tmp_path_root_dir = path[len(root_dir):]
            if tmp_path_def_root_dir and not tmp_path_root_dir:
                # Just the default root dir matched
                path = tmp_path_def_root_dir
            elif tmp_path_root_dir and not tmp_path_def_root_dir:
                # Just the root dir matched
                path = tmp_path_root_dir
            elif tmp_path_def_root_dir and tmp_path_root_dir:
                # In this case both the default root dir and the override root
                # dir matched; this means that either
                # def_root_dir is a substring of root_dir or vice versa
                # We must choose the most specific path
                if def_root_dir in root_dir:
                    path = tmp_path_root_dir
                else:
                    path = tmp_path_def_root_dir
            elif salt.utils.platform.is_windows() and not os.path.splitdrive(path)[0]:
                # In windows, os.path.isabs resolves '/' to 'C:\\' or whatever
                # the root drive is.  This elif prevents the next from being
                # hit, so that the root_dir is prefixed in cases where the
                # drive is not prefixed on a config option
                pass
            elif os.path.isabs(path):
                # Absolute path (not default or overridden root_dir)
                # No prepending required
                continue
            # Prepending the root dir
            opts[path_option] = salt.utils.path.join(root_dir, path)
558762
def localpath(*args):
    """"""
    plist = [ROOT] + list(args)
    return os.path.abspath(pjoin(*plist))
1320703
def _get_default_leveldb_path() -> str:
        
        system = platform.system().lower()
        leveldb_fallback_dir = os.path.expanduser("~")
        if system.startswith("darwin"):
            leveldb_fallback_dir = os.path.join(
                leveldb_fallback_dir, "Library", "Ethereum"
            )
        elif system.startswith("windows"):
            leveldb_fallback_dir = os.path.join(
                leveldb_fallback_dir, "AppData", "Roaming", "Ethereum"
            )
        else:
            leveldb_fallback_dir = os.path.join(leveldb_fallback_dir, ".ethereum")
        return os.path.join(leveldb_fallback_dir, "geth", "chaindata")
647880
def _get_library_root_key_for_os_path(self, path):
        """"""
        path = os.path.realpath(path)
        library_root_key = None
        for library_root_key, library_root_path in self._library_root_paths.items():
            rel_path = os.path.relpath(path, library_root_path)
            if rel_path.startswith('..'):
                library_root_key = None
                continue
            else:
                break
        return library_root_key
1347980
def configuration_get_default_folder():
    
    system = platform.system()
    if system == 'Linux':
        # https://specifications.freedesktop.org/basedir-spec/basedir-spec-latest.html
        sys_config_path = Path(os.getenv('XDG_CONFIG_HOME', os.path.expanduser("~/.config")))
    elif system == 'Windows':
        sys_config_path = Path(os.getenv('APPDATA', ''))
    else:
        log.error('Unknown system: "{system}" (using default configuration path)'.format(system=system))
        sys_config_path = Path()
    log.debug('User-specific system configuration folder="{sys_config_path}"'.format(
        sys_config_path=sys_config_path))
    sys_config = sys_config_path / PROJECT_TITLE
    log.debug('User-specific {project} configuration folder="{sys_config}"'.format(
        project=PROJECT_TITLE, sys_config=sys_config))
    return sys_config
1110712
def get_root_path():
    """"""
    root_path = __file__
    return os.path.dirname(os.path.realpath(root_path))
823017
def _default_runlevel():
    '''
    
    '''
    # Try to get the "main" default.  If this fails, throw up our
    # hands and just guess "2", because things are horribly broken
    try:
        with salt.utils.files.fopen('/etc/init/rc-sysinit.conf') as fp_:
            for line in fp_:
                line = salt.utils.stringutils.to_unicode(line)
                if line.startswith('env DEFAULT_RUNLEVEL'):
                    runlevel = line.split('=')[-1].strip()
    except Exception:
        return '2'

    # Look for an optional "legacy" override in /etc/inittab
    try:
        with salt.utils.files.fopen('/etc/inittab') as fp_:
            for line in fp_:
                line = salt.utils.stringutils.to_unicode(line)
                if not line.startswith('#') and 'initdefault' in line:
                    runlevel = line.split(':')[1]
    except Exception:
        pass

    # The default runlevel can also be set via the kernel command-line.
    # Kinky.
    try:
        valid_strings = set(
            ('0', '1', '2', '3', '4', '5', '6', 's', 'S', '-s', 'single'))
        with salt.utils.files.fopen('/proc/cmdline') as fp_:
            for line in fp_:
                line = salt.utils.stringutils.to_unicode(line)
                for arg in line.strip().split():
                    if arg in valid_strings:
                        runlevel = arg
                        break
    except Exception:
        pass

    return runlevel
1339829
def file_path(self):
        
        return os.path.join(keyring.util.platform.data_root(), self.filename)
437444
def _get_filesystem_path(self, url_path, basedir=settings.MEDIA_ROOT):
        """"""

        if url_path.startswith(settings.MEDIA_URL):
            url_path = url_path[len(settings.MEDIA_URL):]  # strip media root url

        return os.path.normpath(os.path.join(basedir, url2pathname(url_path)))
1276051
def root(path: Union[str, pathlib.Path]) -> _Root:
    
    return _Root.from_path(_normalise_path(path))
1332283
def default_config_filename(root_dir=None):
        
        root_dir = Path(root_dir) if root_dir else Path('.').abspath()
        locale_dir = root_dir / 'locale'
        if not os.path.exists(locale_dir):
            locale_dir = root_dir / 'conf' / 'locale'
        return locale_dir / BASE_CONFIG_FILENAME
226108
def set_root_path(self, root_path=None, settings_module=None):
        
        if root_path:
            self.root_path = root_path
            return

        if settings_module:
            self.root_path = os.path.dirname(os.path.abspath(settings_module.__file__))
            return

        # try to guess which module import app.py
        import inspect

        caller = inspect.stack()[1]
        caller_module = inspect.getmodule(caller[0])
        assert hasattr(caller_module, '__file__'), 'Caller module %s should have __file__ attr' % caller_module
        self.root_path = os.path.dirname(os.path.abspath(caller_module.__file__))
672356
def find_root_with_flag(flag, default=nil)
      root_path = self.called_from[0]

      while root_path && ::File.directory?(root_path) && !::File.exist?("#{root_path}/#{flag}")
        parent = ::File.dirname(root_path)
        root_path = parent != root_path && parent
      end

      root = ::File.exist?("#{root_path}/#{flag}") ? root_path : default
      raise "Could not find root path for #{self}" unless root

      RbConfig::CONFIG['host_os'] =~ /mswin|mingw/ ?
      Pathname.new(root).expand_path : Pathname.new(root).realpath
    end
844474
def abspath(*path):
    """"""
    setup_dir = os.path.dirname(os.path.abspath(__file__))
    return os.path.join(setup_dir, *path)
410694
def insert_system_path(opts, paths):
    '''
    
    '''
    if isinstance(paths, six.string_types):
        paths = [paths]
    for path in paths:
        path_options = {'path': path, 'root_dir': opts['root_dir']}
        prepend_root_dir(path_options, path_options)
        if (os.path.isdir(path_options['path'])
                and path_options['path'] not in sys.path):
            sys.path.insert(0, path_options['path'])