当前位置: 首页>>代码示例>>Python>>正文


Python BaseDirectory.load_config_paths方法代码示例

本文整理汇总了Python中xdg.BaseDirectory.load_config_paths方法的典型用法代码示例。如果您正苦于以下问题:Python BaseDirectory.load_config_paths方法的具体用法?Python BaseDirectory.load_config_paths怎么用?Python BaseDirectory.load_config_paths使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在xdg.BaseDirectory的用法示例。


在下文中一共展示了BaseDirectory.load_config_paths方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: get_config_files

# 需要导入模块: from xdg import BaseDirectory [as 别名]
# 或者: from xdg.BaseDirectory import load_config_paths [as 别名]
def get_config_files(filename):
	"""
	Iterator to @filename in all
	config paths, with most important (takes precendence)
	files first
	"""
	return base.load_config_paths(PACKAGE_NAME, filename) or ()
开发者ID:chmouel,项目名称:kupfer,代码行数:9,代码来源:config.py

示例2: _get_config_file_path

# 需要导入模块: from xdg import BaseDirectory [as 别名]
# 或者: from xdg.BaseDirectory import load_config_paths [as 别名]
def _get_config_file_path(xdg_config_dir, xdg_config_file):
    """Search ``XDG_CONFIG_DIRS`` for a config file and return the first found.

    Search each of the standard XDG configuration directories for a
    configuration file. Return as soon as a configuration file is found. Beware
    that by the time client code attempts to open the file, it may be gone or
    otherwise inaccessible.

    :param xdg_config_dir: A string. The name of the directory that is suffixed
        to the end of each of the ``XDG_CONFIG_DIRS`` paths.
    :param xdg_config_file: A string. The name of the configuration file that
        is being searched for.
    :returns: A ``str`` path to a configuration file.
    :raises nailgun.config.ConfigFileError: When no configuration file can be
        found.

    """
    for config_dir in BaseDirectory.load_config_paths(xdg_config_dir):
        path = join(config_dir, xdg_config_file)
        if isfile(path):
            return path
    raise ConfigFileError(
        'No configuration files could be located after searching for a file '
        'named "{0}" in the standard XDG configuration paths, such as '
        '"~/.config/{1}/".'.format(xdg_config_file, xdg_config_dir)
    )
开发者ID:oshtaier,项目名称:nailgun,代码行数:28,代码来源:config.py

示例3: _get_config_file_path

# 需要导入模块: from xdg import BaseDirectory [as 别名]
# 或者: from xdg.BaseDirectory import load_config_paths [as 别名]
def _get_config_file_path(xdg_config_dir, xdg_config_file):
    """Search ``XDG_CONFIG_DIRS`` for a config file and return the first found.

    Search each of the standard XDG configuration directories for a
    configuration file. Return as soon as a configuration file is found. Beware
    that by the time client code attempts to open the file, it may be gone or
    otherwise inaccessible.

    :param xdg_config_dir: A string. The name of the directory that is suffixed
        to the end of each of the ``XDG_CONFIG_DIRS`` paths.
    :param xdg_config_file: A string. The name of the configuration file that
        is being searched for.
    :returns: A string. A path to a configuration file.
    :raises pulp_smash.exceptions.ConfigFileNotFoundError: If the requested
        configuration file cannot be found.
    """
    paths = [
        os.path.join(config_dir, xdg_config_file)
        for config_dir in BaseDirectory.load_config_paths(xdg_config_dir)
    ]
    for path in paths:
        if os.path.isfile(path):
            return path
    raise exceptions.ConfigFileNotFoundError(
        'Pulp Smash is unable to find a configuration file. The following '
        '(XDG compliant) paths have been searched: ' + ', '.join(paths)
    )
开发者ID:BrnoPCmaniak,项目名称:pulp-smash,代码行数:29,代码来源:config.py

示例4: get_load_path

# 需要导入模块: from xdg import BaseDirectory [as 别名]
# 或者: from xdg.BaseDirectory import load_config_paths [as 别名]
    def get_load_path(cls, xdg_subdir=None, config_file=None):
        """Return the path to where a configuration file may be loaded from.

        Search each of the ``$XDG_CONFIG_DIRS`` for a file named
        ``$xdg_subdir/$config_file``.

        :param xdg_subdir: A string. The directory to append to each of the
            ``$XDG_CONFIG_DIRS``. Defaults to ``'pulp_smash'``.
        :param config_file: A string. The name of the settings file. Typically
            defaults to ``'settings.json'``.
        :returns: A string. The path to a configuration file, if one is found.
        :raises pulp_smash.exceptions.ConfigFileNotFoundError: If no
            configuration file is found.
        """
        if xdg_subdir is None:
            xdg_subdir = cls._get_xdg_subdir()
        if config_file is None:
            config_file = cls._get_config_file()

        for dir_ in BaseDirectory.load_config_paths(xdg_subdir):
            path = os.path.join(dir_, config_file)
            if os.path.exists(path):
                return path

        raise exceptions.ConfigFileNotFoundError(
            'Pulp Smash is unable to find a configuration file. The '
            'following (XDG compliant) paths have been searched: '
            ', '.join((
                os.path.join(xdg_config_dir, xdg_subdir, config_file)
                for xdg_config_dir in BaseDirectory.xdg_config_dirs
            ))
        )
开发者ID:dralley,项目名称:pulp-smash,代码行数:34,代码来源:config.py

示例5: load

# 需要导入模块: from xdg import BaseDirectory [as 别名]
# 或者: from xdg.BaseDirectory import load_config_paths [as 别名]
def load():
    for config_path in BaseDirectory.load_config_paths('buildhck', 'config.yaml'):
        with open(config_path) as f:
            obj = yaml.load(f)
            if obj:
                config.update(obj)
    if not path.isdir(build_directory()):
        makedirs(build_directory())
开发者ID:Cloudef,项目名称:buildhck,代码行数:10,代码来源:config.py

示例6: _read

# 需要导入模块: from xdg import BaseDirectory [as 别名]
# 或者: from xdg.BaseDirectory import load_config_paths [as 别名]
	def _read(self):
		self._save = self._save_xdg
		for d in BaseDirectory.load_config_paths(CONFIG):
			path = os.path.join(d, DOMAINS)
			if os.path.exists(path):
				return self._read_file(path)
		else:
			return {}
开发者ID:skeledrew,项目名称:supergenpass,代码行数:10,代码来源:persistence.py

示例7: load_config

# 需要导入模块: from xdg import BaseDirectory [as 别名]
# 或者: from xdg.BaseDirectory import load_config_paths [as 别名]
def load_config(app, filename):
    config.clear()
    for filename in BaseDirectory.load_config_paths('pb', filename):
        with open(filename) as f:
            obj = yaml.load(f)
            config.update(obj)
    if app:
        app.config.from_mapping(config)
    return config
开发者ID:HalosGhost,项目名称:pb,代码行数:11,代码来源:config.py

示例8: _get_config_paths

# 需要导入模块: from xdg import BaseDirectory [as 别名]
# 或者: from xdg.BaseDirectory import load_config_paths [as 别名]
 def _get_config_paths(self):
     "Get configuration file paths"
     if _xdg_basedirectory:
         paths = list(reversed(list(_xdg_basedirectory.load_config_paths(""))))
         if not paths:  # setup something for a useful log message
             paths.append(_xdg_basedirectory.save_config_path(""))
     else:
         self._log_xdg_import_error()
         paths = [_os_path.expanduser(_os_path.join("~", ".config"))]
     return [_os_path.join(path, "mutt-ldap.cfg") for path in paths]
开发者ID:jpalus,项目名称:mutt-ldap,代码行数:12,代码来源:mutt_ldap.py

示例9: load

# 需要导入模块: from xdg import BaseDirectory [as 别名]
# 或者: from xdg.BaseDirectory import load_config_paths [as 别名]
def load():
    dct = {}
    for filepath in BaseDirectory.load_config_paths("mup/mup.yaml"):
        with open(filepath) as f:
            try:
                dct.update(yaml.load(f))
            except Exception as exc:
                logging.exception("Failed to load {}, skipping it.".format(filepath))

    return dct
开发者ID:CedricCabessa,项目名称:mup,代码行数:12,代码来源:config.py

示例10: _get_config_paths

# 需要导入模块: from xdg import BaseDirectory [as 别名]
# 或者: from xdg.BaseDirectory import load_config_paths [as 别名]
 def _get_config_paths(self):
     "Get configuration file paths"
     if _xdg_basedirectory:
         paths = list(reversed(list(
             _xdg_basedirectory.load_config_paths(''))))
         if not paths:  # setup something for a useful log message
             paths.append(_xdg_basedirectory.save_config_path(''))
     else:
         self._log_xdg_import_error()
         paths = [_os_path.expanduser(_os_path.join('~', '.mutt'))]
     # return [_os_path.join(path, 'mutt-ldap.cfg') for path in paths]
     return '/home/derek/.mutt/mutt-ldap.cfg'
开发者ID:dfaught,项目名称:dotfiles,代码行数:14,代码来源:mutt_ldap.py

示例11: __init__

# 需要导入模块: from xdg import BaseDirectory [as 别名]
# 或者: from xdg.BaseDirectory import load_config_paths [as 别名]
    def __init__(self):
        self._cparser = configparser.ConfigParser()

        paths = list(BaseDirectory.load_config_paths("mnemosyne"))
        paths.append(os.getcwd())

        for path in paths:
            file = os.path.join(path, "mnemosyne.ini")

            if os.path.exists(file):
                self._cparser.read(file)

        self.consumer = Config.Consumer(self._cparser)
        self.web = Config.Web(self._cparser)
开发者ID:jgraichen,项目名称:mnemosyne,代码行数:16,代码来源:config.py

示例12: test_load_config_paths

# 需要导入模块: from xdg import BaseDirectory [as 别名]
# 或者: from xdg.BaseDirectory import load_config_paths [as 别名]
 def test_load_config_paths(self):
     tmpdir = tempfile.mkdtemp()
     path = os.path.join(tmpdir, "wpokewefketnrhruit")
     os.mkdir(path)
     tmpdir2 = tempfile.mkdtemp()
     path2 = os.path.join(tmpdir2, "wpokewefketnrhruit")
     os.mkdir(path2)
     try:
         environ['XDG_CONFIG_HOME'] = tmpdir
         environ['XDG_CONFIG_DIRS'] = tmpdir2 + ":/etc/xdg"
         reload(BaseDirectory)
         configdirs = BaseDirectory.load_config_paths("wpokewefketnrhruit")
         self.assertEqual(list(configdirs), [path, path2])
     finally:
         shutil.rmtree(tmpdir)
         shutil.rmtree(tmpdir2)
开发者ID:0312birdzhang,项目名称:pyxdg,代码行数:18,代码来源:test-basedirectory.py

示例13: autostart

# 需要导入模块: from xdg import BaseDirectory [as 别名]
# 或者: from xdg.BaseDirectory import load_config_paths [as 别名]
def autostart(environments):
    # get the autostart directories
    autodirs = BaseDirectory.load_config_paths("autostart")
    # find all the autostart files
    files = []
    for mdir in autodirs:
        for path in glob.glob(os.path.join(mdir, "*.desktop")):
            try:
                autofile = AutostartFile(path)
            except ParsingError:
                print("Invalid .desktop file: " + path)
            else:
                if not autofile in files:
                    files.append(autofile)
    # run them
    for autofile in files:
        autofile.run(environments)
开发者ID:joshiggins,项目名称:jwmsession,代码行数:19,代码来源:autostart.py

示例14: __init__

# 需要导入模块: from xdg import BaseDirectory [as 别名]
# 或者: from xdg.BaseDirectory import load_config_paths [as 别名]
    def __init__(self):
        gobject.GObject.__init__(self)
        self.config = Config.Config(tgcm.country_support)

        # Determine the path for XDG autostart dirs
        self.autofile_name = 'tgcm-%s.desktop' % tgcm.country_support
        self.user_autodir = None
        for foo in BaseDirectory.load_config_paths('autostart'):
            if foo.startswith(os.path.expanduser('~')):
                self.user_autodir = foo
            else:
                self.system_autodir = foo

        self.__create_desktop_entry_if_necessary()

        # Listen to file changes
        myfile = gio.File(self.user_autofile)
        self.desktopentry_monitor = myfile.monitor_file()
        self.desktopentry_monitor.connect('changed', self.on_desktopentry_changed)
开发者ID:calabozo,项目名称:tgcmlinux,代码行数:21,代码来源:Autostart.py

示例15: get_app_config

# 需要导入模块: from xdg import BaseDirectory [as 别名]
# 或者: from xdg.BaseDirectory import load_config_paths [as 别名]
def get_app_config():  # pragma: nocover
    """
    Gets a dict with the global configuration files set in the XDG dirs.

    """

    # NOTE: This is very quick and dirty and should be baked into the
    # configuration ecosystem of piper at a later point.

    ret = {}
    files = [f for f in BaseDirectory.load_config_paths('piper', 'piper.yml')]
    files.reverse()

    for conf in files:
        with open(conf) as f:
            data = yaml.safe_load(f.read())
            ret.update(data)

    return ret
开发者ID:thiderman,项目名称:piper,代码行数:21,代码来源:config.py


注:本文中的xdg.BaseDirectory.load_config_paths方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。