INNER CODE UNIT · Python

read_pickle_cache

unrealcv/synthetic-computer-vision · src/scholarutil.py:69

def read_pickle_cache(cache_file):
    # Use pickle to implement cache
    print 'Load cache from file %s' % cache_file
    if not os.path.isfile(cache_file):
        empty_db = dict(paper_list = [], scholar_data = [])
        return empty_db

    with open(cache_file, 'r') as f:
        db = pickle.load(f)
        assert(db.get('paper_list'))
        assert(db.get('scholar_data'))
        assert(len(db['paper_list']) == len(db['scholar_data']))
        return db

def save_pickle_cache(cache_file, obj):
    print 'Save obj to cache %s' % cache_file
    with open(cache_file, 'w') as f:
        pickle.dump(obj, f)

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…