/usr/lib/python2.7/dist-packages/bioblend/config.py is in python-bioblend 0.7.0-2.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 | import os
from six.moves import configparser
BioBlendConfigPath = '/etc/bioblend.cfg'
BioBlendConfigLocations = [BioBlendConfigPath]
UserConfigPath = os.path.join(os.path.expanduser('~'), '.bioblend')
BioBlendConfigLocations.append(UserConfigPath)
class Config(configparser.SafeConfigParser):
"""
BioBlend allows library-wide configuration to be set in external files.
These configuration files can be used to specify access keys, for example.
By default we use two locations for the BioBlend configurations:
* System wide: ``/etc/bioblend.cfg``
* Individual user: ``~/.bioblend`` (which works on both Windows and Unix)
"""
def __init__(self, path=None, fp=None, do_load=True):
configparser.SafeConfigParser.__init__(self, {'working_dir': '/mnt/pyami',
'debug': '0'})
if do_load:
if path:
self.load_from_path(path)
elif fp:
self.readfp(fp)
else:
self.read(BioBlendConfigLocations)
def get_value(self, section, name, default=None):
return self.get(section, name, default)
def get(self, section, name, default=None):
try:
val = configparser.SafeConfigParser.get(self, section, name)
except:
val = default
return val
def getint(self, section, name, default=0):
try:
val = configparser.SafeConfigParser.getint(self, section, name)
except:
val = int(default)
return val
def getfloat(self, section, name, default=0.0):
try:
val = configparser.SafeConfigParser.getfloat(self, section, name)
except:
val = float(default)
return val
def getbool(self, section, name, default=False):
if self.has_option(section, name):
val = self.get(section, name)
if val.lower() == 'true':
val = True
else:
val = False
else:
val = default
return val
|