cache.py¶
This module is responsible for accumulating all loaded objects and making sure
they are available in the xxx.db virtual module. It is used extensively in
load_conf.load_conf.
-
class
hutch_python.cache.LoadCache(module, hutch_dir=None, **objs)¶ Class that accumulates objects in a virtual module.
This virtual module can be imported from as if it were a normal module.
- Parameters
module (
str) – Name of the virtual module to create. If the module has the same name as a real module, the real module will be masked.hutch_dir (
Path, optional) – This allows us to write adb.txtfile to let the user know what objects get imported.**objs (kwargs) – Initial objects to place into the namespace
-
objs¶ This is a namespace containing all the objects that have been attached to the
LoadCache.- Type
-
__call__(**objs)¶ Add objects to the namespace.
- Parameters
**objs (kwargs) – The key will is the namespace-accessible name, and the object is the object we are adding.
-
spoof_module(module_name)¶ Create a fake module that is actually self.objs
-
write_file()¶ Write a
db.txtfile in the hutch’s directory. This file informs the user which objects get loaded byhutch-python.