python类user_cache_dir()的实例源码

util.py 文件源码 项目:ngraph 作者: NervanaSystems 项目源码 文件源码 阅读 19 收藏 0 点赞 0 评论 0
def get_cache_dir(subdir=None):
    """
    Function for getting cache directory to store reused files like kernels, or scratch space
    for autotuning, etc.
    """
    cache_dir = os.environ.get("NEON_CACHE_DIR")

    if cache_dir is None:
        cache_dir = appdirs.user_cache_dir("neon", "neon")

    if subdir:
        subdir = subdir if isinstance(subdir, list) else [subdir]
        cache_dir = os.path.join(cache_dir, *subdir)

    if not os.path.exists(cache_dir):
        os.makedirs(cache_dir)

    return cache_dir
__init__.py 文件源码 项目:ivaochdoc 作者: ivaoch 项目源码 文件源码 阅读 59 收藏 0 点赞 0 评论 0
def get_default_cache():
    """
    Return the ``PYTHON_EGG_CACHE`` environment variable
    or a platform-relevant user cache dir for an app
    named "Python-Eggs".
    """
    return (
        os.environ.get('PYTHON_EGG_CACHE')
        or appdirs.user_cache_dir(appname='Python-Eggs')
    )
folders.py 文件源码 项目:modman 作者: haihala 项目源码 文件源码 阅读 20 收藏 0 点赞 0 评论 0
def get_api_cache_folder():
    # NOTE: Using app name for author too
    cache = appdirs.user_cache_dir(APP_NAME, APP_NAME)
    if not os.path.isdir(cache):
        os.makedirs(cache)
    return cache
__init__.py 文件源码 项目:RealtimePythonChat 作者: quangtqag 项目源码 文件源码 阅读 18 收藏 0 点赞 0 评论 0
def get_default_cache():
    """
    Return the ``PYTHON_EGG_CACHE`` environment variable
    or a platform-relevant user cache dir for an app
    named "Python-Eggs".
    """
    return (
        os.environ.get('PYTHON_EGG_CACHE')
        or appdirs.user_cache_dir(appname='Python-Eggs')
    )
cli.py 文件源码 项目:bch-firmware-tool 作者: bigclownlabs 项目源码 文件源码 阅读 19 收藏 0 点赞 0 评论 0
def download_url(url, user_cache_dir, use_cache=True):
    filename = hashlib.sha256(url.encode()).hexdigest()
    filename_bin = os.path.join(user_cache_dir, filename)

    if use_cache and os.path.exists(filename_bin):
        return filename_bin

    print('download firmware from', url)
    print('save as', filename_bin)

    urlretrieve(url, filename_bin, reporthook=download_url_reporthook)

    return filename_bin
cli.py 文件源码 项目:bch-firmware-tool 作者: bigclownlabs 项目源码 文件源码 阅读 16 收藏 0 点赞 0 评论 0
def __call__(self, **kwargs):
        user_cache_dir = appdirs.user_cache_dir('bcf')
        repos = Github_Repos(user_cache_dir)
        # search = kwargs.get('prefix', None)
        firmwares = repos.get_firmware_list()
        if self._find_bin:
            firmwares += glob.glob('*.bin')
        return firmwares
__init__.py 文件源码 项目:coolrelation 作者: mrtial 项目源码 文件源码 阅读 21 收藏 0 点赞 0 评论 0
def get_default_cache():
    """
    Return the ``PYTHON_EGG_CACHE`` environment variable
    or a platform-relevant user cache dir for an app
    named "Python-Eggs".
    """
    return (
        os.environ.get('PYTHON_EGG_CACHE')
        or appdirs.user_cache_dir(appname='Python-Eggs')
    )
__main__.py 文件源码 项目:himawaripy 作者: boramalper 项目源码 文件源码 阅读 20 收藏 0 点赞 0 评论 0
def parse_args():
    parser = argparse.ArgumentParser(description="set (near-realtime) picture of Earth as your desktop background",
                                     epilog="http://labs.boramalper.org/himawaripy")

    parser.add_argument("--version", action="version", version="%(prog)s {}.{}.{}".format(*HIMAWARIPY_VERSION))

    group = parser.add_mutually_exclusive_group()

    group.add_argument("--auto-offset", action="store_true", dest="auto_offset", default=False,
                       help="determine offset automatically")
    group.add_argument("-o", "--offset", type=int, dest="offset", default=10,
                       help="UTC time offset in hours, must be less than or equal to +10")

    parser.add_argument("-l", "--level", type=int, choices=[4, 8, 16, 20], dest="level", default=4,
                        help="increases the quality (and the size) of each tile. possible values are 4, 8, 16, 20")
    parser.add_argument("-d", "--deadline", type=int, dest="deadline", default=6,
                        help="deadline in minutes to download all the tiles, set 0 to cancel")
    parser.add_argument("--save-battery", action="store_true", dest="save_battery", default=False,
                        help="stop refreshing on battery")
    parser.add_argument("--output-dir", type=str, dest="output_dir",
                        help="directory to save the temporary background image",
                        default=appdirs.user_cache_dir(appname="himawaripy", appauthor=False))

    args = parser.parse_args()

    if not -12 <= args.offset <= 10:
        sys.exit("OFFSET has to be between -12 and +10!\n")

    if not args.deadline >= 0:
        sys.exit("DEADLINE has to be greater than (or equal to if you want to disable) zero!\n")

    return args
__init__.py 文件源码 项目:python-group-proj 作者: Sharcee 项目源码 文件源码 阅读 20 收藏 0 点赞 0 评论 0
def get_default_cache():
    """
    Return the ``PYTHON_EGG_CACHE`` environment variable
    or a platform-relevant user cache dir for an app
    named "Python-Eggs".
    """
    return (
        os.environ.get('PYTHON_EGG_CACHE')
        or appdirs.user_cache_dir(appname='Python-Eggs')
    )
logging_utils.py 文件源码 项目:spoppy 作者: sindrig 项目源码 文件源码 阅读 31 收藏 0 点赞 0 评论 0
def configure_logging():
    cache_dir = user_cache_dir(appname='spoppy')

    LOG_FILE_NAME = os.path.join(
        cache_dir, 'spoppy.log'
    )

    LOG_LEVEL = getattr(
        logging,
        os.getenv('SPOPPY_LOG_LEVEL', ''),
        logging.INFO
    )

    if not os.path.isdir(cache_dir):
        os.makedirs(cache_dir)

    logger = logging.getLogger('spoppy')
    logger.setLevel(LOG_LEVEL)
    handler = RotatingFileHandler(
        LOG_FILE_NAME,
        maxBytes=1024 * 1024 * 10,
        backupCount=10,
    )
    handler.setLevel(LOG_LEVEL)
    formatter = logging.Formatter(
        '%(asctime)s - %(name)s - %(levelname)s - %(message)s'
    )
    handler.setFormatter(formatter)
    logger.addHandler(handler)
    logger.debug('Logger set up')
lifecycle.py 文件源码 项目:spoppy 作者: sindrig 项目源码 文件源码 阅读 17 收藏 0 点赞 0 评论 0
def __init__(self, username, password, player):
        if not os.path.isdir(self.user_cache_dir):
            os.makedirs(self.user_cache_dir)
        self.player = player
        self.username = username
        self.password = password
        self._spotipy_token = None
        self._pyspotify_session = None
        self._pyspotify_session_loop = None
        self.service_stop_event = threading.Event()
        self.services = [
            DBusListener(self, self.service_stop_event),
            ResizeChecker(self, self.service_stop_event)
        ]

        self._spotipy_client = Spotify()

        try:
            import alsaaudio  # noqa
            self._sink_klass = spotify.AlsaSink
        except ImportError:
            try:
                import pyaudio  # noqa
                self._sink_klass = spotify.PortAudioSink
            except ImportError:
                raise AudioError(
                    'Neither AlsaAudio nor PortAudio is installed. '
                    'Please install either of these!'
                )
lifecycle.py 文件源码 项目:spoppy 作者: sindrig 项目源码 文件源码 阅读 19 收藏 0 点赞 0 评论 0
def get_spotipy_oauth(self):
        client_id = 'ce333851d4db4ba1b6ccf9eaa52345fc'
        client_secret = '549ec6a308cc4836b7144fc42277a6b2'
        redirect_uri = 'http://localhost:8157/'

        cache_location = os.path.join(
            self.user_cache_dir, 'spotipy_token.cache'
        )
        try:
            # Clean up tokens pre 2.2.1
            # TODO remove soon
            with open(cache_location, 'r') as f:
                contents = f.read()
            data = json.loads(contents)
            if 'scope' in data and data['scope'] is None:
                del data['scope']
                with open(cache_location, 'w') as f:
                    f.write(json.dumps(data))
        except IOError:
            pass
        except ValueError:
            logger.warning(
                'ValueError while getting token info',
                exc_info=True
            )
        return oauth2.SpotifyOAuth(
            client_id, client_secret, redirect_uri,
            scope=SPOFITY_WEB_API_SCOPE,
            cache_path=cache_location
        )
__init__.py 文件源码 项目:PornGuys 作者: followloda 项目源码 文件源码 阅读 60 收藏 0 点赞 0 评论 0
def get_default_cache():
    """
    Return the ``PYTHON_EGG_CACHE`` environment variable
    or a platform-relevant user cache dir for an app
    named "Python-Eggs".
    """
    return (
        os.environ.get('PYTHON_EGG_CACHE')
        or appdirs.user_cache_dir(appname='Python-Eggs')
    )
epitope_prediction.py 文件源码 项目:vaxrank 作者: hammerlab 项目源码 文件源码 阅读 14 收藏 0 点赞 0 评论 0
def fm_index_path(genome):
    """
    Returns a path for cached reference peptides, for the given genome.
    """
    cache_dir = user_cache_dir('vaxrank')
    if not os.path.exists(cache_dir):
        os.makedirs(cache_dir)

    return os.path.join(cache_dir, '%s_%d_%d.fm' % (
        genome.species.latin_name, genome.release, 2 if six.PY2 else 3))
route_animation.py 文件源码 项目:route-plotter 作者: perimosocordiae 项目源码 文件源码 阅读 27 收藏 0 点赞 0 评论 0
def user_cache_dir(appname=None):
    return os.path.join(os.getcwd(), 'tiles')
route_animation.py 文件源码 项目:route-plotter 作者: perimosocordiae 项目源码 文件源码 阅读 28 收藏 0 点赞 0 评论 0
def parse_args():
  cache_dir = user_cache_dir(appname='route-plotter')
  ap = ArgumentParser(description=__doc__,
                      formatter_class=ArgumentDefaultsHelpFormatter)
  ap.add_argument('--color-tiles', action='store_true',
                  help='Use full-color map tiles.')
  ap.add_argument('--scale', type=float, default=1,
                  help='Figure size scale fraction.')
  ap.add_argument('--zoom', type=int, default=None, help='Map zoom level.')
  ap.add_argument('--tile-cache', type=str, default=cache_dir,
                  help='Directory for storing cached map tiles.')
  ap.add_argument('--save', type=str, help='Save animation to disk.')
  ap.add_argument('--max-margin', type=float, default=0.05,
                  help='Keep up to this fraction of width/height as margin.')
  ap.add_argument('--max-loop-gap', type=float, default=200,
                  help='Maximum gap between start/end points, in meters.')
  ap.add_argument('--max-start-dist', type=float, default=200,
                  help=('Maximum distance from route start to the '
                        'mean starting location, in meters.'))
  ap.add_argument('--num-frames', type=int, default=500,
                  help='Number of frames to animate.')
  ap.add_argument('--fps', type=float, default=10, help='Frames per second.')
  ap.add_argument('--bitrate', type=int, help='Bitrate when saving animation.')
  ap.add_argument('--line-width', type=float, default=2.5, help='Line width.')
  ap.add_argument('--tail-color', type=str, default='blue',
                  help='Color of trailing line.')
  ap.add_argument('--tail-alpha', type=float, default=0.2,
                  help='Opacity of trailing line.')
  ap.add_argument('--head-color', type=str, default='red', help='Head color.')
  ap.add_argument('--head-alpha', type=float, default=1, help='Head opacity.')
  ap.add_argument('--head-fade', type=float, default=90,
                  help=('Number of seconds (in route time) over which the head'
                        ' of the line fades out.'))
  ap.add_argument('route', type=str, nargs='+', help='Route file(s) to use.')
  args = ap.parse_args()
  if len(args.route) == 1:
    args.route = glob.glob(args.route[0])
  args.route = map(open, args.route)
  return args
__init__.py 文件源码 项目:Repobot 作者: Desgard 项目源码 文件源码 阅读 17 收藏 0 点赞 0 评论 0
def get_default_cache():
    """
    Return the ``PYTHON_EGG_CACHE`` environment variable
    or a platform-relevant user cache dir for an app
    named "Python-Eggs".
    """
    return (
        os.environ.get('PYTHON_EGG_CACHE')
        or appdirs.user_cache_dir(appname='Python-Eggs')
    )
__init__.py 文件源码 项目:CloudPrint 作者: William-An 项目源码 文件源码 阅读 24 收藏 0 点赞 0 评论 0
def get_default_cache():
    """
    Return the ``PYTHON_EGG_CACHE`` environment variable
    or a platform-relevant user cache dir for an app
    named "Python-Eggs".
    """
    return (
        os.environ.get('PYTHON_EGG_CACHE')
        or appdirs.user_cache_dir(appname='Python-Eggs')
    )
__init__.py 文件源码 项目:pkg_resources 作者: pypa 项目源码 文件源码 阅读 17 收藏 0 点赞 0 评论 0
def get_default_cache():
    """
    Return the ``PYTHON_EGG_CACHE`` environment variable
    or a platform-relevant user cache dir for an app
    named "Python-Eggs".
    """
    return (
        os.environ.get('PYTHON_EGG_CACHE')
        or appdirs.user_cache_dir(appname='Python-Eggs')
    )
__init__.py 文件源码 项目:QualquerMerdaAPI 作者: tiagovizoto 项目源码 文件源码 阅读 21 收藏 0 点赞 0 评论 0
def get_default_cache():
    """
    Return the ``PYTHON_EGG_CACHE`` environment variable
    or a platform-relevant user cache dir for an app
    named "Python-Eggs".
    """
    return (
        os.environ.get('PYTHON_EGG_CACHE')
        or appdirs.user_cache_dir(appname='Python-Eggs')
    )
__init__.py 文件源码 项目:gardenbot 作者: GoestaO 项目源码 文件源码 阅读 22 收藏 0 点赞 0 评论 0
def get_default_cache():
    """
    Return the ``PYTHON_EGG_CACHE`` environment variable
    or a platform-relevant user cache dir for an app
    named "Python-Eggs".
    """
    return (
        os.environ.get('PYTHON_EGG_CACHE')
        or appdirs.user_cache_dir(appname='Python-Eggs')
    )
__init__.py 文件源码 项目:hate-to-hugs 作者: sdoran35 项目源码 文件源码 阅读 38 收藏 0 点赞 0 评论 0
def get_default_cache():
    """
    Return the ``PYTHON_EGG_CACHE`` environment variable
    or a platform-relevant user cache dir for an app
    named "Python-Eggs".
    """
    return (
        os.environ.get('PYTHON_EGG_CACHE')
        or appdirs.user_cache_dir(appname='Python-Eggs')
    )
util.py 文件源码 项目:kotori 作者: daq-tools 项目源码 文件源码 阅读 22 收藏 0 点赞 0 评论 0
def setup_h2m_structs_pyclibrary():
    cache_dir = os.path.join(user_cache_dir('kotori'), 'lst')
    if not os.path.isdir(cache_dir): os.makedirs(cache_dir)
    lib_dir = os.path.join(os.path.dirname(__file__), 'cpp')
    library = LibraryAdapter(u'h2m_structs.h', u'h2m_structs.so', include_path=lib_dir, library_path=lib_dir, cache_path=cache_dir)
    struct_registry = StructRegistryByID(library)
    return struct_registry
util.py 文件源码 项目:kotori 作者: daq-tools 项目源码 文件源码 阅读 19 收藏 0 点赞 0 评论 0
def setup_h2m_structs_cffi():
    cache_dir = os.path.join(user_cache_dir('kotori'), 'lst')
    if not os.path.isdir(cache_dir): os.makedirs(cache_dir)
    lib_dir = os.path.join(os.path.dirname(__file__), 'cpp')
    library = LibraryAdapterCFFI(u'h2m_structs.h', u'h2m_structs.so', include_path=lib_dir, library_path=lib_dir, cache_path=cache_dir)
    struct_registry = StructRegistryByID(library)
    return struct_registry
c.py 文件源码 项目:kotori 作者: daq-tools 项目源码 文件源码 阅读 25 收藏 0 点赞 0 评论 0
def from_header(cls, include_path=None, header_files=None):
        cache_dir = user_cache_dir('lst', 'kotori')
        if not os.path.isdir(cache_dir): os.makedirs(cache_dir)
        library = LibraryAdapter(
            header_files, cls.compile(include_path, header_files),
            include_path=include_path, library_path=include_path,
            cache_path=cache_dir)
        return library
cache.py 文件源码 项目:python-zeep 作者: mvantellingen 项目源码 文件源码 阅读 19 收藏 0 点赞 0 评论 0
def _get_default_cache_path():
    path = appdirs.user_cache_dir('zeep', False)
    try:
        os.makedirs(path)
    except OSError as exc:
        if exc.errno == errno.EEXIST and os.path.isdir(path):
            pass
        else:
            raise
    return os.path.join(path, 'cache.db')
__init__.py 文件源码 项目:minihydra 作者: VillanCh 项目源码 文件源码 阅读 24 收藏 0 点赞 0 评论 0
def get_default_cache():
    """
    Return the ``PYTHON_EGG_CACHE`` environment variable
    or a platform-relevant user cache dir for an app
    named "Python-Eggs".
    """
    return (
        os.environ.get('PYTHON_EGG_CACHE')
        or appdirs.user_cache_dir(appname='Python-Eggs')
    )
__init__.py 文件源码 项目:zenchmarks 作者: squeaky-pl 项目源码 文件源码 阅读 19 收藏 0 点赞 0 评论 0
def get_default_cache():
    """
    Return the ``PYTHON_EGG_CACHE`` environment variable
    or a platform-relevant user cache dir for an app
    named "Python-Eggs".
    """
    return (
        os.environ.get('PYTHON_EGG_CACHE')
        or appdirs.user_cache_dir(appname='Python-Eggs')
    )
__init__.py 文件源码 项目:sam-s-club-auctions 作者: sameer2800 项目源码 文件源码 阅读 19 收藏 0 点赞 0 评论 0
def get_default_cache():
    """
    Return the ``PYTHON_EGG_CACHE`` environment variable
    or a platform-relevant user cache dir for an app
    named "Python-Eggs".
    """
    return (
        os.environ.get('PYTHON_EGG_CACHE')
        or appdirs.user_cache_dir(appname='Python-Eggs')
    )
dirs.py 文件源码 项目:aw-core 作者: ActivityWatch 项目源码 文件源码 阅读 18 收藏 0 点赞 0 评论 0
def get_cache_dir(module_name: Optional[str]) -> str:
    cache_dir = appdirs.user_cache_dir("activitywatch")
    return os.path.join(cache_dir, module_name) if module_name else cache_dir


问题


面经


文章

微信
公众号

扫码关注公众号