source: orga.py @ 38:8a694e2a6847

Revision 38:8a694e2a6847, 703 bytes checked in by hagenbruch@phoibe.ub.rub.de, 6 years ago (diff)

Version 0.3

Line 
1import redis
2
3def read_redis(redis_handle):
4    pnds = redis_handle.hgetall('pndorga')
5    tree = {}
6    for pnd in pnds:
7        orgas = eval(redis_handle.hget('pndorga', pnd))
8        for orga in orgas:
9            tree.setdefault('faculty', {}).setdefault(orga.get('fakultaet'), {}).setdefault(orga.get('fachgebiet'), set()).add(orga.get('institut'))
10            tree.setdefault('department', {}).setdefault(orga.get('fachgebiet'), set()).add(orga.get('institut'))
11    return tree
12
13r = redis.Redis(host='localhost', port=6379, db=0)
14orgas = read_redis(r)
15
16o = open('django/repo/search/orgas.py', 'w')
17o.write('faculties = %s\n' % orgas.get('faculty'))
18
19o.write('departments = %s\n'% orgas.get('department'))
Note: See TracBrowser for help on using the repository browser.