當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。