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
jwass/directions.py
directions/base.py
Router.rate_limit_wait
def rate_limit_wait(self): """ Sleep if rate limiting is required based on current time and last query. """ if self._rate_limit_dt and self._last_query is not None: dt = time.time() - self._last_query wait = self._rate_limit_dt - dt if wait > ...
python
def rate_limit_wait(self): """ Sleep if rate limiting is required based on current time and last query. """ if self._rate_limit_dt and self._last_query is not None: dt = time.time() - self._last_query wait = self._rate_limit_dt - dt if wait > ...
[ "def", "rate_limit_wait", "(", "self", ")", ":", "if", "self", ".", "_rate_limit_dt", "and", "self", ".", "_last_query", "is", "not", "None", ":", "dt", "=", "time", ".", "time", "(", ")", "-", "self", ".", "_last_query", "wait", "=", "self", ".", "_...
Sleep if rate limiting is required based on current time and last query.
[ "Sleep", "if", "rate", "limiting", "is", "required", "based", "on", "current", "time", "and", "last", "query", "." ]
c3734e4cb499fe80e27b2a26575a91ac4e834e95
https://github.com/jwass/directions.py/blob/c3734e4cb499fe80e27b2a26575a91ac4e834e95/directions/base.py#L22-L32
train
jwass/directions.py
directions/base.py
Router.route
def route(self, arg, destination=None, waypoints=None, raw=False, **kwargs): """ Query a route. route(locations): points can be - a sequence of locations - a Shapely LineString route(origin, destination, waypoints=None) - origin and destination are a...
python
def route(self, arg, destination=None, waypoints=None, raw=False, **kwargs): """ Query a route. route(locations): points can be - a sequence of locations - a Shapely LineString route(origin, destination, waypoints=None) - origin and destination are a...
[ "def", "route", "(", "self", ",", "arg", ",", "destination", "=", "None", ",", "waypoints", "=", "None", ",", "raw", "=", "False", ",", "*", "*", "kwargs", ")", ":", "points", "=", "_parse_points", "(", "arg", ",", "destination", ",", "waypoints", ")...
Query a route. route(locations): points can be - a sequence of locations - a Shapely LineString route(origin, destination, waypoints=None) - origin and destination are a single destination - waypoints are the points to be inserted between the ...
[ "Query", "a", "route", "." ]
c3734e4cb499fe80e27b2a26575a91ac4e834e95
https://github.com/jwass/directions.py/blob/c3734e4cb499fe80e27b2a26575a91ac4e834e95/directions/base.py#L38-L99
train
jwass/directions.py
directions/base.py
Route.from_geojson
def from_geojson(cls, data): """ Return a Route from a GeoJSON dictionary, as returned by Route.geojson() """ properties = data['properties'] distance = properties.pop('distance') duration = properties.pop('duration') maneuvers = [] for feature in data['...
python
def from_geojson(cls, data): """ Return a Route from a GeoJSON dictionary, as returned by Route.geojson() """ properties = data['properties'] distance = properties.pop('distance') duration = properties.pop('duration') maneuvers = [] for feature in data['...
[ "def", "from_geojson", "(", "cls", ",", "data", ")", ":", "properties", "=", "data", "[", "'properties'", "]", "distance", "=", "properties", ".", "pop", "(", "'distance'", ")", "duration", "=", "properties", ".", "pop", "(", "'duration'", ")", "maneuvers"...
Return a Route from a GeoJSON dictionary, as returned by Route.geojson()
[ "Return", "a", "Route", "from", "a", "GeoJSON", "dictionary", "as", "returned", "by", "Route", ".", "geojson", "()" ]
c3734e4cb499fe80e27b2a26575a91ac4e834e95
https://github.com/jwass/directions.py/blob/c3734e4cb499fe80e27b2a26575a91ac4e834e95/directions/base.py#L193-L210
train
comtihon/catcher
catcher/utils/module_utils.py
prepare_modules
def prepare_modules(module_paths: list, available: dict) -> dict: """ Scan all paths for external modules and form key-value dict. :param module_paths: list of external modules (either python packages or third-party scripts) :param available: dict of all registered python modules (can contain python mod...
python
def prepare_modules(module_paths: list, available: dict) -> dict: """ Scan all paths for external modules and form key-value dict. :param module_paths: list of external modules (either python packages or third-party scripts) :param available: dict of all registered python modules (can contain python mod...
[ "def", "prepare_modules", "(", "module_paths", ":", "list", ",", "available", ":", "dict", ")", "->", "dict", ":", "indexed", "=", "{", "}", "for", "path", "in", "module_paths", ":", "if", "not", "os", ".", "path", ".", "exists", "(", "path", ")", "a...
Scan all paths for external modules and form key-value dict. :param module_paths: list of external modules (either python packages or third-party scripts) :param available: dict of all registered python modules (can contain python modules from module_paths) :return: dict of external modules, where keys are ...
[ "Scan", "all", "paths", "for", "external", "modules", "and", "form", "key", "-", "value", "dict", ".", ":", "param", "module_paths", ":", "list", "of", "external", "modules", "(", "either", "python", "packages", "or", "third", "-", "party", "scripts", ")",...
5124e69d11cb6987daca595a61a4062d2b5f5ecc
https://github.com/comtihon/catcher/blob/5124e69d11cb6987daca595a61a4062d2b5f5ecc/catcher/utils/module_utils.py#L14-L32
train
keans/lmnotify
lmnotify/ssdp.py
SSDPManager.discover_upnp_devices
def discover_upnp_devices( self, st="upnp:rootdevice", timeout=2, mx=1, retries=1 ): """ sends an SSDP discovery packet to the network and collects the devices that replies to it. A dictionary is returned using the devices unique usn as key """ # prepare UDP s...
python
def discover_upnp_devices( self, st="upnp:rootdevice", timeout=2, mx=1, retries=1 ): """ sends an SSDP discovery packet to the network and collects the devices that replies to it. A dictionary is returned using the devices unique usn as key """ # prepare UDP s...
[ "def", "discover_upnp_devices", "(", "self", ",", "st", "=", "\"upnp:rootdevice\"", ",", "timeout", "=", "2", ",", "mx", "=", "1", ",", "retries", "=", "1", ")", ":", "# prepare UDP socket to transfer the SSDP packets", "s", "=", "socket", ".", "socket", "(", ...
sends an SSDP discovery packet to the network and collects the devices that replies to it. A dictionary is returned using the devices unique usn as key
[ "sends", "an", "SSDP", "discovery", "packet", "to", "the", "network", "and", "collects", "the", "devices", "that", "replies", "to", "it", ".", "A", "dictionary", "is", "returned", "using", "the", "devices", "unique", "usn", "as", "key" ]
b0a5282a582e5090852dc20fea8a135ca258d0d3
https://github.com/keans/lmnotify/blob/b0a5282a582e5090852dc20fea8a135ca258d0d3/lmnotify/ssdp.py#L80-L115
train
keans/lmnotify
lmnotify/ssdp.py
SSDPManager.get_filtered_devices
def get_filtered_devices( self, model_name, device_types="upnp:rootdevice", timeout=2 ): """ returns a dict of devices that contain the given model name """ # get list of all UPNP devices in the network upnp_devices = self.discover_upnp_devices(st=device_types) ...
python
def get_filtered_devices( self, model_name, device_types="upnp:rootdevice", timeout=2 ): """ returns a dict of devices that contain the given model name """ # get list of all UPNP devices in the network upnp_devices = self.discover_upnp_devices(st=device_types) ...
[ "def", "get_filtered_devices", "(", "self", ",", "model_name", ",", "device_types", "=", "\"upnp:rootdevice\"", ",", "timeout", "=", "2", ")", ":", "# get list of all UPNP devices in the network", "upnp_devices", "=", "self", ".", "discover_upnp_devices", "(", "st", "...
returns a dict of devices that contain the given model name
[ "returns", "a", "dict", "of", "devices", "that", "contain", "the", "given", "model", "name" ]
b0a5282a582e5090852dc20fea8a135ca258d0d3
https://github.com/keans/lmnotify/blob/b0a5282a582e5090852dc20fea8a135ca258d0d3/lmnotify/ssdp.py#L117-L180
train
rasbt/mputil
mputil/map.py
lazy_map
def lazy_map(data_processor, data_generator, n_cpus=1, stepsize=None): """A variant of multiprocessing.Pool.map that supports lazy evaluation As with the regular multiprocessing.Pool.map, the processes are spawned off asynchronously while the results are returned in order. In contrast to multiprocessin...
python
def lazy_map(data_processor, data_generator, n_cpus=1, stepsize=None): """A variant of multiprocessing.Pool.map that supports lazy evaluation As with the regular multiprocessing.Pool.map, the processes are spawned off asynchronously while the results are returned in order. In contrast to multiprocessin...
[ "def", "lazy_map", "(", "data_processor", ",", "data_generator", ",", "n_cpus", "=", "1", ",", "stepsize", "=", "None", ")", ":", "if", "not", "n_cpus", ":", "n_cpus", "=", "mp", ".", "cpu_count", "(", ")", "elif", "n_cpus", "<", "0", ":", "n_cpus", ...
A variant of multiprocessing.Pool.map that supports lazy evaluation As with the regular multiprocessing.Pool.map, the processes are spawned off asynchronously while the results are returned in order. In contrast to multiprocessing.Pool.map, the iterator (here: data_generator) is not consumed at once bu...
[ "A", "variant", "of", "multiprocessing", ".", "Pool", ".", "map", "that", "supports", "lazy", "evaluation" ]
952844980d4083eabe7b387de69c3d50b04abb9a
https://github.com/rasbt/mputil/blob/952844980d4083eabe7b387de69c3d50b04abb9a/mputil/map.py#L12-L68
train
rasbt/mputil
mputil/map.py
lazy_imap
def lazy_imap(data_processor, data_generator, n_cpus=1, stepsize=None): """A variant of multiprocessing.Pool.imap that supports lazy evaluation As with the regular multiprocessing.Pool.imap, the processes are spawned off asynchronously while the results are returned in order. In contrast to multiproces...
python
def lazy_imap(data_processor, data_generator, n_cpus=1, stepsize=None): """A variant of multiprocessing.Pool.imap that supports lazy evaluation As with the regular multiprocessing.Pool.imap, the processes are spawned off asynchronously while the results are returned in order. In contrast to multiproces...
[ "def", "lazy_imap", "(", "data_processor", ",", "data_generator", ",", "n_cpus", "=", "1", ",", "stepsize", "=", "None", ")", ":", "if", "not", "n_cpus", ":", "n_cpus", "=", "mp", ".", "cpu_count", "(", ")", "elif", "n_cpus", "<", "0", ":", "n_cpus", ...
A variant of multiprocessing.Pool.imap that supports lazy evaluation As with the regular multiprocessing.Pool.imap, the processes are spawned off asynchronously while the results are returned in order. In contrast to multiprocessing.Pool.imap, the iterator (here: data_generator) is not consumed at once...
[ "A", "variant", "of", "multiprocessing", ".", "Pool", ".", "imap", "that", "supports", "lazy", "evaluation" ]
952844980d4083eabe7b387de69c3d50b04abb9a
https://github.com/rasbt/mputil/blob/952844980d4083eabe7b387de69c3d50b04abb9a/mputil/map.py#L71-L123
train
comtihon/catcher
catcher/steps/step.py
update_variables
def update_variables(func): """ Use this decorator on Step.action implementation. Your action method should always return variables, or both variables and output. This decorator will update variables with output. """ @wraps(func) def wrapper(self, *args, **kwargs): result = f...
python
def update_variables(func): """ Use this decorator on Step.action implementation. Your action method should always return variables, or both variables and output. This decorator will update variables with output. """ @wraps(func) def wrapper(self, *args, **kwargs): result = f...
[ "def", "update_variables", "(", "func", ")", ":", "@", "wraps", "(", "func", ")", "def", "wrapper", "(", "self", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "result", "=", "func", "(", "self", ",", "*", "args", ",", "*", "*", "kwargs", ...
Use this decorator on Step.action implementation. Your action method should always return variables, or both variables and output. This decorator will update variables with output.
[ "Use", "this", "decorator", "on", "Step", ".", "action", "implementation", "." ]
5124e69d11cb6987daca595a61a4062d2b5f5ecc
https://github.com/comtihon/catcher/blob/5124e69d11cb6987daca595a61a4062d2b5f5ecc/catcher/steps/step.py#L156-L175
train
keans/lmnotify
lmnotify/models.py
AppModel._set_properties
def _set_properties(self, data): """ set the properties of the app model by the given data dict """ for property in data.keys(): if property in vars(self): setattr(self, property, data[property])
python
def _set_properties(self, data): """ set the properties of the app model by the given data dict """ for property in data.keys(): if property in vars(self): setattr(self, property, data[property])
[ "def", "_set_properties", "(", "self", ",", "data", ")", ":", "for", "property", "in", "data", ".", "keys", "(", ")", ":", "if", "property", "in", "vars", "(", "self", ")", ":", "setattr", "(", "self", ",", "property", ",", "data", "[", "property", ...
set the properties of the app model by the given data dict
[ "set", "the", "properties", "of", "the", "app", "model", "by", "the", "given", "data", "dict" ]
b0a5282a582e5090852dc20fea8a135ca258d0d3
https://github.com/keans/lmnotify/blob/b0a5282a582e5090852dc20fea8a135ca258d0d3/lmnotify/models.py#L18-L24
train
keans/lmnotify
setup.py
get_long_description
def get_long_description(): """ get long description from README.rst file """ with codecs.open(os.path.join(here, "README.rst"), "r", "utf-8") as f: return f.read()
python
def get_long_description(): """ get long description from README.rst file """ with codecs.open(os.path.join(here, "README.rst"), "r", "utf-8") as f: return f.read()
[ "def", "get_long_description", "(", ")", ":", "with", "codecs", ".", "open", "(", "os", ".", "path", ".", "join", "(", "here", ",", "\"README.rst\"", ")", ",", "\"r\"", ",", "\"utf-8\"", ")", "as", "f", ":", "return", "f", ".", "read", "(", ")" ]
get long description from README.rst file
[ "get", "long", "description", "from", "README", ".", "rst", "file" ]
b0a5282a582e5090852dc20fea8a135ca258d0d3
https://github.com/keans/lmnotify/blob/b0a5282a582e5090852dc20fea8a135ca258d0d3/setup.py#L9-L14
train
AlecAivazis/graphql-over-kafka
nautilus/network/events/actionHandlers/rollCallHandler.py
roll_call_handler
async def roll_call_handler(service, action_type, payload, props, **kwds): """ This action handler responds to the "roll call" emitted by the api gateway when it is brought up with the normal summary produced by the service. """ # if the action type corresponds to a roll call if ...
python
async def roll_call_handler(service, action_type, payload, props, **kwds): """ This action handler responds to the "roll call" emitted by the api gateway when it is brought up with the normal summary produced by the service. """ # if the action type corresponds to a roll call if ...
[ "async", "def", "roll_call_handler", "(", "service", ",", "action_type", ",", "payload", ",", "props", ",", "*", "*", "kwds", ")", ":", "# if the action type corresponds to a roll call", "if", "action_type", "==", "roll_call_type", "(", ")", ":", "# then announce th...
This action handler responds to the "roll call" emitted by the api gateway when it is brought up with the normal summary produced by the service.
[ "This", "action", "handler", "responds", "to", "the", "roll", "call", "emitted", "by", "the", "api", "gateway", "when", "it", "is", "brought", "up", "with", "the", "normal", "summary", "produced", "by", "the", "service", "." ]
70e2acef27a2f87355590be1a6ca60ce3ab4d09c
https://github.com/AlecAivazis/graphql-over-kafka/blob/70e2acef27a2f87355590be1a6ca60ce3ab4d09c/nautilus/network/events/actionHandlers/rollCallHandler.py#L3-L12
train
AlecAivazis/graphql-over-kafka
nautilus/network/events/actionHandlers/flexibleAPIHandler.py
flexible_api_handler
async def flexible_api_handler(service, action_type, payload, props, **kwds): """ This query handler builds the dynamic picture of availible services. """ # if the action represents a new service if action_type == intialize_service_action(): # the treat the payload like json if its a str...
python
async def flexible_api_handler(service, action_type, payload, props, **kwds): """ This query handler builds the dynamic picture of availible services. """ # if the action represents a new service if action_type == intialize_service_action(): # the treat the payload like json if its a str...
[ "async", "def", "flexible_api_handler", "(", "service", ",", "action_type", ",", "payload", ",", "props", ",", "*", "*", "kwds", ")", ":", "# if the action represents a new service", "if", "action_type", "==", "intialize_service_action", "(", ")", ":", "# the treat ...
This query handler builds the dynamic picture of availible services.
[ "This", "query", "handler", "builds", "the", "dynamic", "picture", "of", "availible", "services", "." ]
70e2acef27a2f87355590be1a6ca60ce3ab4d09c
https://github.com/AlecAivazis/graphql-over-kafka/blob/70e2acef27a2f87355590be1a6ca60ce3ab4d09c/nautilus/network/events/actionHandlers/flexibleAPIHandler.py#L7-L51
train
AlecAivazis/graphql-over-kafka
nautilus/api/filter.py
_parse_order_by
def _parse_order_by(model, order_by): """ This function figures out the list of orderings for the given model and argument. Args: model (nautilus.BaseModel): The model to compute ordering against order_by (list of str): the list of fields to order_by. If the field ...
python
def _parse_order_by(model, order_by): """ This function figures out the list of orderings for the given model and argument. Args: model (nautilus.BaseModel): The model to compute ordering against order_by (list of str): the list of fields to order_by. If the field ...
[ "def", "_parse_order_by", "(", "model", ",", "order_by", ")", ":", "# the list of filters for the models", "out", "=", "[", "]", "# for each attribute we have to order by", "for", "key", "in", "order_by", ":", "# remove any whitespace", "key", "=", "key", ".", "strip"...
This function figures out the list of orderings for the given model and argument. Args: model (nautilus.BaseModel): The model to compute ordering against order_by (list of str): the list of fields to order_by. If the field starts with a `+` then the order is acen...
[ "This", "function", "figures", "out", "the", "list", "of", "orderings", "for", "the", "given", "model", "and", "argument", "." ]
70e2acef27a2f87355590be1a6ca60ce3ab4d09c
https://github.com/AlecAivazis/graphql-over-kafka/blob/70e2acef27a2f87355590be1a6ca60ce3ab4d09c/nautilus/api/filter.py#L112-L147
train
AlecAivazis/graphql-over-kafka
nautilus/management/scripts/create.py
model
def model(model_names): """ Creates the example directory structure necessary for a model service. """ # for each model name we need to create for model_name in model_names: # the template context context = { 'name': model_name, } # render the model t...
python
def model(model_names): """ Creates the example directory structure necessary for a model service. """ # for each model name we need to create for model_name in model_names: # the template context context = { 'name': model_name, } # render the model t...
[ "def", "model", "(", "model_names", ")", ":", "# for each model name we need to create", "for", "model_name", "in", "model_names", ":", "# the template context", "context", "=", "{", "'name'", ":", "model_name", ",", "}", "# render the model template", "render_template", ...
Creates the example directory structure necessary for a model service.
[ "Creates", "the", "example", "directory", "structure", "necessary", "for", "a", "model", "service", "." ]
70e2acef27a2f87355590be1a6ca60ce3ab4d09c
https://github.com/AlecAivazis/graphql-over-kafka/blob/70e2acef27a2f87355590be1a6ca60ce3ab4d09c/nautilus/management/scripts/create.py#L19-L32
train
AlecAivazis/graphql-over-kafka
nautilus/management/scripts/create.py
api
def api(): """ Create the folder/directories for an ApiGateway service. """ # the template context context = { 'name': 'api', 'secret_key': random_string(32) } render_template(template='common', context=context) render_template(template='api', context=context)
python
def api(): """ Create the folder/directories for an ApiGateway service. """ # the template context context = { 'name': 'api', 'secret_key': random_string(32) } render_template(template='common', context=context) render_template(template='api', context=context)
[ "def", "api", "(", ")", ":", "# the template context", "context", "=", "{", "'name'", ":", "'api'", ",", "'secret_key'", ":", "random_string", "(", "32", ")", "}", "render_template", "(", "template", "=", "'common'", ",", "context", "=", "context", ")", "r...
Create the folder/directories for an ApiGateway service.
[ "Create", "the", "folder", "/", "directories", "for", "an", "ApiGateway", "service", "." ]
70e2acef27a2f87355590be1a6ca60ce3ab4d09c
https://github.com/AlecAivazis/graphql-over-kafka/blob/70e2acef27a2f87355590be1a6ca60ce3ab4d09c/nautilus/management/scripts/create.py#L36-L47
train
AlecAivazis/graphql-over-kafka
nautilus/management/scripts/create.py
auth
def auth(): """ Create the folder/directories for an Auth service. """ # the template context context = { 'name': 'auth', } render_template(template='common', context=context) render_template(template='auth', context=context)
python
def auth(): """ Create the folder/directories for an Auth service. """ # the template context context = { 'name': 'auth', } render_template(template='common', context=context) render_template(template='auth', context=context)
[ "def", "auth", "(", ")", ":", "# the template context", "context", "=", "{", "'name'", ":", "'auth'", ",", "}", "render_template", "(", "template", "=", "'common'", ",", "context", "=", "context", ")", "render_template", "(", "template", "=", "'auth'", ",", ...
Create the folder/directories for an Auth service.
[ "Create", "the", "folder", "/", "directories", "for", "an", "Auth", "service", "." ]
70e2acef27a2f87355590be1a6ca60ce3ab4d09c
https://github.com/AlecAivazis/graphql-over-kafka/blob/70e2acef27a2f87355590be1a6ca60ce3ab4d09c/nautilus/management/scripts/create.py#L51-L61
train
AlecAivazis/graphql-over-kafka
nautilus/management/scripts/create.py
connection
def connection(model_connections): """ Creates the example directory structure necessary for a connection service. """ # for each connection group for connection_str in model_connections: # the services to connect services = connection_str.split(':') services.so...
python
def connection(model_connections): """ Creates the example directory structure necessary for a connection service. """ # for each connection group for connection_str in model_connections: # the services to connect services = connection_str.split(':') services.so...
[ "def", "connection", "(", "model_connections", ")", ":", "# for each connection group", "for", "connection_str", "in", "model_connections", ":", "# the services to connect", "services", "=", "connection_str", ".", "split", "(", "':'", ")", "services", ".", "sort", "("...
Creates the example directory structure necessary for a connection service.
[ "Creates", "the", "example", "directory", "structure", "necessary", "for", "a", "connection", "service", "." ]
70e2acef27a2f87355590be1a6ca60ce3ab4d09c
https://github.com/AlecAivazis/graphql-over-kafka/blob/70e2acef27a2f87355590be1a6ca60ce3ab4d09c/nautilus/management/scripts/create.py#L66-L89
train
AlecAivazis/graphql-over-kafka
nautilus/conventions/models.py
get_model_string
def get_model_string(model): """ This function returns the conventional action designator for a given model. """ name = model if isinstance(model, str) else model.__name__ return normalize_string(name)
python
def get_model_string(model): """ This function returns the conventional action designator for a given model. """ name = model if isinstance(model, str) else model.__name__ return normalize_string(name)
[ "def", "get_model_string", "(", "model", ")", ":", "name", "=", "model", "if", "isinstance", "(", "model", ",", "str", ")", "else", "model", ".", "__name__", "return", "normalize_string", "(", "name", ")" ]
This function returns the conventional action designator for a given model.
[ "This", "function", "returns", "the", "conventional", "action", "designator", "for", "a", "given", "model", "." ]
70e2acef27a2f87355590be1a6ca60ce3ab4d09c
https://github.com/AlecAivazis/graphql-over-kafka/blob/70e2acef27a2f87355590be1a6ca60ce3ab4d09c/nautilus/conventions/models.py#L8-L13
train
AlecAivazis/graphql-over-kafka
nautilus/api/util/build_native_type_dictionary.py
build_native_type_dictionary
def build_native_type_dictionary(fields, respect_required=False, wrap_field=True, name=''): """ This function takes a list of type summaries and builds a dictionary with native representations of each entry. Useful for dynamically building native class records from summaries. """ # a...
python
def build_native_type_dictionary(fields, respect_required=False, wrap_field=True, name=''): """ This function takes a list of type summaries and builds a dictionary with native representations of each entry. Useful for dynamically building native class records from summaries. """ # a...
[ "def", "build_native_type_dictionary", "(", "fields", ",", "respect_required", "=", "False", ",", "wrap_field", "=", "True", ",", "name", "=", "''", ")", ":", "# a place to start when building the input field attributes", "input_fields", "=", "{", "}", "# go over every ...
This function takes a list of type summaries and builds a dictionary with native representations of each entry. Useful for dynamically building native class records from summaries.
[ "This", "function", "takes", "a", "list", "of", "type", "summaries", "and", "builds", "a", "dictionary", "with", "native", "representations", "of", "each", "entry", ".", "Useful", "for", "dynamically", "building", "native", "class", "records", "from", "summaries...
70e2acef27a2f87355590be1a6ca60ce3ab4d09c
https://github.com/AlecAivazis/graphql-over-kafka/blob/70e2acef27a2f87355590be1a6ca60ce3ab4d09c/nautilus/api/util/build_native_type_dictionary.py#L7-L49
train
AlecAivazis/graphql-over-kafka
nautilus/api/util/summarize_crud_mutation.py
summarize_crud_mutation
def summarize_crud_mutation(method, model, isAsync=False): """ This function provides the standard form for crud mutations. """ # create the approrpriate action type action_type = get_crud_action(method=method, model=model) # the name of the mutation name = crud_mutation_name(model=mode...
python
def summarize_crud_mutation(method, model, isAsync=False): """ This function provides the standard form for crud mutations. """ # create the approrpriate action type action_type = get_crud_action(method=method, model=model) # the name of the mutation name = crud_mutation_name(model=mode...
[ "def", "summarize_crud_mutation", "(", "method", ",", "model", ",", "isAsync", "=", "False", ")", ":", "# create the approrpriate action type", "action_type", "=", "get_crud_action", "(", "method", "=", "method", ",", "model", "=", "model", ")", "# the name of the m...
This function provides the standard form for crud mutations.
[ "This", "function", "provides", "the", "standard", "form", "for", "crud", "mutations", "." ]
70e2acef27a2f87355590be1a6ca60ce3ab4d09c
https://github.com/AlecAivazis/graphql-over-kafka/blob/70e2acef27a2f87355590be1a6ca60ce3ab4d09c/nautilus/api/util/summarize_crud_mutation.py#L15-L48
train
AlecAivazis/graphql-over-kafka
nautilus/network/events/consumers/kafka.py
KafkaBroker.start
def start(self): """ This function starts the brokers interaction with the kafka stream """ self.loop.run_until_complete(self._consumer.start()) self.loop.run_until_complete(self._producer.start()) self._consumer_task = self.loop.create_task(self._consume_event_callba...
python
def start(self): """ This function starts the brokers interaction with the kafka stream """ self.loop.run_until_complete(self._consumer.start()) self.loop.run_until_complete(self._producer.start()) self._consumer_task = self.loop.create_task(self._consume_event_callba...
[ "def", "start", "(", "self", ")", ":", "self", ".", "loop", ".", "run_until_complete", "(", "self", ".", "_consumer", ".", "start", "(", ")", ")", "self", ".", "loop", ".", "run_until_complete", "(", "self", ".", "_producer", ".", "start", "(", ")", ...
This function starts the brokers interaction with the kafka stream
[ "This", "function", "starts", "the", "brokers", "interaction", "with", "the", "kafka", "stream" ]
70e2acef27a2f87355590be1a6ca60ce3ab4d09c
https://github.com/AlecAivazis/graphql-over-kafka/blob/70e2acef27a2f87355590be1a6ca60ce3ab4d09c/nautilus/network/events/consumers/kafka.py#L88-L94
train
AlecAivazis/graphql-over-kafka
nautilus/network/events/consumers/kafka.py
KafkaBroker.stop
def stop(self): """ This method stops the brokers interaction with the kafka stream """ self.loop.run_until_complete(self._consumer.stop()) self.loop.run_until_complete(self._producer.stop()) # attempt try: # to cancel the service self...
python
def stop(self): """ This method stops the brokers interaction with the kafka stream """ self.loop.run_until_complete(self._consumer.stop()) self.loop.run_until_complete(self._producer.stop()) # attempt try: # to cancel the service self...
[ "def", "stop", "(", "self", ")", ":", "self", ".", "loop", ".", "run_until_complete", "(", "self", ".", "_consumer", ".", "stop", "(", ")", ")", "self", ".", "loop", ".", "run_until_complete", "(", "self", ".", "_producer", ".", "stop", "(", ")", ")"...
This method stops the brokers interaction with the kafka stream
[ "This", "method", "stops", "the", "brokers", "interaction", "with", "the", "kafka", "stream" ]
70e2acef27a2f87355590be1a6ca60ce3ab4d09c
https://github.com/AlecAivazis/graphql-over-kafka/blob/70e2acef27a2f87355590be1a6ca60ce3ab4d09c/nautilus/network/events/consumers/kafka.py#L97-L111
train
AlecAivazis/graphql-over-kafka
nautilus/network/events/consumers/kafka.py
KafkaBroker.send
async def send(self, payload='', action_type='', channel=None, **kwds): """ This method sends a message over the kafka stream. """ # use a custom channel if one was provided channel = channel or self.producer_channel # serialize the action type for the messag...
python
async def send(self, payload='', action_type='', channel=None, **kwds): """ This method sends a message over the kafka stream. """ # use a custom channel if one was provided channel = channel or self.producer_channel # serialize the action type for the messag...
[ "async", "def", "send", "(", "self", ",", "payload", "=", "''", ",", "action_type", "=", "''", ",", "channel", "=", "None", ",", "*", "*", "kwds", ")", ":", "# use a custom channel if one was provided", "channel", "=", "channel", "or", "self", ".", "produc...
This method sends a message over the kafka stream.
[ "This", "method", "sends", "a", "message", "over", "the", "kafka", "stream", "." ]
70e2acef27a2f87355590be1a6ca60ce3ab4d09c
https://github.com/AlecAivazis/graphql-over-kafka/blob/70e2acef27a2f87355590be1a6ca60ce3ab4d09c/nautilus/network/events/consumers/kafka.py#L114-L124
train
AlecAivazis/graphql-over-kafka
nautilus/conventions/actions.py
serialize_action
def serialize_action(action_type, payload, **extra_fields): """ This function returns the conventional form of the actions. """ action_dict = dict( action_type=action_type, payload=payload, **extra_fields ) # return a serializable version return json.dumps(action...
python
def serialize_action(action_type, payload, **extra_fields): """ This function returns the conventional form of the actions. """ action_dict = dict( action_type=action_type, payload=payload, **extra_fields ) # return a serializable version return json.dumps(action...
[ "def", "serialize_action", "(", "action_type", ",", "payload", ",", "*", "*", "extra_fields", ")", ":", "action_dict", "=", "dict", "(", "action_type", "=", "action_type", ",", "payload", "=", "payload", ",", "*", "*", "extra_fields", ")", "# return a serializ...
This function returns the conventional form of the actions.
[ "This", "function", "returns", "the", "conventional", "form", "of", "the", "actions", "." ]
70e2acef27a2f87355590be1a6ca60ce3ab4d09c
https://github.com/AlecAivazis/graphql-over-kafka/blob/70e2acef27a2f87355590be1a6ca60ce3ab4d09c/nautilus/conventions/actions.py#L27-L37
train
AlecAivazis/graphql-over-kafka
nautilus/api/util/fields_for_model.py
fields_for_model
def fields_for_model(model): """ This function returns the fields for a schema that matches the provided nautilus model. Args: model (nautilus.model.BaseModel): The model to base the field list on Returns: (dict<field_name: str, graphqlType>): A mapping of f...
python
def fields_for_model(model): """ This function returns the fields for a schema that matches the provided nautilus model. Args: model (nautilus.model.BaseModel): The model to base the field list on Returns: (dict<field_name: str, graphqlType>): A mapping of f...
[ "def", "fields_for_model", "(", "model", ")", ":", "# the attribute arguments (no filters)", "args", "=", "{", "field", ".", "name", ".", "lower", "(", ")", ":", "convert_peewee_field", "(", "field", ")", "for", "field", "in", "model", ".", "fields", "(", ")...
This function returns the fields for a schema that matches the provided nautilus model. Args: model (nautilus.model.BaseModel): The model to base the field list on Returns: (dict<field_name: str, graphqlType>): A mapping of field names to graphql types
[ "This", "function", "returns", "the", "fields", "for", "a", "schema", "that", "matches", "the", "provided", "nautilus", "model", "." ]
70e2acef27a2f87355590be1a6ca60ce3ab4d09c
https://github.com/AlecAivazis/graphql-over-kafka/blob/70e2acef27a2f87355590be1a6ca60ce3ab4d09c/nautilus/api/util/fields_for_model.py#L4-L21
train
AlecAivazis/graphql-over-kafka
nautilus/models/util.py
create_connection_model
def create_connection_model(service): """ Create an SQL Alchemy table that connects the provides services """ # the services connected services = service._services # the mixins / base for the model bases = (BaseModel,) # the fields of the derived attributes = {model_service_name(service): f...
python
def create_connection_model(service): """ Create an SQL Alchemy table that connects the provides services """ # the services connected services = service._services # the mixins / base for the model bases = (BaseModel,) # the fields of the derived attributes = {model_service_name(service): f...
[ "def", "create_connection_model", "(", "service", ")", ":", "# the services connected", "services", "=", "service", ".", "_services", "# the mixins / base for the model", "bases", "=", "(", "BaseModel", ",", ")", "# the fields of the derived", "attributes", "=", "{", "m...
Create an SQL Alchemy table that connects the provides services
[ "Create", "an", "SQL", "Alchemy", "table", "that", "connects", "the", "provides", "services" ]
70e2acef27a2f87355590be1a6ca60ce3ab4d09c
https://github.com/AlecAivazis/graphql-over-kafka/blob/70e2acef27a2f87355590be1a6ca60ce3ab4d09c/nautilus/models/util.py#L5-L16
train
AlecAivazis/graphql-over-kafka
nautilus/network/events/actionHandlers/createHandler.py
create_handler
def create_handler(Model, name=None, **kwds): """ This factory returns an action handler that creates a new instance of the specified model when a create action is recieved, assuming the action follows nautilus convetions. Args: Model (nautilus.BaseModel): The model to c...
python
def create_handler(Model, name=None, **kwds): """ This factory returns an action handler that creates a new instance of the specified model when a create action is recieved, assuming the action follows nautilus convetions. Args: Model (nautilus.BaseModel): The model to c...
[ "def", "create_handler", "(", "Model", ",", "name", "=", "None", ",", "*", "*", "kwds", ")", ":", "async", "def", "action_handler", "(", "service", ",", "action_type", ",", "payload", ",", "props", ",", "notify", "=", "True", ",", "*", "*", "kwds", "...
This factory returns an action handler that creates a new instance of the specified model when a create action is recieved, assuming the action follows nautilus convetions. Args: Model (nautilus.BaseModel): The model to create when the action received. Retur...
[ "This", "factory", "returns", "an", "action", "handler", "that", "creates", "a", "new", "instance", "of", "the", "specified", "model", "when", "a", "create", "action", "is", "recieved", "assuming", "the", "action", "follows", "nautilus", "convetions", "." ]
70e2acef27a2f87355590be1a6ca60ce3ab4d09c
https://github.com/AlecAivazis/graphql-over-kafka/blob/70e2acef27a2f87355590be1a6ca60ce3ab4d09c/nautilus/network/events/actionHandlers/createHandler.py#L12-L83
train
AlecAivazis/graphql-over-kafka
nautilus/api/util/graph_entity.py
GraphEntity._has_id
async def _has_id(self, *args, **kwds): """ Equality checks are overwitten to perform the actual check in a semantic way. """ # if there is only one positional argument if len(args) == 1: # parse the appropriate query result = await parse_s...
python
async def _has_id(self, *args, **kwds): """ Equality checks are overwitten to perform the actual check in a semantic way. """ # if there is only one positional argument if len(args) == 1: # parse the appropriate query result = await parse_s...
[ "async", "def", "_has_id", "(", "self", ",", "*", "args", ",", "*", "*", "kwds", ")", ":", "# if there is only one positional argument", "if", "len", "(", "args", ")", "==", "1", ":", "# parse the appropriate query", "result", "=", "await", "parse_string", "("...
Equality checks are overwitten to perform the actual check in a semantic way.
[ "Equality", "checks", "are", "overwitten", "to", "perform", "the", "actual", "check", "in", "a", "semantic", "way", "." ]
70e2acef27a2f87355590be1a6ca60ce3ab4d09c
https://github.com/AlecAivazis/graphql-over-kafka/blob/70e2acef27a2f87355590be1a6ca60ce3ab4d09c/nautilus/api/util/graph_entity.py#L102-L122
train
AlecAivazis/graphql-over-kafka
nautilus/api/util/graph_entity.py
GraphEntity._find_id
def _find_id(self, result, uid): """ This method performs a depth-first search for the given uid in the dictionary of results. """ # if the result is a list if isinstance(result, list): # if the list has a valid entry if any([self._find_id(value, uid) ...
python
def _find_id(self, result, uid): """ This method performs a depth-first search for the given uid in the dictionary of results. """ # if the result is a list if isinstance(result, list): # if the list has a valid entry if any([self._find_id(value, uid) ...
[ "def", "_find_id", "(", "self", ",", "result", ",", "uid", ")", ":", "# if the result is a list", "if", "isinstance", "(", "result", ",", "list", ")", ":", "# if the list has a valid entry", "if", "any", "(", "[", "self", ".", "_find_id", "(", "value", ",", ...
This method performs a depth-first search for the given uid in the dictionary of results.
[ "This", "method", "performs", "a", "depth", "-", "first", "search", "for", "the", "given", "uid", "in", "the", "dictionary", "of", "results", "." ]
70e2acef27a2f87355590be1a6ca60ce3ab4d09c
https://github.com/AlecAivazis/graphql-over-kafka/blob/70e2acef27a2f87355590be1a6ca60ce3ab4d09c/nautilus/api/util/graph_entity.py#L126-L167
train
pyscaffold/configupdater
src/configupdater/configupdater.py
Block.add_before
def add_before(self): """Returns a builder inserting a new block before the current block""" idx = self._container.structure.index(self) return BlockBuilder(self._container, idx)
python
def add_before(self): """Returns a builder inserting a new block before the current block""" idx = self._container.structure.index(self) return BlockBuilder(self._container, idx)
[ "def", "add_before", "(", "self", ")", ":", "idx", "=", "self", ".", "_container", ".", "structure", ".", "index", "(", "self", ")", "return", "BlockBuilder", "(", "self", ".", "_container", ",", "idx", ")" ]
Returns a builder inserting a new block before the current block
[ "Returns", "a", "builder", "inserting", "a", "new", "block", "before", "the", "current", "block" ]
6ebac0b1fa7b8222baacdd4991d18cfc61659f84
https://github.com/pyscaffold/configupdater/blob/6ebac0b1fa7b8222baacdd4991d18cfc61659f84/src/configupdater/configupdater.py#L115-L118
train
pyscaffold/configupdater
src/configupdater/configupdater.py
Block.add_after
def add_after(self): """Returns a builder inserting a new block after the current block""" idx = self._container.structure.index(self) return BlockBuilder(self._container, idx+1)
python
def add_after(self): """Returns a builder inserting a new block after the current block""" idx = self._container.structure.index(self) return BlockBuilder(self._container, idx+1)
[ "def", "add_after", "(", "self", ")", ":", "idx", "=", "self", ".", "_container", ".", "structure", ".", "index", "(", "self", ")", "return", "BlockBuilder", "(", "self", ".", "_container", ",", "idx", "+", "1", ")" ]
Returns a builder inserting a new block after the current block
[ "Returns", "a", "builder", "inserting", "a", "new", "block", "after", "the", "current", "block" ]
6ebac0b1fa7b8222baacdd4991d18cfc61659f84
https://github.com/pyscaffold/configupdater/blob/6ebac0b1fa7b8222baacdd4991d18cfc61659f84/src/configupdater/configupdater.py#L121-L124
train
pyscaffold/configupdater
src/configupdater/configupdater.py
BlockBuilder.comment
def comment(self, text, comment_prefix='#'): """Creates a comment block Args: text (str): content of comment without # comment_prefix (str): character indicating start of comment Returns: self for chaining """ comment = Comment(self._containe...
python
def comment(self, text, comment_prefix='#'): """Creates a comment block Args: text (str): content of comment without # comment_prefix (str): character indicating start of comment Returns: self for chaining """ comment = Comment(self._containe...
[ "def", "comment", "(", "self", ",", "text", ",", "comment_prefix", "=", "'#'", ")", ":", "comment", "=", "Comment", "(", "self", ".", "_container", ")", "if", "not", "text", ".", "startswith", "(", "comment_prefix", ")", ":", "text", "=", "\"{} {}\"", ...
Creates a comment block Args: text (str): content of comment without # comment_prefix (str): character indicating start of comment Returns: self for chaining
[ "Creates", "a", "comment", "block" ]
6ebac0b1fa7b8222baacdd4991d18cfc61659f84
https://github.com/pyscaffold/configupdater/blob/6ebac0b1fa7b8222baacdd4991d18cfc61659f84/src/configupdater/configupdater.py#L133-L151
train
pyscaffold/configupdater
src/configupdater/configupdater.py
BlockBuilder.section
def section(self, section): """Creates a section block Args: section (str or :class:`Section`): name of section or object Returns: self for chaining """ if not isinstance(self._container, ConfigUpdater): raise ValueError("Sections can only be...
python
def section(self, section): """Creates a section block Args: section (str or :class:`Section`): name of section or object Returns: self for chaining """ if not isinstance(self._container, ConfigUpdater): raise ValueError("Sections can only be...
[ "def", "section", "(", "self", ",", "section", ")", ":", "if", "not", "isinstance", "(", "self", ".", "_container", ",", "ConfigUpdater", ")", ":", "raise", "ValueError", "(", "\"Sections can only be added at section level!\"", ")", "if", "isinstance", "(", "sec...
Creates a section block Args: section (str or :class:`Section`): name of section or object Returns: self for chaining
[ "Creates", "a", "section", "block" ]
6ebac0b1fa7b8222baacdd4991d18cfc61659f84
https://github.com/pyscaffold/configupdater/blob/6ebac0b1fa7b8222baacdd4991d18cfc61659f84/src/configupdater/configupdater.py#L153-L174
train
pyscaffold/configupdater
src/configupdater/configupdater.py
BlockBuilder.space
def space(self, newlines=1): """Creates a vertical space of newlines Args: newlines (int): number of empty lines Returns: self for chaining """ space = Space() for line in range(newlines): space.add_line('\n') self._container....
python
def space(self, newlines=1): """Creates a vertical space of newlines Args: newlines (int): number of empty lines Returns: self for chaining """ space = Space() for line in range(newlines): space.add_line('\n') self._container....
[ "def", "space", "(", "self", ",", "newlines", "=", "1", ")", ":", "space", "=", "Space", "(", ")", "for", "line", "in", "range", "(", "newlines", ")", ":", "space", ".", "add_line", "(", "'\\n'", ")", "self", ".", "_container", ".", "structure", "....
Creates a vertical space of newlines Args: newlines (int): number of empty lines Returns: self for chaining
[ "Creates", "a", "vertical", "space", "of", "newlines" ]
6ebac0b1fa7b8222baacdd4991d18cfc61659f84
https://github.com/pyscaffold/configupdater/blob/6ebac0b1fa7b8222baacdd4991d18cfc61659f84/src/configupdater/configupdater.py#L176-L190
train
pyscaffold/configupdater
src/configupdater/configupdater.py
BlockBuilder.option
def option(self, key, value=None, **kwargs): """Creates a new option inside a section Args: key (str): key of the option value (str or None): value of the option **kwargs: are passed to the constructor of :class:`Option` Returns: self for chainin...
python
def option(self, key, value=None, **kwargs): """Creates a new option inside a section Args: key (str): key of the option value (str or None): value of the option **kwargs: are passed to the constructor of :class:`Option` Returns: self for chainin...
[ "def", "option", "(", "self", ",", "key", ",", "value", "=", "None", ",", "*", "*", "kwargs", ")", ":", "if", "not", "isinstance", "(", "self", ".", "_container", ",", "Section", ")", ":", "raise", "ValueError", "(", "\"Options can only be added inside a s...
Creates a new option inside a section Args: key (str): key of the option value (str or None): value of the option **kwargs: are passed to the constructor of :class:`Option` Returns: self for chaining
[ "Creates", "a", "new", "option", "inside", "a", "section" ]
6ebac0b1fa7b8222baacdd4991d18cfc61659f84
https://github.com/pyscaffold/configupdater/blob/6ebac0b1fa7b8222baacdd4991d18cfc61659f84/src/configupdater/configupdater.py#L192-L209
train
pyscaffold/configupdater
src/configupdater/configupdater.py
Section.add_comment
def add_comment(self, line): """Add a Comment object to the section Used during initial parsing mainly Args: line (str): one line in the comment """ if not isinstance(self.last_item, Comment): comment = Comment(self._structure) self._structur...
python
def add_comment(self, line): """Add a Comment object to the section Used during initial parsing mainly Args: line (str): one line in the comment """ if not isinstance(self.last_item, Comment): comment = Comment(self._structure) self._structur...
[ "def", "add_comment", "(", "self", ",", "line", ")", ":", "if", "not", "isinstance", "(", "self", ".", "last_item", ",", "Comment", ")", ":", "comment", "=", "Comment", "(", "self", ".", "_structure", ")", "self", ".", "_structure", ".", "append", "(",...
Add a Comment object to the section Used during initial parsing mainly Args: line (str): one line in the comment
[ "Add", "a", "Comment", "object", "to", "the", "section" ]
6ebac0b1fa7b8222baacdd4991d18cfc61659f84
https://github.com/pyscaffold/configupdater/blob/6ebac0b1fa7b8222baacdd4991d18cfc61659f84/src/configupdater/configupdater.py#L254-L266
train
pyscaffold/configupdater
src/configupdater/configupdater.py
Section.add_space
def add_space(self, line): """Add a Space object to the section Used during initial parsing mainly Args: line (str): one line that defines the space, maybe whitespaces """ if not isinstance(self.last_item, Space): space = Space(self._structure) ...
python
def add_space(self, line): """Add a Space object to the section Used during initial parsing mainly Args: line (str): one line that defines the space, maybe whitespaces """ if not isinstance(self.last_item, Space): space = Space(self._structure) ...
[ "def", "add_space", "(", "self", ",", "line", ")", ":", "if", "not", "isinstance", "(", "self", ".", "last_item", ",", "Space", ")", ":", "space", "=", "Space", "(", "self", ".", "_structure", ")", "self", ".", "_structure", ".", "append", "(", "spac...
Add a Space object to the section Used during initial parsing mainly Args: line (str): one line that defines the space, maybe whitespaces
[ "Add", "a", "Space", "object", "to", "the", "section" ]
6ebac0b1fa7b8222baacdd4991d18cfc61659f84
https://github.com/pyscaffold/configupdater/blob/6ebac0b1fa7b8222baacdd4991d18cfc61659f84/src/configupdater/configupdater.py#L268-L280
train
pyscaffold/configupdater
src/configupdater/configupdater.py
Section.to_dict
def to_dict(self): """Transform to dictionary Returns: dict: dictionary with same content """ return {key: self.__getitem__(key).value for key in self.options()}
python
def to_dict(self): """Transform to dictionary Returns: dict: dictionary with same content """ return {key: self.__getitem__(key).value for key in self.options()}
[ "def", "to_dict", "(", "self", ")", ":", "return", "{", "key", ":", "self", ".", "__getitem__", "(", "key", ")", ".", "value", "for", "key", "in", "self", ".", "options", "(", ")", "}" ]
Transform to dictionary Returns: dict: dictionary with same content
[ "Transform", "to", "dictionary" ]
6ebac0b1fa7b8222baacdd4991d18cfc61659f84
https://github.com/pyscaffold/configupdater/blob/6ebac0b1fa7b8222baacdd4991d18cfc61659f84/src/configupdater/configupdater.py#L356-L362
train
pyscaffold/configupdater
src/configupdater/configupdater.py
Section.set
def set(self, option, value=None): """Set an option for chaining. Args: option (str): option name value (str): value, default None """ option = self._container.optionxform(option) if option in self.options(): self.__getitem__(option).value = v...
python
def set(self, option, value=None): """Set an option for chaining. Args: option (str): option name value (str): value, default None """ option = self._container.optionxform(option) if option in self.options(): self.__getitem__(option).value = v...
[ "def", "set", "(", "self", ",", "option", ",", "value", "=", "None", ")", ":", "option", "=", "self", ".", "_container", ".", "optionxform", "(", "option", ")", "if", "option", "in", "self", ".", "options", "(", ")", ":", "self", ".", "__getitem__", ...
Set an option for chaining. Args: option (str): option name value (str): value, default None
[ "Set", "an", "option", "for", "chaining", "." ]
6ebac0b1fa7b8222baacdd4991d18cfc61659f84
https://github.com/pyscaffold/configupdater/blob/6ebac0b1fa7b8222baacdd4991d18cfc61659f84/src/configupdater/configupdater.py#L379-L391
train
pyscaffold/configupdater
src/configupdater/configupdater.py
Option.set_values
def set_values(self, values, separator='\n', indent=4*' '): """Sets the value to a given list of options, e.g. multi-line values Args: values (list): list of values separator (str): separator for values, default: line separator indent (str): indentation depth in case...
python
def set_values(self, values, separator='\n', indent=4*' '): """Sets the value to a given list of options, e.g. multi-line values Args: values (list): list of values separator (str): separator for values, default: line separator indent (str): indentation depth in case...
[ "def", "set_values", "(", "self", ",", "values", ",", "separator", "=", "'\\n'", ",", "indent", "=", "4", "*", "' '", ")", ":", "self", ".", "_updated", "=", "True", "self", ".", "_multiline_value_joined", "=", "True", "self", ".", "_values", "=", "val...
Sets the value to a given list of options, e.g. multi-line values Args: values (list): list of values separator (str): separator for values, default: line separator indent (str): indentation depth in case of line separator
[ "Sets", "the", "value", "to", "a", "given", "list", "of", "options", "e", ".", "g", ".", "multi", "-", "line", "values" ]
6ebac0b1fa7b8222baacdd4991d18cfc61659f84
https://github.com/pyscaffold/configupdater/blob/6ebac0b1fa7b8222baacdd4991d18cfc61659f84/src/configupdater/configupdater.py#L478-L492
train
pyscaffold/configupdater
src/configupdater/configupdater.py
ConfigUpdater.read
def read(self, filename, encoding=None): """Read and parse a filename. Args: filename (str): path to file encoding (str): encoding of file, default None """ with open(filename, encoding=encoding) as fp: self._read(fp, filename) self._filename ...
python
def read(self, filename, encoding=None): """Read and parse a filename. Args: filename (str): path to file encoding (str): encoding of file, default None """ with open(filename, encoding=encoding) as fp: self._read(fp, filename) self._filename ...
[ "def", "read", "(", "self", ",", "filename", ",", "encoding", "=", "None", ")", ":", "with", "open", "(", "filename", ",", "encoding", "=", "encoding", ")", "as", "fp", ":", "self", ".", "_read", "(", "fp", ",", "filename", ")", "self", ".", "_file...
Read and parse a filename. Args: filename (str): path to file encoding (str): encoding of file, default None
[ "Read", "and", "parse", "a", "filename", "." ]
6ebac0b1fa7b8222baacdd4991d18cfc61659f84
https://github.com/pyscaffold/configupdater/blob/6ebac0b1fa7b8222baacdd4991d18cfc61659f84/src/configupdater/configupdater.py#L597-L606
train
pyscaffold/configupdater
src/configupdater/configupdater.py
ConfigUpdater.update_file
def update_file(self): """Update the read-in configuration file. """ if self._filename is None: raise NoConfigFileReadError() with open(self._filename, 'w') as fb: self.write(fb)
python
def update_file(self): """Update the read-in configuration file. """ if self._filename is None: raise NoConfigFileReadError() with open(self._filename, 'w') as fb: self.write(fb)
[ "def", "update_file", "(", "self", ")", ":", "if", "self", ".", "_filename", "is", "None", ":", "raise", "NoConfigFileReadError", "(", ")", "with", "open", "(", "self", ".", "_filename", ",", "'w'", ")", "as", "fb", ":", "self", ".", "write", "(", "f...
Update the read-in configuration file.
[ "Update", "the", "read", "-", "in", "configuration", "file", "." ]
6ebac0b1fa7b8222baacdd4991d18cfc61659f84
https://github.com/pyscaffold/configupdater/blob/6ebac0b1fa7b8222baacdd4991d18cfc61659f84/src/configupdater/configupdater.py#L825-L831
train
pyscaffold/configupdater
src/configupdater/configupdater.py
ConfigUpdater.validate_format
def validate_format(self, **kwargs): """Call ConfigParser to validate config Args: kwargs: are passed to :class:`configparser.ConfigParser` """ args = dict( dict_type=self._dict, allow_no_value=self._allow_no_value, inline_comment_prefixes...
python
def validate_format(self, **kwargs): """Call ConfigParser to validate config Args: kwargs: are passed to :class:`configparser.ConfigParser` """ args = dict( dict_type=self._dict, allow_no_value=self._allow_no_value, inline_comment_prefixes...
[ "def", "validate_format", "(", "self", ",", "*", "*", "kwargs", ")", ":", "args", "=", "dict", "(", "dict_type", "=", "self", ".", "_dict", ",", "allow_no_value", "=", "self", ".", "_allow_no_value", ",", "inline_comment_prefixes", "=", "self", ".", "_inli...
Call ConfigParser to validate config Args: kwargs: are passed to :class:`configparser.ConfigParser`
[ "Call", "ConfigParser", "to", "validate", "config" ]
6ebac0b1fa7b8222baacdd4991d18cfc61659f84
https://github.com/pyscaffold/configupdater/blob/6ebac0b1fa7b8222baacdd4991d18cfc61659f84/src/configupdater/configupdater.py#L833-L849
train
pyscaffold/configupdater
src/configupdater/configupdater.py
ConfigUpdater.add_section
def add_section(self, section): """Create a new section in the configuration. Raise DuplicateSectionError if a section by the specified name already exists. Raise ValueError if name is DEFAULT. Args: section (str or :class:`Section`): name or Section type """ ...
python
def add_section(self, section): """Create a new section in the configuration. Raise DuplicateSectionError if a section by the specified name already exists. Raise ValueError if name is DEFAULT. Args: section (str or :class:`Section`): name or Section type """ ...
[ "def", "add_section", "(", "self", ",", "section", ")", ":", "if", "section", "in", "self", ".", "sections", "(", ")", ":", "raise", "DuplicateSectionError", "(", "section", ")", "if", "isinstance", "(", "section", ",", "str", ")", ":", "# create a new sec...
Create a new section in the configuration. Raise DuplicateSectionError if a section by the specified name already exists. Raise ValueError if name is DEFAULT. Args: section (str or :class:`Section`): name or Section type
[ "Create", "a", "new", "section", "in", "the", "configuration", "." ]
6ebac0b1fa7b8222baacdd4991d18cfc61659f84
https://github.com/pyscaffold/configupdater/blob/6ebac0b1fa7b8222baacdd4991d18cfc61659f84/src/configupdater/configupdater.py#L912-L928
train
pyscaffold/configupdater
src/configupdater/configupdater.py
ConfigUpdater.options
def options(self, section): """Returns list of configuration options for the named section. Args: section (str): name of section Returns: list: list of option names """ if not self.has_section(section): raise NoSectionError(section) from None...
python
def options(self, section): """Returns list of configuration options for the named section. Args: section (str): name of section Returns: list: list of option names """ if not self.has_section(section): raise NoSectionError(section) from None...
[ "def", "options", "(", "self", ",", "section", ")", ":", "if", "not", "self", ".", "has_section", "(", "section", ")", ":", "raise", "NoSectionError", "(", "section", ")", "from", "None", "return", "self", ".", "__getitem__", "(", "section", ")", ".", ...
Returns list of configuration options for the named section. Args: section (str): name of section Returns: list: list of option names
[ "Returns", "list", "of", "configuration", "options", "for", "the", "named", "section", "." ]
6ebac0b1fa7b8222baacdd4991d18cfc61659f84
https://github.com/pyscaffold/configupdater/blob/6ebac0b1fa7b8222baacdd4991d18cfc61659f84/src/configupdater/configupdater.py#L941-L952
train
pyscaffold/configupdater
src/configupdater/configupdater.py
ConfigUpdater.get
def get(self, section, option): """Gets an option value for a given section. Args: section (str): section name option (str): option name Returns: :class:`Option`: Option object holding key/value pair """ if not self.has_section(section): ...
python
def get(self, section, option): """Gets an option value for a given section. Args: section (str): section name option (str): option name Returns: :class:`Option`: Option object holding key/value pair """ if not self.has_section(section): ...
[ "def", "get", "(", "self", ",", "section", ",", "option", ")", ":", "if", "not", "self", ".", "has_section", "(", "section", ")", ":", "raise", "NoSectionError", "(", "section", ")", "from", "None", "section", "=", "self", ".", "__getitem__", "(", "sec...
Gets an option value for a given section. Args: section (str): section name option (str): option name Returns: :class:`Option`: Option object holding key/value pair
[ "Gets", "an", "option", "value", "for", "a", "given", "section", "." ]
6ebac0b1fa7b8222baacdd4991d18cfc61659f84
https://github.com/pyscaffold/configupdater/blob/6ebac0b1fa7b8222baacdd4991d18cfc61659f84/src/configupdater/configupdater.py#L954-L974
train
pyscaffold/configupdater
src/configupdater/configupdater.py
ConfigUpdater.items
def items(self, section=_UNSET): """Return a list of (name, value) tuples for options or sections. If section is given, return a list of tuples with (name, value) for each option in the section. Otherwise, return a list of tuples with (section_name, section_type) for each section. ...
python
def items(self, section=_UNSET): """Return a list of (name, value) tuples for options or sections. If section is given, return a list of tuples with (name, value) for each option in the section. Otherwise, return a list of tuples with (section_name, section_type) for each section. ...
[ "def", "items", "(", "self", ",", "section", "=", "_UNSET", ")", ":", "if", "section", "is", "_UNSET", ":", "return", "[", "(", "sect", ".", "name", ",", "sect", ")", "for", "sect", "in", "self", ".", "sections_blocks", "(", ")", "]", "section", "=...
Return a list of (name, value) tuples for options or sections. If section is given, return a list of tuples with (name, value) for each option in the section. Otherwise, return a list of tuples with (section_name, section_type) for each section. Args: section (str): optiona...
[ "Return", "a", "list", "of", "(", "name", "value", ")", "tuples", "for", "options", "or", "sections", "." ]
6ebac0b1fa7b8222baacdd4991d18cfc61659f84
https://github.com/pyscaffold/configupdater/blob/6ebac0b1fa7b8222baacdd4991d18cfc61659f84/src/configupdater/configupdater.py#L976-L993
train
pyscaffold/configupdater
src/configupdater/configupdater.py
ConfigUpdater.has_option
def has_option(self, section, option): """Checks for the existence of a given option in a given section. Args: section (str): name of section option (str): name of option Returns: bool: whether the option exists in the given section """ if se...
python
def has_option(self, section, option): """Checks for the existence of a given option in a given section. Args: section (str): name of section option (str): name of option Returns: bool: whether the option exists in the given section """ if se...
[ "def", "has_option", "(", "self", ",", "section", ",", "option", ")", ":", "if", "section", "not", "in", "self", ".", "sections", "(", ")", ":", "return", "False", "else", ":", "option", "=", "self", ".", "optionxform", "(", "option", ")", "return", ...
Checks for the existence of a given option in a given section. Args: section (str): name of section option (str): name of option Returns: bool: whether the option exists in the given section
[ "Checks", "for", "the", "existence", "of", "a", "given", "option", "in", "a", "given", "section", "." ]
6ebac0b1fa7b8222baacdd4991d18cfc61659f84
https://github.com/pyscaffold/configupdater/blob/6ebac0b1fa7b8222baacdd4991d18cfc61659f84/src/configupdater/configupdater.py#L995-L1009
train
pyscaffold/configupdater
src/configupdater/configupdater.py
ConfigUpdater.set
def set(self, section, option, value=None): """Set an option. Args: section (str): section name option (str): option name value (str): value, default None """ try: section = self.__getitem__(section) except KeyError: ra...
python
def set(self, section, option, value=None): """Set an option. Args: section (str): section name option (str): option name value (str): value, default None """ try: section = self.__getitem__(section) except KeyError: ra...
[ "def", "set", "(", "self", ",", "section", ",", "option", ",", "value", "=", "None", ")", ":", "try", ":", "section", "=", "self", ".", "__getitem__", "(", "section", ")", "except", "KeyError", ":", "raise", "NoSectionError", "(", "section", ")", "from...
Set an option. Args: section (str): section name option (str): option name value (str): value, default None
[ "Set", "an", "option", "." ]
6ebac0b1fa7b8222baacdd4991d18cfc61659f84
https://github.com/pyscaffold/configupdater/blob/6ebac0b1fa7b8222baacdd4991d18cfc61659f84/src/configupdater/configupdater.py#L1011-L1028
train
pyscaffold/configupdater
src/configupdater/configupdater.py
ConfigUpdater.remove_option
def remove_option(self, section, option): """Remove an option. Args: section (str): section name option (str): option name Returns: bool: whether the option was actually removed """ try: section = self.__getitem__(section) ...
python
def remove_option(self, section, option): """Remove an option. Args: section (str): section name option (str): option name Returns: bool: whether the option was actually removed """ try: section = self.__getitem__(section) ...
[ "def", "remove_option", "(", "self", ",", "section", ",", "option", ")", ":", "try", ":", "section", "=", "self", ".", "__getitem__", "(", "section", ")", "except", "KeyError", ":", "raise", "NoSectionError", "(", "section", ")", "from", "None", "option", ...
Remove an option. Args: section (str): section name option (str): option name Returns: bool: whether the option was actually removed
[ "Remove", "an", "option", "." ]
6ebac0b1fa7b8222baacdd4991d18cfc61659f84
https://github.com/pyscaffold/configupdater/blob/6ebac0b1fa7b8222baacdd4991d18cfc61659f84/src/configupdater/configupdater.py#L1030-L1048
train
pyscaffold/configupdater
src/configupdater/configupdater.py
ConfigUpdater.remove_section
def remove_section(self, name): """Remove a file section. Args: name: name of the section Returns: bool: whether the section was actually removed """ existed = self.has_section(name) if existed: idx = self._get_section_idx(name) ...
python
def remove_section(self, name): """Remove a file section. Args: name: name of the section Returns: bool: whether the section was actually removed """ existed = self.has_section(name) if existed: idx = self._get_section_idx(name) ...
[ "def", "remove_section", "(", "self", ",", "name", ")", ":", "existed", "=", "self", ".", "has_section", "(", "name", ")", "if", "existed", ":", "idx", "=", "self", ".", "_get_section_idx", "(", "name", ")", "del", "self", ".", "_structure", "[", "idx"...
Remove a file section. Args: name: name of the section Returns: bool: whether the section was actually removed
[ "Remove", "a", "file", "section", "." ]
6ebac0b1fa7b8222baacdd4991d18cfc61659f84
https://github.com/pyscaffold/configupdater/blob/6ebac0b1fa7b8222baacdd4991d18cfc61659f84/src/configupdater/configupdater.py#L1050-L1063
train
pyscaffold/configupdater
src/configupdater/configupdater.py
ConfigUpdater.to_dict
def to_dict(self): """Transform to dictionary Returns: dict: dictionary with same content """ return {sect: self.__getitem__(sect).to_dict() for sect in self.sections()}
python
def to_dict(self): """Transform to dictionary Returns: dict: dictionary with same content """ return {sect: self.__getitem__(sect).to_dict() for sect in self.sections()}
[ "def", "to_dict", "(", "self", ")", ":", "return", "{", "sect", ":", "self", ".", "__getitem__", "(", "sect", ")", ".", "to_dict", "(", ")", "for", "sect", "in", "self", ".", "sections", "(", ")", "}" ]
Transform to dictionary Returns: dict: dictionary with same content
[ "Transform", "to", "dictionary" ]
6ebac0b1fa7b8222baacdd4991d18cfc61659f84
https://github.com/pyscaffold/configupdater/blob/6ebac0b1fa7b8222baacdd4991d18cfc61659f84/src/configupdater/configupdater.py#L1065-L1072
train
AlecAivazis/graphql-over-kafka
nautilus/management/util/render_template.py
render_template
def render_template(template, out_dir='.', context=None): ''' This function renders the template desginated by the argument to the designated directory using the given context. Args: template (string) : the source template to use (relative to ./templates) out_dir (st...
python
def render_template(template, out_dir='.', context=None): ''' This function renders the template desginated by the argument to the designated directory using the given context. Args: template (string) : the source template to use (relative to ./templates) out_dir (st...
[ "def", "render_template", "(", "template", ",", "out_dir", "=", "'.'", ",", "context", "=", "None", ")", ":", "# the directory containing templates", "template_directory", "=", "os", ".", "path", ".", "join", "(", "os", ".", "path", ".", "dirname", "(", "os"...
This function renders the template desginated by the argument to the designated directory using the given context. Args: template (string) : the source template to use (relative to ./templates) out_dir (string) : the name of the output directory context (dict) : the ...
[ "This", "function", "renders", "the", "template", "desginated", "by", "the", "argument", "to", "the", "designated", "directory", "using", "the", "given", "context", "." ]
70e2acef27a2f87355590be1a6ca60ce3ab4d09c
https://github.com/AlecAivazis/graphql-over-kafka/blob/70e2acef27a2f87355590be1a6ca60ce3ab4d09c/nautilus/management/util/render_template.py#L6-L86
train
AlecAivazis/graphql-over-kafka
nautilus/management/scripts/events/publish.py
publish
def publish(type, payload): """ Publish a message with the specified action_type and payload over the event system. Useful for debugging. """ async def _produce(): # fire an action with the given values await producer.send(action_type=type, payload=payload) # notify t...
python
def publish(type, payload): """ Publish a message with the specified action_type and payload over the event system. Useful for debugging. """ async def _produce(): # fire an action with the given values await producer.send(action_type=type, payload=payload) # notify t...
[ "def", "publish", "(", "type", ",", "payload", ")", ":", "async", "def", "_produce", "(", ")", ":", "# fire an action with the given values", "await", "producer", ".", "send", "(", "action_type", "=", "type", ",", "payload", "=", "payload", ")", "# notify the ...
Publish a message with the specified action_type and payload over the event system. Useful for debugging.
[ "Publish", "a", "message", "with", "the", "specified", "action_type", "and", "payload", "over", "the", "event", "system", ".", "Useful", "for", "debugging", "." ]
70e2acef27a2f87355590be1a6ca60ce3ab4d09c
https://github.com/AlecAivazis/graphql-over-kafka/blob/70e2acef27a2f87355590be1a6ca60ce3ab4d09c/nautilus/management/scripts/events/publish.py#L15-L38
train
AlecAivazis/graphql-over-kafka
nautilus/network/events/actionHandlers/deleteHandler.py
delete_handler
def delete_handler(Model, name=None, **kwds): """ This factory returns an action handler that deletes a new instance of the specified model when a delete action is recieved, assuming the action follows nautilus convetions. Args: Model (nautilus.BaseModel): The model to d...
python
def delete_handler(Model, name=None, **kwds): """ This factory returns an action handler that deletes a new instance of the specified model when a delete action is recieved, assuming the action follows nautilus convetions. Args: Model (nautilus.BaseModel): The model to d...
[ "def", "delete_handler", "(", "Model", ",", "name", "=", "None", ",", "*", "*", "kwds", ")", ":", "# necessary imports", "from", "nautilus", ".", "database", "import", "db", "async", "def", "action_handler", "(", "service", ",", "action_type", ",", "payload"...
This factory returns an action handler that deletes a new instance of the specified model when a delete action is recieved, assuming the action follows nautilus convetions. Args: Model (nautilus.BaseModel): The model to delete when the action received. Retur...
[ "This", "factory", "returns", "an", "action", "handler", "that", "deletes", "a", "new", "instance", "of", "the", "specified", "model", "when", "a", "delete", "action", "is", "recieved", "assuming", "the", "action", "follows", "nautilus", "convetions", "." ]
70e2acef27a2f87355590be1a6ca60ce3ab4d09c
https://github.com/AlecAivazis/graphql-over-kafka/blob/70e2acef27a2f87355590be1a6ca60ce3ab4d09c/nautilus/network/events/actionHandlers/deleteHandler.py#L10-L71
train
AlecAivazis/graphql-over-kafka
nautilus/network/events/actionHandlers/readHandler.py
read_handler
def read_handler(Model, name=None, **kwds): """ This factory returns an action handler that responds to read requests by resolving the payload as a graphql query against the internal schema. Args: Model (nautilus.BaseModel): The model to delete when the action r...
python
def read_handler(Model, name=None, **kwds): """ This factory returns an action handler that responds to read requests by resolving the payload as a graphql query against the internal schema. Args: Model (nautilus.BaseModel): The model to delete when the action r...
[ "def", "read_handler", "(", "Model", ",", "name", "=", "None", ",", "*", "*", "kwds", ")", ":", "async", "def", "action_handler", "(", "service", ",", "action_type", ",", "payload", ",", "props", ",", "*", "*", "kwds", ")", ":", "# if the payload represe...
This factory returns an action handler that responds to read requests by resolving the payload as a graphql query against the internal schema. Args: Model (nautilus.BaseModel): The model to delete when the action received. Returns: function(type, payloa...
[ "This", "factory", "returns", "an", "action", "handler", "that", "responds", "to", "read", "requests", "by", "resolving", "the", "payload", "as", "a", "graphql", "query", "against", "the", "internal", "schema", "." ]
70e2acef27a2f87355590be1a6ca60ce3ab4d09c
https://github.com/AlecAivazis/graphql-over-kafka/blob/70e2acef27a2f87355590be1a6ca60ce3ab4d09c/nautilus/network/events/actionHandlers/readHandler.py#L6-L56
train
AlecAivazis/graphql-over-kafka
nautilus/network/events/actionHandlers/crudHandler.py
crud_handler
def crud_handler(Model, name=None, **kwds): """ This action handler factory reaturns an action handler that responds to actions with CRUD types (following nautilus conventions) and performs the necessary mutation on the model's database. Args: Model (nautilus.BaseModel):...
python
def crud_handler(Model, name=None, **kwds): """ This action handler factory reaturns an action handler that responds to actions with CRUD types (following nautilus conventions) and performs the necessary mutation on the model's database. Args: Model (nautilus.BaseModel):...
[ "def", "crud_handler", "(", "Model", ",", "name", "=", "None", ",", "*", "*", "kwds", ")", ":", "# import the necessary modules", "from", "nautilus", ".", "network", ".", "events", "import", "combine_action_handlers", "from", ".", "import", "update_handler", ","...
This action handler factory reaturns an action handler that responds to actions with CRUD types (following nautilus conventions) and performs the necessary mutation on the model's database. Args: Model (nautilus.BaseModel): The model to delete when the action receive...
[ "This", "action", "handler", "factory", "reaturns", "an", "action", "handler", "that", "responds", "to", "actions", "with", "CRUD", "types", "(", "following", "nautilus", "conventions", ")", "and", "performs", "the", "necessary", "mutation", "on", "the", "model"...
70e2acef27a2f87355590be1a6ca60ce3ab4d09c
https://github.com/AlecAivazis/graphql-over-kafka/blob/70e2acef27a2f87355590be1a6ca60ce3ab4d09c/nautilus/network/events/actionHandlers/crudHandler.py#L1-L25
train
AlecAivazis/graphql-over-kafka
nautilus/management/scripts/events/ask.py
ask
def ask(type, payload): """ Publish a message with the specified action_type and payload over the event system. Useful for debugging. """ async def _produce(): # notify the user that we were successful print("Dispatching action with type {}...".format(type)) # fire an...
python
def ask(type, payload): """ Publish a message with the specified action_type and payload over the event system. Useful for debugging. """ async def _produce(): # notify the user that we were successful print("Dispatching action with type {}...".format(type)) # fire an...
[ "def", "ask", "(", "type", ",", "payload", ")", ":", "async", "def", "_produce", "(", ")", ":", "# notify the user that we were successful", "print", "(", "\"Dispatching action with type {}...\"", ".", "format", "(", "type", ")", ")", "# fire an action with the given ...
Publish a message with the specified action_type and payload over the event system. Useful for debugging.
[ "Publish", "a", "message", "with", "the", "specified", "action_type", "and", "payload", "over", "the", "event", "system", ".", "Useful", "for", "debugging", "." ]
70e2acef27a2f87355590be1a6ca60ce3ab4d09c
https://github.com/AlecAivazis/graphql-over-kafka/blob/70e2acef27a2f87355590be1a6ca60ce3ab4d09c/nautilus/management/scripts/events/ask.py#L15-L40
train
AlecAivazis/graphql-over-kafka
nautilus/config/config.py
Config._from_type
def _from_type(self, config): """ This method converts a type into a dict. """ def is_user_attribute(attr): return ( not attr.startswith('__') and not isinstance(getattr(config, attr), collections.abc.Callable) ) return...
python
def _from_type(self, config): """ This method converts a type into a dict. """ def is_user_attribute(attr): return ( not attr.startswith('__') and not isinstance(getattr(config, attr), collections.abc.Callable) ) return...
[ "def", "_from_type", "(", "self", ",", "config", ")", ":", "def", "is_user_attribute", "(", "attr", ")", ":", "return", "(", "not", "attr", ".", "startswith", "(", "'__'", ")", "and", "not", "isinstance", "(", "getattr", "(", "config", ",", "attr", ")"...
This method converts a type into a dict.
[ "This", "method", "converts", "a", "type", "into", "a", "dict", "." ]
70e2acef27a2f87355590be1a6ca60ce3ab4d09c
https://github.com/AlecAivazis/graphql-over-kafka/blob/70e2acef27a2f87355590be1a6ca60ce3ab4d09c/nautilus/config/config.py#L41-L52
train
AlecAivazis/graphql-over-kafka
nautilus/api/util/walk_query.py
walk_query
async def walk_query(obj, object_resolver, connection_resolver, errors, current_user=None, __naut_name=None, obey_auth=True, **filters): """ This function traverses a query and collects the corresponding information in a dictionary. """ # if the object has no selection set if not hasattr...
python
async def walk_query(obj, object_resolver, connection_resolver, errors, current_user=None, __naut_name=None, obey_auth=True, **filters): """ This function traverses a query and collects the corresponding information in a dictionary. """ # if the object has no selection set if not hasattr...
[ "async", "def", "walk_query", "(", "obj", ",", "object_resolver", ",", "connection_resolver", ",", "errors", ",", "current_user", "=", "None", ",", "__naut_name", "=", "None", ",", "obey_auth", "=", "True", ",", "*", "*", "filters", ")", ":", "# if the objec...
This function traverses a query and collects the corresponding information in a dictionary.
[ "This", "function", "traverses", "a", "query", "and", "collects", "the", "corresponding", "information", "in", "a", "dictionary", "." ]
70e2acef27a2f87355590be1a6ca60ce3ab4d09c
https://github.com/AlecAivazis/graphql-over-kafka/blob/70e2acef27a2f87355590be1a6ca60ce3ab4d09c/nautilus/api/util/walk_query.py#L1-L102
train
AlecAivazis/graphql-over-kafka
nautilus/network/events/actionHandlers/queryHandler.py
query_handler
async def query_handler(service, action_type, payload, props, **kwds): """ This action handler interprets the payload as a query to be executed by the api gateway service. """ # check that the action type indicates a query if action_type == query_action_type(): print('encountered...
python
async def query_handler(service, action_type, payload, props, **kwds): """ This action handler interprets the payload as a query to be executed by the api gateway service. """ # check that the action type indicates a query if action_type == query_action_type(): print('encountered...
[ "async", "def", "query_handler", "(", "service", ",", "action_type", ",", "payload", ",", "props", ",", "*", "*", "kwds", ")", ":", "# check that the action type indicates a query", "if", "action_type", "==", "query_action_type", "(", ")", ":", "print", "(", "'e...
This action handler interprets the payload as a query to be executed by the api gateway service.
[ "This", "action", "handler", "interprets", "the", "payload", "as", "a", "query", "to", "be", "executed", "by", "the", "api", "gateway", "service", "." ]
70e2acef27a2f87355590be1a6ca60ce3ab4d09c
https://github.com/AlecAivazis/graphql-over-kafka/blob/70e2acef27a2f87355590be1a6ca60ce3ab4d09c/nautilus/network/events/actionHandlers/queryHandler.py#L5-L29
train
AlecAivazis/graphql-over-kafka
nautilus/api/util/summarize_mutation_io.py
summarize_mutation_io
def summarize_mutation_io(name, type, required=False): """ This function returns the standard summary for mutations inputs and outputs """ return dict( name=name, type=type, required=required )
python
def summarize_mutation_io(name, type, required=False): """ This function returns the standard summary for mutations inputs and outputs """ return dict( name=name, type=type, required=required )
[ "def", "summarize_mutation_io", "(", "name", ",", "type", ",", "required", "=", "False", ")", ":", "return", "dict", "(", "name", "=", "name", ",", "type", "=", "type", ",", "required", "=", "required", ")" ]
This function returns the standard summary for mutations inputs and outputs
[ "This", "function", "returns", "the", "standard", "summary", "for", "mutations", "inputs", "and", "outputs" ]
70e2acef27a2f87355590be1a6ca60ce3ab4d09c
https://github.com/AlecAivazis/graphql-over-kafka/blob/70e2acef27a2f87355590be1a6ca60ce3ab4d09c/nautilus/api/util/summarize_mutation_io.py#L1-L10
train
AlecAivazis/graphql-over-kafka
nautilus/conventions/api.py
crud_mutation_name
def crud_mutation_name(action, model): """ This function returns the name of a mutation that performs the specified crud action on the given model service """ model_string = get_model_string(model) # make sure the mutation name is correctly camelcases model_string = model_string[0].u...
python
def crud_mutation_name(action, model): """ This function returns the name of a mutation that performs the specified crud action on the given model service """ model_string = get_model_string(model) # make sure the mutation name is correctly camelcases model_string = model_string[0].u...
[ "def", "crud_mutation_name", "(", "action", ",", "model", ")", ":", "model_string", "=", "get_model_string", "(", "model", ")", "# make sure the mutation name is correctly camelcases", "model_string", "=", "model_string", "[", "0", "]", ".", "upper", "(", ")", "+", ...
This function returns the name of a mutation that performs the specified crud action on the given model service
[ "This", "function", "returns", "the", "name", "of", "a", "mutation", "that", "performs", "the", "specified", "crud", "action", "on", "the", "given", "model", "service" ]
70e2acef27a2f87355590be1a6ca60ce3ab4d09c
https://github.com/AlecAivazis/graphql-over-kafka/blob/70e2acef27a2f87355590be1a6ca60ce3ab4d09c/nautilus/conventions/api.py#L15-L25
train
AlecAivazis/graphql-over-kafka
nautilus/conventions/api.py
create_mutation_inputs
def create_mutation_inputs(service): """ Args: service : The service being created by the mutation Returns: (list) : a list of all of the fields availible for the service, with the required ones respected. """ # grab the default list of field summaries...
python
def create_mutation_inputs(service): """ Args: service : The service being created by the mutation Returns: (list) : a list of all of the fields availible for the service, with the required ones respected. """ # grab the default list of field summaries...
[ "def", "create_mutation_inputs", "(", "service", ")", ":", "# grab the default list of field summaries", "inputs", "=", "_service_mutation_summaries", "(", "service", ")", "# make sure the pk isn't in the list", "inputs", ".", "remove", "(", "[", "field", "for", "field", ...
Args: service : The service being created by the mutation Returns: (list) : a list of all of the fields availible for the service, with the required ones respected.
[ "Args", ":", "service", ":", "The", "service", "being", "created", "by", "the", "mutation", "Returns", ":", "(", "list", ")", ":", "a", "list", "of", "all", "of", "the", "fields", "availible", "for", "the", "service", "with", "the", "required", "ones", ...
70e2acef27a2f87355590be1a6ca60ce3ab4d09c
https://github.com/AlecAivazis/graphql-over-kafka/blob/70e2acef27a2f87355590be1a6ca60ce3ab4d09c/nautilus/conventions/api.py#L28-L42
train
AlecAivazis/graphql-over-kafka
nautilus/conventions/api.py
update_mutation_inputs
def update_mutation_inputs(service): """ Args: service : The service being updated by the mutation Returns: (list) : a list of all of the fields availible for the service. Pk is a required field in order to filter the results """ # grab the default lis...
python
def update_mutation_inputs(service): """ Args: service : The service being updated by the mutation Returns: (list) : a list of all of the fields availible for the service. Pk is a required field in order to filter the results """ # grab the default lis...
[ "def", "update_mutation_inputs", "(", "service", ")", ":", "# grab the default list of field summaries", "inputs", "=", "_service_mutation_summaries", "(", "service", ")", "# visit each field", "for", "field", "in", "inputs", ":", "# if we're looking at the id field", "if", ...
Args: service : The service being updated by the mutation Returns: (list) : a list of all of the fields availible for the service. Pk is a required field in order to filter the results
[ "Args", ":", "service", ":", "The", "service", "being", "updated", "by", "the", "mutation", "Returns", ":", "(", "list", ")", ":", "a", "list", "of", "all", "of", "the", "fields", "availible", "for", "the", "service", ".", "Pk", "is", "a", "required", ...
70e2acef27a2f87355590be1a6ca60ce3ab4d09c
https://github.com/AlecAivazis/graphql-over-kafka/blob/70e2acef27a2f87355590be1a6ca60ce3ab4d09c/nautilus/conventions/api.py#L57-L80
train
AlecAivazis/graphql-over-kafka
nautilus/conventions/api.py
delete_mutation_inputs
def delete_mutation_inputs(service): """ Args: service : The service being deleted by the mutation Returns: ([str]): the only input for delete is the pk of the service. """ from nautilus.api.util import summarize_mutation_io # the only input for delete events is...
python
def delete_mutation_inputs(service): """ Args: service : The service being deleted by the mutation Returns: ([str]): the only input for delete is the pk of the service. """ from nautilus.api.util import summarize_mutation_io # the only input for delete events is...
[ "def", "delete_mutation_inputs", "(", "service", ")", ":", "from", "nautilus", ".", "api", ".", "util", "import", "summarize_mutation_io", "# the only input for delete events is the pk of the service record", "return", "[", "summarize_mutation_io", "(", "name", "=", "'pk'",...
Args: service : The service being deleted by the mutation Returns: ([str]): the only input for delete is the pk of the service.
[ "Args", ":", "service", ":", "The", "service", "being", "deleted", "by", "the", "mutation", "Returns", ":", "(", "[", "str", "]", ")", ":", "the", "only", "input", "for", "delete", "is", "the", "pk", "of", "the", "service", "." ]
70e2acef27a2f87355590be1a6ca60ce3ab4d09c
https://github.com/AlecAivazis/graphql-over-kafka/blob/70e2acef27a2f87355590be1a6ca60ce3ab4d09c/nautilus/conventions/api.py#L96-L106
train
AlecAivazis/graphql-over-kafka
nautilus/conventions/api.py
_summarize_o_mutation_type
def _summarize_o_mutation_type(model): """ This function create the actual mutation io summary corresponding to the model """ from nautilus.api.util import summarize_mutation_io # compute the appropriate name for the object object_type_name = get_model_string(model) # return a mutation ...
python
def _summarize_o_mutation_type(model): """ This function create the actual mutation io summary corresponding to the model """ from nautilus.api.util import summarize_mutation_io # compute the appropriate name for the object object_type_name = get_model_string(model) # return a mutation ...
[ "def", "_summarize_o_mutation_type", "(", "model", ")", ":", "from", "nautilus", ".", "api", ".", "util", "import", "summarize_mutation_io", "# compute the appropriate name for the object", "object_type_name", "=", "get_model_string", "(", "model", ")", "# return a mutation...
This function create the actual mutation io summary corresponding to the model
[ "This", "function", "create", "the", "actual", "mutation", "io", "summary", "corresponding", "to", "the", "model" ]
70e2acef27a2f87355590be1a6ca60ce3ab4d09c
https://github.com/AlecAivazis/graphql-over-kafka/blob/70e2acef27a2f87355590be1a6ca60ce3ab4d09c/nautilus/conventions/api.py#L134-L147
train
AlecAivazis/graphql-over-kafka
nautilus/conventions/api.py
_summarize_object_type
def _summarize_object_type(model): """ This function returns the summary for a given model """ # the fields for the service's model model_fields = {field.name: field for field in list(model.fields())} # summarize the model return { 'fields': [{ 'name': key, ...
python
def _summarize_object_type(model): """ This function returns the summary for a given model """ # the fields for the service's model model_fields = {field.name: field for field in list(model.fields())} # summarize the model return { 'fields': [{ 'name': key, ...
[ "def", "_summarize_object_type", "(", "model", ")", ":", "# the fields for the service's model", "model_fields", "=", "{", "field", ".", "name", ":", "field", "for", "field", "in", "list", "(", "model", ".", "fields", "(", ")", ")", "}", "# summarize the model",...
This function returns the summary for a given model
[ "This", "function", "returns", "the", "summary", "for", "a", "given", "model" ]
70e2acef27a2f87355590be1a6ca60ce3ab4d09c
https://github.com/AlecAivazis/graphql-over-kafka/blob/70e2acef27a2f87355590be1a6ca60ce3ab4d09c/nautilus/conventions/api.py#L149-L162
train
AlecAivazis/graphql-over-kafka
nautilus/network/events/util.py
combine_action_handlers
def combine_action_handlers(*handlers): """ This function combines the given action handlers into a single function which will call all of them. """ # make sure each of the given handlers is callable for handler in handlers: # if the handler is not a function if not (isco...
python
def combine_action_handlers(*handlers): """ This function combines the given action handlers into a single function which will call all of them. """ # make sure each of the given handlers is callable for handler in handlers: # if the handler is not a function if not (isco...
[ "def", "combine_action_handlers", "(", "*", "handlers", ")", ":", "# make sure each of the given handlers is callable", "for", "handler", "in", "handlers", ":", "# if the handler is not a function", "if", "not", "(", "iscoroutinefunction", "(", "handler", ")", "or", "isco...
This function combines the given action handlers into a single function which will call all of them.
[ "This", "function", "combines", "the", "given", "action", "handlers", "into", "a", "single", "function", "which", "will", "call", "all", "of", "them", "." ]
70e2acef27a2f87355590be1a6ca60ce3ab4d09c
https://github.com/AlecAivazis/graphql-over-kafka/blob/70e2acef27a2f87355590be1a6ca60ce3ab4d09c/nautilus/network/events/util.py#L6-L26
train
AlecAivazis/graphql-over-kafka
nautilus/network/events/actionHandlers/updateHandler.py
update_handler
def update_handler(Model, name=None, **kwds): """ This factory returns an action handler that updates a new instance of the specified model when a update action is recieved, assuming the action follows nautilus convetions. Args: Model (nautilus.BaseModel): The model to u...
python
def update_handler(Model, name=None, **kwds): """ This factory returns an action handler that updates a new instance of the specified model when a update action is recieved, assuming the action follows nautilus convetions. Args: Model (nautilus.BaseModel): The model to u...
[ "def", "update_handler", "(", "Model", ",", "name", "=", "None", ",", "*", "*", "kwds", ")", ":", "async", "def", "action_handler", "(", "service", ",", "action_type", ",", "payload", ",", "props", ",", "notify", "=", "True", ",", "*", "*", "kwds", "...
This factory returns an action handler that updates a new instance of the specified model when a update action is recieved, assuming the action follows nautilus convetions. Args: Model (nautilus.BaseModel): The model to update when the action received. Retur...
[ "This", "factory", "returns", "an", "action", "handler", "that", "updates", "a", "new", "instance", "of", "the", "specified", "model", "when", "a", "update", "action", "is", "recieved", "assuming", "the", "action", "follows", "nautilus", "convetions", "." ]
70e2acef27a2f87355590be1a6ca60ce3ab4d09c
https://github.com/AlecAivazis/graphql-over-kafka/blob/70e2acef27a2f87355590be1a6ca60ce3ab4d09c/nautilus/network/events/actionHandlers/updateHandler.py#L10-L83
train
AlecAivazis/graphql-over-kafka
nautilus/api/util/graphql_mutation_from_summary.py
graphql_mutation_from_summary
def graphql_mutation_from_summary(summary): """ This function returns a graphql mutation corresponding to the provided summary. """ # get the name of the mutation from the summary mutation_name = summary['name'] # print(summary) # the treat the "type" string as a gra input_...
python
def graphql_mutation_from_summary(summary): """ This function returns a graphql mutation corresponding to the provided summary. """ # get the name of the mutation from the summary mutation_name = summary['name'] # print(summary) # the treat the "type" string as a gra input_...
[ "def", "graphql_mutation_from_summary", "(", "summary", ")", ":", "# get the name of the mutation from the summary", "mutation_name", "=", "summary", "[", "'name'", "]", "# print(summary)", "# the treat the \"type\" string as a gra", "input_name", "=", "mutation_name", "+", "\"...
This function returns a graphql mutation corresponding to the provided summary.
[ "This", "function", "returns", "a", "graphql", "mutation", "corresponding", "to", "the", "provided", "summary", "." ]
70e2acef27a2f87355590be1a6ca60ce3ab4d09c
https://github.com/AlecAivazis/graphql-over-kafka/blob/70e2acef27a2f87355590be1a6ca60ce3ab4d09c/nautilus/api/util/graphql_mutation_from_summary.py#L6-L38
train
AlecAivazis/graphql-over-kafka
nautilus/api/util/arg_string_from_dict.py
arg_string_from_dict
def arg_string_from_dict(arg_dict, **kwds): """ This function takes a series of ditionaries and creates an argument string for a graphql query """ # the filters dictionary filters = { **arg_dict, **kwds, } # return the correctly formed string return ", ".join(...
python
def arg_string_from_dict(arg_dict, **kwds): """ This function takes a series of ditionaries and creates an argument string for a graphql query """ # the filters dictionary filters = { **arg_dict, **kwds, } # return the correctly formed string return ", ".join(...
[ "def", "arg_string_from_dict", "(", "arg_dict", ",", "*", "*", "kwds", ")", ":", "# the filters dictionary", "filters", "=", "{", "*", "*", "arg_dict", ",", "*", "*", "kwds", ",", "}", "# return the correctly formed string", "return", "\", \"", ".", "join", "(...
This function takes a series of ditionaries and creates an argument string for a graphql query
[ "This", "function", "takes", "a", "series", "of", "ditionaries", "and", "creates", "an", "argument", "string", "for", "a", "graphql", "query" ]
70e2acef27a2f87355590be1a6ca60ce3ab4d09c
https://github.com/AlecAivazis/graphql-over-kafka/blob/70e2acef27a2f87355590be1a6ca60ce3ab4d09c/nautilus/api/util/arg_string_from_dict.py#L3-L14
train
AlecAivazis/graphql-over-kafka
nautilus/api/util/create_model_schema.py
create_model_schema
def create_model_schema(target_model): """ This function creates a graphql schema that provides a single model """ from nautilus.database import db # create the schema instance schema = graphene.Schema(auto_camelcase=False) # grab the primary key from the model primary_key = target_model.prim...
python
def create_model_schema(target_model): """ This function creates a graphql schema that provides a single model """ from nautilus.database import db # create the schema instance schema = graphene.Schema(auto_camelcase=False) # grab the primary key from the model primary_key = target_model.prim...
[ "def", "create_model_schema", "(", "target_model", ")", ":", "from", "nautilus", ".", "database", "import", "db", "# create the schema instance", "schema", "=", "graphene", ".", "Schema", "(", "auto_camelcase", "=", "False", ")", "# grab the primary key from the model",...
This function creates a graphql schema that provides a single model
[ "This", "function", "creates", "a", "graphql", "schema", "that", "provides", "a", "single", "model" ]
70e2acef27a2f87355590be1a6ca60ce3ab4d09c
https://github.com/AlecAivazis/graphql-over-kafka/blob/70e2acef27a2f87355590be1a6ca60ce3ab4d09c/nautilus/api/util/create_model_schema.py#L9-L48
train
AlecAivazis/graphql-over-kafka
nautilus/conventions/services.py
connection_service_name
def connection_service_name(service, *args): ''' the name of a service that manages the connection between services ''' # if the service is a string if isinstance(service, str): return service return normalize_string(type(service).__name__)
python
def connection_service_name(service, *args): ''' the name of a service that manages the connection between services ''' # if the service is a string if isinstance(service, str): return service return normalize_string(type(service).__name__)
[ "def", "connection_service_name", "(", "service", ",", "*", "args", ")", ":", "# if the service is a string", "if", "isinstance", "(", "service", ",", "str", ")", ":", "return", "service", "return", "normalize_string", "(", "type", "(", "service", ")", ".", "_...
the name of a service that manages the connection between services
[ "the", "name", "of", "a", "service", "that", "manages", "the", "connection", "between", "services" ]
70e2acef27a2f87355590be1a6ca60ce3ab4d09c
https://github.com/AlecAivazis/graphql-over-kafka/blob/70e2acef27a2f87355590be1a6ca60ce3ab4d09c/nautilus/conventions/services.py#L22-L28
train
AlecAivazis/graphql-over-kafka
nautilus/auth/util/read_session_token.py
read_session_token
def read_session_token(secret_key, token): """ This function verifies the token using the secret key and returns its contents. """ return jwt.decode(token.encode('utf-8'), secret_key, algorithms=[token_encryption_algorithm()] )
python
def read_session_token(secret_key, token): """ This function verifies the token using the secret key and returns its contents. """ return jwt.decode(token.encode('utf-8'), secret_key, algorithms=[token_encryption_algorithm()] )
[ "def", "read_session_token", "(", "secret_key", ",", "token", ")", ":", "return", "jwt", ".", "decode", "(", "token", ".", "encode", "(", "'utf-8'", ")", ",", "secret_key", ",", "algorithms", "=", "[", "token_encryption_algorithm", "(", ")", "]", ")" ]
This function verifies the token using the secret key and returns its contents.
[ "This", "function", "verifies", "the", "token", "using", "the", "secret", "key", "and", "returns", "its", "contents", "." ]
70e2acef27a2f87355590be1a6ca60ce3ab4d09c
https://github.com/AlecAivazis/graphql-over-kafka/blob/70e2acef27a2f87355590be1a6ca60ce3ab4d09c/nautilus/auth/util/read_session_token.py#L6-L13
train
AlecAivazis/graphql-over-kafka
nautilus/services/service.py
ServiceActionHandler.handle_action
async def handle_action(self, action_type, payload, **kwds): """ The default action Handler has no action. """ # if there is a service attached to the action handler if hasattr(self, 'service'): # handle roll calls await roll_call_handler(self.service,...
python
async def handle_action(self, action_type, payload, **kwds): """ The default action Handler has no action. """ # if there is a service attached to the action handler if hasattr(self, 'service'): # handle roll calls await roll_call_handler(self.service,...
[ "async", "def", "handle_action", "(", "self", ",", "action_type", ",", "payload", ",", "*", "*", "kwds", ")", ":", "# if there is a service attached to the action handler", "if", "hasattr", "(", "self", ",", "'service'", ")", ":", "# handle roll calls", "await", "...
The default action Handler has no action.
[ "The", "default", "action", "Handler", "has", "no", "action", "." ]
70e2acef27a2f87355590be1a6ca60ce3ab4d09c
https://github.com/AlecAivazis/graphql-over-kafka/blob/70e2acef27a2f87355590be1a6ca60ce3ab4d09c/nautilus/services/service.py#L47-L54
train
AlecAivazis/graphql-over-kafka
nautilus/services/service.py
Service.announce
async def announce(self): """ This method is used to announce the existence of the service """ # send a serialized event await self.event_broker.send( action_type=intialize_service_action(), payload=json.dumps(self.summarize()) )
python
async def announce(self): """ This method is used to announce the existence of the service """ # send a serialized event await self.event_broker.send( action_type=intialize_service_action(), payload=json.dumps(self.summarize()) )
[ "async", "def", "announce", "(", "self", ")", ":", "# send a serialized event", "await", "self", ".", "event_broker", ".", "send", "(", "action_type", "=", "intialize_service_action", "(", ")", ",", "payload", "=", "json", ".", "dumps", "(", "self", ".", "su...
This method is used to announce the existence of the service
[ "This", "method", "is", "used", "to", "announce", "the", "existence", "of", "the", "service" ]
70e2acef27a2f87355590be1a6ca60ce3ab4d09c
https://github.com/AlecAivazis/graphql-over-kafka/blob/70e2acef27a2f87355590be1a6ca60ce3ab4d09c/nautilus/services/service.py#L166-L174
train
AlecAivazis/graphql-over-kafka
nautilus/services/service.py
Service.run
def run(self, host="localhost", port=8000, shutdown_timeout=60.0, **kwargs): """ This function starts the service's network intefaces. Args: port (int): The port for the http server. """ print("Running service on http://localhost:%i. " % port + \ ...
python
def run(self, host="localhost", port=8000, shutdown_timeout=60.0, **kwargs): """ This function starts the service's network intefaces. Args: port (int): The port for the http server. """ print("Running service on http://localhost:%i. " % port + \ ...
[ "def", "run", "(", "self", ",", "host", "=", "\"localhost\"", ",", "port", "=", "8000", ",", "shutdown_timeout", "=", "60.0", ",", "*", "*", "kwargs", ")", ":", "print", "(", "\"Running service on http://localhost:%i. \"", "%", "port", "+", "\"Press Ctrl+C to ...
This function starts the service's network intefaces. Args: port (int): The port for the http server.
[ "This", "function", "starts", "the", "service", "s", "network", "intefaces", "." ]
70e2acef27a2f87355590be1a6ca60ce3ab4d09c
https://github.com/AlecAivazis/graphql-over-kafka/blob/70e2acef27a2f87355590be1a6ca60ce3ab4d09c/nautilus/services/service.py#L208-L257
train
AlecAivazis/graphql-over-kafka
nautilus/services/service.py
Service.cleanup
def cleanup(self): """ This function is called when the service has finished running regardless of intentionally or not. """ # if an event broker has been created for this service if self.event_broker: # stop the event broker self.event_br...
python
def cleanup(self): """ This function is called when the service has finished running regardless of intentionally or not. """ # if an event broker has been created for this service if self.event_broker: # stop the event broker self.event_br...
[ "def", "cleanup", "(", "self", ")", ":", "# if an event broker has been created for this service", "if", "self", ".", "event_broker", ":", "# stop the event broker", "self", ".", "event_broker", ".", "stop", "(", ")", "# attempt", "try", ":", "# close the http server", ...
This function is called when the service has finished running regardless of intentionally or not.
[ "This", "function", "is", "called", "when", "the", "service", "has", "finished", "running", "regardless", "of", "intentionally", "or", "not", "." ]
70e2acef27a2f87355590be1a6ca60ce3ab4d09c
https://github.com/AlecAivazis/graphql-over-kafka/blob/70e2acef27a2f87355590be1a6ca60ce3ab4d09c/nautilus/services/service.py#L260-L284
train
AlecAivazis/graphql-over-kafka
nautilus/services/service.py
Service.add_http_endpoint
def add_http_endpoint(self, url, request_handler): """ This method provides a programatic way of added invidual routes to the http server. Args: url (str): the url to be handled by the request_handler request_handler (nautilus.network.RequestH...
python
def add_http_endpoint(self, url, request_handler): """ This method provides a programatic way of added invidual routes to the http server. Args: url (str): the url to be handled by the request_handler request_handler (nautilus.network.RequestH...
[ "def", "add_http_endpoint", "(", "self", ",", "url", ",", "request_handler", ")", ":", "self", ".", "app", ".", "router", ".", "add_route", "(", "'*'", ",", "url", ",", "request_handler", ")" ]
This method provides a programatic way of added invidual routes to the http server. Args: url (str): the url to be handled by the request_handler request_handler (nautilus.network.RequestHandler): The request handler
[ "This", "method", "provides", "a", "programatic", "way", "of", "added", "invidual", "routes", "to", "the", "http", "server", "." ]
70e2acef27a2f87355590be1a6ca60ce3ab4d09c
https://github.com/AlecAivazis/graphql-over-kafka/blob/70e2acef27a2f87355590be1a6ca60ce3ab4d09c/nautilus/services/service.py#L287-L296
train
AlecAivazis/graphql-over-kafka
nautilus/services/service.py
Service.route
def route(cls, route, config=None): """ This method provides a decorator for adding endpoints to the http server. Args: route (str): The url to be handled by the RequestHandled config (dict): Configuration for the request handler ...
python
def route(cls, route, config=None): """ This method provides a decorator for adding endpoints to the http server. Args: route (str): The url to be handled by the RequestHandled config (dict): Configuration for the request handler ...
[ "def", "route", "(", "cls", ",", "route", ",", "config", "=", "None", ")", ":", "def", "decorator", "(", "wrapped_class", ",", "*", "*", "kwds", ")", ":", "# add the endpoint at the given route", "cls", ".", "_routes", ".", "append", "(", "dict", "(", "u...
This method provides a decorator for adding endpoints to the http server. Args: route (str): The url to be handled by the RequestHandled config (dict): Configuration for the request handler Example: .. code-block:: python ...
[ "This", "method", "provides", "a", "decorator", "for", "adding", "endpoints", "to", "the", "http", "server", "." ]
70e2acef27a2f87355590be1a6ca60ce3ab4d09c
https://github.com/AlecAivazis/graphql-over-kafka/blob/70e2acef27a2f87355590be1a6ca60ce3ab4d09c/nautilus/services/service.py#L300-L334
train
AlecAivazis/graphql-over-kafka
nautilus/auth/util/generate_session_token.py
generate_session_token
def generate_session_token(secret_key, **payload): """ This function generates a session token signed by the secret key which can be used to extract the user credentials in a verifiable way. """ return jwt.encode(payload, secret_key, algorithm=token_encryption_algorithm()).decode('utf-8')
python
def generate_session_token(secret_key, **payload): """ This function generates a session token signed by the secret key which can be used to extract the user credentials in a verifiable way. """ return jwt.encode(payload, secret_key, algorithm=token_encryption_algorithm()).decode('utf-8')
[ "def", "generate_session_token", "(", "secret_key", ",", "*", "*", "payload", ")", ":", "return", "jwt", ".", "encode", "(", "payload", ",", "secret_key", ",", "algorithm", "=", "token_encryption_algorithm", "(", ")", ")", ".", "decode", "(", "'utf-8'", ")" ...
This function generates a session token signed by the secret key which can be used to extract the user credentials in a verifiable way.
[ "This", "function", "generates", "a", "session", "token", "signed", "by", "the", "secret", "key", "which", "can", "be", "used", "to", "extract", "the", "user", "credentials", "in", "a", "verifiable", "way", "." ]
70e2acef27a2f87355590be1a6ca60ce3ab4d09c
https://github.com/AlecAivazis/graphql-over-kafka/blob/70e2acef27a2f87355590be1a6ca60ce3ab4d09c/nautilus/auth/util/generate_session_token.py#L6-L11
train
AlecAivazis/graphql-over-kafka
nautilus/api/util/summarize_mutation.py
summarize_mutation
def summarize_mutation(mutation_name, event, inputs, outputs, isAsync=False): """ This function provides a standard representation of mutations to be used when services announce themselves """ return dict( name=mutation_name, event=event, isAsync=isAsync, inpu...
python
def summarize_mutation(mutation_name, event, inputs, outputs, isAsync=False): """ This function provides a standard representation of mutations to be used when services announce themselves """ return dict( name=mutation_name, event=event, isAsync=isAsync, inpu...
[ "def", "summarize_mutation", "(", "mutation_name", ",", "event", ",", "inputs", ",", "outputs", ",", "isAsync", "=", "False", ")", ":", "return", "dict", "(", "name", "=", "mutation_name", ",", "event", "=", "event", ",", "isAsync", "=", "isAsync", ",", ...
This function provides a standard representation of mutations to be used when services announce themselves
[ "This", "function", "provides", "a", "standard", "representation", "of", "mutations", "to", "be", "used", "when", "services", "announce", "themselves" ]
70e2acef27a2f87355590be1a6ca60ce3ab4d09c
https://github.com/AlecAivazis/graphql-over-kafka/blob/70e2acef27a2f87355590be1a6ca60ce3ab4d09c/nautilus/api/util/summarize_mutation.py#L1-L12
train
AlecAivazis/graphql-over-kafka
nautilus/auth/primitives/passwordHash.py
PasswordHash.new
def new(cls, password, rounds): """Creates a PasswordHash from the given password.""" if isinstance(password, str): password = password.encode('utf-8') return cls(cls._new(password, rounds))
python
def new(cls, password, rounds): """Creates a PasswordHash from the given password.""" if isinstance(password, str): password = password.encode('utf-8') return cls(cls._new(password, rounds))
[ "def", "new", "(", "cls", ",", "password", ",", "rounds", ")", ":", "if", "isinstance", "(", "password", ",", "str", ")", ":", "password", "=", "password", ".", "encode", "(", "'utf-8'", ")", "return", "cls", "(", "cls", ".", "_new", "(", "password",...
Creates a PasswordHash from the given password.
[ "Creates", "a", "PasswordHash", "from", "the", "given", "password", "." ]
70e2acef27a2f87355590be1a6ca60ce3ab4d09c
https://github.com/AlecAivazis/graphql-over-kafka/blob/70e2acef27a2f87355590be1a6ca60ce3ab4d09c/nautilus/auth/primitives/passwordHash.py#L51-L55
train
AlecAivazis/graphql-over-kafka
nautilus/auth/primitives/passwordHash.py
PasswordHash.coerce
def coerce(cls, key, value): """Ensure that loaded values are PasswordHashes.""" if isinstance(value, PasswordHash): return value return super(PasswordHash, cls).coerce(key, value)
python
def coerce(cls, key, value): """Ensure that loaded values are PasswordHashes.""" if isinstance(value, PasswordHash): return value return super(PasswordHash, cls).coerce(key, value)
[ "def", "coerce", "(", "cls", ",", "key", ",", "value", ")", ":", "if", "isinstance", "(", "value", ",", "PasswordHash", ")", ":", "return", "value", "return", "super", "(", "PasswordHash", ",", "cls", ")", ".", "coerce", "(", "key", ",", "value", ")"...
Ensure that loaded values are PasswordHashes.
[ "Ensure", "that", "loaded", "values", "are", "PasswordHashes", "." ]
70e2acef27a2f87355590be1a6ca60ce3ab4d09c
https://github.com/AlecAivazis/graphql-over-kafka/blob/70e2acef27a2f87355590be1a6ca60ce3ab4d09c/nautilus/auth/primitives/passwordHash.py#L59-L63
train
AlecAivazis/graphql-over-kafka
nautilus/auth/primitives/passwordHash.py
PasswordHash.rehash
def rehash(self, password): """Recreates the internal hash.""" self.hash = self._new(password, self.desired_rounds) self.rounds = self.desired_rounds
python
def rehash(self, password): """Recreates the internal hash.""" self.hash = self._new(password, self.desired_rounds) self.rounds = self.desired_rounds
[ "def", "rehash", "(", "self", ",", "password", ")", ":", "self", ".", "hash", "=", "self", ".", "_new", "(", "password", ",", "self", ".", "desired_rounds", ")", "self", ".", "rounds", "=", "self", ".", "desired_rounds" ]
Recreates the internal hash.
[ "Recreates", "the", "internal", "hash", "." ]
70e2acef27a2f87355590be1a6ca60ce3ab4d09c
https://github.com/AlecAivazis/graphql-over-kafka/blob/70e2acef27a2f87355590be1a6ca60ce3ab4d09c/nautilus/auth/primitives/passwordHash.py#L75-L78
train
AlecAivazis/graphql-over-kafka
nautilus/services/modelService.py
ModelService.init_db
def init_db(self): """ This function configures the database used for models to make the configuration parameters. """ # get the database url from the configuration db_url = self.config.get('database_url', 'sqlite:///nautilus.db') # configure the nautilus ...
python
def init_db(self): """ This function configures the database used for models to make the configuration parameters. """ # get the database url from the configuration db_url = self.config.get('database_url', 'sqlite:///nautilus.db') # configure the nautilus ...
[ "def", "init_db", "(", "self", ")", ":", "# get the database url from the configuration", "db_url", "=", "self", ".", "config", ".", "get", "(", "'database_url'", ",", "'sqlite:///nautilus.db'", ")", "# configure the nautilus database to the url", "nautilus", ".", "databa...
This function configures the database used for models to make the configuration parameters.
[ "This", "function", "configures", "the", "database", "used", "for", "models", "to", "make", "the", "configuration", "parameters", "." ]
70e2acef27a2f87355590be1a6ca60ce3ab4d09c
https://github.com/AlecAivazis/graphql-over-kafka/blob/70e2acef27a2f87355590be1a6ca60ce3ab4d09c/nautilus/services/modelService.py#L101-L109
train
AlecAivazis/graphql-over-kafka
nautilus/services/apiGateway.py
APIGateway.auth_criteria
def auth_criteria(self): """ This attribute provides the mapping of services to their auth requirement Returns: (dict) : the mapping from services to their auth requirements. """ # the dictionary we will return auth = {} # go over each at...
python
def auth_criteria(self): """ This attribute provides the mapping of services to their auth requirement Returns: (dict) : the mapping from services to their auth requirements. """ # the dictionary we will return auth = {} # go over each at...
[ "def", "auth_criteria", "(", "self", ")", ":", "# the dictionary we will return", "auth", "=", "{", "}", "# go over each attribute of the service", "for", "attr", "in", "dir", "(", "self", ")", ":", "# make sure we could hit an infinite loop", "if", "attr", "!=", "'au...
This attribute provides the mapping of services to their auth requirement Returns: (dict) : the mapping from services to their auth requirements.
[ "This", "attribute", "provides", "the", "mapping", "of", "services", "to", "their", "auth", "requirement" ]
70e2acef27a2f87355590be1a6ca60ce3ab4d09c
https://github.com/AlecAivazis/graphql-over-kafka/blob/70e2acef27a2f87355590be1a6ca60ce3ab4d09c/nautilus/services/apiGateway.py#L87-L109
train
AlecAivazis/graphql-over-kafka
nautilus/services/apiGateway.py
APIGateway.login_user
async def login_user(self, password, **kwds): """ This function handles the registration of the given user credentials in the database """ # find the matching user with the given email user_data = (await self._get_matching_user(fields=list(kwds.keys()), **kwds))['data'] ...
python
async def login_user(self, password, **kwds): """ This function handles the registration of the given user credentials in the database """ # find the matching user with the given email user_data = (await self._get_matching_user(fields=list(kwds.keys()), **kwds))['data'] ...
[ "async", "def", "login_user", "(", "self", ",", "password", ",", "*", "*", "kwds", ")", ":", "# find the matching user with the given email", "user_data", "=", "(", "await", "self", ".", "_get_matching_user", "(", "fields", "=", "list", "(", "kwds", ".", "keys...
This function handles the registration of the given user credentials in the database
[ "This", "function", "handles", "the", "registration", "of", "the", "given", "user", "credentials", "in", "the", "database" ]
70e2acef27a2f87355590be1a6ca60ce3ab4d09c
https://github.com/AlecAivazis/graphql-over-kafka/blob/70e2acef27a2f87355590be1a6ca60ce3ab4d09c/nautilus/services/apiGateway.py#L144-L172
train
AlecAivazis/graphql-over-kafka
nautilus/services/apiGateway.py
APIGateway.register_user
async def register_user(self, password, **kwds): """ This function is used to provide a sessionToken for later requests. Args: uid (str): The """ # so make one user = await self._create_remote_user(password=password, **kwds) # if there is ...
python
async def register_user(self, password, **kwds): """ This function is used to provide a sessionToken for later requests. Args: uid (str): The """ # so make one user = await self._create_remote_user(password=password, **kwds) # if there is ...
[ "async", "def", "register_user", "(", "self", ",", "password", ",", "*", "*", "kwds", ")", ":", "# so make one", "user", "=", "await", "self", ".", "_create_remote_user", "(", "password", "=", "password", ",", "*", "*", "kwds", ")", "# if there is no pk fiel...
This function is used to provide a sessionToken for later requests. Args: uid (str): The
[ "This", "function", "is", "used", "to", "provide", "a", "sessionToken", "for", "later", "requests", "." ]
70e2acef27a2f87355590be1a6ca60ce3ab4d09c
https://github.com/AlecAivazis/graphql-over-kafka/blob/70e2acef27a2f87355590be1a6ca60ce3ab4d09c/nautilus/services/apiGateway.py#L175-L207
train
AlecAivazis/graphql-over-kafka
nautilus/services/apiGateway.py
APIGateway.object_resolver
async def object_resolver(self, object_name, fields, obey_auth=False, current_user=None, **filters): """ This function resolves a given object in the remote backend services """ try: # check if an object with that name has been registered registered = [model ...
python
async def object_resolver(self, object_name, fields, obey_auth=False, current_user=None, **filters): """ This function resolves a given object in the remote backend services """ try: # check if an object with that name has been registered registered = [model ...
[ "async", "def", "object_resolver", "(", "self", ",", "object_name", ",", "fields", ",", "obey_auth", "=", "False", ",", "current_user", "=", "None", ",", "*", "*", "filters", ")", ":", "try", ":", "# check if an object with that name has been registered", "registe...
This function resolves a given object in the remote backend services
[ "This", "function", "resolves", "a", "given", "object", "in", "the", "remote", "backend", "services" ]
70e2acef27a2f87355590be1a6ca60ce3ab4d09c
https://github.com/AlecAivazis/graphql-over-kafka/blob/70e2acef27a2f87355590be1a6ca60ce3ab4d09c/nautilus/services/apiGateway.py#L210-L293
train
AlecAivazis/graphql-over-kafka
nautilus/services/apiGateway.py
APIGateway.mutation_resolver
async def mutation_resolver(self, mutation_name, args, fields): """ the default behavior for mutations is to look up the event, publish the correct event type with the args as the body, and return the fields contained in the result """ try: # make...
python
async def mutation_resolver(self, mutation_name, args, fields): """ the default behavior for mutations is to look up the event, publish the correct event type with the args as the body, and return the fields contained in the result """ try: # make...
[ "async", "def", "mutation_resolver", "(", "self", ",", "mutation_name", ",", "args", ",", "fields", ")", ":", "try", ":", "# make sure we can identify the mutation", "mutation_summary", "=", "[", "mutation", "for", "mutation", "in", "self", ".", "_external_service_d...
the default behavior for mutations is to look up the event, publish the correct event type with the args as the body, and return the fields contained in the result
[ "the", "default", "behavior", "for", "mutations", "is", "to", "look", "up", "the", "event", "publish", "the", "correct", "event", "type", "with", "the", "args", "as", "the", "body", "and", "return", "the", "fields", "contained", "in", "the", "result" ]
70e2acef27a2f87355590be1a6ca60ce3ab4d09c
https://github.com/AlecAivazis/graphql-over-kafka/blob/70e2acef27a2f87355590be1a6ca60ce3ab4d09c/nautilus/services/apiGateway.py#L350-L385
train
AlecAivazis/graphql-over-kafka
nautilus/services/apiGateway.py
APIGateway._check_for_matching_user
async def _check_for_matching_user(self, **user_filters): """ This function checks if there is a user with the same uid in the remote user service Args: **kwds : the filters of the user to check for Returns: (bool): wether or not th...
python
async def _check_for_matching_user(self, **user_filters): """ This function checks if there is a user with the same uid in the remote user service Args: **kwds : the filters of the user to check for Returns: (bool): wether or not th...
[ "async", "def", "_check_for_matching_user", "(", "self", ",", "*", "*", "user_filters", ")", ":", "# there is a matching user if there are no errors and no results from", "user_data", "=", "self", ".", "_get_matching_user", "(", "user_filters", ")", "# return true if there we...
This function checks if there is a user with the same uid in the remote user service Args: **kwds : the filters of the user to check for Returns: (bool): wether or not there is a matching user
[ "This", "function", "checks", "if", "there", "is", "a", "user", "with", "the", "same", "uid", "in", "the", "remote", "user", "service", "Args", ":", "**", "kwds", ":", "the", "filters", "of", "the", "user", "to", "check", "for", "Returns", ":", "(", ...
70e2acef27a2f87355590be1a6ca60ce3ab4d09c
https://github.com/AlecAivazis/graphql-over-kafka/blob/70e2acef27a2f87355590be1a6ca60ce3ab4d09c/nautilus/services/apiGateway.py#L434-L447
train
AlecAivazis/graphql-over-kafka
nautilus/services/apiGateway.py
APIGateway._create_remote_user
async def _create_remote_user(self, **payload): """ This method creates a service record in the remote user service with the given email. Args: uid (str): the user identifier to create Returns: (dict): a summary of the user that was...
python
async def _create_remote_user(self, **payload): """ This method creates a service record in the remote user service with the given email. Args: uid (str): the user identifier to create Returns: (dict): a summary of the user that was...
[ "async", "def", "_create_remote_user", "(", "self", ",", "*", "*", "payload", ")", ":", "# the action for reading user entries", "read_action", "=", "get_crud_action", "(", "method", "=", "'create'", ",", "model", "=", "'user'", ")", "# see if there is a matching user...
This method creates a service record in the remote user service with the given email. Args: uid (str): the user identifier to create Returns: (dict): a summary of the user that was created
[ "This", "method", "creates", "a", "service", "record", "in", "the", "remote", "user", "service", "with", "the", "given", "email", ".", "Args", ":", "uid", "(", "str", ")", ":", "the", "user", "identifier", "to", "create", "Returns", ":", "(", "dict", "...
70e2acef27a2f87355590be1a6ca60ce3ab4d09c
https://github.com/AlecAivazis/graphql-over-kafka/blob/70e2acef27a2f87355590be1a6ca60ce3ab4d09c/nautilus/services/apiGateway.py#L450-L468
train
MartinThoma/asr
asr/align.py
calculate_wer
def calculate_wer(reference, hypothesis): """ Calculation of WER with Levenshtein distance. Works only for iterables up to 254 elements (uint8). O(nm) time and space complexity. >>> calculate_wer("who is there".split(), "is there".split()) 1 >>> calculate_wer("who is...
python
def calculate_wer(reference, hypothesis): """ Calculation of WER with Levenshtein distance. Works only for iterables up to 254 elements (uint8). O(nm) time and space complexity. >>> calculate_wer("who is there".split(), "is there".split()) 1 >>> calculate_wer("who is...
[ "def", "calculate_wer", "(", "reference", ",", "hypothesis", ")", ":", "# initialisation", "import", "numpy", "d", "=", "numpy", ".", "zeros", "(", "(", "len", "(", "reference", ")", "+", "1", ")", "*", "(", "len", "(", "hypothesis", ")", "+", "1", "...
Calculation of WER with Levenshtein distance. Works only for iterables up to 254 elements (uint8). O(nm) time and space complexity. >>> calculate_wer("who is there".split(), "is there".split()) 1 >>> calculate_wer("who is there".split(), "".split()) 3 >>> calcula...
[ "Calculation", "of", "WER", "with", "Levenshtein", "distance", ".", "Works", "only", "for", "iterables", "up", "to", "254", "elements", "(", "uint8", ")", ".", "O", "(", "nm", ")", "time", "and", "space", "complexity", "." ]
b453074761a4a2f1ee40cd5315b2e000c3b72142
https://github.com/MartinThoma/asr/blob/b453074761a4a2f1ee40cd5315b2e000c3b72142/asr/align.py#L7-L42
train
MartinThoma/asr
asr/align.py
get_parser
def get_parser(): """Get a parser object""" from argparse import ArgumentParser, ArgumentDefaultsHelpFormatter parser = ArgumentParser(description=__doc__, formatter_class=ArgumentDefaultsHelpFormatter) parser.add_argument("-s1", dest="s1", help="sequence 1") parser.add_a...
python
def get_parser(): """Get a parser object""" from argparse import ArgumentParser, ArgumentDefaultsHelpFormatter parser = ArgumentParser(description=__doc__, formatter_class=ArgumentDefaultsHelpFormatter) parser.add_argument("-s1", dest="s1", help="sequence 1") parser.add_a...
[ "def", "get_parser", "(", ")", ":", "from", "argparse", "import", "ArgumentParser", ",", "ArgumentDefaultsHelpFormatter", "parser", "=", "ArgumentParser", "(", "description", "=", "__doc__", ",", "formatter_class", "=", "ArgumentDefaultsHelpFormatter", ")", "parser", ...
Get a parser object
[ "Get", "a", "parser", "object" ]
b453074761a4a2f1ee40cd5315b2e000c3b72142
https://github.com/MartinThoma/asr/blob/b453074761a4a2f1ee40cd5315b2e000c3b72142/asr/align.py#L45-L52
train
pschmitt/pyteleloisirs
pyteleloisirs/pyteleloisirs.py
_async_request_soup
async def _async_request_soup(url): ''' Perform a GET web request and return a bs4 parser ''' from bs4 import BeautifulSoup import aiohttp _LOGGER.debug('GET %s', url) async with aiohttp.ClientSession() as session: resp = await session.get(url) text = await resp.text() ...
python
async def _async_request_soup(url): ''' Perform a GET web request and return a bs4 parser ''' from bs4 import BeautifulSoup import aiohttp _LOGGER.debug('GET %s', url) async with aiohttp.ClientSession() as session: resp = await session.get(url) text = await resp.text() ...
[ "async", "def", "_async_request_soup", "(", "url", ")", ":", "from", "bs4", "import", "BeautifulSoup", "import", "aiohttp", "_LOGGER", ".", "debug", "(", "'GET %s'", ",", "url", ")", "async", "with", "aiohttp", ".", "ClientSession", "(", ")", "as", "session"...
Perform a GET web request and return a bs4 parser
[ "Perform", "a", "GET", "web", "request", "and", "return", "a", "bs4", "parser" ]
d63610fd3729862455ac42afca440469f8063fba
https://github.com/pschmitt/pyteleloisirs/blob/d63610fd3729862455ac42afca440469f8063fba/pyteleloisirs/pyteleloisirs.py#L15-L25
train
pschmitt/pyteleloisirs
pyteleloisirs/pyteleloisirs.py
async_determine_channel
async def async_determine_channel(channel): ''' Check whether the current channel is correct. If not try to determine it using fuzzywuzzy ''' from fuzzywuzzy import process channel_data = await async_get_channels() if not channel_data: _LOGGER.error('No channel data. Cannot determine...
python
async def async_determine_channel(channel): ''' Check whether the current channel is correct. If not try to determine it using fuzzywuzzy ''' from fuzzywuzzy import process channel_data = await async_get_channels() if not channel_data: _LOGGER.error('No channel data. Cannot determine...
[ "async", "def", "async_determine_channel", "(", "channel", ")", ":", "from", "fuzzywuzzy", "import", "process", "channel_data", "=", "await", "async_get_channels", "(", ")", "if", "not", "channel_data", ":", "_LOGGER", ".", "error", "(", "'No channel data. Cannot de...
Check whether the current channel is correct. If not try to determine it using fuzzywuzzy
[ "Check", "whether", "the", "current", "channel", "is", "correct", ".", "If", "not", "try", "to", "determine", "it", "using", "fuzzywuzzy" ]
d63610fd3729862455ac42afca440469f8063fba
https://github.com/pschmitt/pyteleloisirs/blob/d63610fd3729862455ac42afca440469f8063fba/pyteleloisirs/pyteleloisirs.py#L28-L45
train
pschmitt/pyteleloisirs
pyteleloisirs/pyteleloisirs.py
async_get_channels
async def async_get_channels(no_cache=False, refresh_interval=4): ''' Get channel list and corresponding urls ''' # Check cache now = datetime.datetime.now() max_cache_age = datetime.timedelta(hours=refresh_interval) if not no_cache and 'channels' in _CACHE: cache = _CACHE.get('chann...
python
async def async_get_channels(no_cache=False, refresh_interval=4): ''' Get channel list and corresponding urls ''' # Check cache now = datetime.datetime.now() max_cache_age = datetime.timedelta(hours=refresh_interval) if not no_cache and 'channels' in _CACHE: cache = _CACHE.get('chann...
[ "async", "def", "async_get_channels", "(", "no_cache", "=", "False", ",", "refresh_interval", "=", "4", ")", ":", "# Check cache", "now", "=", "datetime", ".", "datetime", ".", "now", "(", ")", "max_cache_age", "=", "datetime", ".", "timedelta", "(", "hours"...
Get channel list and corresponding urls
[ "Get", "channel", "list", "and", "corresponding", "urls" ]
d63610fd3729862455ac42afca440469f8063fba
https://github.com/pschmitt/pyteleloisirs/blob/d63610fd3729862455ac42afca440469f8063fba/pyteleloisirs/pyteleloisirs.py#L48-L80
train