Utilities¶
-
brain.utils.general.general.
build_routemap
(app)[source]¶ Builds a Flask Web App’s dictionary of routes
Constructs a dictionary containing all the routes defined inside a given Flask Web App. The route endpoints are deconstructed into a set of nested dictionaries of the form [blueprint][endpoint], which contains a methods and a url key. The url key returns the full route path.
E.g. the API route to get a cube, which has a name “getCube” is expressed as [‘api’][‘getCube’]. To access the url, [‘api’][‘getCube’][‘url’] returns “/marvin/api/cubes/{name}/”
- Parameters
app (Flask Application) – The Flask app to extract routes from
- Returns
A dict of all routes
-
brain.utils.general.general.
collaboration_authenticate
(username=None, password=None, verbose=None)[source]¶ Authenticate with Trac using Collaboration
Authenticate using the SDSS collaboration python package
-
brain.utils.general.general.
compress_data
(data, compress_with=None, uncompress=None)[source]¶ Compress data via json or msgpack
-
brain.utils.general.general.
convertIvarToErr
(ivar)[source]¶ Converts a list of inverse variance into an a list of standard errors
-
brain.utils.general.general.
getDbMachine
()[source]¶ Get the machine that the app is running on.
This determines correct database and app configuration
-
brain.utils.general.general.
get_db_user
(username, password, dbsession=None, user_model=None, request=None)[source]¶ Get a User from a database session
Gets a User object from the database User table. If the User does not exists, adds the User.
-
brain.utils.general.general.
get_yaml_loader
()[source]¶ Get a yaml loader based on the yaml package version
-
brain.utils.general.general.
inspection_authenticate
(session, username=None, password=None)[source]¶ Authenticate with Trac using Inspection
Deprecated since version 2.3.0.
Use
brain.utils.general.collaboration_authenticate
instead.
-
brain.utils.general.general.
merge
(user, default)[source]¶ Merges a user configuration with the default one.
Merges two dictionaries, replacing default values of similar matching keys from user.
-
brain.utils.general.general.
uncompress_data
(data, uncompress_with=None)[source]¶ Compress data via json or msgpack
- Parameters
data (obj) – The data to compress
uncompress_with (str) – Compression algorithm. Defaults to config.compression.
- Returns
Data compressed with with json or msgpack