Mercurial > repos > shellac > guppy_basecaller
comparison env/lib/python3.7/site-packages/bioblend/config.py @ 0:26e78fe6e8c4 draft
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
author | shellac |
---|---|
date | Sat, 02 May 2020 07:14:21 -0400 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 0:26e78fe6e8c4 |
---|---|
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 |