repo
stringlengths
7
55
path
stringlengths
4
223
func_name
stringlengths
1
134
original_string
stringlengths
75
104k
language
stringclasses
1 value
code
stringlengths
75
104k
code_tokens
listlengths
19
28.4k
docstring
stringlengths
1
46.9k
docstring_tokens
listlengths
1
1.97k
sha
stringlengths
40
40
url
stringlengths
87
315
partition
stringclasses
1 value
jay-johnson/antinex-client
antinex_client/scripts/ai_train_dnn.py
train_new_deep_neural_network
def train_new_deep_neural_network(): """train_new_deep_neural_network Train a new deep neural network and store the results as a new: ``MLJob`` and ``MLJobResult`` database records. """ parser = argparse.ArgumentParser( description=( "Python client to Train a Deep Neural Netwo...
python
def train_new_deep_neural_network(): """train_new_deep_neural_network Train a new deep neural network and store the results as a new: ``MLJob`` and ``MLJobResult`` database records. """ parser = argparse.ArgumentParser( description=( "Python client to Train a Deep Neural Netwo...
[ "def", "train_new_deep_neural_network", "(", ")", ":", "parser", "=", "argparse", ".", "ArgumentParser", "(", "description", "=", "(", "\"Python client to Train a Deep Neural Network \"", "\"with AntiNex Django Rest Framework\"", ")", ")", "parser", ".", "add_argument", "("...
train_new_deep_neural_network Train a new deep neural network and store the results as a new: ``MLJob`` and ``MLJobResult`` database records.
[ "train_new_deep_neural_network" ]
850ba2a2fe21c836e071def618dcecc9caf5d59c
https://github.com/jay-johnson/antinex-client/blob/850ba2a2fe21c836e071def618dcecc9caf5d59c/antinex_client/scripts/ai_train_dnn.py#L22-L329
train
jay-johnson/antinex-client
antinex_client/scripts/ai_prepare_dataset.py
prepare_new_dataset
def prepare_new_dataset(): """prepare_new_dataset Prepare a new ``MLPrepare`` record and dataset files on disk. """ parser = argparse.ArgumentParser( description=( "Python client to Prepare a dataset")) parser.add_argument( "-u", help="username", requir...
python
def prepare_new_dataset(): """prepare_new_dataset Prepare a new ``MLPrepare`` record and dataset files on disk. """ parser = argparse.ArgumentParser( description=( "Python client to Prepare a dataset")) parser.add_argument( "-u", help="username", requir...
[ "def", "prepare_new_dataset", "(", ")", ":", "parser", "=", "argparse", ".", "ArgumentParser", "(", "description", "=", "(", "\"Python client to Prepare a dataset\"", ")", ")", "parser", ".", "add_argument", "(", "\"-u\"", ",", "help", "=", "\"username\"", ",", ...
prepare_new_dataset Prepare a new ``MLPrepare`` record and dataset files on disk.
[ "prepare_new_dataset" ]
850ba2a2fe21c836e071def618dcecc9caf5d59c
https://github.com/jay-johnson/antinex-client/blob/850ba2a2fe21c836e071def618dcecc9caf5d59c/antinex_client/scripts/ai_prepare_dataset.py#L21-L276
train
mrahnis/drapery
drapery/ops/sample.py
drape
def drape(raster, feature): """Convert a 2D feature to a 3D feature by sampling a raster Parameters: raster (rasterio): raster to provide the z coordinate feature (dict): fiona feature record to convert Returns: result (Point or Linestring): shapely Point or LineString of xyz coord...
python
def drape(raster, feature): """Convert a 2D feature to a 3D feature by sampling a raster Parameters: raster (rasterio): raster to provide the z coordinate feature (dict): fiona feature record to convert Returns: result (Point or Linestring): shapely Point or LineString of xyz coord...
[ "def", "drape", "(", "raster", ",", "feature", ")", ":", "coords", "=", "feature", "[", "'geometry'", "]", "[", "'coordinates'", "]", "geom_type", "=", "feature", "[", "'geometry'", "]", "[", "'type'", "]", "if", "geom_type", "==", "'Point'", ":", "xyz",...
Convert a 2D feature to a 3D feature by sampling a raster Parameters: raster (rasterio): raster to provide the z coordinate feature (dict): fiona feature record to convert Returns: result (Point or Linestring): shapely Point or LineString of xyz coordinate triples
[ "Convert", "a", "2D", "feature", "to", "a", "3D", "feature", "by", "sampling", "a", "raster" ]
c0c0906fb5ff846cf591cb9fe8a9eaee68e8820c
https://github.com/mrahnis/drapery/blob/c0c0906fb5ff846cf591cb9fe8a9eaee68e8820c/drapery/ops/sample.py#L6-L30
train
mrahnis/drapery
drapery/ops/sample.py
sample
def sample(raster, coords): """Sample a raster at given coordinates Given a list of coordinates, return a list of x,y,z triples with z coordinates sampled from an input raster Parameters: raster (rasterio): raster dataset to sample coords: array of tuples containing coordinate pairs (x,y) ...
python
def sample(raster, coords): """Sample a raster at given coordinates Given a list of coordinates, return a list of x,y,z triples with z coordinates sampled from an input raster Parameters: raster (rasterio): raster dataset to sample coords: array of tuples containing coordinate pairs (x,y) ...
[ "def", "sample", "(", "raster", ",", "coords", ")", ":", "if", "len", "(", "coords", "[", "0", "]", ")", "==", "3", ":", "logging", ".", "info", "(", "'Input is a 3D geometry, z coordinate will be updated.'", ")", "z", "=", "raster", ".", "sample", "(", ...
Sample a raster at given coordinates Given a list of coordinates, return a list of x,y,z triples with z coordinates sampled from an input raster Parameters: raster (rasterio): raster dataset to sample coords: array of tuples containing coordinate pairs (x,y) or triples (x,y,z) Returns: ...
[ "Sample", "a", "raster", "at", "given", "coordinates" ]
c0c0906fb5ff846cf591cb9fe8a9eaee68e8820c
https://github.com/mrahnis/drapery/blob/c0c0906fb5ff846cf591cb9fe8a9eaee68e8820c/drapery/ops/sample.py#L32-L53
train
jay-johnson/antinex-client
antinex_client/log/setup_logging.py
setup_logging
def setup_logging( default_level=logging.INFO, default_path="{}/logging.json".format( os.getenv( "LOG_DIR", os.path.dirname(os.path.realpath(__file__)))), env_key="LOG_CFG", config_name=None): """setup_logging Setup logging configurati...
python
def setup_logging( default_level=logging.INFO, default_path="{}/logging.json".format( os.getenv( "LOG_DIR", os.path.dirname(os.path.realpath(__file__)))), env_key="LOG_CFG", config_name=None): """setup_logging Setup logging configurati...
[ "def", "setup_logging", "(", "default_level", "=", "logging", ".", "INFO", ",", "default_path", "=", "\"{}/logging.json\"", ".", "format", "(", "os", ".", "getenv", "(", "\"LOG_DIR\"", ",", "os", ".", "path", ".", "dirname", "(", "os", ".", "path", ".", ...
setup_logging Setup logging configuration :param default_level: level to log :param default_path: path to config (optional) :param env_key: path to config in this env var :param config_name: filename for config
[ "setup_logging" ]
850ba2a2fe21c836e071def618dcecc9caf5d59c
https://github.com/jay-johnson/antinex-client/blob/850ba2a2fe21c836e071def618dcecc9caf5d59c/antinex_client/log/setup_logging.py#L6-L59
train
jay-johnson/antinex-client
antinex_client/log/setup_logging.py
build_logger
def build_logger( name=os.getenv( "LOG_NAME", "client"), config="logging.json", log_level=logging.INFO, log_config_path="{}/logging.json".format( os.getenv( "LOG_CFG", os.path.dirname(os.path.realpath(__file__))))): """build_logger :param name: na...
python
def build_logger( name=os.getenv( "LOG_NAME", "client"), config="logging.json", log_level=logging.INFO, log_config_path="{}/logging.json".format( os.getenv( "LOG_CFG", os.path.dirname(os.path.realpath(__file__))))): """build_logger :param name: na...
[ "def", "build_logger", "(", "name", "=", "os", ".", "getenv", "(", "\"LOG_NAME\"", ",", "\"client\"", ")", ",", "config", "=", "\"logging.json\"", ",", "log_level", "=", "logging", ".", "INFO", ",", "log_config_path", "=", "\"{}/logging.json\"", ".", "format",...
build_logger :param name: name that shows in the logger :param config: name of the config file :param log_level: level to log :param log_config_path: path to log config file
[ "build_logger" ]
850ba2a2fe21c836e071def618dcecc9caf5d59c
https://github.com/jay-johnson/antinex-client/blob/850ba2a2fe21c836e071def618dcecc9caf5d59c/antinex_client/log/setup_logging.py#L63-L94
train
jay-johnson/antinex-client
antinex_client/log/setup_logging.py
build_colorized_logger
def build_colorized_logger( name=os.getenv( "LOG_NAME", "client"), config="colors-logging.json", log_level=logging.INFO, log_config_path="{}/logging.json".format( os.getenv( "LOG_CFG", os.path.dirname(os.path.realpath(__file__))))): """build_colorized_...
python
def build_colorized_logger( name=os.getenv( "LOG_NAME", "client"), config="colors-logging.json", log_level=logging.INFO, log_config_path="{}/logging.json".format( os.getenv( "LOG_CFG", os.path.dirname(os.path.realpath(__file__))))): """build_colorized_...
[ "def", "build_colorized_logger", "(", "name", "=", "os", ".", "getenv", "(", "\"LOG_NAME\"", ",", "\"client\"", ")", ",", "config", "=", "\"colors-logging.json\"", ",", "log_level", "=", "logging", ".", "INFO", ",", "log_config_path", "=", "\"{}/logging.json\"", ...
build_colorized_logger :param name: name that shows in the logger :param config: name of the config file :param log_level: level to log :param log_config_path: path to log config file
[ "build_colorized_logger" ]
850ba2a2fe21c836e071def618dcecc9caf5d59c
https://github.com/jay-johnson/antinex-client/blob/850ba2a2fe21c836e071def618dcecc9caf5d59c/antinex_client/log/setup_logging.py#L98-L169
train
feliphebueno/Rinzler
rinzler/auth/base_auth_service.py
BaseAuthService.authenticate
def authenticate(self, request: HttpRequest, auth_route: str, actual_params: dict) -> bool: """ Your AuhtService should override this method for request authentication, otherwise means no authentication. :param request: HttpRequest Django's HttpRequest object :param auth_route: str User'...
python
def authenticate(self, request: HttpRequest, auth_route: str, actual_params: dict) -> bool: """ Your AuhtService should override this method for request authentication, otherwise means no authentication. :param request: HttpRequest Django's HttpRequest object :param auth_route: str User'...
[ "def", "authenticate", "(", "self", ",", "request", ":", "HttpRequest", ",", "auth_route", ":", "str", ",", "actual_params", ":", "dict", ")", "->", "bool", ":", "if", "auth_route", "and", "actual_params", ":", "self", ".", "auth_data", "=", "{", "}", "r...
Your AuhtService should override this method for request authentication, otherwise means no authentication. :param request: HttpRequest Django's HttpRequest object :param auth_route: str User's resqueted route :param actual_params: User's url parameters :return: bool
[ "Your", "AuhtService", "should", "override", "this", "method", "for", "request", "authentication", "otherwise", "means", "no", "authentication", ".", ":", "param", "request", ":", "HttpRequest", "Django", "s", "HttpRequest", "object", ":", "param", "auth_route", "...
7f6d5445b5662cba2e8938bb82c7f3ef94e5ded8
https://github.com/feliphebueno/Rinzler/blob/7f6d5445b5662cba2e8938bb82c7f3ef94e5ded8/rinzler/auth/base_auth_service.py#L13-L23
train
mrahnis/drapery
drapery/cli/drape.py
cli
def cli(source_f, raster_f, output, verbose): """ Converts 2D geometries to 3D using GEOS sample through fiona. \b Example: drape point.shp elevation.tif -o point_z.shp """ with fiona.open(source_f, 'r') as source: source_driver = source.driver source_crs = source.crs ...
python
def cli(source_f, raster_f, output, verbose): """ Converts 2D geometries to 3D using GEOS sample through fiona. \b Example: drape point.shp elevation.tif -o point_z.shp """ with fiona.open(source_f, 'r') as source: source_driver = source.driver source_crs = source.crs ...
[ "def", "cli", "(", "source_f", ",", "raster_f", ",", "output", ",", "verbose", ")", ":", "with", "fiona", ".", "open", "(", "source_f", ",", "'r'", ")", "as", "source", ":", "source_driver", "=", "source", ".", "driver", "source_crs", "=", "source", "....
Converts 2D geometries to 3D using GEOS sample through fiona. \b Example: drape point.shp elevation.tif -o point_z.shp
[ "Converts", "2D", "geometries", "to", "3D", "using", "GEOS", "sample", "through", "fiona", "." ]
c0c0906fb5ff846cf591cb9fe8a9eaee68e8820c
https://github.com/mrahnis/drapery/blob/c0c0906fb5ff846cf591cb9fe8a9eaee68e8820c/drapery/cli/drape.py#L21-L67
train
praekeltfoundation/molo.commenting
molo/commenting/managers.py
MoloCommentManager.for_model
def for_model(self, model): """ QuerySet for all comments for a particular model (either an instance or a class). """ ct = ContentType.objects.get_for_model(model) qs = self.get_queryset().filter(content_type=ct) if isinstance(model, models.Model): qs ...
python
def for_model(self, model): """ QuerySet for all comments for a particular model (either an instance or a class). """ ct = ContentType.objects.get_for_model(model) qs = self.get_queryset().filter(content_type=ct) if isinstance(model, models.Model): qs ...
[ "def", "for_model", "(", "self", ",", "model", ")", ":", "ct", "=", "ContentType", ".", "objects", ".", "get_for_model", "(", "model", ")", "qs", "=", "self", ".", "get_queryset", "(", ")", ".", "filter", "(", "content_type", "=", "ct", ")", "if", "i...
QuerySet for all comments for a particular model (either an instance or a class).
[ "QuerySet", "for", "all", "comments", "for", "a", "particular", "model", "(", "either", "an", "instance", "or", "a", "class", ")", "." ]
94549bd75e4a5c5b3db43149e32d636330b3969c
https://github.com/praekeltfoundation/molo.commenting/blob/94549bd75e4a5c5b3db43149e32d636330b3969c/molo/commenting/managers.py#L9-L18
train
oksome/Skink
skink/remote.py
RemotePage.eval
def eval(self, command): 'Blocking call, returns the value of the execution in JS' event = threading.Event() # TODO: Add event to server #job_id = str(id(command)) import random job_id = str(random.random()) server.EVALUATIONS[job_id] = event message = '?...
python
def eval(self, command): 'Blocking call, returns the value of the execution in JS' event = threading.Event() # TODO: Add event to server #job_id = str(id(command)) import random job_id = str(random.random()) server.EVALUATIONS[job_id] = event message = '?...
[ "def", "eval", "(", "self", ",", "command", ")", ":", "event", "=", "threading", ".", "Event", "(", ")", "# TODO: Add event to server", "#job_id = str(id(command))", "import", "random", "job_id", "=", "str", "(", "random", ".", "random", "(", ")", ")", "serv...
Blocking call, returns the value of the execution in JS
[ "Blocking", "call", "returns", "the", "value", "of", "the", "execution", "in", "JS" ]
77560fb92749c1a21924cbd0017b8481a727be3e
https://github.com/oksome/Skink/blob/77560fb92749c1a21924cbd0017b8481a727be3e/skink/remote.py#L132-L158
train
oksome/Skink
skink/remote.py
RemotePage.register
def register(self, callback, name): 'Register a callback on server and on connected clients.' server.CALLBACKS[name] = callback self.run(''' window.skink.%s = function(args=[]) { window.skink.call("%s", args); }''' % (name, name))
python
def register(self, callback, name): 'Register a callback on server and on connected clients.' server.CALLBACKS[name] = callback self.run(''' window.skink.%s = function(args=[]) { window.skink.call("%s", args); }''' % (name, name))
[ "def", "register", "(", "self", ",", "callback", ",", "name", ")", ":", "server", ".", "CALLBACKS", "[", "name", "]", "=", "callback", "self", ".", "run", "(", "'''\n window.skink.%s = function(args=[]) {\n window.skink.call(\"%s\", args);\n ...
Register a callback on server and on connected clients.
[ "Register", "a", "callback", "on", "server", "and", "on", "connected", "clients", "." ]
77560fb92749c1a21924cbd0017b8481a727be3e
https://github.com/oksome/Skink/blob/77560fb92749c1a21924cbd0017b8481a727be3e/skink/remote.py#L160-L166
train
oksome/Skink
skink/server.py
launch_exception
def launch_exception(message): """ Launch a Python exception from an error that took place in the browser. messsage format: - name: str - description: str """ error_name = message['name'] error_descr = message['description'] mapping = { 'ReferenceError': Name...
python
def launch_exception(message): """ Launch a Python exception from an error that took place in the browser. messsage format: - name: str - description: str """ error_name = message['name'] error_descr = message['description'] mapping = { 'ReferenceError': Name...
[ "def", "launch_exception", "(", "message", ")", ":", "error_name", "=", "message", "[", "'name'", "]", "error_descr", "=", "message", "[", "'description'", "]", "mapping", "=", "{", "'ReferenceError'", ":", "NameError", ",", "}", "if", "message", "[", "'name...
Launch a Python exception from an error that took place in the browser. messsage format: - name: str - description: str
[ "Launch", "a", "Python", "exception", "from", "an", "error", "that", "took", "place", "in", "the", "browser", "." ]
77560fb92749c1a21924cbd0017b8481a727be3e
https://github.com/oksome/Skink/blob/77560fb92749c1a21924cbd0017b8481a727be3e/skink/server.py#L42-L58
train
jay-johnson/antinex-client
antinex_client/scripts/ai_env_predict.py
start_predictions
def start_predictions(): """start_predictions Using environment variables, create an AntiNex AI Client. You can also use command line args if you want. This can train a new deep neural network if it does not exist or it can use an existing pre-trained deep neural network within the AntiNex Cor...
python
def start_predictions(): """start_predictions Using environment variables, create an AntiNex AI Client. You can also use command line args if you want. This can train a new deep neural network if it does not exist or it can use an existing pre-trained deep neural network within the AntiNex Cor...
[ "def", "start_predictions", "(", ")", ":", "parser", "=", "argparse", ".", "ArgumentParser", "(", "description", "=", "(", "\"Python client to make Predictions \"", "\"using a Pre-trained Deep Neural Network \"", "\"with AntiNex Django Rest Framework\"", ")", ")", "parser", "...
start_predictions Using environment variables, create an AntiNex AI Client. You can also use command line args if you want. This can train a new deep neural network if it does not exist or it can use an existing pre-trained deep neural network within the AntiNex Core to make new predictions.
[ "start_predictions" ]
850ba2a2fe21c836e071def618dcecc9caf5d59c
https://github.com/jay-johnson/antinex-client/blob/850ba2a2fe21c836e071def618dcecc9caf5d59c/antinex_client/scripts/ai_env_predict.py#L23-L288
train
jay-johnson/antinex-client
antinex_client/ai_client.py
AIClient.login
def login( self): """login""" auth_url = self.api_urls["login"] if self.verbose: log.info(("log in user={} url={} ca_dir={} cert={}") .format( self.user, auth_url, self.ca_dir, ...
python
def login( self): """login""" auth_url = self.api_urls["login"] if self.verbose: log.info(("log in user={} url={} ca_dir={} cert={}") .format( self.user, auth_url, self.ca_dir, ...
[ "def", "login", "(", "self", ")", ":", "auth_url", "=", "self", ".", "api_urls", "[", "\"login\"", "]", "if", "self", ".", "verbose", ":", "log", ".", "info", "(", "(", "\"log in user={} url={} ca_dir={} cert={}\"", ")", ".", "format", "(", "self", ".", ...
login
[ "login" ]
850ba2a2fe21c836e071def618dcecc9caf5d59c
https://github.com/jay-johnson/antinex-client/blob/850ba2a2fe21c836e071def618dcecc9caf5d59c/antinex_client/ai_client.py#L121-L186
train
jay-johnson/antinex-client
antinex_client/ai_client.py
AIClient.build_response
def build_response( self, status=NOT_SET, error="", data=None): """build_response :param status: status code :param error: error message :param data: dictionary to send back """ res_node = { "status": status, ...
python
def build_response( self, status=NOT_SET, error="", data=None): """build_response :param status: status code :param error: error message :param data: dictionary to send back """ res_node = { "status": status, ...
[ "def", "build_response", "(", "self", ",", "status", "=", "NOT_SET", ",", "error", "=", "\"\"", ",", "data", "=", "None", ")", ":", "res_node", "=", "{", "\"status\"", ":", "status", ",", "\"error\"", ":", "error", ",", "\"data\"", ":", "data", "}", ...
build_response :param status: status code :param error: error message :param data: dictionary to send back
[ "build_response" ]
850ba2a2fe21c836e071def618dcecc9caf5d59c
https://github.com/jay-johnson/antinex-client/blob/850ba2a2fe21c836e071def618dcecc9caf5d59c/antinex_client/ai_client.py#L211-L228
train
jay-johnson/antinex-client
antinex_client/ai_client.py
AIClient.retry_login
def retry_login( self): """retry_login""" if not self.user or not self.password: return self.build_response( status=ERROR, error="please set the user and password") retry = 0 not_done = True while not_done: if ...
python
def retry_login( self): """retry_login""" if not self.user or not self.password: return self.build_response( status=ERROR, error="please set the user and password") retry = 0 not_done = True while not_done: if ...
[ "def", "retry_login", "(", "self", ")", ":", "if", "not", "self", ".", "user", "or", "not", "self", ".", "password", ":", "return", "self", ".", "build_response", "(", "status", "=", "ERROR", ",", "error", "=", "\"please set the user and password\"", ")", ...
retry_login
[ "retry_login" ]
850ba2a2fe21c836e071def618dcecc9caf5d59c
https://github.com/jay-johnson/antinex-client/blob/850ba2a2fe21c836e071def618dcecc9caf5d59c/antinex_client/ai_client.py#L231-L273
train
jay-johnson/antinex-client
antinex_client/ai_client.py
AIClient.get_prepare_by_id
def get_prepare_by_id( self, prepare_id=None): """get_prepare_by_id :param prepare_id: MLJob.id in the database """ if not prepare_id: log.error("missing prepare_id for get_prepare_by_id") return self.build_response( statu...
python
def get_prepare_by_id( self, prepare_id=None): """get_prepare_by_id :param prepare_id: MLJob.id in the database """ if not prepare_id: log.error("missing prepare_id for get_prepare_by_id") return self.build_response( statu...
[ "def", "get_prepare_by_id", "(", "self", ",", "prepare_id", "=", "None", ")", ":", "if", "not", "prepare_id", ":", "log", ".", "error", "(", "\"missing prepare_id for get_prepare_by_id\"", ")", "return", "self", ".", "build_response", "(", "status", "=", "ERROR"...
get_prepare_by_id :param prepare_id: MLJob.id in the database
[ "get_prepare_by_id" ]
850ba2a2fe21c836e071def618dcecc9caf5d59c
https://github.com/jay-johnson/antinex-client/blob/850ba2a2fe21c836e071def618dcecc9caf5d59c/antinex_client/ai_client.py#L276-L377
train
jay-johnson/antinex-client
antinex_client/ai_client.py
AIClient.wait_for_job_to_finish
def wait_for_job_to_finish( self, job_id, sec_to_sleep=5.0, max_retries=100000): """wait_for_job_to_finish :param job_id: MLJob.id to wait on :param sec_to_sleep: seconds to sleep during polling :param max_retries: max retires until stoppi...
python
def wait_for_job_to_finish( self, job_id, sec_to_sleep=5.0, max_retries=100000): """wait_for_job_to_finish :param job_id: MLJob.id to wait on :param sec_to_sleep: seconds to sleep during polling :param max_retries: max retires until stoppi...
[ "def", "wait_for_job_to_finish", "(", "self", ",", "job_id", ",", "sec_to_sleep", "=", "5.0", ",", "max_retries", "=", "100000", ")", ":", "not_done", "=", "True", "retry_attempt", "=", "1", "while", "not_done", ":", "if", "self", ".", "debug", ":", "log",...
wait_for_job_to_finish :param job_id: MLJob.id to wait on :param sec_to_sleep: seconds to sleep during polling :param max_retries: max retires until stopping
[ "wait_for_job_to_finish" ]
850ba2a2fe21c836e071def618dcecc9caf5d59c
https://github.com/jay-johnson/antinex-client/blob/850ba2a2fe21c836e071def618dcecc9caf5d59c/antinex_client/ai_client.py#L726-L870
train
jay-johnson/antinex-client
antinex_client/ai_client.py
AIClient.wait_for_prepare_to_finish
def wait_for_prepare_to_finish( self, prepare_id, sec_to_sleep=5.0, max_retries=100000): """wait_for_prepare_to_finish :param prepare_id: MLPrepare.id to wait on :param sec_to_sleep: seconds to sleep during polling :param max_retries: max ...
python
def wait_for_prepare_to_finish( self, prepare_id, sec_to_sleep=5.0, max_retries=100000): """wait_for_prepare_to_finish :param prepare_id: MLPrepare.id to wait on :param sec_to_sleep: seconds to sleep during polling :param max_retries: max ...
[ "def", "wait_for_prepare_to_finish", "(", "self", ",", "prepare_id", ",", "sec_to_sleep", "=", "5.0", ",", "max_retries", "=", "100000", ")", ":", "not_done", "=", "True", "retry_attempt", "=", "1", "while", "not_done", ":", "if", "self", ".", "debug", ":", ...
wait_for_prepare_to_finish :param prepare_id: MLPrepare.id to wait on :param sec_to_sleep: seconds to sleep during polling :param max_retries: max retires until stopping
[ "wait_for_prepare_to_finish" ]
850ba2a2fe21c836e071def618dcecc9caf5d59c
https://github.com/jay-johnson/antinex-client/blob/850ba2a2fe21c836e071def618dcecc9caf5d59c/antinex_client/ai_client.py#L985-L1065
train
praekeltfoundation/molo.commenting
molo/commenting/forms.py
MoloCommentForm.get_comment_object
def get_comment_object(self): """ NB: Overridden to remove dupe comment check for admins (necessary for canned responses) Return a new (unsaved) comment object based on the information in this form. Assumes that the form is already validated and will throw a ValueError i...
python
def get_comment_object(self): """ NB: Overridden to remove dupe comment check for admins (necessary for canned responses) Return a new (unsaved) comment object based on the information in this form. Assumes that the form is already validated and will throw a ValueError i...
[ "def", "get_comment_object", "(", "self", ")", ":", "if", "not", "self", ".", "is_valid", "(", ")", ":", "raise", "ValueError", "(", "\"get_comment_object may only be called on valid forms\"", ")", "CommentModel", "=", "self", ".", "get_comment_model", "(", ")", "...
NB: Overridden to remove dupe comment check for admins (necessary for canned responses) Return a new (unsaved) comment object based on the information in this form. Assumes that the form is already validated and will throw a ValueError if not. Does not set any of the fields tha...
[ "NB", ":", "Overridden", "to", "remove", "dupe", "comment", "check", "for", "admins", "(", "necessary", "for", "canned", "responses", ")" ]
94549bd75e4a5c5b3db43149e32d636330b3969c
https://github.com/praekeltfoundation/molo.commenting/blob/94549bd75e4a5c5b3db43149e32d636330b3969c/molo/commenting/forms.py#L31-L59
train
feliphebueno/Rinzler
rinzler/__init__.py
boot
def boot(app_name) -> Rinzler: """ Start Rinzler App :param app_name: str Application's identifier :return: dict """ app = Rinzler(app_name) app.log.info("App booted =)") return app
python
def boot(app_name) -> Rinzler: """ Start Rinzler App :param app_name: str Application's identifier :return: dict """ app = Rinzler(app_name) app.log.info("App booted =)") return app
[ "def", "boot", "(", "app_name", ")", "->", "Rinzler", ":", "app", "=", "Rinzler", "(", "app_name", ")", "app", ".", "log", ".", "info", "(", "\"App booted =)\"", ")", "return", "app" ]
Start Rinzler App :param app_name: str Application's identifier :return: dict
[ "Start", "Rinzler", "App", ":", "param", "app_name", ":", "str", "Application", "s", "identifier", ":", "return", ":", "dict" ]
7f6d5445b5662cba2e8938bb82c7f3ef94e5ded8
https://github.com/feliphebueno/Rinzler/blob/7f6d5445b5662cba2e8938bb82c7f3ef94e5ded8/rinzler/__init__.py#L391-L400
train
feliphebueno/Rinzler
rinzler/__init__.py
Rinzler.mount
def mount(self, route: str, controller: callable) -> url: """ Maps a route namespace with the given params and point it's requests to the especified controller. :param route: str Namespace route to be mapped :param controller: callback Controller callable to map end-points :rtype...
python
def mount(self, route: str, controller: callable) -> url: """ Maps a route namespace with the given params and point it's requests to the especified controller. :param route: str Namespace route to be mapped :param controller: callback Controller callable to map end-points :rtype...
[ "def", "mount", "(", "self", ",", "route", ":", "str", ",", "controller", ":", "callable", ")", "->", "url", ":", "if", "issubclass", "(", "controller", ",", "TemplateView", ")", ":", "return", "url", "(", "r\"%s\"", "%", "route", ",", "Router", "(", ...
Maps a route namespace with the given params and point it's requests to the especified controller. :param route: str Namespace route to be mapped :param controller: callback Controller callable to map end-points :rtype: url
[ "Maps", "a", "route", "namespace", "with", "the", "given", "params", "and", "point", "it", "s", "requests", "to", "the", "especified", "controller", ".", ":", "param", "route", ":", "str", "Namespace", "route", "to", "be", "mapped", ":", "param", "controll...
7f6d5445b5662cba2e8938bb82c7f3ef94e5ded8
https://github.com/feliphebueno/Rinzler/blob/7f6d5445b5662cba2e8938bb82c7f3ef94e5ded8/rinzler/__init__.py#L52-L68
train
feliphebueno/Rinzler
rinzler/__init__.py
Rinzler.set_auth_service
def set_auth_service(self, auth_service: BaseAuthService): """ Sets the authentication service :param auth_service: BaseAuthService Authentication service :raises: TypeError If the auth_service object is not a subclass of rinzler.auth.BaseAuthService :rtype: Rinzler """ ...
python
def set_auth_service(self, auth_service: BaseAuthService): """ Sets the authentication service :param auth_service: BaseAuthService Authentication service :raises: TypeError If the auth_service object is not a subclass of rinzler.auth.BaseAuthService :rtype: Rinzler """ ...
[ "def", "set_auth_service", "(", "self", ",", "auth_service", ":", "BaseAuthService", ")", ":", "if", "issubclass", "(", "auth_service", ".", "__class__", ",", "BaseAuthService", ")", ":", "self", ".", "auth_service", "=", "auth_service", "return", "self", "else"...
Sets the authentication service :param auth_service: BaseAuthService Authentication service :raises: TypeError If the auth_service object is not a subclass of rinzler.auth.BaseAuthService :rtype: Rinzler
[ "Sets", "the", "authentication", "service", ":", "param", "auth_service", ":", "BaseAuthService", "Authentication", "service", ":", "raises", ":", "TypeError", "If", "the", "auth_service", "object", "is", "not", "a", "subclass", "of", "rinzler", ".", "auth", "."...
7f6d5445b5662cba2e8938bb82c7f3ef94e5ded8
https://github.com/feliphebueno/Rinzler/blob/7f6d5445b5662cba2e8938bb82c7f3ef94e5ded8/rinzler/__init__.py#L88-L99
train
feliphebueno/Rinzler
rinzler/__init__.py
Router.handle
def handle(self, request: HttpRequest) -> HttpResponse: """ Prepares for the CallBackResolver and handles the response and exceptions :param request HttpRequest :rtype: HttpResponse """ self.__request_start = datetime.now() self.__request = request self.__...
python
def handle(self, request: HttpRequest) -> HttpResponse: """ Prepares for the CallBackResolver and handles the response and exceptions :param request HttpRequest :rtype: HttpResponse """ self.__request_start = datetime.now() self.__request = request self.__...
[ "def", "handle", "(", "self", ",", "request", ":", "HttpRequest", ")", "->", "HttpResponse", ":", "self", ".", "__request_start", "=", "datetime", ".", "now", "(", ")", "self", ".", "__request", "=", "request", "self", ".", "__uri", "=", "request", ".", ...
Prepares for the CallBackResolver and handles the response and exceptions :param request HttpRequest :rtype: HttpResponse
[ "Prepares", "for", "the", "CallBackResolver", "and", "handles", "the", "response", "and", "exceptions", ":", "param", "request", "HttpRequest", ":", "rtype", ":", "HttpResponse" ]
7f6d5445b5662cba2e8938bb82c7f3ef94e5ded8
https://github.com/feliphebueno/Rinzler/blob/7f6d5445b5662cba2e8938bb82c7f3ef94e5ded8/rinzler/__init__.py#L125-L165
train
feliphebueno/Rinzler
rinzler/__init__.py
Router.exec_route_callback
def exec_route_callback(self) -> Response or object: """ Executes the resolved end-point callback, or its fallback :rtype: Response or object """ if self.__method.lower() in self.__end_points: for bound in self.__end_points[self.__method.lower()]: rou...
python
def exec_route_callback(self) -> Response or object: """ Executes the resolved end-point callback, or its fallback :rtype: Response or object """ if self.__method.lower() in self.__end_points: for bound in self.__end_points[self.__method.lower()]: rou...
[ "def", "exec_route_callback", "(", "self", ")", "->", "Response", "or", "object", ":", "if", "self", ".", "__method", ".", "lower", "(", ")", "in", "self", ".", "__end_points", ":", "for", "bound", "in", "self", ".", "__end_points", "[", "self", ".", "...
Executes the resolved end-point callback, or its fallback :rtype: Response or object
[ "Executes", "the", "resolved", "end", "-", "point", "callback", "or", "its", "fallback", ":", "rtype", ":", "Response", "or", "object" ]
7f6d5445b5662cba2e8938bb82c7f3ef94e5ded8
https://github.com/feliphebueno/Rinzler/blob/7f6d5445b5662cba2e8938bb82c7f3ef94e5ded8/rinzler/__init__.py#L167-L201
train
feliphebueno/Rinzler
rinzler/__init__.py
Router.request_matches_route
def request_matches_route(self, actual_route: str, expected_route: str): """ Determines whether a route matches the actual requested route or not :param actual_route str :param expected_route :rtype: Boolean """ expected_params = self.get_url_params(expected_route...
python
def request_matches_route(self, actual_route: str, expected_route: str): """ Determines whether a route matches the actual requested route or not :param actual_route str :param expected_route :rtype: Boolean """ expected_params = self.get_url_params(expected_route...
[ "def", "request_matches_route", "(", "self", ",", "actual_route", ":", "str", ",", "expected_route", ":", "str", ")", ":", "expected_params", "=", "self", ".", "get_url_params", "(", "expected_route", ")", "actual_params", "=", "self", ".", "get_url_params", "("...
Determines whether a route matches the actual requested route or not :param actual_route str :param expected_route :rtype: Boolean
[ "Determines", "whether", "a", "route", "matches", "the", "actual", "requested", "route", "or", "not", ":", "param", "actual_route", "str", ":", "param", "expected_route", ":", "rtype", ":", "Boolean" ]
7f6d5445b5662cba2e8938bb82c7f3ef94e5ded8
https://github.com/feliphebueno/Rinzler/blob/7f6d5445b5662cba2e8938bb82c7f3ef94e5ded8/rinzler/__init__.py#L203-L223
train
feliphebueno/Rinzler
rinzler/__init__.py
Router.authenticate
def authenticate(self, bound_route, actual_params) -> bool: """ Runs the pre-defined authenticaton service :param bound_route str route matched :param actual_params dict actual url parameters :rtype: bool """ if self.__auth_service is not None: auth_ro...
python
def authenticate(self, bound_route, actual_params) -> bool: """ Runs the pre-defined authenticaton service :param bound_route str route matched :param actual_params dict actual url parameters :rtype: bool """ if self.__auth_service is not None: auth_ro...
[ "def", "authenticate", "(", "self", ",", "bound_route", ",", "actual_params", ")", "->", "bool", ":", "if", "self", ".", "__auth_service", "is", "not", "None", ":", "auth_route", "=", "\"{0}_{1}{2}\"", ".", "format", "(", "self", ".", "__method", ",", "sel...
Runs the pre-defined authenticaton service :param bound_route str route matched :param actual_params dict actual url parameters :rtype: bool
[ "Runs", "the", "pre", "-", "defined", "authenticaton", "service", ":", "param", "bound_route", "str", "route", "matched", ":", "param", "actual_params", "dict", "actual", "url", "parameters", ":", "rtype", ":", "bool" ]
7f6d5445b5662cba2e8938bb82c7f3ef94e5ded8
https://github.com/feliphebueno/Rinzler/blob/7f6d5445b5662cba2e8938bb82c7f3ef94e5ded8/rinzler/__init__.py#L225-L240
train
feliphebueno/Rinzler
rinzler/__init__.py
Router.get_callback_pattern
def get_callback_pattern(expected_params, actual_params): """ Assembles a dictionary whith the parameters schema defined for this route :param expected_params dict parameters schema defined for this route :param actual_params dict actual url parameters :rtype: dict """ ...
python
def get_callback_pattern(expected_params, actual_params): """ Assembles a dictionary whith the parameters schema defined for this route :param expected_params dict parameters schema defined for this route :param actual_params dict actual url parameters :rtype: dict """ ...
[ "def", "get_callback_pattern", "(", "expected_params", ",", "actual_params", ")", ":", "pattern", "=", "dict", "(", ")", "key", "=", "0", "for", "exp_param", "in", "expected_params", ":", "if", "exp_param", "[", "0", "]", "==", "'{'", "and", "exp_param", "...
Assembles a dictionary whith the parameters schema defined for this route :param expected_params dict parameters schema defined for this route :param actual_params dict actual url parameters :rtype: dict
[ "Assembles", "a", "dictionary", "whith", "the", "parameters", "schema", "defined", "for", "this", "route", ":", "param", "expected_params", "dict", "parameters", "schema", "defined", "for", "this", "route", ":", "param", "actual_params", "dict", "actual", "url", ...
7f6d5445b5662cba2e8938bb82c7f3ef94e5ded8
https://github.com/feliphebueno/Rinzler/blob/7f6d5445b5662cba2e8938bb82c7f3ef94e5ded8/rinzler/__init__.py#L243-L256
train
feliphebueno/Rinzler
rinzler/__init__.py
Router.get_url_params
def get_url_params(end_point: str) -> list: """ Gets route parameters as dictionary :param end_point str target route :rtype: list """ var_params = end_point.split('/') if len(var_params) == 1 and var_params[0] == '': return [] elif len(var_p...
python
def get_url_params(end_point: str) -> list: """ Gets route parameters as dictionary :param end_point str target route :rtype: list """ var_params = end_point.split('/') if len(var_params) == 1 and var_params[0] == '': return [] elif len(var_p...
[ "def", "get_url_params", "(", "end_point", ":", "str", ")", "->", "list", ":", "var_params", "=", "end_point", ".", "split", "(", "'/'", ")", "if", "len", "(", "var_params", ")", "==", "1", "and", "var_params", "[", "0", "]", "==", "''", ":", "return...
Gets route parameters as dictionary :param end_point str target route :rtype: list
[ "Gets", "route", "parameters", "as", "dictionary", ":", "param", "end_point", "str", "target", "route", ":", "rtype", ":", "list" ]
7f6d5445b5662cba2e8938bb82c7f3ef94e5ded8
https://github.com/feliphebueno/Rinzler/blob/7f6d5445b5662cba2e8938bb82c7f3ef94e5ded8/rinzler/__init__.py#L259-L277
train
feliphebueno/Rinzler
rinzler/__init__.py
Router.set_end_point_uri
def set_end_point_uri(self) -> bool: """ Extracts the route from the accessed URL and sets it to __end_point_uri :rtype: bool """ expected_parts = self.__route.split("/") actual_parts = self.__uri.split("/") i = 0 for part in expected_parts: i...
python
def set_end_point_uri(self) -> bool: """ Extracts the route from the accessed URL and sets it to __end_point_uri :rtype: bool """ expected_parts = self.__route.split("/") actual_parts = self.__uri.split("/") i = 0 for part in expected_parts: i...
[ "def", "set_end_point_uri", "(", "self", ")", "->", "bool", ":", "expected_parts", "=", "self", ".", "__route", ".", "split", "(", "\"/\"", ")", "actual_parts", "=", "self", ".", "__uri", ".", "split", "(", "\"/\"", ")", "i", "=", "0", "for", "part", ...
Extracts the route from the accessed URL and sets it to __end_point_uri :rtype: bool
[ "Extracts", "the", "route", "from", "the", "accessed", "URL", "and", "sets", "it", "to", "__end_point_uri", ":", "rtype", ":", "bool" ]
7f6d5445b5662cba2e8938bb82c7f3ef94e5ded8
https://github.com/feliphebueno/Rinzler/blob/7f6d5445b5662cba2e8938bb82c7f3ef94e5ded8/rinzler/__init__.py#L286-L302
train
feliphebueno/Rinzler
rinzler/__init__.py
Router.no_route_found
def no_route_found(self, request): """ Default callback for route not found :param request HttpRequest :rtype: Response """ response_obj = OrderedDict() response_obj["status"] = False response_obj["exceptions"] = { "message": "No route found fo...
python
def no_route_found(self, request): """ Default callback for route not found :param request HttpRequest :rtype: Response """ response_obj = OrderedDict() response_obj["status"] = False response_obj["exceptions"] = { "message": "No route found fo...
[ "def", "no_route_found", "(", "self", ",", "request", ")", ":", "response_obj", "=", "OrderedDict", "(", ")", "response_obj", "[", "\"status\"", "]", "=", "False", "response_obj", "[", "\"exceptions\"", "]", "=", "{", "\"message\"", ":", "\"No route found for {0...
Default callback for route not found :param request HttpRequest :rtype: Response
[ "Default", "callback", "for", "route", "not", "found", ":", "param", "request", "HttpRequest", ":", "rtype", ":", "Response" ]
7f6d5445b5662cba2e8938bb82c7f3ef94e5ded8
https://github.com/feliphebueno/Rinzler/blob/7f6d5445b5662cba2e8938bb82c7f3ef94e5ded8/rinzler/__init__.py#L304-L322
train
feliphebueno/Rinzler
rinzler/__init__.py
Router.welcome_page
def welcome_page(self): """ Defaulf welcome page when the route / is note mapped yet :rtype: HttpResponse """ message = "HTTP/1.1 200 OK RINZLER FRAMEWORK" return HttpResponse( "<center><h1>{0}({1})</h1></center>".format(message, self.app.app_name), ...
python
def welcome_page(self): """ Defaulf welcome page when the route / is note mapped yet :rtype: HttpResponse """ message = "HTTP/1.1 200 OK RINZLER FRAMEWORK" return HttpResponse( "<center><h1>{0}({1})</h1></center>".format(message, self.app.app_name), ...
[ "def", "welcome_page", "(", "self", ")", ":", "message", "=", "\"HTTP/1.1 200 OK RINZLER FRAMEWORK\"", "return", "HttpResponse", "(", "\"<center><h1>{0}({1})</h1></center>\"", ".", "format", "(", "message", ",", "self", ".", "app", ".", "app_name", ")", ",", "conten...
Defaulf welcome page when the route / is note mapped yet :rtype: HttpResponse
[ "Defaulf", "welcome", "page", "when", "the", "route", "/", "is", "note", "mapped", "yet", ":", "rtype", ":", "HttpResponse" ]
7f6d5445b5662cba2e8938bb82c7f3ef94e5ded8
https://github.com/feliphebueno/Rinzler/blob/7f6d5445b5662cba2e8938bb82c7f3ef94e5ded8/rinzler/__init__.py#L324-L333
train
feliphebueno/Rinzler
rinzler/__init__.py
Router.default_route_options
def default_route_options(): """ Default callback for OPTIONS request :rtype: Response """ response_obj = OrderedDict() response_obj["status"] = True response_obj["data"] = "Ok" return Response(response_obj, content_type="application/json", charset="utf-...
python
def default_route_options(): """ Default callback for OPTIONS request :rtype: Response """ response_obj = OrderedDict() response_obj["status"] = True response_obj["data"] = "Ok" return Response(response_obj, content_type="application/json", charset="utf-...
[ "def", "default_route_options", "(", ")", ":", "response_obj", "=", "OrderedDict", "(", ")", "response_obj", "[", "\"status\"", "]", "=", "True", "response_obj", "[", "\"data\"", "]", "=", "\"Ok\"", "return", "Response", "(", "response_obj", ",", "content_type",...
Default callback for OPTIONS request :rtype: Response
[ "Default", "callback", "for", "OPTIONS", "request", ":", "rtype", ":", "Response" ]
7f6d5445b5662cba2e8938bb82c7f3ef94e5ded8
https://github.com/feliphebueno/Rinzler/blob/7f6d5445b5662cba2e8938bb82c7f3ef94e5ded8/rinzler/__init__.py#L336-L346
train
feliphebueno/Rinzler
rinzler/__init__.py
Router.set_response_headers
def set_response_headers(self, response: HttpResponse) -> HttpResponse: """ Appends default headers to every response returned by the API :param response HttpResponse :rtype: HttpResponse """ public_name = os.environ.get('SERVER_PUBLIC_NAME') response_headers = { ...
python
def set_response_headers(self, response: HttpResponse) -> HttpResponse: """ Appends default headers to every response returned by the API :param response HttpResponse :rtype: HttpResponse """ public_name = os.environ.get('SERVER_PUBLIC_NAME') response_headers = { ...
[ "def", "set_response_headers", "(", "self", ",", "response", ":", "HttpResponse", ")", "->", "HttpResponse", ":", "public_name", "=", "os", ".", "environ", ".", "get", "(", "'SERVER_PUBLIC_NAME'", ")", "response_headers", "=", "{", "'access-control-allow-headers'", ...
Appends default headers to every response returned by the API :param response HttpResponse :rtype: HttpResponse
[ "Appends", "default", "headers", "to", "every", "response", "returned", "by", "the", "API", ":", "param", "response", "HttpResponse", ":", "rtype", ":", "HttpResponse" ]
7f6d5445b5662cba2e8938bb82c7f3ef94e5ded8
https://github.com/feliphebueno/Rinzler/blob/7f6d5445b5662cba2e8938bb82c7f3ef94e5ded8/rinzler/__init__.py#L348-L374
train
feliphebueno/Rinzler
rinzler/__init__.py
Router.get_json_ident
def get_json_ident(request_headers: dict) -> int: """ Defines whether the JSON response will be indented or not :param request_headers: dict :return: self """ if 'HTTP_USER_AGENT' in request_headers: indent = 2 if re.match("[Mozilla]{7}", request_headers['HTTP...
python
def get_json_ident(request_headers: dict) -> int: """ Defines whether the JSON response will be indented or not :param request_headers: dict :return: self """ if 'HTTP_USER_AGENT' in request_headers: indent = 2 if re.match("[Mozilla]{7}", request_headers['HTTP...
[ "def", "get_json_ident", "(", "request_headers", ":", "dict", ")", "->", "int", ":", "if", "'HTTP_USER_AGENT'", "in", "request_headers", ":", "indent", "=", "2", "if", "re", ".", "match", "(", "\"[Mozilla]{7}\"", ",", "request_headers", "[", "'HTTP_USER_AGENT'",...
Defines whether the JSON response will be indented or not :param request_headers: dict :return: self
[ "Defines", "whether", "the", "JSON", "response", "will", "be", "indented", "or", "not", ":", "param", "request_headers", ":", "dict", ":", "return", ":", "self" ]
7f6d5445b5662cba2e8938bb82c7f3ef94e5ded8
https://github.com/feliphebueno/Rinzler/blob/7f6d5445b5662cba2e8938bb82c7f3ef94e5ded8/rinzler/__init__.py#L377-L388
train
calocan/rescape-python-helpers
rescape_python_helpers/functional/ramda.py
prop
def prop(key, dct_or_obj): """ Implementation of prop (get_item) that also supports object attributes :param key: :param dct_or_obj: :return: """ # Note that hasattr is a builtin and getattr is a ramda function, hence the different arg position if isinstance(dict, dct_or_obj): ...
python
def prop(key, dct_or_obj): """ Implementation of prop (get_item) that also supports object attributes :param key: :param dct_or_obj: :return: """ # Note that hasattr is a builtin and getattr is a ramda function, hence the different arg position if isinstance(dict, dct_or_obj): ...
[ "def", "prop", "(", "key", ",", "dct_or_obj", ")", ":", "# Note that hasattr is a builtin and getattr is a ramda function, hence the different arg position", "if", "isinstance", "(", "dict", ",", "dct_or_obj", ")", ":", "if", "has", "(", "key", ",", "dct_or_obj", ")", ...
Implementation of prop (get_item) that also supports object attributes :param key: :param dct_or_obj: :return:
[ "Implementation", "of", "prop", "(", "get_item", ")", "that", "also", "supports", "object", "attributes", ":", "param", "key", ":", ":", "param", "dct_or_obj", ":", ":", "return", ":" ]
91a1724f062ee40a25aa60fc96b2d7acadd99618
https://github.com/calocan/rescape-python-helpers/blob/91a1724f062ee40a25aa60fc96b2d7acadd99618/rescape_python_helpers/functional/ramda.py#L12-L36
train
calocan/rescape-python-helpers
rescape_python_helpers/functional/ramda.py
all_pass_dict
def all_pass_dict(f, dct): """ Returns true if all dct values pass f :param f: binary lambda predicate :param dct: :return: True or false """ return all(map_with_obj_to_values( lambda key, value: f(key, value), dct ))
python
def all_pass_dict(f, dct): """ Returns true if all dct values pass f :param f: binary lambda predicate :param dct: :return: True or false """ return all(map_with_obj_to_values( lambda key, value: f(key, value), dct ))
[ "def", "all_pass_dict", "(", "f", ",", "dct", ")", ":", "return", "all", "(", "map_with_obj_to_values", "(", "lambda", "key", ",", "value", ":", "f", "(", "key", ",", "value", ")", ",", "dct", ")", ")" ]
Returns true if all dct values pass f :param f: binary lambda predicate :param dct: :return: True or false
[ "Returns", "true", "if", "all", "dct", "values", "pass", "f", ":", "param", "f", ":", "binary", "lambda", "predicate", ":", "param", "dct", ":", ":", "return", ":", "True", "or", "false" ]
91a1724f062ee40a25aa60fc96b2d7acadd99618
https://github.com/calocan/rescape-python-helpers/blob/91a1724f062ee40a25aa60fc96b2d7acadd99618/rescape_python_helpers/functional/ramda.py#L50-L60
train
calocan/rescape-python-helpers
rescape_python_helpers/functional/ramda.py
prop_or
def prop_or(default, key, dct_or_obj): """ Ramda propOr implementation. This also resolves object attributes, so key can be a dict prop or an attribute of dct_or_obj :param default: Value if dct_or_obj doesn't have key_or_prop or the resolved value is null :param key: :param dct_or_obj: ...
python
def prop_or(default, key, dct_or_obj): """ Ramda propOr implementation. This also resolves object attributes, so key can be a dict prop or an attribute of dct_or_obj :param default: Value if dct_or_obj doesn't have key_or_prop or the resolved value is null :param key: :param dct_or_obj: ...
[ "def", "prop_or", "(", "default", ",", "key", ",", "dct_or_obj", ")", ":", "# Note that hasattr is a builtin and getattr is a ramda function, hence the different arg position", "if", "isinstance", "(", "dict", ",", "dct_or_obj", ")", ":", "value", "=", "dct_or_obj", "[", ...
Ramda propOr implementation. This also resolves object attributes, so key can be a dict prop or an attribute of dct_or_obj :param default: Value if dct_or_obj doesn't have key_or_prop or the resolved value is null :param key: :param dct_or_obj: :return:
[ "Ramda", "propOr", "implementation", ".", "This", "also", "resolves", "object", "attributes", "so", "key", "can", "be", "a", "dict", "prop", "or", "an", "attribute", "of", "dct_or_obj", ":", "param", "default", ":", "Value", "if", "dct_or_obj", "doesn", "t",...
91a1724f062ee40a25aa60fc96b2d7acadd99618
https://github.com/calocan/rescape-python-helpers/blob/91a1724f062ee40a25aa60fc96b2d7acadd99618/rescape_python_helpers/functional/ramda.py#L82-L101
train
calocan/rescape-python-helpers
rescape_python_helpers/functional/ramda.py
prop_eq_or
def prop_eq_or(default, key, value, dct): """ Ramda propEq plus propOr implementation :param default: :param key: :param value: :param dct: :return: """ return dct[key] and dct[key] == value if key in dct else default
python
def prop_eq_or(default, key, value, dct): """ Ramda propEq plus propOr implementation :param default: :param key: :param value: :param dct: :return: """ return dct[key] and dct[key] == value if key in dct else default
[ "def", "prop_eq_or", "(", "default", ",", "key", ",", "value", ",", "dct", ")", ":", "return", "dct", "[", "key", "]", "and", "dct", "[", "key", "]", "==", "value", "if", "key", "in", "dct", "else", "default" ]
Ramda propEq plus propOr implementation :param default: :param key: :param value: :param dct: :return:
[ "Ramda", "propEq", "plus", "propOr", "implementation", ":", "param", "default", ":", ":", "param", "key", ":", ":", "param", "value", ":", ":", "param", "dct", ":", ":", "return", ":" ]
91a1724f062ee40a25aa60fc96b2d7acadd99618
https://github.com/calocan/rescape-python-helpers/blob/91a1724f062ee40a25aa60fc96b2d7acadd99618/rescape_python_helpers/functional/ramda.py#L117-L126
train
calocan/rescape-python-helpers
rescape_python_helpers/functional/ramda.py
prop_eq_or_in_or
def prop_eq_or_in_or(default, key, value, dct): """ Ramda propEq/propIn plus propOr :param default: :param key: :param value: :param dct: :return: """ return has(key, dct) and \ (dct[key] == value if key in dct else ( dct[key] in value if isinstance((lis...
python
def prop_eq_or_in_or(default, key, value, dct): """ Ramda propEq/propIn plus propOr :param default: :param key: :param value: :param dct: :return: """ return has(key, dct) and \ (dct[key] == value if key in dct else ( dct[key] in value if isinstance((lis...
[ "def", "prop_eq_or_in_or", "(", "default", ",", "key", ",", "value", ",", "dct", ")", ":", "return", "has", "(", "key", ",", "dct", ")", "and", "(", "dct", "[", "key", "]", "==", "value", "if", "key", "in", "dct", "else", "(", "dct", "[", "key", ...
Ramda propEq/propIn plus propOr :param default: :param key: :param value: :param dct: :return:
[ "Ramda", "propEq", "/", "propIn", "plus", "propOr", ":", "param", "default", ":", ":", "param", "key", ":", ":", "param", "value", ":", ":", "param", "dct", ":", ":", "return", ":" ]
91a1724f062ee40a25aa60fc96b2d7acadd99618
https://github.com/calocan/rescape-python-helpers/blob/91a1724f062ee40a25aa60fc96b2d7acadd99618/rescape_python_helpers/functional/ramda.py#L142-L155
train
calocan/rescape-python-helpers
rescape_python_helpers/functional/ramda.py
item_path_or
def item_path_or(default, keys, dict_or_obj): """ Optional version of item_path with a default value. keys can be dict keys or object attributes, or a combination :param default: :param keys: List of keys or dot-separated string :param dict_or_obj: A dict or obj :return: """ if not keys:...
python
def item_path_or(default, keys, dict_or_obj): """ Optional version of item_path with a default value. keys can be dict keys or object attributes, or a combination :param default: :param keys: List of keys or dot-separated string :param dict_or_obj: A dict or obj :return: """ if not keys:...
[ "def", "item_path_or", "(", "default", ",", "keys", ",", "dict_or_obj", ")", ":", "if", "not", "keys", ":", "raise", "ValueError", "(", "\"Expected at least one key, got {0}\"", ".", "format", "(", "keys", ")", ")", "resolved_keys", "=", "keys", ".", "split", ...
Optional version of item_path with a default value. keys can be dict keys or object attributes, or a combination :param default: :param keys: List of keys or dot-separated string :param dict_or_obj: A dict or obj :return:
[ "Optional", "version", "of", "item_path", "with", "a", "default", "value", ".", "keys", "can", "be", "dict", "keys", "or", "object", "attributes", "or", "a", "combination", ":", "param", "default", ":", ":", "param", "keys", ":", "List", "of", "keys", "o...
91a1724f062ee40a25aa60fc96b2d7acadd99618
https://github.com/calocan/rescape-python-helpers/blob/91a1724f062ee40a25aa60fc96b2d7acadd99618/rescape_python_helpers/functional/ramda.py#L170-L184
train
calocan/rescape-python-helpers
rescape_python_helpers/functional/ramda.py
item_str_path
def item_str_path(keys, dct): """ Given a string of path segments separated by ., splits them into an array. Int strings are converted to numbers to serve as an array index :param keys: e.g. 'foo.bar.1.goo' :param dct: e.g. dict(foo=dict(bar=[dict(goo='a'), dict(goo='b')]) :return: The r...
python
def item_str_path(keys, dct): """ Given a string of path segments separated by ., splits them into an array. Int strings are converted to numbers to serve as an array index :param keys: e.g. 'foo.bar.1.goo' :param dct: e.g. dict(foo=dict(bar=[dict(goo='a'), dict(goo='b')]) :return: The r...
[ "def", "item_str_path", "(", "keys", ",", "dct", ")", ":", "return", "item_path", "(", "map", "(", "lambda", "segment", ":", "int", "(", "segment", ")", "if", "isint", "(", "segment", ")", "else", "segment", ",", "keys", ".", "split", "(", "'.'", ")"...
Given a string of path segments separated by ., splits them into an array. Int strings are converted to numbers to serve as an array index :param keys: e.g. 'foo.bar.1.goo' :param dct: e.g. dict(foo=dict(bar=[dict(goo='a'), dict(goo='b')]) :return: The resolved value or an error. E.g. for above the ...
[ "Given", "a", "string", "of", "path", "segments", "separated", "by", ".", "splits", "them", "into", "an", "array", ".", "Int", "strings", "are", "converted", "to", "numbers", "to", "serve", "as", "an", "array", "index", ":", "param", "keys", ":", "e", ...
91a1724f062ee40a25aa60fc96b2d7acadd99618
https://github.com/calocan/rescape-python-helpers/blob/91a1724f062ee40a25aa60fc96b2d7acadd99618/rescape_python_helpers/functional/ramda.py#L212-L220
train
calocan/rescape-python-helpers
rescape_python_helpers/functional/ramda.py
item_str_path_or
def item_str_path_or(default, keys, dct): """ Given a string of path segments separated by ., splits them into an array. Int strings are converted to numbers to serve as an array index :param default: Value if any part yields None or undefined :param keys: e.g. 'foo.bar.1.goo' :param dct...
python
def item_str_path_or(default, keys, dct): """ Given a string of path segments separated by ., splits them into an array. Int strings are converted to numbers to serve as an array index :param default: Value if any part yields None or undefined :param keys: e.g. 'foo.bar.1.goo' :param dct...
[ "def", "item_str_path_or", "(", "default", ",", "keys", ",", "dct", ")", ":", "return", "item_path_or", "(", "default", ",", "map", "(", "lambda", "segment", ":", "int", "(", "segment", ")", "if", "isint", "(", "segment", ")", "else", "segment", ",", "...
Given a string of path segments separated by ., splits them into an array. Int strings are converted to numbers to serve as an array index :param default: Value if any part yields None or undefined :param keys: e.g. 'foo.bar.1.goo' :param dct: e.g. dict(foo=dict(bar=[dict(goo='a'), dict(goo='b')]) ...
[ "Given", "a", "string", "of", "path", "segments", "separated", "by", ".", "splits", "them", "into", "an", "array", ".", "Int", "strings", "are", "converted", "to", "numbers", "to", "serve", "as", "an", "array", "index", ":", "param", "default", ":", "Val...
91a1724f062ee40a25aa60fc96b2d7acadd99618
https://github.com/calocan/rescape-python-helpers/blob/91a1724f062ee40a25aa60fc96b2d7acadd99618/rescape_python_helpers/functional/ramda.py#L224-L233
train
calocan/rescape-python-helpers
rescape_python_helpers/functional/ramda.py
has
def has(prop, object_or_dct): """ Implementation of ramda has :param prop: :param object_or_dct: :return: """ return prop in object_or_dct if isinstance(dict, object_or_dct) else hasattr(object_or_dct, prop)
python
def has(prop, object_or_dct): """ Implementation of ramda has :param prop: :param object_or_dct: :return: """ return prop in object_or_dct if isinstance(dict, object_or_dct) else hasattr(object_or_dct, prop)
[ "def", "has", "(", "prop", ",", "object_or_dct", ")", ":", "return", "prop", "in", "object_or_dct", "if", "isinstance", "(", "dict", ",", "object_or_dct", ")", "else", "hasattr", "(", "object_or_dct", ",", "prop", ")" ]
Implementation of ramda has :param prop: :param object_or_dct: :return:
[ "Implementation", "of", "ramda", "has", ":", "param", "prop", ":", ":", "param", "object_or_dct", ":", ":", "return", ":" ]
91a1724f062ee40a25aa60fc96b2d7acadd99618
https://github.com/calocan/rescape-python-helpers/blob/91a1724f062ee40a25aa60fc96b2d7acadd99618/rescape_python_helpers/functional/ramda.py#L237-L244
train
calocan/rescape-python-helpers
rescape_python_helpers/functional/ramda.py
omit_deep
def omit_deep(omit_props, dct): """ Implementation of omit that recurses. This tests the same keys at every level of dict and in lists :param omit_props: :param dct: :return: """ omit_partial = omit_deep(omit_props) if isinstance(dict, dct): # Filter out keys and then recurse o...
python
def omit_deep(omit_props, dct): """ Implementation of omit that recurses. This tests the same keys at every level of dict and in lists :param omit_props: :param dct: :return: """ omit_partial = omit_deep(omit_props) if isinstance(dict, dct): # Filter out keys and then recurse o...
[ "def", "omit_deep", "(", "omit_props", ",", "dct", ")", ":", "omit_partial", "=", "omit_deep", "(", "omit_props", ")", "if", "isinstance", "(", "dict", ",", "dct", ")", ":", "# Filter out keys and then recurse on each value that wasn't filtered out", "return", "map_di...
Implementation of omit that recurses. This tests the same keys at every level of dict and in lists :param omit_props: :param dct: :return:
[ "Implementation", "of", "omit", "that", "recurses", ".", "This", "tests", "the", "same", "keys", "at", "every", "level", "of", "dict", "and", "in", "lists", ":", "param", "omit_props", ":", ":", "param", "dct", ":", ":", "return", ":" ]
91a1724f062ee40a25aa60fc96b2d7acadd99618
https://github.com/calocan/rescape-python-helpers/blob/91a1724f062ee40a25aa60fc96b2d7acadd99618/rescape_python_helpers/functional/ramda.py#L259-L276
train
calocan/rescape-python-helpers
rescape_python_helpers/functional/ramda.py
pick_deep
def pick_deep(pick_dct, dct): """ Implementation of pick that recurses. This tests the same keys at every level of dict and in lists :param pick_dct: Deep dict matching some portion of dct. :param dct: Dct to filter. Any key matching pick_dct pass through. It doesn't matter what the pick_dct value i...
python
def pick_deep(pick_dct, dct): """ Implementation of pick that recurses. This tests the same keys at every level of dict and in lists :param pick_dct: Deep dict matching some portion of dct. :param dct: Dct to filter. Any key matching pick_dct pass through. It doesn't matter what the pick_dct value i...
[ "def", "pick_deep", "(", "pick_dct", ",", "dct", ")", ":", "if", "isinstance", "(", "dict", ",", "dct", ")", ":", "# Filter out keys and then recurse on each value that wasn't filtered out", "return", "map_with_obj", "(", "lambda", "k", ",", "v", ":", "pick_deep", ...
Implementation of pick that recurses. This tests the same keys at every level of dict and in lists :param pick_dct: Deep dict matching some portion of dct. :param dct: Dct to filter. Any key matching pick_dct pass through. It doesn't matter what the pick_dct value is as long as the key exists. Arrays also p...
[ "Implementation", "of", "pick", "that", "recurses", ".", "This", "tests", "the", "same", "keys", "at", "every", "level", "of", "dict", "and", "in", "lists", ":", "param", "pick_dct", ":", "Deep", "dict", "matching", "some", "portion", "of", "dct", ".", "...
91a1724f062ee40a25aa60fc96b2d7acadd99618
https://github.com/calocan/rescape-python-helpers/blob/91a1724f062ee40a25aa60fc96b2d7acadd99618/rescape_python_helpers/functional/ramda.py#L280-L302
train
calocan/rescape-python-helpers
rescape_python_helpers/functional/ramda.py
map_with_obj_deep
def map_with_obj_deep(f, dct): """ Implementation of map that recurses. This tests the same keys at every level of dict and in lists :param f: 2-ary function expecting a key and value and returns a modified value :param dct: Dict for deep processing :return: Modified dct with matching props mapped ...
python
def map_with_obj_deep(f, dct): """ Implementation of map that recurses. This tests the same keys at every level of dict and in lists :param f: 2-ary function expecting a key and value and returns a modified value :param dct: Dict for deep processing :return: Modified dct with matching props mapped ...
[ "def", "map_with_obj_deep", "(", "f", ",", "dct", ")", ":", "return", "_map_deep", "(", "lambda", "k", ",", "v", ":", "[", "k", ",", "f", "(", "k", ",", "v", ")", "]", ",", "dct", ")" ]
Implementation of map that recurses. This tests the same keys at every level of dict and in lists :param f: 2-ary function expecting a key and value and returns a modified value :param dct: Dict for deep processing :return: Modified dct with matching props mapped
[ "Implementation", "of", "map", "that", "recurses", ".", "This", "tests", "the", "same", "keys", "at", "every", "level", "of", "dict", "and", "in", "lists", ":", "param", "f", ":", "2", "-", "ary", "function", "expecting", "a", "key", "and", "value", "a...
91a1724f062ee40a25aa60fc96b2d7acadd99618
https://github.com/calocan/rescape-python-helpers/blob/91a1724f062ee40a25aa60fc96b2d7acadd99618/rescape_python_helpers/functional/ramda.py#L306-L313
train
calocan/rescape-python-helpers
rescape_python_helpers/functional/ramda.py
map_keys_deep
def map_keys_deep(f, dct): """ Implementation of map that recurses. This tests the same keys at every level of dict and in lists :param f: 2-ary function expecting a key and value and returns a modified key :param dct: Dict for deep processing :return: Modified dct with matching props mapped """...
python
def map_keys_deep(f, dct): """ Implementation of map that recurses. This tests the same keys at every level of dict and in lists :param f: 2-ary function expecting a key and value and returns a modified key :param dct: Dict for deep processing :return: Modified dct with matching props mapped """...
[ "def", "map_keys_deep", "(", "f", ",", "dct", ")", ":", "return", "_map_deep", "(", "lambda", "k", ",", "v", ":", "[", "f", "(", "k", ",", "v", ")", ",", "v", "]", ",", "dct", ")" ]
Implementation of map that recurses. This tests the same keys at every level of dict and in lists :param f: 2-ary function expecting a key and value and returns a modified key :param dct: Dict for deep processing :return: Modified dct with matching props mapped
[ "Implementation", "of", "map", "that", "recurses", ".", "This", "tests", "the", "same", "keys", "at", "every", "level", "of", "dict", "and", "in", "lists", ":", "param", "f", ":", "2", "-", "ary", "function", "expecting", "a", "key", "and", "value", "a...
91a1724f062ee40a25aa60fc96b2d7acadd99618
https://github.com/calocan/rescape-python-helpers/blob/91a1724f062ee40a25aa60fc96b2d7acadd99618/rescape_python_helpers/functional/ramda.py#L317-L324
train
calocan/rescape-python-helpers
rescape_python_helpers/functional/ramda.py
_map_deep
def _map_deep(f, dct): """ Used by map_deep and map_keys_deep :param map_props: :param f: Expects a key and value and returns a pair :param dct: :return: """ if isinstance(dict, dct): return map_key_values(lambda k, v: f(k, _map_deep(f, v)), dct) elif isinstance((list, tuple...
python
def _map_deep(f, dct): """ Used by map_deep and map_keys_deep :param map_props: :param f: Expects a key and value and returns a pair :param dct: :return: """ if isinstance(dict, dct): return map_key_values(lambda k, v: f(k, _map_deep(f, v)), dct) elif isinstance((list, tuple...
[ "def", "_map_deep", "(", "f", ",", "dct", ")", ":", "if", "isinstance", "(", "dict", ",", "dct", ")", ":", "return", "map_key_values", "(", "lambda", "k", ",", "v", ":", "f", "(", "k", ",", "_map_deep", "(", "f", ",", "v", ")", ")", ",", "dct",...
Used by map_deep and map_keys_deep :param map_props: :param f: Expects a key and value and returns a pair :param dct: :return:
[ "Used", "by", "map_deep", "and", "map_keys_deep", ":", "param", "map_props", ":", ":", "param", "f", ":", "Expects", "a", "key", "and", "value", "and", "returns", "a", "pair", ":", "param", "dct", ":", ":", "return", ":" ]
91a1724f062ee40a25aa60fc96b2d7acadd99618
https://github.com/calocan/rescape-python-helpers/blob/91a1724f062ee40a25aa60fc96b2d7acadd99618/rescape_python_helpers/functional/ramda.py#L327-L343
train
calocan/rescape-python-helpers
rescape_python_helpers/functional/ramda.py
dict_matches_params_deep
def dict_matches_params_deep(params_dct, dct): """ Filters deeply by comparing dct to filter_dct's value at each depth. Whenever a mismatch occurs the whole thing returns false :param params_dct: dict matching any portion of dct. E.g. filter_dct = {foo: {bar: 1}} would allow {foo: {bar: 1, car: 2}} ...
python
def dict_matches_params_deep(params_dct, dct): """ Filters deeply by comparing dct to filter_dct's value at each depth. Whenever a mismatch occurs the whole thing returns false :param params_dct: dict matching any portion of dct. E.g. filter_dct = {foo: {bar: 1}} would allow {foo: {bar: 1, car: 2}} ...
[ "def", "dict_matches_params_deep", "(", "params_dct", ",", "dct", ")", ":", "def", "recurse_if_param_exists", "(", "params", ",", "key", ",", "value", ")", ":", "\"\"\"\n If a param[key] exists, recurse. Otherwise return True since there is no param to contest value\n ...
Filters deeply by comparing dct to filter_dct's value at each depth. Whenever a mismatch occurs the whole thing returns false :param params_dct: dict matching any portion of dct. E.g. filter_dct = {foo: {bar: 1}} would allow {foo: {bar: 1, car: 2}} to pass, {foo: {bar: 2}} would fail, {goo: ...} would fail ...
[ "Filters", "deeply", "by", "comparing", "dct", "to", "filter_dct", "s", "value", "at", "each", "depth", ".", "Whenever", "a", "mismatch", "occurs", "the", "whole", "thing", "returns", "false", ":", "param", "params_dct", ":", "dict", "matching", "any", "port...
91a1724f062ee40a25aa60fc96b2d7acadd99618
https://github.com/calocan/rescape-python-helpers/blob/91a1724f062ee40a25aa60fc96b2d7acadd99618/rescape_python_helpers/functional/ramda.py#L347-L402
train
calocan/rescape-python-helpers
rescape_python_helpers/functional/ramda.py
join
def join(strin, items): """ Ramda implementation of join :param strin: :param items: :return: """ return strin.join(map(lambda item: str(item), items))
python
def join(strin, items): """ Ramda implementation of join :param strin: :param items: :return: """ return strin.join(map(lambda item: str(item), items))
[ "def", "join", "(", "strin", ",", "items", ")", ":", "return", "strin", ".", "join", "(", "map", "(", "lambda", "item", ":", "str", "(", "item", ")", ",", "items", ")", ")" ]
Ramda implementation of join :param strin: :param items: :return:
[ "Ramda", "implementation", "of", "join", ":", "param", "strin", ":", ":", "param", "items", ":", ":", "return", ":" ]
91a1724f062ee40a25aa60fc96b2d7acadd99618
https://github.com/calocan/rescape-python-helpers/blob/91a1724f062ee40a25aa60fc96b2d7acadd99618/rescape_python_helpers/functional/ramda.py#L406-L413
train
calocan/rescape-python-helpers
rescape_python_helpers/functional/ramda.py
map_with_obj
def map_with_obj(f, dct): """ Implementation of Ramda's mapObjIndexed without the final argument. This returns the original key with the mapped value. Use map_key_values to modify the keys too :param f: Called with a key and value :param dct: :return {dict}: Keyed by the original key, va...
python
def map_with_obj(f, dct): """ Implementation of Ramda's mapObjIndexed without the final argument. This returns the original key with the mapped value. Use map_key_values to modify the keys too :param f: Called with a key and value :param dct: :return {dict}: Keyed by the original key, va...
[ "def", "map_with_obj", "(", "f", ",", "dct", ")", ":", "f_dict", "=", "{", "}", "for", "k", ",", "v", "in", "dct", ".", "items", "(", ")", ":", "f_dict", "[", "k", "]", "=", "f", "(", "k", ",", "v", ")", "return", "f_dict" ]
Implementation of Ramda's mapObjIndexed without the final argument. This returns the original key with the mapped value. Use map_key_values to modify the keys too :param f: Called with a key and value :param dct: :return {dict}: Keyed by the original key, valued by the mapped value
[ "Implementation", "of", "Ramda", "s", "mapObjIndexed", "without", "the", "final", "argument", ".", "This", "returns", "the", "original", "key", "with", "the", "mapped", "value", ".", "Use", "map_key_values", "to", "modify", "the", "keys", "too", ":", "param", ...
91a1724f062ee40a25aa60fc96b2d7acadd99618
https://github.com/calocan/rescape-python-helpers/blob/91a1724f062ee40a25aa60fc96b2d7acadd99618/rescape_python_helpers/functional/ramda.py#L462-L473
train
calocan/rescape-python-helpers
rescape_python_helpers/functional/ramda.py
map_keys
def map_keys(f, dct): """ Calls f with each key of dct, possibly returning a modified key. Values are unchanged :param f: Called with each key and returns the same key or a modified key :param dct: :return: A dct with keys possibly modifed but values unchanged """ f_dict = {} for k, ...
python
def map_keys(f, dct): """ Calls f with each key of dct, possibly returning a modified key. Values are unchanged :param f: Called with each key and returns the same key or a modified key :param dct: :return: A dct with keys possibly modifed but values unchanged """ f_dict = {} for k, ...
[ "def", "map_keys", "(", "f", ",", "dct", ")", ":", "f_dict", "=", "{", "}", "for", "k", ",", "v", "in", "dct", ".", "items", "(", ")", ":", "f_dict", "[", "f", "(", "k", ")", "]", "=", "v", "return", "f_dict" ]
Calls f with each key of dct, possibly returning a modified key. Values are unchanged :param f: Called with each key and returns the same key or a modified key :param dct: :return: A dct with keys possibly modifed but values unchanged
[ "Calls", "f", "with", "each", "key", "of", "dct", "possibly", "returning", "a", "modified", "key", ".", "Values", "are", "unchanged", ":", "param", "f", ":", "Called", "with", "each", "key", "and", "returns", "the", "same", "key", "or", "a", "modified", ...
91a1724f062ee40a25aa60fc96b2d7acadd99618
https://github.com/calocan/rescape-python-helpers/blob/91a1724f062ee40a25aa60fc96b2d7acadd99618/rescape_python_helpers/functional/ramda.py#L499-L509
train
calocan/rescape-python-helpers
rescape_python_helpers/functional/ramda.py
map_keys_with_obj
def map_keys_with_obj(f, dct): """ Calls f with each key and value of dct, possibly returning a modified key. Values are unchanged :param f: Called with each key and value and returns the same key or a modified key :param dct: :return: A dct with keys possibly modifed but values unchanged ""...
python
def map_keys_with_obj(f, dct): """ Calls f with each key and value of dct, possibly returning a modified key. Values are unchanged :param f: Called with each key and value and returns the same key or a modified key :param dct: :return: A dct with keys possibly modifed but values unchanged ""...
[ "def", "map_keys_with_obj", "(", "f", ",", "dct", ")", ":", "f_dict", "=", "{", "}", "for", "k", ",", "v", "in", "dct", ".", "items", "(", ")", ":", "f_dict", "[", "f", "(", "k", ",", "v", ")", "]", "=", "v", "return", "f_dict" ]
Calls f with each key and value of dct, possibly returning a modified key. Values are unchanged :param f: Called with each key and value and returns the same key or a modified key :param dct: :return: A dct with keys possibly modifed but values unchanged
[ "Calls", "f", "with", "each", "key", "and", "value", "of", "dct", "possibly", "returning", "a", "modified", "key", ".", "Values", "are", "unchanged", ":", "param", "f", ":", "Called", "with", "each", "key", "and", "value", "and", "returns", "the", "same"...
91a1724f062ee40a25aa60fc96b2d7acadd99618
https://github.com/calocan/rescape-python-helpers/blob/91a1724f062ee40a25aa60fc96b2d7acadd99618/rescape_python_helpers/functional/ramda.py#L513-L523
train
calocan/rescape-python-helpers
rescape_python_helpers/functional/ramda.py
merge_deep
def merge_deep(dct1, dct2, merger=None): """ Deep merge by this spec below :param dct1: :param dct2: :param merger Optional merger :return: """ my_merger = merger or Merger( # pass in a list of tuples,with the # strategies you are looking to apply # to each ty...
python
def merge_deep(dct1, dct2, merger=None): """ Deep merge by this spec below :param dct1: :param dct2: :param merger Optional merger :return: """ my_merger = merger or Merger( # pass in a list of tuples,with the # strategies you are looking to apply # to each ty...
[ "def", "merge_deep", "(", "dct1", ",", "dct2", ",", "merger", "=", "None", ")", ":", "my_merger", "=", "merger", "or", "Merger", "(", "# pass in a list of tuples,with the", "# strategies you are looking to apply", "# to each type.", "[", "(", "list", ",", "[", "\"...
Deep merge by this spec below :param dct1: :param dct2: :param merger Optional merger :return:
[ "Deep", "merge", "by", "this", "spec", "below", ":", "param", "dct1", ":", ":", "param", "dct2", ":", ":", "param", "merger", "Optional", "merger", ":", "return", ":" ]
91a1724f062ee40a25aa60fc96b2d7acadd99618
https://github.com/calocan/rescape-python-helpers/blob/91a1724f062ee40a25aa60fc96b2d7acadd99618/rescape_python_helpers/functional/ramda.py#L538-L561
train
calocan/rescape-python-helpers
rescape_python_helpers/functional/ramda.py
merge_all
def merge_all(dcts): """ Shallow merge all the dcts :param dcts: :return: """ return reduce( lambda accum, dct: merge(accum, dct), dict(), dcts )
python
def merge_all(dcts): """ Shallow merge all the dcts :param dcts: :return: """ return reduce( lambda accum, dct: merge(accum, dct), dict(), dcts )
[ "def", "merge_all", "(", "dcts", ")", ":", "return", "reduce", "(", "lambda", "accum", ",", "dct", ":", "merge", "(", "accum", ",", "dct", ")", ",", "dict", "(", ")", ",", "dcts", ")" ]
Shallow merge all the dcts :param dcts: :return:
[ "Shallow", "merge", "all", "the", "dcts", ":", "param", "dcts", ":", ":", "return", ":" ]
91a1724f062ee40a25aa60fc96b2d7acadd99618
https://github.com/calocan/rescape-python-helpers/blob/91a1724f062ee40a25aa60fc96b2d7acadd99618/rescape_python_helpers/functional/ramda.py#L564-L574
train
calocan/rescape-python-helpers
rescape_python_helpers/functional/ramda.py
from_pairs_to_array_values
def from_pairs_to_array_values(pairs): """ Like from pairs but combines duplicate key values into arrays :param pairs: :return: """ result = {} for pair in pairs: result[pair[0]] = concat(prop_or([], pair[0], result), [pair[1]]) return result
python
def from_pairs_to_array_values(pairs): """ Like from pairs but combines duplicate key values into arrays :param pairs: :return: """ result = {} for pair in pairs: result[pair[0]] = concat(prop_or([], pair[0], result), [pair[1]]) return result
[ "def", "from_pairs_to_array_values", "(", "pairs", ")", ":", "result", "=", "{", "}", "for", "pair", "in", "pairs", ":", "result", "[", "pair", "[", "0", "]", "]", "=", "concat", "(", "prop_or", "(", "[", "]", ",", "pair", "[", "0", "]", ",", "re...
Like from pairs but combines duplicate key values into arrays :param pairs: :return:
[ "Like", "from", "pairs", "but", "combines", "duplicate", "key", "values", "into", "arrays", ":", "param", "pairs", ":", ":", "return", ":" ]
91a1724f062ee40a25aa60fc96b2d7acadd99618
https://github.com/calocan/rescape-python-helpers/blob/91a1724f062ee40a25aa60fc96b2d7acadd99618/rescape_python_helpers/functional/ramda.py#L658-L667
train
calocan/rescape-python-helpers
rescape_python_helpers/functional/ramda.py
map_prop_value_as_index
def map_prop_value_as_index(prp, lst): """ Returns the given prop of each item in the list :param prp: :param lst: :return: """ return from_pairs(map(lambda item: (prop(prp, item), item), lst))
python
def map_prop_value_as_index(prp, lst): """ Returns the given prop of each item in the list :param prp: :param lst: :return: """ return from_pairs(map(lambda item: (prop(prp, item), item), lst))
[ "def", "map_prop_value_as_index", "(", "prp", ",", "lst", ")", ":", "return", "from_pairs", "(", "map", "(", "lambda", "item", ":", "(", "prop", "(", "prp", ",", "item", ")", ",", "item", ")", ",", "lst", ")", ")" ]
Returns the given prop of each item in the list :param prp: :param lst: :return:
[ "Returns", "the", "given", "prop", "of", "each", "item", "in", "the", "list", ":", "param", "prp", ":", ":", "param", "lst", ":", ":", "return", ":" ]
91a1724f062ee40a25aa60fc96b2d7acadd99618
https://github.com/calocan/rescape-python-helpers/blob/91a1724f062ee40a25aa60fc96b2d7acadd99618/rescape_python_helpers/functional/ramda.py#L698-L705
train
calocan/rescape-python-helpers
rescape_python_helpers/functional/ramda.py
key_string_to_lens_path
def key_string_to_lens_path(key_string): """ Converts a key string like 'foo.bar.0.wopper' to ['foo', 'bar', 0, 'wopper'] :param {String} keyString The dot-separated key string :return {[String]} The lens array containing string or integers """ return map( if_else( isinstance(int)...
python
def key_string_to_lens_path(key_string): """ Converts a key string like 'foo.bar.0.wopper' to ['foo', 'bar', 0, 'wopper'] :param {String} keyString The dot-separated key string :return {[String]} The lens array containing string or integers """ return map( if_else( isinstance(int)...
[ "def", "key_string_to_lens_path", "(", "key_string", ")", ":", "return", "map", "(", "if_else", "(", "isinstance", "(", "int", ")", ",", "# convert to int", "lambda", "s", ":", "int", "(", "s", ")", ",", "# Leave the string alone", "identity", ")", ",", "key...
Converts a key string like 'foo.bar.0.wopper' to ['foo', 'bar', 0, 'wopper'] :param {String} keyString The dot-separated key string :return {[String]} The lens array containing string or integers
[ "Converts", "a", "key", "string", "like", "foo", ".", "bar", ".", "0", ".", "wopper", "to", "[", "foo", "bar", "0", "wopper", "]", ":", "param", "{", "String", "}", "keyString", "The", "dot", "-", "separated", "key", "string", ":", "return", "{", "...
91a1724f062ee40a25aa60fc96b2d7acadd99618
https://github.com/calocan/rescape-python-helpers/blob/91a1724f062ee40a25aa60fc96b2d7acadd99618/rescape_python_helpers/functional/ramda.py#L791-L806
train
calocan/rescape-python-helpers
rescape_python_helpers/functional/ramda.py
fake_lens_path_view
def fake_lens_path_view(lens_path, obj): """ Simulates R.view with a lens_path since we don't have lens functions :param lens_path: Array of string paths :param obj: Object containing the given path :return: The value at the path or None """ segment = head(lens_path) return if_else( ...
python
def fake_lens_path_view(lens_path, obj): """ Simulates R.view with a lens_path since we don't have lens functions :param lens_path: Array of string paths :param obj: Object containing the given path :return: The value at the path or None """ segment = head(lens_path) return if_else( ...
[ "def", "fake_lens_path_view", "(", "lens_path", ",", "obj", ")", ":", "segment", "=", "head", "(", "lens_path", ")", "return", "if_else", "(", "both", "(", "lambda", "_", ":", "identity", "(", "segment", ")", ",", "has", "(", "segment", ")", ")", ",", ...
Simulates R.view with a lens_path since we don't have lens functions :param lens_path: Array of string paths :param obj: Object containing the given path :return: The value at the path or None
[ "Simulates", "R", ".", "view", "with", "a", "lens_path", "since", "we", "don", "t", "have", "lens", "functions", ":", "param", "lens_path", ":", "Array", "of", "string", "paths", ":", "param", "obj", ":", "Object", "containing", "the", "given", "path", "...
91a1724f062ee40a25aa60fc96b2d7acadd99618
https://github.com/calocan/rescape-python-helpers/blob/91a1724f062ee40a25aa60fc96b2d7acadd99618/rescape_python_helpers/functional/ramda.py#L810-L824
train
calocan/rescape-python-helpers
rescape_python_helpers/functional/ramda.py
fake_lens_path_set
def fake_lens_path_set(lens_path, value, obj): """ Simulates R.set with a lens_path since we don't have lens functions :param lens_path: Array of string paths :param value: The value to set at the lens path :param obj: Object containing the given path :return: The value at the path or None "...
python
def fake_lens_path_set(lens_path, value, obj): """ Simulates R.set with a lens_path since we don't have lens functions :param lens_path: Array of string paths :param value: The value to set at the lens path :param obj: Object containing the given path :return: The value at the path or None "...
[ "def", "fake_lens_path_set", "(", "lens_path", ",", "value", ",", "obj", ")", ":", "segment", "=", "head", "(", "lens_path", ")", "obj_copy", "=", "copy", ".", "copy", "(", "obj", ")", "def", "set_array_index", "(", "i", ",", "v", ",", "l", ")", ":",...
Simulates R.set with a lens_path since we don't have lens functions :param lens_path: Array of string paths :param value: The value to set at the lens path :param obj: Object containing the given path :return: The value at the path or None
[ "Simulates", "R", ".", "set", "with", "a", "lens_path", "since", "we", "don", "t", "have", "lens", "functions", ":", "param", "lens_path", ":", "Array", "of", "string", "paths", ":", "param", "value", ":", "The", "value", "to", "set", "at", "the", "len...
91a1724f062ee40a25aa60fc96b2d7acadd99618
https://github.com/calocan/rescape-python-helpers/blob/91a1724f062ee40a25aa60fc96b2d7acadd99618/rescape_python_helpers/functional/ramda.py#L828-L870
train
calocan/rescape-python-helpers
rescape_python_helpers/functional/ramda.py
unflatten_dct
def unflatten_dct(obj): """ Undoes the work of flatten_dict @param {Object} obj 1-D object in the form returned by flattenObj @returns {Object} The original :param obj: :return: """ def reduce_func(accum, key_string_and_value): key_string = key_string_and_value[0] val...
python
def unflatten_dct(obj): """ Undoes the work of flatten_dict @param {Object} obj 1-D object in the form returned by flattenObj @returns {Object} The original :param obj: :return: """ def reduce_func(accum, key_string_and_value): key_string = key_string_and_value[0] val...
[ "def", "unflatten_dct", "(", "obj", ")", ":", "def", "reduce_func", "(", "accum", ",", "key_string_and_value", ")", ":", "key_string", "=", "key_string_and_value", "[", "0", "]", "value", "=", "key_string_and_value", "[", "1", "]", "item_key_path", "=", "key_s...
Undoes the work of flatten_dict @param {Object} obj 1-D object in the form returned by flattenObj @returns {Object} The original :param obj: :return:
[ "Undoes", "the", "work", "of", "flatten_dict" ]
91a1724f062ee40a25aa60fc96b2d7acadd99618
https://github.com/calocan/rescape-python-helpers/blob/91a1724f062ee40a25aa60fc96b2d7acadd99618/rescape_python_helpers/functional/ramda.py#L873-L915
train
jay-johnson/antinex-client
antinex_client/utils.py
ppj
def ppj(json_data): """ppj :param json_data: dictionary to print """ return str(json.dumps( json_data, sort_keys=True, indent=4, separators=(',', ': ')))
python
def ppj(json_data): """ppj :param json_data: dictionary to print """ return str(json.dumps( json_data, sort_keys=True, indent=4, separators=(',', ': ')))
[ "def", "ppj", "(", "json_data", ")", ":", "return", "str", "(", "json", ".", "dumps", "(", "json_data", ",", "sort_keys", "=", "True", ",", "indent", "=", "4", ",", "separators", "=", "(", "','", ",", "': '", ")", ")", ")" ]
ppj :param json_data: dictionary to print
[ "ppj" ]
850ba2a2fe21c836e071def618dcecc9caf5d59c
https://github.com/jay-johnson/antinex-client/blob/850ba2a2fe21c836e071def618dcecc9caf5d59c/antinex_client/utils.py#L41-L50
train
praekeltfoundation/molo.commenting
molo/commenting/admin.py
AdminModeratorMixin.change_view
def change_view(self, request, object_id, form_url='', extra_context=None): """ Override change view to add extra context enabling moderate tool. """ context = { 'has_moderate_tool': True } if extra_context: context.update(extra_context) re...
python
def change_view(self, request, object_id, form_url='', extra_context=None): """ Override change view to add extra context enabling moderate tool. """ context = { 'has_moderate_tool': True } if extra_context: context.update(extra_context) re...
[ "def", "change_view", "(", "self", ",", "request", ",", "object_id", ",", "form_url", "=", "''", ",", "extra_context", "=", "None", ")", ":", "context", "=", "{", "'has_moderate_tool'", ":", "True", "}", "if", "extra_context", ":", "context", ".", "update"...
Override change view to add extra context enabling moderate tool.
[ "Override", "change", "view", "to", "add", "extra", "context", "enabling", "moderate", "tool", "." ]
94549bd75e4a5c5b3db43149e32d636330b3969c
https://github.com/praekeltfoundation/molo.commenting/blob/94549bd75e4a5c5b3db43149e32d636330b3969c/molo/commenting/admin.py#L156-L170
train
praekeltfoundation/molo.commenting
molo/commenting/admin.py
AdminModeratorMixin.get_urls
def get_urls(self): """ Add aditional moderate url. """ from django.conf.urls import url urls = super(AdminModeratorMixin, self).get_urls() info = self.model._meta.app_label, self.model._meta.model_name return [ url(r'^(.+)/moderate/$', ...
python
def get_urls(self): """ Add aditional moderate url. """ from django.conf.urls import url urls = super(AdminModeratorMixin, self).get_urls() info = self.model._meta.app_label, self.model._meta.model_name return [ url(r'^(.+)/moderate/$', ...
[ "def", "get_urls", "(", "self", ")", ":", "from", "django", ".", "conf", ".", "urls", "import", "url", "urls", "=", "super", "(", "AdminModeratorMixin", ",", "self", ")", ".", "get_urls", "(", ")", "info", "=", "self", ".", "model", ".", "_meta", "."...
Add aditional moderate url.
[ "Add", "aditional", "moderate", "url", "." ]
94549bd75e4a5c5b3db43149e32d636330b3969c
https://github.com/praekeltfoundation/molo.commenting/blob/94549bd75e4a5c5b3db43149e32d636330b3969c/molo/commenting/admin.py#L172-L183
train
feliphebueno/Rinzler
rinzler/core/response.py
Response.render
def render(self, indent=0): """ Renders a HttpResponse for the ongoing request :param indent int :rtype: HttpResponse """ self.__indent = indent return HttpResponse( str(self), content_type=self.__content_type, charset=self.__charset, **self.__kwargs ...
python
def render(self, indent=0): """ Renders a HttpResponse for the ongoing request :param indent int :rtype: HttpResponse """ self.__indent = indent return HttpResponse( str(self), content_type=self.__content_type, charset=self.__charset, **self.__kwargs ...
[ "def", "render", "(", "self", ",", "indent", "=", "0", ")", ":", "self", ".", "__indent", "=", "indent", "return", "HttpResponse", "(", "str", "(", "self", ")", ",", "content_type", "=", "self", ".", "__content_type", ",", "charset", "=", "self", ".", ...
Renders a HttpResponse for the ongoing request :param indent int :rtype: HttpResponse
[ "Renders", "a", "HttpResponse", "for", "the", "ongoing", "request", ":", "param", "indent", "int", ":", "rtype", ":", "HttpResponse" ]
7f6d5445b5662cba2e8938bb82c7f3ef94e5ded8
https://github.com/feliphebueno/Rinzler/blob/7f6d5445b5662cba2e8938bb82c7f3ef94e5ded8/rinzler/core/response.py#L34-L43
train
feliphebueno/Rinzler
rinzler/logger/log.py
setup_logging
def setup_logging(default_path='logging.yaml', env_key='LOG_CFG'): """ Setup logging configuration """ path = default_path value = os.getenv(env_key, None) if value: path = value if os.path.exists(path): with open(path, 'rt') as f: configs = yaml.safe_load(f.read(...
python
def setup_logging(default_path='logging.yaml', env_key='LOG_CFG'): """ Setup logging configuration """ path = default_path value = os.getenv(env_key, None) if value: path = value if os.path.exists(path): with open(path, 'rt') as f: configs = yaml.safe_load(f.read(...
[ "def", "setup_logging", "(", "default_path", "=", "'logging.yaml'", ",", "env_key", "=", "'LOG_CFG'", ")", ":", "path", "=", "default_path", "value", "=", "os", ".", "getenv", "(", "env_key", ",", "None", ")", "if", "value", ":", "path", "=", "value", "i...
Setup logging configuration
[ "Setup", "logging", "configuration" ]
7f6d5445b5662cba2e8938bb82c7f3ef94e5ded8
https://github.com/feliphebueno/Rinzler/blob/7f6d5445b5662cba2e8938bb82c7f3ef94e5ded8/rinzler/logger/log.py#L9-L22
train
feliphebueno/Rinzler
rinzler/core/route_mapping.py
RouteMapping.get
def get(self, route: str(), callback: object()): """ Binds a GET route with the given callback :rtype: object """ self.__set_route('get', {route: callback}) return RouteMapping
python
def get(self, route: str(), callback: object()): """ Binds a GET route with the given callback :rtype: object """ self.__set_route('get', {route: callback}) return RouteMapping
[ "def", "get", "(", "self", ",", "route", ":", "str", "(", ")", ",", "callback", ":", "object", "(", ")", ")", ":", "self", ".", "__set_route", "(", "'get'", ",", "{", "route", ":", "callback", "}", ")", "return", "RouteMapping" ]
Binds a GET route with the given callback :rtype: object
[ "Binds", "a", "GET", "route", "with", "the", "given", "callback", ":", "rtype", ":", "object" ]
7f6d5445b5662cba2e8938bb82c7f3ef94e5ded8
https://github.com/feliphebueno/Rinzler/blob/7f6d5445b5662cba2e8938bb82c7f3ef94e5ded8/rinzler/core/route_mapping.py#L16-L22
train
feliphebueno/Rinzler
rinzler/core/route_mapping.py
RouteMapping.post
def post(self, route: str(), callback: object()): """ Binds a POST route with the given callback :rtype: object """ self.__set_route('post', {route: callback}) return RouteMapping
python
def post(self, route: str(), callback: object()): """ Binds a POST route with the given callback :rtype: object """ self.__set_route('post', {route: callback}) return RouteMapping
[ "def", "post", "(", "self", ",", "route", ":", "str", "(", ")", ",", "callback", ":", "object", "(", ")", ")", ":", "self", ".", "__set_route", "(", "'post'", ",", "{", "route", ":", "callback", "}", ")", "return", "RouteMapping" ]
Binds a POST route with the given callback :rtype: object
[ "Binds", "a", "POST", "route", "with", "the", "given", "callback", ":", "rtype", ":", "object" ]
7f6d5445b5662cba2e8938bb82c7f3ef94e5ded8
https://github.com/feliphebueno/Rinzler/blob/7f6d5445b5662cba2e8938bb82c7f3ef94e5ded8/rinzler/core/route_mapping.py#L24-L30
train
feliphebueno/Rinzler
rinzler/core/route_mapping.py
RouteMapping.put
def put(self, route: str(), callback: object()): """ Binds a PUT route with the given callback :rtype: object """ self.__set_route('put', {route: callback}) return RouteMapping
python
def put(self, route: str(), callback: object()): """ Binds a PUT route with the given callback :rtype: object """ self.__set_route('put', {route: callback}) return RouteMapping
[ "def", "put", "(", "self", ",", "route", ":", "str", "(", ")", ",", "callback", ":", "object", "(", ")", ")", ":", "self", ".", "__set_route", "(", "'put'", ",", "{", "route", ":", "callback", "}", ")", "return", "RouteMapping" ]
Binds a PUT route with the given callback :rtype: object
[ "Binds", "a", "PUT", "route", "with", "the", "given", "callback", ":", "rtype", ":", "object" ]
7f6d5445b5662cba2e8938bb82c7f3ef94e5ded8
https://github.com/feliphebueno/Rinzler/blob/7f6d5445b5662cba2e8938bb82c7f3ef94e5ded8/rinzler/core/route_mapping.py#L32-L38
train
feliphebueno/Rinzler
rinzler/core/route_mapping.py
RouteMapping.patch
def patch(self, route: str(), callback: object()): """ Binds a PATCH route with the given callback :rtype: object """ self.__set_route('patch', {route: callback}) return RouteMapping
python
def patch(self, route: str(), callback: object()): """ Binds a PATCH route with the given callback :rtype: object """ self.__set_route('patch', {route: callback}) return RouteMapping
[ "def", "patch", "(", "self", ",", "route", ":", "str", "(", ")", ",", "callback", ":", "object", "(", ")", ")", ":", "self", ".", "__set_route", "(", "'patch'", ",", "{", "route", ":", "callback", "}", ")", "return", "RouteMapping" ]
Binds a PATCH route with the given callback :rtype: object
[ "Binds", "a", "PATCH", "route", "with", "the", "given", "callback", ":", "rtype", ":", "object" ]
7f6d5445b5662cba2e8938bb82c7f3ef94e5ded8
https://github.com/feliphebueno/Rinzler/blob/7f6d5445b5662cba2e8938bb82c7f3ef94e5ded8/rinzler/core/route_mapping.py#L40-L46
train
feliphebueno/Rinzler
rinzler/core/route_mapping.py
RouteMapping.delete
def delete(self, route: str(), callback: object()): """ Binds a PUT route with the given callback :rtype: object """ self.__set_route('delete', {route: callback}) return RouteMapping
python
def delete(self, route: str(), callback: object()): """ Binds a PUT route with the given callback :rtype: object """ self.__set_route('delete', {route: callback}) return RouteMapping
[ "def", "delete", "(", "self", ",", "route", ":", "str", "(", ")", ",", "callback", ":", "object", "(", ")", ")", ":", "self", ".", "__set_route", "(", "'delete'", ",", "{", "route", ":", "callback", "}", ")", "return", "RouteMapping" ]
Binds a PUT route with the given callback :rtype: object
[ "Binds", "a", "PUT", "route", "with", "the", "given", "callback", ":", "rtype", ":", "object" ]
7f6d5445b5662cba2e8938bb82c7f3ef94e5ded8
https://github.com/feliphebueno/Rinzler/blob/7f6d5445b5662cba2e8938bb82c7f3ef94e5ded8/rinzler/core/route_mapping.py#L48-L54
train
feliphebueno/Rinzler
rinzler/core/route_mapping.py
RouteMapping.head
def head(self, route: str(), callback: object()): """ Binds a HEAD route with the given callback :rtype: object """ self.__set_route('head', {route: callback}) return RouteMapping
python
def head(self, route: str(), callback: object()): """ Binds a HEAD route with the given callback :rtype: object """ self.__set_route('head', {route: callback}) return RouteMapping
[ "def", "head", "(", "self", ",", "route", ":", "str", "(", ")", ",", "callback", ":", "object", "(", ")", ")", ":", "self", ".", "__set_route", "(", "'head'", ",", "{", "route", ":", "callback", "}", ")", "return", "RouteMapping" ]
Binds a HEAD route with the given callback :rtype: object
[ "Binds", "a", "HEAD", "route", "with", "the", "given", "callback", ":", "rtype", ":", "object" ]
7f6d5445b5662cba2e8938bb82c7f3ef94e5ded8
https://github.com/feliphebueno/Rinzler/blob/7f6d5445b5662cba2e8938bb82c7f3ef94e5ded8/rinzler/core/route_mapping.py#L56-L62
train
feliphebueno/Rinzler
rinzler/core/route_mapping.py
RouteMapping.options
def options(self, route: str(), callback: object()): """ Binds a OPTIONS route with the given callback :rtype: object """ self.__set_route('options', {route: callback}) return RouteMapping
python
def options(self, route: str(), callback: object()): """ Binds a OPTIONS route with the given callback :rtype: object """ self.__set_route('options', {route: callback}) return RouteMapping
[ "def", "options", "(", "self", ",", "route", ":", "str", "(", ")", ",", "callback", ":", "object", "(", ")", ")", ":", "self", ".", "__set_route", "(", "'options'", ",", "{", "route", ":", "callback", "}", ")", "return", "RouteMapping" ]
Binds a OPTIONS route with the given callback :rtype: object
[ "Binds", "a", "OPTIONS", "route", "with", "the", "given", "callback", ":", "rtype", ":", "object" ]
7f6d5445b5662cba2e8938bb82c7f3ef94e5ded8
https://github.com/feliphebueno/Rinzler/blob/7f6d5445b5662cba2e8938bb82c7f3ef94e5ded8/rinzler/core/route_mapping.py#L64-L70
train
feliphebueno/Rinzler
rinzler/core/route_mapping.py
RouteMapping.__set_route
def __set_route(self, type_route, route): """ Sets the given type_route and route to the route mapping :rtype: object """ if type_route in self.__routes: if not self.verify_route_already_bound(type_route, route): self.__routes[type_route].append(route)...
python
def __set_route(self, type_route, route): """ Sets the given type_route and route to the route mapping :rtype: object """ if type_route in self.__routes: if not self.verify_route_already_bound(type_route, route): self.__routes[type_route].append(route)...
[ "def", "__set_route", "(", "self", ",", "type_route", ",", "route", ")", ":", "if", "type_route", "in", "self", ".", "__routes", ":", "if", "not", "self", ".", "verify_route_already_bound", "(", "type_route", ",", "route", ")", ":", "self", ".", "__routes"...
Sets the given type_route and route to the route mapping :rtype: object
[ "Sets", "the", "given", "type_route", "and", "route", "to", "the", "route", "mapping", ":", "rtype", ":", "object" ]
7f6d5445b5662cba2e8938bb82c7f3ef94e5ded8
https://github.com/feliphebueno/Rinzler/blob/7f6d5445b5662cba2e8938bb82c7f3ef94e5ded8/rinzler/core/route_mapping.py#L72-L82
train
gmr/helper
helper/unix.py
operating_system
def operating_system(): """Return a string identifying the operating system the application is running on. :rtype: str """ if platform.system() == 'Darwin': return 'OS X Version %s' % platform.mac_ver()[0] distribution = ' '.join(platform.linux_distribution()).strip() os_platform =...
python
def operating_system(): """Return a string identifying the operating system the application is running on. :rtype: str """ if platform.system() == 'Darwin': return 'OS X Version %s' % platform.mac_ver()[0] distribution = ' '.join(platform.linux_distribution()).strip() os_platform =...
[ "def", "operating_system", "(", ")", ":", "if", "platform", ".", "system", "(", ")", "==", "'Darwin'", ":", "return", "'OS X Version %s'", "%", "platform", ".", "mac_ver", "(", ")", "[", "0", "]", "distribution", "=", "' '", ".", "join", "(", "platform",...
Return a string identifying the operating system the application is running on. :rtype: str
[ "Return", "a", "string", "identifying", "the", "operating", "system", "the", "application", "is", "running", "on", "." ]
fe8e45fc8eabf619429b2940c682c252ee33c082
https://github.com/gmr/helper/blob/fe8e45fc8eabf619429b2940c682c252ee33c082/helper/unix.py#L27-L40
train
gmr/helper
helper/unix.py
Daemon.start
def start(self): """Daemonize if the process is not already running.""" if self._is_already_running(): LOGGER.error('Is already running') sys.exit(1) try: self._daemonize() self.controller.start() except Exception as error: sys....
python
def start(self): """Daemonize if the process is not already running.""" if self._is_already_running(): LOGGER.error('Is already running') sys.exit(1) try: self._daemonize() self.controller.start() except Exception as error: sys....
[ "def", "start", "(", "self", ")", ":", "if", "self", ".", "_is_already_running", "(", ")", ":", "LOGGER", ".", "error", "(", "'Is already running'", ")", "sys", ".", "exit", "(", "1", ")", "try", ":", "self", ".", "_daemonize", "(", ")", "self", ".",...
Daemonize if the process is not already running.
[ "Daemonize", "if", "the", "process", "is", "not", "already", "running", "." ]
fe8e45fc8eabf619429b2940c682c252ee33c082
https://github.com/gmr/helper/blob/fe8e45fc8eabf619429b2940c682c252ee33c082/helper/unix.py#L85-L114
train
gmr/helper
helper/unix.py
Daemon.gid
def gid(self): """Return the group id that the daemon will run with :rtype: int """ if not self._gid: if self.controller.config.daemon.group: self._gid = grp.getgrnam(self.config.daemon.group).gr_gid else: self._gid = os.getgid() ...
python
def gid(self): """Return the group id that the daemon will run with :rtype: int """ if not self._gid: if self.controller.config.daemon.group: self._gid = grp.getgrnam(self.config.daemon.group).gr_gid else: self._gid = os.getgid() ...
[ "def", "gid", "(", "self", ")", ":", "if", "not", "self", ".", "_gid", ":", "if", "self", ".", "controller", ".", "config", ".", "daemon", ".", "group", ":", "self", ".", "_gid", "=", "grp", ".", "getgrnam", "(", "self", ".", "config", ".", "daem...
Return the group id that the daemon will run with :rtype: int
[ "Return", "the", "group", "id", "that", "the", "daemon", "will", "run", "with" ]
fe8e45fc8eabf619429b2940c682c252ee33c082
https://github.com/gmr/helper/blob/fe8e45fc8eabf619429b2940c682c252ee33c082/helper/unix.py#L117-L128
train
gmr/helper
helper/unix.py
Daemon.uid
def uid(self): """Return the user id that the process will run as :rtype: int """ if not self._uid: if self.config.daemon.user: self._uid = pwd.getpwnam(self.config.daemon.user).pw_uid else: self._uid = os.getuid() return ...
python
def uid(self): """Return the user id that the process will run as :rtype: int """ if not self._uid: if self.config.daemon.user: self._uid = pwd.getpwnam(self.config.daemon.user).pw_uid else: self._uid = os.getuid() return ...
[ "def", "uid", "(", "self", ")", ":", "if", "not", "self", ".", "_uid", ":", "if", "self", ".", "config", ".", "daemon", ".", "user", ":", "self", ".", "_uid", "=", "pwd", ".", "getpwnam", "(", "self", ".", "config", ".", "daemon", ".", "user", ...
Return the user id that the process will run as :rtype: int
[ "Return", "the", "user", "id", "that", "the", "process", "will", "run", "as" ]
fe8e45fc8eabf619429b2940c682c252ee33c082
https://github.com/gmr/helper/blob/fe8e45fc8eabf619429b2940c682c252ee33c082/helper/unix.py#L131-L142
train
gmr/helper
helper/unix.py
Daemon._daemonize
def _daemonize(self): """Fork into a background process and setup the process, copied in part from http://www.jejik.com/files/examples/daemon3x.py """ LOGGER.info('Forking %s into the background', sys.argv[0]) # Write the pidfile if current uid != final uid if os.getuid...
python
def _daemonize(self): """Fork into a background process and setup the process, copied in part from http://www.jejik.com/files/examples/daemon3x.py """ LOGGER.info('Forking %s into the background', sys.argv[0]) # Write the pidfile if current uid != final uid if os.getuid...
[ "def", "_daemonize", "(", "self", ")", ":", "LOGGER", ".", "info", "(", "'Forking %s into the background'", ",", "sys", ".", "argv", "[", "0", "]", ")", "# Write the pidfile if current uid != final uid", "if", "os", ".", "getuid", "(", ")", "!=", "self", ".", ...
Fork into a background process and setup the process, copied in part from http://www.jejik.com/files/examples/daemon3x.py
[ "Fork", "into", "a", "background", "process", "and", "setup", "the", "process", "copied", "in", "part", "from", "http", ":", "//", "www", ".", "jejik", ".", "com", "/", "files", "/", "examples", "/", "daemon3x", ".", "py" ]
fe8e45fc8eabf619429b2940c682c252ee33c082
https://github.com/gmr/helper/blob/fe8e45fc8eabf619429b2940c682c252ee33c082/helper/unix.py#L144-L201
train
gmr/helper
helper/unix.py
Daemon._get_exception_log_path
def _get_exception_log_path(): """Return the normalized path for the connection log, raising an exception if it can not written to. :return: str """ app = sys.argv[0].split('/')[-1] for exception_log in ['/var/log/%s.errors' % app, '/var/tm...
python
def _get_exception_log_path(): """Return the normalized path for the connection log, raising an exception if it can not written to. :return: str """ app = sys.argv[0].split('/')[-1] for exception_log in ['/var/log/%s.errors' % app, '/var/tm...
[ "def", "_get_exception_log_path", "(", ")", ":", "app", "=", "sys", ".", "argv", "[", "0", "]", ".", "split", "(", "'/'", ")", "[", "-", "1", "]", "for", "exception_log", "in", "[", "'/var/log/%s.errors'", "%", "app", ",", "'/var/tmp/%s.errors'", "%", ...
Return the normalized path for the connection log, raising an exception if it can not written to. :return: str
[ "Return", "the", "normalized", "path", "for", "the", "connection", "log", "raising", "an", "exception", "if", "it", "can", "not", "written", "to", "." ]
fe8e45fc8eabf619429b2940c682c252ee33c082
https://github.com/gmr/helper/blob/fe8e45fc8eabf619429b2940c682c252ee33c082/helper/unix.py#L204-L217
train
gmr/helper
helper/unix.py
Daemon._get_pidfile_path
def _get_pidfile_path(self): """Return the normalized path for the pidfile, raising an exception if it can not written to. :return: str :raises: ValueError :raises: OSError """ if self.config.daemon.pidfile: pidfile = path.abspath(self.config.daemon....
python
def _get_pidfile_path(self): """Return the normalized path for the pidfile, raising an exception if it can not written to. :return: str :raises: ValueError :raises: OSError """ if self.config.daemon.pidfile: pidfile = path.abspath(self.config.daemon....
[ "def", "_get_pidfile_path", "(", "self", ")", ":", "if", "self", ".", "config", ".", "daemon", ".", "pidfile", ":", "pidfile", "=", "path", ".", "abspath", "(", "self", ".", "config", ".", "daemon", ".", "pidfile", ")", "if", "not", "os", ".", "acces...
Return the normalized path for the pidfile, raising an exception if it can not written to. :return: str :raises: ValueError :raises: OSError
[ "Return", "the", "normalized", "path", "for", "the", "pidfile", "raising", "an", "exception", "if", "it", "can", "not", "written", "to", "." ]
fe8e45fc8eabf619429b2940c682c252ee33c082
https://github.com/gmr/helper/blob/fe8e45fc8eabf619429b2940c682c252ee33c082/helper/unix.py#L219-L243
train
gmr/helper
helper/unix.py
Daemon._is_already_running
def _is_already_running(self): """Check to see if the process is running, first looking for a pidfile, then shelling out in either case, removing a pidfile if it exists but the process is not running. """ # Look for the pidfile, if exists determine if the process is alive ...
python
def _is_already_running(self): """Check to see if the process is running, first looking for a pidfile, then shelling out in either case, removing a pidfile if it exists but the process is not running. """ # Look for the pidfile, if exists determine if the process is alive ...
[ "def", "_is_already_running", "(", "self", ")", ":", "# Look for the pidfile, if exists determine if the process is alive", "pidfile", "=", "self", ".", "_get_pidfile_path", "(", ")", "if", "os", ".", "path", ".", "exists", "(", "pidfile", ")", ":", "pid", "=", "o...
Check to see if the process is running, first looking for a pidfile, then shelling out in either case, removing a pidfile if it exists but the process is not running.
[ "Check", "to", "see", "if", "the", "process", "is", "running", "first", "looking", "for", "a", "pidfile", "then", "shelling", "out", "in", "either", "case", "removing", "a", "pidfile", "if", "it", "exists", "but", "the", "process", "is", "not", "running", ...
fe8e45fc8eabf619429b2940c682c252ee33c082
https://github.com/gmr/helper/blob/fe8e45fc8eabf619429b2940c682c252ee33c082/helper/unix.py#L245-L284
train
gmr/helper
helper/unix.py
Daemon._remove_pidfile
def _remove_pidfile(self): """Remove the pid file from the filesystem""" LOGGER.debug('Removing pidfile: %s', self.pidfile_path) try: os.unlink(self.pidfile_path) except OSError: pass
python
def _remove_pidfile(self): """Remove the pid file from the filesystem""" LOGGER.debug('Removing pidfile: %s', self.pidfile_path) try: os.unlink(self.pidfile_path) except OSError: pass
[ "def", "_remove_pidfile", "(", "self", ")", ":", "LOGGER", ".", "debug", "(", "'Removing pidfile: %s'", ",", "self", ".", "pidfile_path", ")", "try", ":", "os", ".", "unlink", "(", "self", ".", "pidfile_path", ")", "except", "OSError", ":", "pass" ]
Remove the pid file from the filesystem
[ "Remove", "the", "pid", "file", "from", "the", "filesystem" ]
fe8e45fc8eabf619429b2940c682c252ee33c082
https://github.com/gmr/helper/blob/fe8e45fc8eabf619429b2940c682c252ee33c082/helper/unix.py#L286-L292
train
gmr/helper
helper/unix.py
Daemon._write_pidfile
def _write_pidfile(self): """Write the pid file out with the process number in the pid file""" LOGGER.debug('Writing pidfile: %s', self.pidfile_path) with open(self.pidfile_path, "w") as handle: handle.write(str(os.getpid()))
python
def _write_pidfile(self): """Write the pid file out with the process number in the pid file""" LOGGER.debug('Writing pidfile: %s', self.pidfile_path) with open(self.pidfile_path, "w") as handle: handle.write(str(os.getpid()))
[ "def", "_write_pidfile", "(", "self", ")", ":", "LOGGER", ".", "debug", "(", "'Writing pidfile: %s'", ",", "self", ".", "pidfile_path", ")", "with", "open", "(", "self", ".", "pidfile_path", ",", "\"w\"", ")", "as", "handle", ":", "handle", ".", "write", ...
Write the pid file out with the process number in the pid file
[ "Write", "the", "pid", "file", "out", "with", "the", "process", "number", "in", "the", "pid", "file" ]
fe8e45fc8eabf619429b2940c682c252ee33c082
https://github.com/gmr/helper/blob/fe8e45fc8eabf619429b2940c682c252ee33c082/helper/unix.py#L294-L298
train
CitrineInformatics/pypif
pypif/util/case.py
to_camel_case
def to_camel_case(snake_case_string): """ Convert a string from snake case to camel case. For example, "some_var" would become "someVar". :param snake_case_string: Snake-cased string to convert to camel case. :returns: Camel-cased version of snake_case_string. """ parts = snake_case_string.lstr...
python
def to_camel_case(snake_case_string): """ Convert a string from snake case to camel case. For example, "some_var" would become "someVar". :param snake_case_string: Snake-cased string to convert to camel case. :returns: Camel-cased version of snake_case_string. """ parts = snake_case_string.lstr...
[ "def", "to_camel_case", "(", "snake_case_string", ")", ":", "parts", "=", "snake_case_string", ".", "lstrip", "(", "'_'", ")", ".", "split", "(", "'_'", ")", "return", "parts", "[", "0", "]", "+", "''", ".", "join", "(", "[", "i", ".", "title", "(", ...
Convert a string from snake case to camel case. For example, "some_var" would become "someVar". :param snake_case_string: Snake-cased string to convert to camel case. :returns: Camel-cased version of snake_case_string.
[ "Convert", "a", "string", "from", "snake", "case", "to", "camel", "case", ".", "For", "example", "some_var", "would", "become", "someVar", "." ]
938348a8ff7b10b330770cccaaeb2109922f681b
https://github.com/CitrineInformatics/pypif/blob/938348a8ff7b10b330770cccaaeb2109922f681b/pypif/util/case.py#L8-L16
train
CitrineInformatics/pypif
pypif/util/case.py
to_capitalized_camel_case
def to_capitalized_camel_case(snake_case_string): """ Convert a string from snake case to camel case with the first letter capitalized. For example, "some_var" would become "SomeVar". :param snake_case_string: Snake-cased string to convert to camel case. :returns: Camel-cased version of snake_case_...
python
def to_capitalized_camel_case(snake_case_string): """ Convert a string from snake case to camel case with the first letter capitalized. For example, "some_var" would become "SomeVar". :param snake_case_string: Snake-cased string to convert to camel case. :returns: Camel-cased version of snake_case_...
[ "def", "to_capitalized_camel_case", "(", "snake_case_string", ")", ":", "parts", "=", "snake_case_string", ".", "split", "(", "'_'", ")", "return", "''", ".", "join", "(", "[", "i", ".", "title", "(", ")", "for", "i", "in", "parts", "]", ")" ]
Convert a string from snake case to camel case with the first letter capitalized. For example, "some_var" would become "SomeVar". :param snake_case_string: Snake-cased string to convert to camel case. :returns: Camel-cased version of snake_case_string.
[ "Convert", "a", "string", "from", "snake", "case", "to", "camel", "case", "with", "the", "first", "letter", "capitalized", ".", "For", "example", "some_var", "would", "become", "SomeVar", "." ]
938348a8ff7b10b330770cccaaeb2109922f681b
https://github.com/CitrineInformatics/pypif/blob/938348a8ff7b10b330770cccaaeb2109922f681b/pypif/util/case.py#L19-L28
train
CitrineInformatics/pypif
pypif/util/case.py
to_snake_case
def to_snake_case(camel_case_string): """ Convert a string from camel case to snake case. From example, "someVar" would become "some_var". :param camel_case_string: Camel-cased string to convert to snake case. :return: Snake-cased version of camel_case_string. """ first_pass = _first_camel_case...
python
def to_snake_case(camel_case_string): """ Convert a string from camel case to snake case. From example, "someVar" would become "some_var". :param camel_case_string: Camel-cased string to convert to snake case. :return: Snake-cased version of camel_case_string. """ first_pass = _first_camel_case...
[ "def", "to_snake_case", "(", "camel_case_string", ")", ":", "first_pass", "=", "_first_camel_case_regex", ".", "sub", "(", "r'\\1_\\2'", ",", "camel_case_string", ")", "return", "_second_camel_case_regex", ".", "sub", "(", "r'\\1_\\2'", ",", "first_pass", ")", ".", ...
Convert a string from camel case to snake case. From example, "someVar" would become "some_var". :param camel_case_string: Camel-cased string to convert to snake case. :return: Snake-cased version of camel_case_string.
[ "Convert", "a", "string", "from", "camel", "case", "to", "snake", "case", ".", "From", "example", "someVar", "would", "become", "some_var", "." ]
938348a8ff7b10b330770cccaaeb2109922f681b
https://github.com/CitrineInformatics/pypif/blob/938348a8ff7b10b330770cccaaeb2109922f681b/pypif/util/case.py#L31-L39
train
CitrineInformatics/pypif
pypif/util/case.py
keys_to_snake_case
def keys_to_snake_case(camel_case_dict): """ Make a copy of a dictionary with all keys converted to snake case. This is just calls to_snake_case on each of the keys in the dictionary and returns a new dictionary. :param camel_case_dict: Dictionary with the keys to convert. :type camel_case_dict: Di...
python
def keys_to_snake_case(camel_case_dict): """ Make a copy of a dictionary with all keys converted to snake case. This is just calls to_snake_case on each of the keys in the dictionary and returns a new dictionary. :param camel_case_dict: Dictionary with the keys to convert. :type camel_case_dict: Di...
[ "def", "keys_to_snake_case", "(", "camel_case_dict", ")", ":", "return", "dict", "(", "(", "to_snake_case", "(", "key", ")", ",", "value", ")", "for", "(", "key", ",", "value", ")", "in", "camel_case_dict", ".", "items", "(", ")", ")" ]
Make a copy of a dictionary with all keys converted to snake case. This is just calls to_snake_case on each of the keys in the dictionary and returns a new dictionary. :param camel_case_dict: Dictionary with the keys to convert. :type camel_case_dict: Dictionary. :return: Dictionary with the keys conv...
[ "Make", "a", "copy", "of", "a", "dictionary", "with", "all", "keys", "converted", "to", "snake", "case", ".", "This", "is", "just", "calls", "to_snake_case", "on", "each", "of", "the", "keys", "in", "the", "dictionary", "and", "returns", "a", "new", "dic...
938348a8ff7b10b330770cccaaeb2109922f681b
https://github.com/CitrineInformatics/pypif/blob/938348a8ff7b10b330770cccaaeb2109922f681b/pypif/util/case.py#L42-L52
train
glomex/gcdt
gcdt/ramuda_core.py
list_functions
def list_functions(awsclient): """List the deployed lambda functions and print configuration. :return: exit_code """ client_lambda = awsclient.get_client('lambda') response = client_lambda.list_functions() for function in response['Functions']: log.info(function['FunctionName']) ...
python
def list_functions(awsclient): """List the deployed lambda functions and print configuration. :return: exit_code """ client_lambda = awsclient.get_client('lambda') response = client_lambda.list_functions() for function in response['Functions']: log.info(function['FunctionName']) ...
[ "def", "list_functions", "(", "awsclient", ")", ":", "client_lambda", "=", "awsclient", ".", "get_client", "(", "'lambda'", ")", "response", "=", "client_lambda", ".", "list_functions", "(", ")", "for", "function", "in", "response", "[", "'Functions'", "]", ":...
List the deployed lambda functions and print configuration. :return: exit_code
[ "List", "the", "deployed", "lambda", "functions", "and", "print", "configuration", "." ]
cd67cf416371337b83cb9ca3f696277125703339
https://github.com/glomex/gcdt/blob/cd67cf416371337b83cb9ca3f696277125703339/gcdt/ramuda_core.py#L125-L142
train
glomex/gcdt
gcdt/ramuda_core.py
deploy_lambda
def deploy_lambda(awsclient, function_name, role, handler_filename, handler_function, folders, description, timeout, memory, subnet_ids=None, security_groups=None, artifact_bucket=None, zipfile=None, fail_deployment_on_unsuccessfu...
python
def deploy_lambda(awsclient, function_name, role, handler_filename, handler_function, folders, description, timeout, memory, subnet_ids=None, security_groups=None, artifact_bucket=None, zipfile=None, fail_deployment_on_unsuccessfu...
[ "def", "deploy_lambda", "(", "awsclient", ",", "function_name", ",", "role", ",", "handler_filename", ",", "handler_function", ",", "folders", ",", "description", ",", "timeout", ",", "memory", ",", "subnet_ids", "=", "None", ",", "security_groups", "=", "None",...
Create or update a lambda function. :param awsclient: :param function_name: :param role: :param handler_filename: :param handler_function: :param folders: :param description: :param timeout: :param memory: :param subnet_ids: :param security_groups: :param artifact_bucket...
[ "Create", "or", "update", "a", "lambda", "function", "." ]
cd67cf416371337b83cb9ca3f696277125703339
https://github.com/glomex/gcdt/blob/cd67cf416371337b83cb9ca3f696277125703339/gcdt/ramuda_core.py#L145-L213
train
glomex/gcdt
gcdt/ramuda_core.py
bundle_lambda
def bundle_lambda(zipfile): """Write zipfile contents to file. :param zipfile: :return: exit_code """ # TODO have 'bundle.zip' as default config if not zipfile: return 1 with open('bundle.zip', 'wb') as zfile: zfile.write(zipfile) log.info('Finished - a bundle.zip is wai...
python
def bundle_lambda(zipfile): """Write zipfile contents to file. :param zipfile: :return: exit_code """ # TODO have 'bundle.zip' as default config if not zipfile: return 1 with open('bundle.zip', 'wb') as zfile: zfile.write(zipfile) log.info('Finished - a bundle.zip is wai...
[ "def", "bundle_lambda", "(", "zipfile", ")", ":", "# TODO have 'bundle.zip' as default config", "if", "not", "zipfile", ":", "return", "1", "with", "open", "(", "'bundle.zip'", ",", "'wb'", ")", "as", "zfile", ":", "zfile", ".", "write", "(", "zipfile", ")", ...
Write zipfile contents to file. :param zipfile: :return: exit_code
[ "Write", "zipfile", "contents", "to", "file", "." ]
cd67cf416371337b83cb9ca3f696277125703339
https://github.com/glomex/gcdt/blob/cd67cf416371337b83cb9ca3f696277125703339/gcdt/ramuda_core.py#L319-L331
train
glomex/gcdt
gcdt/ramuda_core.py
get_metrics
def get_metrics(awsclient, name): """Print out cloudformation metrics for a lambda function. :param awsclient :param name: name of the lambda function :return: exit_code """ metrics = ['Duration', 'Errors', 'Invocations', 'Throttles'] client_cw = awsclient.get_client('cloudwatch') for m...
python
def get_metrics(awsclient, name): """Print out cloudformation metrics for a lambda function. :param awsclient :param name: name of the lambda function :return: exit_code """ metrics = ['Duration', 'Errors', 'Invocations', 'Throttles'] client_cw = awsclient.get_client('cloudwatch') for m...
[ "def", "get_metrics", "(", "awsclient", ",", "name", ")", ":", "metrics", "=", "[", "'Duration'", ",", "'Errors'", ",", "'Invocations'", ",", "'Throttles'", "]", "client_cw", "=", "awsclient", ".", "get_client", "(", "'cloudwatch'", ")", "for", "metric", "in...
Print out cloudformation metrics for a lambda function. :param awsclient :param name: name of the lambda function :return: exit_code
[ "Print", "out", "cloudformation", "metrics", "for", "a", "lambda", "function", "." ]
cd67cf416371337b83cb9ca3f696277125703339
https://github.com/glomex/gcdt/blob/cd67cf416371337b83cb9ca3f696277125703339/gcdt/ramuda_core.py#L419-L450
train
glomex/gcdt
gcdt/ramuda_core.py
rollback
def rollback(awsclient, function_name, alias_name=ALIAS_NAME, version=None): """Rollback a lambda function to a given version. :param awsclient: :param function_name: :param alias_name: :param version: :return: exit_code """ if version: log.info('rolling back to version {}'.form...
python
def rollback(awsclient, function_name, alias_name=ALIAS_NAME, version=None): """Rollback a lambda function to a given version. :param awsclient: :param function_name: :param alias_name: :param version: :return: exit_code """ if version: log.info('rolling back to version {}'.form...
[ "def", "rollback", "(", "awsclient", ",", "function_name", ",", "alias_name", "=", "ALIAS_NAME", ",", "version", "=", "None", ")", ":", "if", "version", ":", "log", ".", "info", "(", "'rolling back to version {}'", ".", "format", "(", "version", ")", ")", ...
Rollback a lambda function to a given version. :param awsclient: :param function_name: :param alias_name: :param version: :return: exit_code
[ "Rollback", "a", "lambda", "function", "to", "a", "given", "version", "." ]
cd67cf416371337b83cb9ca3f696277125703339
https://github.com/glomex/gcdt/blob/cd67cf416371337b83cb9ca3f696277125703339/gcdt/ramuda_core.py#L453-L474
train
glomex/gcdt
gcdt/ramuda_core.py
delete_lambda
def delete_lambda(awsclient, function_name, events=None, delete_logs=False): """Delete a lambda function. :param awsclient: :param function_name: :param events: list of events :param delete_logs: :return: exit_code """ if events is not None: unwire(awsclient, events, function_na...
python
def delete_lambda(awsclient, function_name, events=None, delete_logs=False): """Delete a lambda function. :param awsclient: :param function_name: :param events: list of events :param delete_logs: :return: exit_code """ if events is not None: unwire(awsclient, events, function_na...
[ "def", "delete_lambda", "(", "awsclient", ",", "function_name", ",", "events", "=", "None", ",", "delete_logs", "=", "False", ")", ":", "if", "events", "is", "not", "None", ":", "unwire", "(", "awsclient", ",", "events", ",", "function_name", ",", "alias_n...
Delete a lambda function. :param awsclient: :param function_name: :param events: list of events :param delete_logs: :return: exit_code
[ "Delete", "a", "lambda", "function", "." ]
cd67cf416371337b83cb9ca3f696277125703339
https://github.com/glomex/gcdt/blob/cd67cf416371337b83cb9ca3f696277125703339/gcdt/ramuda_core.py#L477-L496
train
glomex/gcdt
gcdt/ramuda_core.py
delete_lambda_deprecated
def delete_lambda_deprecated(awsclient, function_name, s3_event_sources=[], time_event_sources=[], delete_logs=False): # FIXME: mutable default arguments! """Deprecated: please use delete_lambda! :param awsclient: :param function_name: :param s3_event_sources: :para...
python
def delete_lambda_deprecated(awsclient, function_name, s3_event_sources=[], time_event_sources=[], delete_logs=False): # FIXME: mutable default arguments! """Deprecated: please use delete_lambda! :param awsclient: :param function_name: :param s3_event_sources: :para...
[ "def", "delete_lambda_deprecated", "(", "awsclient", ",", "function_name", ",", "s3_event_sources", "=", "[", "]", ",", "time_event_sources", "=", "[", "]", ",", "delete_logs", "=", "False", ")", ":", "# FIXME: mutable default arguments!", "unwire_deprecated", "(", ...
Deprecated: please use delete_lambda! :param awsclient: :param function_name: :param s3_event_sources: :param time_event_sources: :param delete_logs: :return: exit_code
[ "Deprecated", ":", "please", "use", "delete_lambda!" ]
cd67cf416371337b83cb9ca3f696277125703339
https://github.com/glomex/gcdt/blob/cd67cf416371337b83cb9ca3f696277125703339/gcdt/ramuda_core.py#L499-L522
train
glomex/gcdt
gcdt/ramuda_core.py
cleanup_bundle
def cleanup_bundle(): """Deletes files used for creating bundle. * vendored/* * bundle.zip """ paths = ['./vendored', './bundle.zip'] for path in paths: if os.path.exists(path): log.debug("Deleting %s..." % path) if os.path.isdir(path): shu...
python
def cleanup_bundle(): """Deletes files used for creating bundle. * vendored/* * bundle.zip """ paths = ['./vendored', './bundle.zip'] for path in paths: if os.path.exists(path): log.debug("Deleting %s..." % path) if os.path.isdir(path): shu...
[ "def", "cleanup_bundle", "(", ")", ":", "paths", "=", "[", "'./vendored'", ",", "'./bundle.zip'", "]", "for", "path", "in", "paths", ":", "if", "os", ".", "path", ".", "exists", "(", "path", ")", ":", "log", ".", "debug", "(", "\"Deleting %s...\"", "%"...
Deletes files used for creating bundle. * vendored/* * bundle.zip
[ "Deletes", "files", "used", "for", "creating", "bundle", ".", "*", "vendored", "/", "*", "*", "bundle", ".", "zip" ]
cd67cf416371337b83cb9ca3f696277125703339
https://github.com/glomex/gcdt/blob/cd67cf416371337b83cb9ca3f696277125703339/gcdt/ramuda_core.py#L623-L635
train
glomex/gcdt
gcdt/ramuda_core.py
ping
def ping(awsclient, function_name, alias_name=ALIAS_NAME, version=None): """Send a ping request to a lambda function. :param awsclient: :param function_name: :param alias_name: :param version: :return: ping response payload """ log.debug('sending ping to lambda function: %s', function_n...
python
def ping(awsclient, function_name, alias_name=ALIAS_NAME, version=None): """Send a ping request to a lambda function. :param awsclient: :param function_name: :param alias_name: :param version: :return: ping response payload """ log.debug('sending ping to lambda function: %s', function_n...
[ "def", "ping", "(", "awsclient", ",", "function_name", ",", "alias_name", "=", "ALIAS_NAME", ",", "version", "=", "None", ")", ":", "log", ".", "debug", "(", "'sending ping to lambda function: %s'", ",", "function_name", ")", "payload", "=", "'{\"ramuda_action\": ...
Send a ping request to a lambda function. :param awsclient: :param function_name: :param alias_name: :param version: :return: ping response payload
[ "Send", "a", "ping", "request", "to", "a", "lambda", "function", "." ]
cd67cf416371337b83cb9ca3f696277125703339
https://github.com/glomex/gcdt/blob/cd67cf416371337b83cb9ca3f696277125703339/gcdt/ramuda_core.py#L638-L651
train
glomex/gcdt
gcdt/ramuda_core.py
invoke
def invoke(awsclient, function_name, payload, invocation_type=None, alias_name=ALIAS_NAME, version=None, outfile=None): """Send a ping request to a lambda function. :param awsclient: :param function_name: :param payload: :param invocation_type: :param alias_name: :param version: ...
python
def invoke(awsclient, function_name, payload, invocation_type=None, alias_name=ALIAS_NAME, version=None, outfile=None): """Send a ping request to a lambda function. :param awsclient: :param function_name: :param payload: :param invocation_type: :param alias_name: :param version: ...
[ "def", "invoke", "(", "awsclient", ",", "function_name", ",", "payload", ",", "invocation_type", "=", "None", ",", "alias_name", "=", "ALIAS_NAME", ",", "version", "=", "None", ",", "outfile", "=", "None", ")", ":", "log", ".", "debug", "(", "'invoking lam...
Send a ping request to a lambda function. :param awsclient: :param function_name: :param payload: :param invocation_type: :param alias_name: :param version: :param outfile: write response to file :return: ping response payload
[ "Send", "a", "ping", "request", "to", "a", "lambda", "function", "." ]
cd67cf416371337b83cb9ca3f696277125703339
https://github.com/glomex/gcdt/blob/cd67cf416371337b83cb9ca3f696277125703339/gcdt/ramuda_core.py#L654-L700
train