当前位置: 首页>>代码示例>>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;未经允许,请勿转载。