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


Python BaseDirectory.xdg_config_home方法代码示例

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


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

示例1: get_user_dir

# 需要导入模块: from xdg import BaseDirectory [as 别名]
# 或者: from xdg.BaseDirectory import xdg_config_home [as 别名]
def get_user_dir(key):
    """
    http://www.freedesktop.org/wiki/Software/xdg-user-dirs
     - XDG_DESKTOP_DIR
     - XDG_DOWNLOAD_DIR
     - XDG_TEMPLATES_DIR
     - XDG_PUBLICSHARE_DIR
     - XDG_DOCUMENTS_DIR
     - XDG_MUSIC_DIR
     - XDG_PICTURES_DIR
     - XDG_VIDEOS_DIR

    Taken from FrontBringer
    (distributed under the GNU GPL v3 license),
    courtesy of Jean-François Fortin Tam.
    """
    user_dirs_dirs = os.path.join(xdg_config_home, "user-dirs.dirs")
    user_dirs_dirs = os.path.expanduser(user_dirs_dirs)
    if not os.path.exists(user_dirs_dirs):
        return
    for line in open(user_dirs_dirs, "r"):
        if line.startswith(key):
            return os.path.expandvars(line[len(key) + 2:-2]) 
开发者ID:getting-things-gnome,项目名称:gtg,代码行数:25,代码来源:export.py

示例2: get_config_dir

# 需要导入模块: from xdg import BaseDirectory [as 别名]
# 或者: from xdg.BaseDirectory import xdg_config_home [as 别名]
def get_config_dir(app_name):
    if 'XDG_CONFIG_HOME' in os.environ:
        confighome = os.environ['XDG_CONFIG_HOME']

    elif 'APPDATA' in os.environ:  # On Windows
        confighome = os.environ['APPDATA']

    else:
        try:
            from xdg import BaseDirectory
            confighome = BaseDirectory.xdg_config_home

        except ImportError:  # Most likely a Linux/Unix system anyway
            confighome = os.path.join(os.path.expanduser('~'), '.config')

    configdir = os.path.join(confighome, app_name)

    return configdir 
开发者ID:bharadwaj-raju,项目名称:WeatherDesk,代码行数:20,代码来源:Desktop.py

示例3: __init__

# 需要导入模块: from xdg import BaseDirectory [as 别名]
# 或者: from xdg.BaseDirectory import xdg_config_home [as 别名]
def __init__(self):
        """
        Manages book files and provides metadata
        """
        self.config = configparser.ConfigParser()
        # Loads configuration from $XDG_CONFIG_HOME/easy-ebook-viewer.conf
        self.__config_path = os.path.expanduser(os.path.join(xdg_config_home, "easy-ebook-viewer.conf"))
        if os.access(self.__config_path, os.W_OK):  # Checks if a config file exists
            # Config file exists, loads it.
            self.config.read(self.__config_path)
        else:
            # Config file doesn't exist, creates new
            self.__create_new_configuration()

        # Validates configuration
        self.__validate_configuration() 
开发者ID:michaldaniel,项目名称:ebook-viewer,代码行数:18,代码来源:config_provider.py

示例4: __init__

# 需要导入模块: from xdg import BaseDirectory [as 别名]
# 或者: from xdg.BaseDirectory import xdg_config_home [as 别名]
def __init__(self):
        # The home dir
        self.HOME_DIR = os.path.expanduser('~')

        # The default song dir
        self.SONG_DIR = self._get_music_dir()

        # The temp dir
        self.SONG_TEMP_DIR = os.path.join(self.SONG_DIR, 'ytmdl')

        # The default song quality
        self.SONG_QUALITY = '320'

        # The config path
        self.CONFIG_PATH = os.path.join(xdg_config_home, 'ytmdl') 
开发者ID:deepjyoti30,项目名称:ytmdl,代码行数:17,代码来源:setupConfig.py

示例5: test_confdir_xdg

# 需要导入模块: from xdg import BaseDirectory [as 别名]
# 或者: from xdg.BaseDirectory import xdg_config_home [as 别名]
def test_confdir_xdg(self):
        direct = helpers.get_confdir()
        self.assertEqual(direct, os.path.join(BaseDirectory.xdg_config_home, 'fades')) 
开发者ID:PyAr,项目名称:fades,代码行数:5,代码来源:test_helpers.py

示例6: test_confdir_xdg_nonexistant

# 需要导入模块: from xdg import BaseDirectory [as 别名]
# 或者: from xdg.BaseDirectory import xdg_config_home [as 别名]
def test_confdir_xdg_nonexistant(self):
        with patch("xdg.BaseDirectory") as mock:
            with tempfile.TemporaryDirectory() as dirname:
                mock.xdg_config_home = dirname
                direct = helpers.get_confdir()
                self.assertTrue(os.path.exists(direct)) 
开发者ID:PyAr,项目名称:fades,代码行数:8,代码来源:test_helpers.py


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