Exemplo n.º 1
0
def _initialise(cache_path):
    cache_path = expand(cache_path)

    def initialise_path(path):
        if not os.path.isdir(path):
            (head, tail) = os.path.split(path)
            if not os.path.isdir(head):
                initialise_path(head)
            os.mkdir(path)

    initialise_path(cache_path)
Exemplo n.º 2
0
def _initialise(cache_path):
    cache_path = expand(cache_path)

    def initialise_path(path):
        if not os.path.isdir(path):
            (head, tail) = os.path.split(path)
            if not os.path.isdir(head):
                initialise_path(head)
            os.mkdir(path)

    initialise_path(cache_path)
Exemplo n.º 3
0
def __call__(self, *args, **kwargs):
    if args:
        arg_names = self.arg_names
        if 'self' in arg_names:
            arg_names.remove('self')
        key_args = dict(zip(arg_names, args))
        key_args.update(kwargs)
    else:
        key_args = kwargs
    self._initialise(cache_path=expand(self.cache_path))
    key = self._build_key(key_args)
    if self.key_exists(key):
        result = self.get_key(key)
    else:
        result = self.f()
        self.set_key(key, result)
    return result
Exemplo n.º 4
0
def __call__(self, *args, **kwargs):
    if args:
        arg_names = self.arg_names
        if 'self' in arg_names:
            arg_names.remove('self')
        key_args = dict(zip(arg_names, args))
        key_args.update(kwargs)
    else:
        key_args = kwargs
    self._initialise(cache_path=expand(self.cache_path))
    key = self._build_key(key_args)
    if self.key_exists(key):
        result = self.get_key(key)
    else:
        result = self.f()
        self.set_key(key, result)
    return result
Exemplo n.º 5
0
def _key_path(key, cache_path):
    return os.path.join(expand(cache_path), key)
Exemplo n.º 6
0
def _key_path(key, cache_path):
    return os.path.join(expand(cache_path), key)