comparison env/lib/python3.7/site-packages/bioblend/config.py @ 5:9b1c78e6ba9c draft default tip

"planemo upload commit 6c0a8142489327ece472c84e558c47da711a9142"
author shellac
date Mon, 01 Jun 2020 08:59:25 -0400
parents 79f47841a781
children
comparison
equal deleted inserted replaced
4:79f47841a781 5:9b1c78e6ba9c
1 import os
2
3 from six.moves import configparser
4
5 BioBlendConfigPath = '/etc/bioblend.cfg'
6 BioBlendConfigLocations = [BioBlendConfigPath]
7 UserConfigPath = os.path.join(os.path.expanduser('~'), '.bioblend')
8 BioBlendConfigLocations.append(UserConfigPath)
9
10
11 class Config(configparser.SafeConfigParser):
12 """
13 BioBlend allows library-wide configuration to be set in external files.
14 These configuration files can be used to specify access keys, for example.
15 By default we use two locations for the BioBlend configurations:
16
17 * System wide: ``/etc/bioblend.cfg``
18 * Individual user: ``~/.bioblend`` (which works on both Windows and Unix)
19 """
20 def __init__(self, path=None, fp=None, do_load=True):
21 configparser.SafeConfigParser.__init__(self, {'working_dir': '/mnt/pyami',
22 'debug': '0'})
23 if do_load:
24 if path:
25 self.load_from_path(path)
26 elif fp:
27 self.readfp(fp)
28 else:
29 self.read(BioBlendConfigLocations)
30
31 def get_value(self, section, name, default=None):
32 return self.get(section, name, default)
33
34 def get(self, section, name, default=None):
35 try:
36 val = configparser.SafeConfigParser.get(self, section, name)
37 except Exception:
38 val = default
39 return val
40
41 def getint(self, section, name, default=0):
42 try:
43 val = configparser.SafeConfigParser.getint(self, section, name)
44 except Exception:
45 val = int(default)
46 return val
47
48 def getfloat(self, section, name, default=0.0):
49 try:
50 val = configparser.SafeConfigParser.getfloat(self, section, name)
51 except Exception:
52 val = float(default)
53 return val
54
55 def getbool(self, section, name, default=False):
56 if self.has_option(section, name):
57 val = self.get(section, name)
58 if val.lower() == 'true':
59 val = True
60 else:
61 val = False
62 else:
63 val = default
64 return val