banana package
- banana.register(path)[source]
Register configurations.
This function is provided for its simple heuristics for configuration file detection. The idea behind is that it can be invoked by runner scripts in the following way:
import banana banana.register(__file__)
Thus, if it’s pointing to a file with a name different from the conventional one (see
cfg.name
), it is assumed that this file is in the same folder of the configuration file, that is named with the conventional name.- Parameters
path (str or os.PathLike) – a path pointing to configuration file, its parent directory, or another file in the same directory
Subpackages
Submodules
banana.cfg module
Configurations related objects.
This module contains the functions used to manage configurations.
Moreover, the actual loaded configurations are stored in the module variable
cfg
, that is used as the source of truth for them.
- banana.cfg.cfg = None
Global store for configurations
- banana.cfg.detect(path=None)[source]
Search configurations file.
It searches the configuration file in the following places, sorted:
provided path (e.g. CLI argument)
current directory
home directory
user default configurations directory
system default configurations directory
If the path resolved is a directory (all cases but file path provided), it is assumed that the file name is that stored in the module level variable
name
.- Parameters
path (str ot os.PathLike) – path to a configuration file, or to a folder containing it
- Returns
the resolved path
- Return type
- Raises
FileNotFoundError – if the configuration file is not foundd in any of the places above
- banana.cfg.load(path)[source]
Load configurations.
Load everything as a dictionary. Determines root from the loaded dictionary:
if the key root is found in the configuration file, it is treated as an absolute path, or a relative one (relative to the configuration file parent folder)
otherwise root is assigned to the configuration file parent folder itself
For the section “path”, all paths are converted to
pathlib.Path
type, and (if not absolute) they are considered to be relative to root.No other conversion is performed.
- Parameters
path (str or os.PathLike) – configurations file path
- Returns
loaded configurations
- Return type
- banana.cfg.name = 'banana.yaml'
Configurations file conventional name
banana.toy module
This module contains the Toy PDF.
It is defined at the initial scale \(Q = sqrt(2) GeV\).
- banana.toy.mkPDF(_setname, _member)[source]
Factory functions for making single PDF members.
Create a new PDF with the given PDF set name and member ID.