Return a path to the pickled data with key ``name``.
426048
def _get_instance_path(self, name):
        ""
        fname = self.pattern.format(**{'name': name})
        logger.debug(f'path {self.create_path}: {self.create_path.exists()}')
        self._create_path_dir()
        return Path(self.create_path, fname)
689313
def _parse_file(cls, path, pickle=False):
        """"""

        fname = path
        if fname.endswith(".gz"):
            fname = path[:-3]

        if fname.endswith('.pkl'):
            #you asked for the pickled file. I'll give it to you
            log.debug("loading pickled file %s ..." % fname)
            return cPickle.load( open(fname, "rb") )
        elif os.path.isfile("%s.pkl" % fname):
            #there is a cached version I can give to you
            log.info("loading pickled file %s.pkl ..." % fname)
            if os.stat(path).st_mtime > os.stat("%s.pkl" % fname).st_mtime:
                log.critical("*** pickled file %s.pkl is not up to date ***" % (path))
            return cPickle.load( open("%s.pkl" % fname, "rb") )

        data = fastLoadChain(path, cls._strfactory)
        if pickle and not os.path.isfile('%s.pkl' % fname):
            log.info("pckling to %s.pkl" % (fname))
            with open('%s.pkl' % fname, 'wb') as fd:
                cPickle.dump(data, fd)
        return data
340210
def get(self, name: str, default: Optional[Any]=None) -> Any:
        """"""
        return self.__dict__.get(name, default)
301314
def store_pickle(file_path, data):
    
    pkl_file = open(file_path, 'wb')
    pickle.dump(data, pkl_file)
    pkl_file.close()
1027398
def get_data(query_func, load_data=False, save_data=False):
    """"""
    if hasattr(query_func, '__name__'):
        func_name = query_func.__name__
    elif hasattr(query_func, 'func'):
        func_name = query_func.func.__name__

    pickle_file = '{}.pickle'.format(func_name)

    if load_data:
        data = load_object(pickle_file)
    else:
        data = query_func()
        if save_data:
            save_object(pickle_file, data)
    return data
1193383
def path_for(self, *args):
        """"""
        if args and args[0].startswith(os.path.sep):
            return os.path.join(*args)
        return os.path.join(self._root_path or os.getcwd(), *args)
354843
def get_data_filepath(name, environ=None):
    
    dr = data_root(environ)

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

    return os.path.join(dr, name)
197308
def cache_path(self, name):
        
        return os.path.join(self._path, self.CACHE_DIR, name)
923834
def load(name, path=None, ext="dat", silent=False):
    
    filename = __get_filename(path, name, ext)

    if not os.path.exists(filename):
        if not silent:
            raise ValueException("Specified input filename doesn't exist.")
        return None

    with open(filename, "rb") as f:
        return pickle.load(f)
532403
def convert_to_path(name):
    """"""
    if name.startswith('.'):
        remainder = name.lstrip('.')
        dot_count = (len(name) - len(remainder))
        prefix = '../'*(dot_count-1)
    else:
        remainder = name
        dot_count = 0
        prefix = ''
    filename = prefix + os.path.join(*remainder.split('.'))
    return (filename, dot_count)
427513
def get_root_path(self, name):
        
        module = modules.get(name)
        if module is not None and hasattr(module, '__file__'):
            return dirname(abspath(module.__file__))

        # Flask keeps looking at this point. We instead set the root path to None,
        # assume that the user doesn't need resource loading, and raise an error
        # when resolving the resource path.
        return None
903888
def load_dictionary(filename):
    """"""
    filename = osp.abspath(filename)
    old_cwd = getcwd()
    tmp_folder = tempfile.mkdtemp()
    os.chdir(tmp_folder)
    data = None
    error_message = None
    try:
        with tarfile.open(filename, "r") as tar:
            tar.extractall()
        pickle_filename = glob.glob('*.pickle')[0]
        # 'New' format (Spyder >=2.2 for Python 2 and Python 3)
        with open(pickle_filename, 'rb') as fdesc:
            data = pickle.loads(fdesc.read())
        saved_arrays = {}
        if load_array is not None:
            # Loading numpy arrays saved with np.save
            try:
                saved_arrays = data.pop('__saved_arrays__')
                for (name, index), fname in list(saved_arrays.items()):
                    arr = np.load( osp.join(tmp_folder, fname) )
                    if index is None:
                        data[name] = arr
                    elif isinstance(data[name], dict):
                        data[name][index] = arr
                    else:
                        data[name].insert(index, arr)
            except KeyError:
                pass
    # Except AttributeError from e.g. trying to load function no longer present
    except (AttributeError, EOFError, ValueError) as error:
        error_message = to_text_string(error)
    # To ensure working dir gets changed back and temp dir wiped no matter what
    finally:
        os.chdir(old_cwd)
        try:
            shutil.rmtree(tmp_folder)
        except OSError as error:
            error_message = to_text_string(error)
    return data, error_message
474705
def pickle_save(thing,fname=None):
    """"""
    if fname is None:
        fname=os.path.expanduser("~")+"/%d.pkl"%time.time()
    assert type(fname) is str and os.path.isdir(os.path.dirname(fname))
    pickle.dump(thing, open(fname,"wb"),pickle.HIGHEST_PROTOCOL)
    print("saved",fname)
1115988
def get_data_by_key(self, name):
        
        data = graceful_chain_get(self.json, "data")

        if data is None or name not in data:
            return {}

        if self.is_yaml(name):
            return yaml.load(data[name]) or {}
        return json.loads(data[name])
1248427
def get(self, name):
        
        # not much we can do with that
        if name is None:
            return

        # if name isn't in archive try some similar values
        if name not in self.archive:
            if hasattr(name, 'decode'):
                name = name.decode('utf-8')
            # try with cleared whitespace, split paths
            for option in [name,
                           name.lstrip('./'),
                           name.strip(),
                           name.split('/')[-1]]:
                if option in self.archive:
                    name = option
                    break
        # read file object from beginning
        self.archive[name].seek(0)
        # data is stored as a file object
        data = self.archive[name].read()

        return data
1088434
def get_cookbook_path(cookbook_name):
    """"""
    for cookbook_path in cookbook_paths:
        path = os.path.join(cookbook_path, cookbook_name)
        if os.path.exists(path):
            return path
    raise IOError('Can\'t find cookbook with name "{0}"'.format(cookbook_name))
647068
def pickle_load(name, extension='.pkl'):
    
    filename = name + extension
    infile = open(filename, 'rb')
    data = pickle.load(infile)
    infile.close()
    return data