The Gaudi Framework  v41r0 (bdbe7744)
Loading...
Searching...
No Matches
GaudiConfig2._db.ConfDB2 Class Reference

Public Member Functions

 __init__ (self)
 __getitem__ (self, key)
 __contains__ (self, key)
 __iter__ (self)

Protected Attributes

dict _dbs = {}

Detailed Description

Definition at line 17 of file _db.py.

Constructor & Destructor Documentation

◆ __init__()

GaudiConfig2._db.ConfDB2.__init__ ( self)

Definition at line 18 of file _db.py.

18 def __init__(self):
19 import shelve
20 from pathlib import Path
21
22 from GaudiPluginService.cpluginsvc import GAUDI_DEFAULT_PLUGIN_PATH
23
24 self._dbs = {}
25 ignored_files = set(os.environ.get("CONFIGURABLE_DB_IGNORE", "").split(","))
26 loaded = set()
27 for path in GAUDI_DEFAULT_PLUGIN_PATH:
28 if not path or not os.path.isdir(path):
29 continue
30 dbfiles = [
31 fabs
32 for f in Path(path).glob("*.confdb2")
33 if (fabs := f.absolute().as_posix()) not in ignored_files
34 and fabs not in loaded
35 ]
36 dbfiles.sort()
37 # Avoid loading same file twice (can happen if entries in search path point to same dir)
38 loaded.update(dbfiles)
39 for db in [shelve.open(f, "r") for f in dbfiles]:
40 for key in db:
41 self._dbs.setdefault(key, db)
42

Member Function Documentation

◆ __contains__()

GaudiConfig2._db.ConfDB2.__contains__ ( self,
key )

Definition at line 46 of file _db.py.

46 def __contains__(self, key):
47 return key in self._dbs
48

◆ __getitem__()

GaudiConfig2._db.ConfDB2.__getitem__ ( self,
key )

Definition at line 43 of file _db.py.

43 def __getitem__(self, key):
44 return self._dbs[key][key]
45

◆ __iter__()

GaudiConfig2._db.ConfDB2.__iter__ ( self)

Definition at line 49 of file _db.py.

49 def __iter__(self):
50 return iter(self._dbs)
51
52
53# allow overriding the low level DB access for testing

Member Data Documentation

◆ _dbs

GaudiConfig2._db.ConfDB2._dbs = {}
protected

Definition at line 24 of file _db.py.


The documentation for this class was generated from the following file:
  • GaudiConfiguration/python/GaudiConfig2/_db.py