File: config.py

package info (click to toggle)
python-bioblend 1.2.0-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 1,096 kB
  • sloc: python: 7,596; sh: 219; makefile: 158
file content (32 lines) | stat: -rw-r--r-- 1,065 bytes parent folder | download | duplicates (2)
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
import configparser
import os
from typing import (
    IO,
    Optional,
)

BioBlendConfigPath = "/etc/bioblend.cfg"
BioBlendConfigLocations = [BioBlendConfigPath]
UserConfigPath = os.path.join(os.path.expanduser("~"), ".bioblend")
BioBlendConfigLocations.append(UserConfigPath)


class Config(configparser.ConfigParser):
    """
    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: Optional[str] = None, fp: Optional[IO[str]] = None, do_load: bool = True) -> None:
        super().__init__({"working_dir": "/mnt/pyami", "debug": "0"})
        if do_load:
            if path:
                self.read([path])
            elif fp:
                self.read_file(fp)
            else:
                self.read(BioBlendConfigLocations)