當前位置: 首頁>>代碼示例>>Python>>正文


Python BaseDirectory.xdg_cache_home方法代碼示例

本文整理匯總了Python中xdg.BaseDirectory.xdg_cache_home方法的典型用法代碼示例。如果您正苦於以下問題:Python BaseDirectory.xdg_cache_home方法的具體用法?Python BaseDirectory.xdg_cache_home怎麽用?Python BaseDirectory.xdg_cache_home使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在xdg.BaseDirectory的用法示例。


在下文中一共展示了BaseDirectory.xdg_cache_home方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: cli

# 需要導入模塊: from xdg import BaseDirectory [as 別名]
# 或者: from xdg.BaseDirectory import xdg_cache_home [as 別名]
def cli():
    global APPNAME, CONFIGDIR, CACHEDIR, AUTHFILE, COOKIEJAR

    APPNAME   = osp.basename(osp.splitext(__file__)[0])
    CONFIGDIR = xdg.save_config_path(APPNAME)  # creates the dir
    CACHEDIR  = osp.join(xdg.xdg_cache_home, APPNAME)
    AUTHFILE  = osp.join(CONFIGDIR, "login.conf")
    COOKIEJAR = osp.join(CONFIGDIR, "cookies.txt")
    # No changes in DATADIR

    try:
        sys.exit(main())

    except KeyboardInterrupt:
        pass
    except HumbleBundleError as e:
        log.critical(e)
        sys.exit(1)
    except Exception as e:
        log.critical(e, exc_info=True)
        sys.exit(1) 
開發者ID:MestreLion,項目名稱:humblebundle,代碼行數:23,代碼來源:humblebundle.py

示例2: __init__

# 需要導入模塊: from xdg import BaseDirectory [as 別名]
# 或者: from xdg.BaseDirectory import xdg_cache_home [as 別名]
def __init__(
            self,
            name,
            level='INFO',
            disable_file=False
    ):
        self.name = name
        self._file_format = ''
        self._console_format = ''
        self._log_file = Path(os.path.join(xdg_cache_home, 'ytmdl/logs/log.cat'))
        self._check_logfile()
        self._level_number = {
                                'DEBUG': 0,
                                'INFO': 1,
                                'WARNING': 2,
                                'ERROR': 3,
                                'CRITICAL': 4
                             }
        self.level = self._level_number[level]
        self._disable_file = disable_file
        self._instances.append(self) 
開發者ID:deepjyoti30,項目名稱:ytmdl,代碼行數:23,代碼來源:logger.py

示例3: cached_response

# 需要導入模塊: from xdg import BaseDirectory [as 別名]
# 或者: from xdg.BaseDirectory import xdg_cache_home [as 別名]
def cached_response(prefix=''):
    """
    Add `cache=True` keyword argument to a function to allow result caching based on single string
    argument.
    """
    def decorator_itself(func):
        def function_wrapper(cache_key, cache=True, **kwargs):
            cachedir = Path(xdg_cache_home) / 'duden'
            filename = prefix + sanitize_word(cache_key) + '.gz'
            full_path = str(cachedir / filename)

            if cache:
                # try to read from cache
                cachedir.mkdir(exist_ok=True)
                try:
                    with gzip.open(full_path, 'rt') as f:
                        return f.read()
                except FileNotFoundError:
                    pass

            result = func(cache_key, **kwargs)

            if cache and result is not None:
                with gzip.open(full_path, 'wt') as f:
                    f.write(result)

            return result

        return function_wrapper
    return decorator_itself 
開發者ID:radomirbosak,項目名稱:duden,代碼行數:32,代碼來源:search.py


注:本文中的xdg.BaseDirectory.xdg_cache_home方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。