This helper will output the idevice to a pickled file named
    after the passed filename.

    This allows the data to be used without resorting to screen / pipe
    scrapping.
178759
def create_pickled_data(idevice, filename):
    
    data = {}
    for x in idevice.content:
        data[x] = idevice.content[x]
    location = filename
    pickle_file = open(location, 'wb')
    pickle.dump(data, pickle_file, protocol=pickle.HIGHEST_PROTOCOL)
    pickle_file.close()
1053163
def dump_pickle(name, obj):
    ''''''
    with open(name,"wb") as f:
        pickle.dump(obj,f,2);
    pass;
1112866
def save(self, foldername: str, path_to_folder: str=None) -> None:
        '''  '''
        self.create_pickle((self.g.namespaces, ))
        self.df.to_pickle(output)
1103059
def dump(self, obj, key=None):
        """"""
        if key is None:
            key = '_pickle'
        with preserve_current_directory():
            self.__file.cd()
            if sys.version_info[0] < 3:
                pickle.Pickler.dump(self, obj)
            else:
                super(Pickler, self).dump(obj)
            s = ROOT.TObjString(self.__io.getvalue())
            self.__io.reopen()
            s.Write(key)
            self.__file.GetFile().Flush()
            self.__pmap.clear()
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)
686043
def store(self):
        
        with open(self.filename, "wb") as f:
            pickle.dump(self, f)
1086101
def write_pickles (self, objs):
        
        try:
            import cPickle as pickle
        except ImportError:
            import pickle

        with self.open (mode='wb') as f:
            for obj in objs:
                pickle.dump (obj, f)
514436
def save(self, obj, id_code):
        
        filestream = open('{0}/{1}'.format(self.data_path, id_code), 'w+')
        pickle.dump(obj, filestream)
        filestream.close()
805509
def load_pickle(file_path):
    
    pkl_file = open(file_path, 'rb')
    data = pickle.load(pkl_file)
    pkl_file.close()
    return data
964184
def save(self, obj, label, format='text'):
        

        # initialize hidden state directory

        objloc = '{0}/{1}'.format(self.statedir, label)

        with open(objloc, 'w') as fp:
            if format == 'pickle':
                pickle.dump(obj, fp)
            elif format == 'text':
                fp.write(str(obj))
            else:
                print('Format {0} not recognized. Please choose either pickle or text.'.format(format))

        print('Saving {0} to label {1}'.format(obj, label))
1044127
def save(self, *args):
        
        with open(self.file_root + '.pkl', "wb") as f:
            pickle.dump(args, f, protocol=pickle.HIGHEST_PROTOCOL)
1074183
def get_file(self, name):
        
        files = self.get_output_files()
        for f in files:
            if f.get_name() == name:
                return f
        return None
1336983
def load_object(filename):
    """"""
    logging.info('loading {}...'.format(filename))
    try:
        with gzip.GzipFile(filename, 'rb') as f:
            buf = ''
            while True:
                data = f.read()
                if data == '':
                    break
                buf += data
            return pickle.loads(buf)
    except Exception as e:
        logging.error('load failure: {}'.format(e))
        raise
611748
def unpickle_file(picklefile, **kwargs):
    """"""
    with open(picklefile, 'rb') as f:
        return pickle.load(f, **kwargs)
460587
def csv_to_pickle(path=ROOT / "raw", clean=False):
    """"""

    for file in os.listdir(path):
        base, ext = os.path.splitext(file)
        if ext != ".csv":
            continue

        LOG(f"converting {file} to pickle")
        df = pd.read_csv(path / file, low_memory=True)
        WRITE_DF(df, path / (base + "." + FILE_EXTENSION), **WRITE_DF_OPTS)
        if clean:
            os.remove(path / file)
            LOG(f"removed {file}")
1065638
def load(self):
        
        try:
            with open(self.file_root + '.pkl', "rb") as f:
                return pickle.load(f)
        except IOError:
            raise CacheMissing(self.file_root)
774652
def save(self, fname: str):
        
        with open(fname, "wb") as fp:
            pickle.dump(self, fp)