The UtilityLayer¶
You can import from ./ or with bfly installed.
from bfly import UtilityLayer
Or, in scripts in some directories:
# if './bfly/' in sys.path
from CoreLayer.AccessLayer import UtilityLayer
# if './bfly/CoreLayer/' in sys.path
from AccessLayer import UtilityLayer
# if './bfly/CoreLayer/AccessLayer' in sys.path
from QueryLayer import UtilityLayer
# if './bfly/CoreLayer/AccessLayer/QueryLayer' in sys.path
import UtilityLayer
UtilityLayer¶
Provieds Keywords, Logging templates, and an argument handler.
-
UtilityLayer.BFLY_CONFIG¶ dict – Loads all data from the rh-config givenby the
rh_configmodule.
-
UtilityLayer.PORT= 2001¶
-
UtilityLayer.DB_TYPE= 'Nodb'¶
-
UtilityLayer.DB_PATH= 'bfly.db'¶
You can import UtilityLayer from bfly, CoreLayer, AccessLayer, and QueryLayer.
UtilityLayer classes¶
-
class
UtilityLayer.INPUT[source]¶ Keywords to read input files and requests All the attributes and their attributes store a mutable VALUE of and type, and some store a static NAME that should always be used externally.
-
METHODS¶ NamedStruct– All methods forRequestHandlerrequests
-
GROUP¶ NamedStruct– All groups from theUtilityLayer.BFLY_CONFIG
-
FEATURES¶ NamedStruct– All features for /api/entity_feature requests
-
POSITION¶ NamelessStruct– Center coordintates forDatabase.load_config()All coordinates forRequestHandlerrequests
-
RESOLUTION¶ NamelessStruct– All resolutions forRequestHandlerrequests
-
INFO¶ NamelessStruct– Formats for /api/channel_metadata requests and id for /api/entity_feature requests
-
IMAGE¶ NamelessStruct– Formats and views forRequestHandlerdata or mask requests.
-
-
class
UtilityLayer.RUNTIME[source]¶ Keywords passed between classes and layers. All the attributes and their attributes store a mutable VALUE of and type, and some store a static NAME that should always be used externally.
-
TILE¶
-
IMAGE¶
-
CACHE¶
-
DB¶ NamelessStruct– ForDatabaseLayer
-
-
class
UtilityLayer.OUTPUT[source]¶ Keywords used for writing out from server. All the attributes and their attributes store a mutable VALUE of and type, and some store a static NAME that should always be used externally.
-
INFO¶ NamelessStruct– Outputs for /api/channel_metadata requests
-
FEATURES¶ NamelessStruct– Outputs for /api/entity_feature requests
-
Private classes¶
-
class
UtilityLayer.NamedStruct(_name, **_keywords)[source]¶ It’s a NamelessStruct with a NAME attribute.
Parameters: - _name (str) – The name becomes
NAME - _keywords (dict) – Each keyword becomes an attribute
-
NAME¶ str – This is a constant used externally whenever passing the
VALUEattribute between classes, methods, and external files. AllNamedStructorNamelessStructwith aNamedStructattribute can access theNameStructwith the NAME as a dictionary key such as parent[‘a_name’].
-
LIST¶ list – see
NamelessStruct.LIST
-
VALUE¶ anything – see
NamelessStruct.VALUE
Methods
-
_n_get(name)¶ Get a
NamedStructattribute by NAME.Parameters: name (str) – The NAME attribute of the requested NamedStruct.
- _name (str) – The name becomes
-
class
UtilityLayer.NamelessStruct(**_keywords)[source]¶ Provides a dictionary-like class interface
Parameters: _keywords (dict) – Each keyword becomes an attribute -
VALUE¶ anything – Any instance has its own mutable VALUE.
-
LIST¶ list – All unique attributes are given here. If ‘LIST’ is given as a keyword, the orderof the attributes given in the ‘LIST’ keywordis preserved at the top of the
LIST.
Methods
-
_n_get(name)[source]¶ Get a
NamedStructattribute by NAME.Parameters: name (str) – The NAME attribute of the requested NamedStruct.
-
__getitem__(key)[source]¶ Get any attribute as if from a dictionary
If the attribute is a
NamedStruct, then the key can be either the attribute or the NAME of the attribute. The key is first used as an attribute and then used as a NAME with_n_get()if not an attribute.Parameters: key (str) – The attribute to get
-
get(key, default=None)[source]¶ Get any attribute with a default value
This returns
__getitem__()ordefault.Parameters: - key (str) – The attribute to get
- default (anything) – The value if attribute is not found.
-
__weakref__¶ list of weak references to the object (if defined)
-
UtilityLayer functions¶
-
UtilityLayer.to_argv(*args, **flags)¶ Turns arguments and keywords into a list
Parameters: - args (list) – All in list must be able to become
str - flags (dict) – All keys,values in dict must be able to become
str
Returns: Allows
argparse.ArgumentParserto handle a list and dictionary in the same way that it would handlesys.argv.Return type: list
- args (list) – All in list must be able to become
The Settings module¶
Loads Settings from UtilityLayer.rh_config
-
UtilityLayer.Settings.MAX_CACHE_SIZE¶ int – Cache 1024^3 bytes or 1024^2 times ‘max-cache-size’in megabytes from
config
-
UtilityLayer.Settings.config¶ dict – From
UtilityLayer.rh_config.config
-
UtilityLayer.Settings.config_filename¶ str – From
UtilityLayer.rh_config.config_filename
The rh_config module¶
Loads config from the path config_filename
-
UtilityLayer.rh_config.config_filename¶ str – Tries environment variable “RH_CONFIG_FILENAME” but defaults to ~/.rh-config.yaml.
-
UtilityLayer.rh_config.config¶ dict – Loaded from a yaml file at
config_filename