source: cowsclient/trunk/cowsclient/lib/utils.py @ 5698

Subversion URL: http://proj.badc.rl.ac.uk/svn/ndg/cowsclient/trunk/cowsclient/lib/utils.py@5698
Revision 5698, 971 bytes checked in by pnorton, 10 years ago (diff)

Implemented the display options to hide and set defaults for named endpoints and layers. This was done to hide some of the less common display options provided by the server but also allow them to be set on specific datasets.

Line 
1
2from cowsclient.lib.base import config
3
4import logging 
5import simplejson as json
6
7log = logging.getLogger(__name__)
8
9def readEndpoints():
10    endpoints = {}
11   
12    if 'endpointList' in config.keys():
13        log.debug("config['endpointList'] = %s" % (config['endpointList'],))
14       
15       
16        currentKey = None
17        for l in open(config['endpointList']):
18            l = l.strip()
19            if l == '' or l[0] == '#':
20                continue
21           
22            if l[0] == '[' and l[-1] == ']':
23                currentKey = l[1:-1]
24                log.debug("currentKey = %s" % (currentKey,))
25                continue
26           
27            if currentKey != None:
28                if currentKey not in endpoints:
29                    endpoints[currentKey] = []
30                endpoints[currentKey].append(l)
31                log.debug("l = %s" % (l,))
32   
33    return endpoints
34
35
36def toJSON(obj):
37    return json.dumps(obj).replace('"', '\\"')
38
39
Note: See TracBrowser for help on using the repository browser.