repository_name
stringlengths
5
67
func_path_in_repository
stringlengths
4
234
func_name
stringlengths
0
314
whole_func_string
stringlengths
52
3.87M
language
stringclasses
6 values
func_code_string
stringlengths
52
3.87M
func_code_tokens
listlengths
15
672k
func_documentation_string
stringlengths
1
47.2k
func_documentation_tokens
listlengths
1
3.92k
split_name
stringclasses
1 value
func_code_url
stringlengths
85
339
robertpeteuil/aws-shortcuts
awss/awsc.py
get_all_aminames
def get_all_aminames(i_info): """Get Image_Name for each instance in i_info. Args: i_info (dict): information on instances and details. Returns: i_info (dict): i_info is returned with the aminame added for each instance. """ for i in i_info: try: ...
python
def get_all_aminames(i_info): """Get Image_Name for each instance in i_info. Args: i_info (dict): information on instances and details. Returns: i_info (dict): i_info is returned with the aminame added for each instance. """ for i in i_info: try: ...
[ "def", "get_all_aminames", "(", "i_info", ")", ":", "for", "i", "in", "i_info", ":", "try", ":", "# pylint: disable=maybe-no-member", "i_info", "[", "i", "]", "[", "'aminame'", "]", "=", "EC2R", ".", "Image", "(", "i_info", "[", "i", "]", "[", "'ami'", ...
Get Image_Name for each instance in i_info. Args: i_info (dict): information on instances and details. Returns: i_info (dict): i_info is returned with the aminame added for each instance.
[ "Get", "Image_Name", "for", "each", "instance", "in", "i_info", "." ]
train
https://github.com/robertpeteuil/aws-shortcuts/blob/cf453ca996978a4d88015d1cf6125bce8ca4873b/awss/awsc.py#L71-L87
robertpeteuil/aws-shortcuts
awss/awsc.py
get_one_aminame
def get_one_aminame(inst_img_id): """Get Image_Name for the image_id specified. Args: inst_img_id (str): image_id to get name value from. Returns: aminame (str): name of the image. """ try: aminame = EC2R.Image(inst_img_id).name except AttributeError: aminame = ...
python
def get_one_aminame(inst_img_id): """Get Image_Name for the image_id specified. Args: inst_img_id (str): image_id to get name value from. Returns: aminame (str): name of the image. """ try: aminame = EC2R.Image(inst_img_id).name except AttributeError: aminame = ...
[ "def", "get_one_aminame", "(", "inst_img_id", ")", ":", "try", ":", "aminame", "=", "EC2R", ".", "Image", "(", "inst_img_id", ")", ".", "name", "except", "AttributeError", ":", "aminame", "=", "\"Unknown\"", "return", "aminame" ]
Get Image_Name for the image_id specified. Args: inst_img_id (str): image_id to get name value from. Returns: aminame (str): name of the image.
[ "Get", "Image_Name", "for", "the", "image_id", "specified", "." ]
train
https://github.com/robertpeteuil/aws-shortcuts/blob/cf453ca996978a4d88015d1cf6125bce8ca4873b/awss/awsc.py#L90-L103
robertpeteuil/aws-shortcuts
awss/awsc.py
startstop
def startstop(inst_id, cmdtodo): """Start or Stop the Specified Instance. Args: inst_id (str): instance-id to perform command against cmdtodo (str): command to perform (start or stop) Returns: response (dict): reponse returned from AWS after performing speci...
python
def startstop(inst_id, cmdtodo): """Start or Stop the Specified Instance. Args: inst_id (str): instance-id to perform command against cmdtodo (str): command to perform (start or stop) Returns: response (dict): reponse returned from AWS after performing speci...
[ "def", "startstop", "(", "inst_id", ",", "cmdtodo", ")", ":", "tar_inst", "=", "EC2R", ".", "Instance", "(", "inst_id", ")", "thecmd", "=", "getattr", "(", "tar_inst", ",", "cmdtodo", ")", "response", "=", "thecmd", "(", ")", "return", "response" ]
Start or Stop the Specified Instance. Args: inst_id (str): instance-id to perform command against cmdtodo (str): command to perform (start or stop) Returns: response (dict): reponse returned from AWS after performing specified action.
[ "Start", "or", "Stop", "the", "Specified", "Instance", "." ]
train
https://github.com/robertpeteuil/aws-shortcuts/blob/cf453ca996978a4d88015d1cf6125bce8ca4873b/awss/awsc.py#L106-L120
iblancasa/GitHubCity
src/githubcity/ghregion.py
GitHubRegion.addCity
def addCity(self, fileName): """Add a JSON file and read the users. :param fileName: path to the JSON file. This file has to have a list of users, called users. :type fileName: str. """ with open(fileName) as data_file: data = load(data_file) for u in...
python
def addCity(self, fileName): """Add a JSON file and read the users. :param fileName: path to the JSON file. This file has to have a list of users, called users. :type fileName: str. """ with open(fileName) as data_file: data = load(data_file) for u in...
[ "def", "addCity", "(", "self", ",", "fileName", ")", ":", "with", "open", "(", "fileName", ")", "as", "data_file", ":", "data", "=", "load", "(", "data_file", ")", "for", "u", "in", "data", "[", "\"users\"", "]", ":", "if", "not", "any", "(", "d", ...
Add a JSON file and read the users. :param fileName: path to the JSON file. This file has to have a list of users, called users. :type fileName: str.
[ "Add", "a", "JSON", "file", "and", "read", "the", "users", "." ]
train
https://github.com/iblancasa/GitHubCity/blob/c5299c6859dbefbd869e2ac6ff2faff2a39cf32f/src/githubcity/ghregion.py#L49-L60
iblancasa/GitHubCity
src/githubcity/ghregion.py
GitHubRegion.export
def export(self, template_file_name, output_file_name, sort="public", data=None, limit=0): """Export ranking to a file. Args: template_file_name (str): where is the template (moustache template) output_file_name (str): where create the file with th...
python
def export(self, template_file_name, output_file_name, sort="public", data=None, limit=0): """Export ranking to a file. Args: template_file_name (str): where is the template (moustache template) output_file_name (str): where create the file with th...
[ "def", "export", "(", "self", ",", "template_file_name", ",", "output_file_name", ",", "sort", "=", "\"public\"", ",", "data", "=", "None", ",", "limit", "=", "0", ")", ":", "exportedData", "=", "{", "}", "exportedUsers", "=", "self", ".", "getSortedUsers"...
Export ranking to a file. Args: template_file_name (str): where is the template (moustache template) output_file_name (str): where create the file with the ranking sort (str): field to sort the users
[ "Export", "ranking", "to", "a", "file", "." ]
train
https://github.com/iblancasa/GitHubCity/blob/c5299c6859dbefbd869e2ac6ff2faff2a39cf32f/src/githubcity/ghregion.py#L62-L93
iblancasa/GitHubCity
src/githubcity/ghregion.py
GitHubRegion.__getTemplate
def __getTemplate(template_file_name): """Get temaplte to save the ranking. :param template_file_name: path to the template. :type template_file_name: str. :return: template for the file. :rtype: pystache's template. """ with open(template_file_name) as template...
python
def __getTemplate(template_file_name): """Get temaplte to save the ranking. :param template_file_name: path to the template. :type template_file_name: str. :return: template for the file. :rtype: pystache's template. """ with open(template_file_name) as template...
[ "def", "__getTemplate", "(", "template_file_name", ")", ":", "with", "open", "(", "template_file_name", ")", "as", "template_file", ":", "template_raw", "=", "template_file", ".", "read", "(", ")", "template", "=", "parse", "(", "template_raw", ")", "return", ...
Get temaplte to save the ranking. :param template_file_name: path to the template. :type template_file_name: str. :return: template for the file. :rtype: pystache's template.
[ "Get", "temaplte", "to", "save", "the", "ranking", "." ]
train
https://github.com/iblancasa/GitHubCity/blob/c5299c6859dbefbd869e2ac6ff2faff2a39cf32f/src/githubcity/ghregion.py#L96-L109
iblancasa/GitHubCity
src/githubcity/ghregion.py
GitHubRegion.getSortedUsers
def getSortedUsers(self, order="public"): """Return a list with sorted users. :param order: the field to sort the users. - contributions (total number of contributions) - public (public contributions) - private (private contributions) - name -...
python
def getSortedUsers(self, order="public"): """Return a list with sorted users. :param order: the field to sort the users. - contributions (total number of contributions) - public (public contributions) - private (private contributions) - name -...
[ "def", "getSortedUsers", "(", "self", ",", "order", "=", "\"public\"", ")", ":", "if", "order", "==", "\"contributions\"", ":", "self", ".", "__users", ".", "sort", "(", "key", "=", "lambda", "u", ":", "u", "[", "\"contributions\"", "]", ",", "reverse", ...
Return a list with sorted users. :param order: the field to sort the users. - contributions (total number of contributions) - public (public contributions) - private (private contributions) - name - followers - join - organizat...
[ "Return", "a", "list", "with", "sorted", "users", "." ]
train
https://github.com/iblancasa/GitHubCity/blob/c5299c6859dbefbd869e2ac6ff2faff2a39cf32f/src/githubcity/ghregion.py#L111-L148
diefans/docker-events
src/docker_events/scripts.py
setup_logging
def setup_logging(logging_config, debug=False): """Setup logging config.""" if logging_config is not None: logging.config.fileConfig(logging_config) else: logging.basicConfig(level=debug and logging.DEBUG or logging.ERROR)
python
def setup_logging(logging_config, debug=False): """Setup logging config.""" if logging_config is not None: logging.config.fileConfig(logging_config) else: logging.basicConfig(level=debug and logging.DEBUG or logging.ERROR)
[ "def", "setup_logging", "(", "logging_config", ",", "debug", "=", "False", ")", ":", "if", "logging_config", "is", "not", "None", ":", "logging", ".", "config", ".", "fileConfig", "(", "logging_config", ")", "else", ":", "logging", ".", "basicConfig", "(", ...
Setup logging config.
[ "Setup", "logging", "config", "." ]
train
https://github.com/diefans/docker-events/blob/cc07591d908fefcc265285ba7fc0047632e06dea/src/docker_events/scripts.py#L25-L32
diefans/docker-events
src/docker_events/scripts.py
loop
def loop(sock, config=None): """Loops over all docker events and executes subscribed callbacks with an optional config value. :param config: a dictionary with external config values """ if config is None: config = {} client = docker.Client(base_url=sock) # fake a running event f...
python
def loop(sock, config=None): """Loops over all docker events and executes subscribed callbacks with an optional config value. :param config: a dictionary with external config values """ if config is None: config = {} client = docker.Client(base_url=sock) # fake a running event f...
[ "def", "loop", "(", "sock", ",", "config", "=", "None", ")", ":", "if", "config", "is", "None", ":", "config", "=", "{", "}", "client", "=", "docker", ".", "Client", "(", "base_url", "=", "sock", ")", "# fake a running event for all running containers", "f...
Loops over all docker events and executes subscribed callbacks with an optional config value. :param config: a dictionary with external config values
[ "Loops", "over", "all", "docker", "events", "and", "executes", "subscribed", "callbacks", "with", "an", "optional", "config", "value", "." ]
train
https://github.com/diefans/docker-events/blob/cc07591d908fefcc265285ba7fc0047632e06dea/src/docker_events/scripts.py#L35-L74
diefans/docker-events
src/docker_events/scripts.py
join_configs
def join_configs(configs): """Join all config files into one config.""" joined_config = {} for config in configs: joined_config.update(yaml.load(config)) return joined_config
python
def join_configs(configs): """Join all config files into one config.""" joined_config = {} for config in configs: joined_config.update(yaml.load(config)) return joined_config
[ "def", "join_configs", "(", "configs", ")", ":", "joined_config", "=", "{", "}", "for", "config", "in", "configs", ":", "joined_config", ".", "update", "(", "yaml", ".", "load", "(", "config", ")", ")", "return", "joined_config" ]
Join all config files into one config.
[ "Join", "all", "config", "files", "into", "one", "config", "." ]
train
https://github.com/diefans/docker-events/blob/cc07591d908fefcc265285ba7fc0047632e06dea/src/docker_events/scripts.py#L77-L86
diefans/docker-events
src/docker_events/scripts.py
load_modules
def load_modules(modules): """Load a module.""" for dotted_module in modules: try: __import__(dotted_module) except ImportError as e: LOG.error("Unable to import %s: %s", dotted_module, e)
python
def load_modules(modules): """Load a module.""" for dotted_module in modules: try: __import__(dotted_module) except ImportError as e: LOG.error("Unable to import %s: %s", dotted_module, e)
[ "def", "load_modules", "(", "modules", ")", ":", "for", "dotted_module", "in", "modules", ":", "try", ":", "__import__", "(", "dotted_module", ")", "except", "ImportError", "as", "e", ":", "LOG", ".", "error", "(", "\"Unable to import %s: %s\"", ",", "dotted_m...
Load a module.
[ "Load", "a", "module", "." ]
train
https://github.com/diefans/docker-events/blob/cc07591d908fefcc265285ba7fc0047632e06dea/src/docker_events/scripts.py#L89-L97
diefans/docker-events
src/docker_events/scripts.py
load_files
def load_files(files): """Load and execute a python file.""" for py_file in files: LOG.debug("exec %s", py_file) execfile(py_file, globals(), locals())
python
def load_files(files): """Load and execute a python file.""" for py_file in files: LOG.debug("exec %s", py_file) execfile(py_file, globals(), locals())
[ "def", "load_files", "(", "files", ")", ":", "for", "py_file", "in", "files", ":", "LOG", ".", "debug", "(", "\"exec %s\"", ",", "py_file", ")", "execfile", "(", "py_file", ",", "globals", "(", ")", ",", "locals", "(", ")", ")" ]
Load and execute a python file.
[ "Load", "and", "execute", "a", "python", "file", "." ]
train
https://github.com/diefans/docker-events/blob/cc07591d908fefcc265285ba7fc0047632e06dea/src/docker_events/scripts.py#L100-L105
diefans/docker-events
src/docker_events/scripts.py
summarize_events
def summarize_events(): """Some information about active events and callbacks.""" for ev in event.events: if ev.callbacks: LOG.info("subscribed to %s by %s", ev, ', '.join(imap(repr, ev.callbacks)))
python
def summarize_events(): """Some information about active events and callbacks.""" for ev in event.events: if ev.callbacks: LOG.info("subscribed to %s by %s", ev, ', '.join(imap(repr, ev.callbacks)))
[ "def", "summarize_events", "(", ")", ":", "for", "ev", "in", "event", ".", "events", ":", "if", "ev", ".", "callbacks", ":", "LOG", ".", "info", "(", "\"subscribed to %s by %s\"", ",", "ev", ",", "', '", ".", "join", "(", "imap", "(", "repr", ",", "e...
Some information about active events and callbacks.
[ "Some", "information", "about", "active", "events", "and", "callbacks", "." ]
train
https://github.com/diefans/docker-events/blob/cc07591d908fefcc265285ba7fc0047632e06dea/src/docker_events/scripts.py#L108-L113
diefans/docker-events
src/docker_events/scripts.py
cli
def cli(sock, configs, modules, files, log, debug): """The CLI.""" setup_logging(log, debug) config = join_configs(configs) # load python modules load_modules(modules) # load python files load_files(files) # summarize active events and callbacks summarize_events() gloop = g...
python
def cli(sock, configs, modules, files, log, debug): """The CLI.""" setup_logging(log, debug) config = join_configs(configs) # load python modules load_modules(modules) # load python files load_files(files) # summarize active events and callbacks summarize_events() gloop = g...
[ "def", "cli", "(", "sock", ",", "configs", ",", "modules", ",", "files", ",", "log", ",", "debug", ")", ":", "setup_logging", "(", "log", ",", "debug", ")", "config", "=", "join_configs", "(", "configs", ")", "# load python modules", "load_modules", "(", ...
The CLI.
[ "The", "CLI", "." ]
train
https://github.com/diefans/docker-events/blob/cc07591d908fefcc265285ba7fc0047632e06dea/src/docker_events/scripts.py#L136-L154
grahambell/pymoc
lib/pymoc/moc.py
MOC.type
def type(self, value): """Set the type of the MOC. The value should be either "IMAGE" or "CATALOG". """ self._type = None if value is None: return value = value.upper() if value in MOC_TYPES: self._type = value else: ...
python
def type(self, value): """Set the type of the MOC. The value should be either "IMAGE" or "CATALOG". """ self._type = None if value is None: return value = value.upper() if value in MOC_TYPES: self._type = value else: ...
[ "def", "type", "(", "self", ",", "value", ")", ":", "self", ".", "_type", "=", "None", "if", "value", "is", "None", ":", "return", "value", "=", "value", ".", "upper", "(", ")", "if", "value", "in", "MOC_TYPES", ":", "self", ".", "_type", "=", "v...
Set the type of the MOC. The value should be either "IMAGE" or "CATALOG".
[ "Set", "the", "type", "of", "the", "MOC", "." ]
train
https://github.com/grahambell/pymoc/blob/0e2e57ce07ff3de6ac024627c1fb6ad30c2fde48/lib/pymoc/moc.py#L302-L316
grahambell/pymoc
lib/pymoc/moc.py
MOC.area
def area(self): """The area enclosed by the MOC, in steradians. >>> m = MOC(0, (0, 1, 2)) >>> round(m.area, 2) 3.14 """ self.normalize() area = 0.0 for (order, cells) in self: area += (len(cells) * pi) / (3 * 4 ** order) return area
python
def area(self): """The area enclosed by the MOC, in steradians. >>> m = MOC(0, (0, 1, 2)) >>> round(m.area, 2) 3.14 """ self.normalize() area = 0.0 for (order, cells) in self: area += (len(cells) * pi) / (3 * 4 ** order) return area
[ "def", "area", "(", "self", ")", ":", "self", ".", "normalize", "(", ")", "area", "=", "0.0", "for", "(", "order", ",", "cells", ")", "in", "self", ":", "area", "+=", "(", "len", "(", "cells", ")", "*", "pi", ")", "/", "(", "3", "*", "4", "...
The area enclosed by the MOC, in steradians. >>> m = MOC(0, (0, 1, 2)) >>> round(m.area, 2) 3.14
[ "The", "area", "enclosed", "by", "the", "MOC", "in", "steradians", "." ]
train
https://github.com/grahambell/pymoc/blob/0e2e57ce07ff3de6ac024627c1fb6ad30c2fde48/lib/pymoc/moc.py#L336-L350
grahambell/pymoc
lib/pymoc/moc.py
MOC.cells
def cells(self): """The number of cells in the MOC. This gives the total number of cells at all orders, with cells from every order counted equally. >>> m = MOC(0, (1, 2)) >>> m.cells 2 """ n = 0 for (order, cells) in self: n += len...
python
def cells(self): """The number of cells in the MOC. This gives the total number of cells at all orders, with cells from every order counted equally. >>> m = MOC(0, (1, 2)) >>> m.cells 2 """ n = 0 for (order, cells) in self: n += len...
[ "def", "cells", "(", "self", ")", ":", "n", "=", "0", "for", "(", "order", ",", "cells", ")", "in", "self", ":", "n", "+=", "len", "(", "cells", ")", "return", "n" ]
The number of cells in the MOC. This gives the total number of cells at all orders, with cells from every order counted equally. >>> m = MOC(0, (1, 2)) >>> m.cells 2
[ "The", "number", "of", "cells", "in", "the", "MOC", "." ]
train
https://github.com/grahambell/pymoc/blob/0e2e57ce07ff3de6ac024627c1fb6ad30c2fde48/lib/pymoc/moc.py#L365-L381
grahambell/pymoc
lib/pymoc/moc.py
MOC.add
def add(self, order, cells, no_validation=False): """Add cells at a given order to the MOC. The cells are inserted into the MOC at the specified order. This leaves the MOC in an un-normalized state. The cells are given as a collection of integers (or types which can be converted ...
python
def add(self, order, cells, no_validation=False): """Add cells at a given order to the MOC. The cells are inserted into the MOC at the specified order. This leaves the MOC in an un-normalized state. The cells are given as a collection of integers (or types which can be converted ...
[ "def", "add", "(", "self", ",", "order", ",", "cells", ",", "no_validation", "=", "False", ")", ":", "self", ".", "_normalized", "=", "False", "order", "=", "self", ".", "_validate_order", "(", "order", ")", "if", "no_validation", ":", "# Simply add the gi...
Add cells at a given order to the MOC. The cells are inserted into the MOC at the specified order. This leaves the MOC in an un-normalized state. The cells are given as a collection of integers (or types which can be converted to integers). >>> m = MOC() >>> m.add(4, ...
[ "Add", "cells", "at", "a", "given", "order", "to", "the", "MOC", "." ]
train
https://github.com/grahambell/pymoc/blob/0e2e57ce07ff3de6ac024627c1fb6ad30c2fde48/lib/pymoc/moc.py#L383-L420
grahambell/pymoc
lib/pymoc/moc.py
MOC.remove
def remove(self, order, cells): """Remove cells at a given order from the MOC. """ self._normalized = False order = self._validate_order(order) for cell in cells: cell = self._validate_cell(order, cell) self._compare_operation(order, cell, True, 'remov...
python
def remove(self, order, cells): """Remove cells at a given order from the MOC. """ self._normalized = False order = self._validate_order(order) for cell in cells: cell = self._validate_cell(order, cell) self._compare_operation(order, cell, True, 'remov...
[ "def", "remove", "(", "self", ",", "order", ",", "cells", ")", ":", "self", ".", "_normalized", "=", "False", "order", "=", "self", ".", "_validate_order", "(", "order", ")", "for", "cell", "in", "cells", ":", "cell", "=", "self", ".", "_validate_cell"...
Remove cells at a given order from the MOC.
[ "Remove", "cells", "at", "a", "given", "order", "from", "the", "MOC", "." ]
train
https://github.com/grahambell/pymoc/blob/0e2e57ce07ff3de6ac024627c1fb6ad30c2fde48/lib/pymoc/moc.py#L422-L433
grahambell/pymoc
lib/pymoc/moc.py
MOC.clear
def clear(self): """Clears all cells from a MOC. >>> m = MOC(4, (5, 6)) >>> m.clear() >>> m.cells 0 """ for order in range(0, MAX_ORDER + 1): self._orders[order].clear() self._normalized = True
python
def clear(self): """Clears all cells from a MOC. >>> m = MOC(4, (5, 6)) >>> m.clear() >>> m.cells 0 """ for order in range(0, MAX_ORDER + 1): self._orders[order].clear() self._normalized = True
[ "def", "clear", "(", "self", ")", ":", "for", "order", "in", "range", "(", "0", ",", "MAX_ORDER", "+", "1", ")", ":", "self", ".", "_orders", "[", "order", "]", ".", "clear", "(", ")", "self", ".", "_normalized", "=", "True" ]
Clears all cells from a MOC. >>> m = MOC(4, (5, 6)) >>> m.clear() >>> m.cells 0
[ "Clears", "all", "cells", "from", "a", "MOC", "." ]
train
https://github.com/grahambell/pymoc/blob/0e2e57ce07ff3de6ac024627c1fb6ad30c2fde48/lib/pymoc/moc.py#L435-L447
grahambell/pymoc
lib/pymoc/moc.py
MOC.copy
def copy(self): """Return a copy of a MOC. >>> p = MOC(4, (5, 6)) >>> q = p.copy() >>> repr(q) '<MOC: [(4, [5, 6])]>' """ copy = MOC(name=self.name, mocid=self.id, origin=self.origin, moctype=self.type) copy += self return co...
python
def copy(self): """Return a copy of a MOC. >>> p = MOC(4, (5, 6)) >>> q = p.copy() >>> repr(q) '<MOC: [(4, [5, 6])]>' """ copy = MOC(name=self.name, mocid=self.id, origin=self.origin, moctype=self.type) copy += self return co...
[ "def", "copy", "(", "self", ")", ":", "copy", "=", "MOC", "(", "name", "=", "self", ".", "name", ",", "mocid", "=", "self", ".", "id", ",", "origin", "=", "self", ".", "origin", ",", "moctype", "=", "self", ".", "type", ")", "copy", "+=", "self...
Return a copy of a MOC. >>> p = MOC(4, (5, 6)) >>> q = p.copy() >>> repr(q) '<MOC: [(4, [5, 6])]>'
[ "Return", "a", "copy", "of", "a", "MOC", "." ]
train
https://github.com/grahambell/pymoc/blob/0e2e57ce07ff3de6ac024627c1fb6ad30c2fde48/lib/pymoc/moc.py#L449-L463
grahambell/pymoc
lib/pymoc/moc.py
MOC.contains
def contains(self, order, cell, include_smaller=False): """Test whether the MOC contains the given cell. If the include_smaller argument is true then the MOC is considered to include a cell if it includes part of that cell (at a higher order). >>> m = MOC(1, (5,)) >>> m...
python
def contains(self, order, cell, include_smaller=False): """Test whether the MOC contains the given cell. If the include_smaller argument is true then the MOC is considered to include a cell if it includes part of that cell (at a higher order). >>> m = MOC(1, (5,)) >>> m...
[ "def", "contains", "(", "self", ",", "order", ",", "cell", ",", "include_smaller", "=", "False", ")", ":", "order", "=", "self", ".", "_validate_order", "(", "order", ")", "cell", "=", "self", ".", "_validate_cell", "(", "order", ",", "cell", ")", "ret...
Test whether the MOC contains the given cell. If the include_smaller argument is true then the MOC is considered to include a cell if it includes part of that cell (at a higher order). >>> m = MOC(1, (5,)) >>> m.contains(0, 0) False >>> m.contains(0, 1, True) ...
[ "Test", "whether", "the", "MOC", "contains", "the", "given", "cell", "." ]
train
https://github.com/grahambell/pymoc/blob/0e2e57ce07ff3de6ac024627c1fb6ad30c2fde48/lib/pymoc/moc.py#L465-L492
grahambell/pymoc
lib/pymoc/moc.py
MOC._compare_operation
def _compare_operation(self, order, cell, include_smaller, operation): """General internal method for comparison-based operations. This is a private method, and does not update the normalized flag. """ # Check for a larger cell (lower order) which contains the # given c...
python
def _compare_operation(self, order, cell, include_smaller, operation): """General internal method for comparison-based operations. This is a private method, and does not update the normalized flag. """ # Check for a larger cell (lower order) which contains the # given c...
[ "def", "_compare_operation", "(", "self", ",", "order", ",", "cell", ",", "include_smaller", ",", "operation", ")", ":", "# Check for a larger cell (lower order) which contains the", "# given cell.", "for", "order_i", "in", "range", "(", "0", ",", "order", ")", ":",...
General internal method for comparison-based operations. This is a private method, and does not update the normalized flag.
[ "General", "internal", "method", "for", "comparison", "-", "based", "operations", "." ]
train
https://github.com/grahambell/pymoc/blob/0e2e57ce07ff3de6ac024627c1fb6ad30c2fde48/lib/pymoc/moc.py#L494-L558
grahambell/pymoc
lib/pymoc/moc.py
MOC.intersection
def intersection(self, other): """Returns a MOC representing the intersection with another MOC. >>> p = MOC(2, (3, 4, 5)) >>> q = MOC(2, (4, 5, 6)) >>> p.intersection(q) <MOC: [(2, [4, 5])]> """ inter = MOC() for (order, cells) in other: for...
python
def intersection(self, other): """Returns a MOC representing the intersection with another MOC. >>> p = MOC(2, (3, 4, 5)) >>> q = MOC(2, (4, 5, 6)) >>> p.intersection(q) <MOC: [(2, [4, 5])]> """ inter = MOC() for (order, cells) in other: for...
[ "def", "intersection", "(", "self", ",", "other", ")", ":", "inter", "=", "MOC", "(", ")", "for", "(", "order", ",", "cells", ")", "in", "other", ":", "for", "cell", "in", "cells", ":", "for", "i", "in", "self", ".", "_compare_operation", "(", "ord...
Returns a MOC representing the intersection with another MOC. >>> p = MOC(2, (3, 4, 5)) >>> q = MOC(2, (4, 5, 6)) >>> p.intersection(q) <MOC: [(2, [4, 5])]>
[ "Returns", "a", "MOC", "representing", "the", "intersection", "with", "another", "MOC", "." ]
train
https://github.com/grahambell/pymoc/blob/0e2e57ce07ff3de6ac024627c1fb6ad30c2fde48/lib/pymoc/moc.py#L560-L576
grahambell/pymoc
lib/pymoc/moc.py
MOC.normalize
def normalize(self, max_order=MAX_ORDER): """Ensure that the MOC is "well-formed". This structures the MOC as is required for the FITS and JSON representation. This method is invoked automatically when writing to these formats. The number of cells in the MOC will be minimized,...
python
def normalize(self, max_order=MAX_ORDER): """Ensure that the MOC is "well-formed". This structures the MOC as is required for the FITS and JSON representation. This method is invoked automatically when writing to these formats. The number of cells in the MOC will be minimized,...
[ "def", "normalize", "(", "self", ",", "max_order", "=", "MAX_ORDER", ")", ":", "max_order", "=", "self", ".", "_validate_order", "(", "max_order", ")", "# If the MOC is already normalized and we are not being asked", "# to reduce the order, then do nothing.", "if", "self", ...
Ensure that the MOC is "well-formed". This structures the MOC as is required for the FITS and JSON representation. This method is invoked automatically when writing to these formats. The number of cells in the MOC will be minimized, so that no area of the sky is covered multip...
[ "Ensure", "that", "the", "MOC", "is", "well", "-", "formed", "." ]
train
https://github.com/grahambell/pymoc/blob/0e2e57ce07ff3de6ac024627c1fb6ad30c2fde48/lib/pymoc/moc.py#L578-L657
grahambell/pymoc
lib/pymoc/moc.py
MOC.flattened
def flattened(self, order=None, include_smaller=True): """Return a flattened pixel collection at a single order.""" if order is None: order = self.order else: order = self._validate_order(order) # Start with the cells which are already at this order. fla...
python
def flattened(self, order=None, include_smaller=True): """Return a flattened pixel collection at a single order.""" if order is None: order = self.order else: order = self._validate_order(order) # Start with the cells which are already at this order. fla...
[ "def", "flattened", "(", "self", ",", "order", "=", "None", ",", "include_smaller", "=", "True", ")", ":", "if", "order", "is", "None", ":", "order", "=", "self", ".", "order", "else", ":", "order", "=", "self", ".", "_validate_order", "(", "order", ...
Return a flattened pixel collection at a single order.
[ "Return", "a", "flattened", "pixel", "collection", "at", "a", "single", "order", "." ]
train
https://github.com/grahambell/pymoc/blob/0e2e57ce07ff3de6ac024627c1fb6ad30c2fde48/lib/pymoc/moc.py#L659-L688
grahambell/pymoc
lib/pymoc/moc.py
MOC.read
def read(self, filename, filetype=None, include_meta=False, **kwargs): """Read data from the given file into the MOC object. The cell lists read from the file are added to the current object. Therefore if the object already contains some cells, it will be updated to represent the union...
python
def read(self, filename, filetype=None, include_meta=False, **kwargs): """Read data from the given file into the MOC object. The cell lists read from the file are added to the current object. Therefore if the object already contains some cells, it will be updated to represent the union...
[ "def", "read", "(", "self", ",", "filename", ",", "filetype", "=", "None", ",", "include_meta", "=", "False", ",", "*", "*", "kwargs", ")", ":", "if", "filetype", "is", "not", "None", ":", "filetype", "=", "filetype", ".", "lower", "(", ")", "else", ...
Read data from the given file into the MOC object. The cell lists read from the file are added to the current object. Therefore if the object already contains some cells, it will be updated to represent the union of the current coverge and that from the file. The file type can...
[ "Read", "data", "from", "the", "given", "file", "into", "the", "MOC", "object", "." ]
train
https://github.com/grahambell/pymoc/blob/0e2e57ce07ff3de6ac024627c1fb6ad30c2fde48/lib/pymoc/moc.py#L690-L729
grahambell/pymoc
lib/pymoc/moc.py
MOC.write
def write(self, filename, filetype=None, **kwargs): """Write the coverage data in the MOC object to a file. The filetype can be given or left to be inferred as for the read method. Any additional keyword arguments (kwargs) are passed on to the corresponding pymoc.io write funct...
python
def write(self, filename, filetype=None, **kwargs): """Write the coverage data in the MOC object to a file. The filetype can be given or left to be inferred as for the read method. Any additional keyword arguments (kwargs) are passed on to the corresponding pymoc.io write funct...
[ "def", "write", "(", "self", ",", "filename", ",", "filetype", "=", "None", ",", "*", "*", "kwargs", ")", ":", "if", "filetype", "is", "not", "None", ":", "filetype", "=", "filetype", ".", "lower", "(", ")", "else", ":", "filetype", "=", "self", "....
Write the coverage data in the MOC object to a file. The filetype can be given or left to be inferred as for the read method. Any additional keyword arguments (kwargs) are passed on to the corresponding pymoc.io write functions (write_moc_fits, write_moc_json or write_moc_ascii...
[ "Write", "the", "coverage", "data", "in", "the", "MOC", "object", "to", "a", "file", "." ]
train
https://github.com/grahambell/pymoc/blob/0e2e57ce07ff3de6ac024627c1fb6ad30c2fde48/lib/pymoc/moc.py#L731-L762
grahambell/pymoc
lib/pymoc/moc.py
MOC._guess_file_type
def _guess_file_type(self, filename): """Attempt to guess the type of a MOC file. Returns "fits", "json" or "ascii" if successful and raised a ValueError otherwise. """ # First attempt to guess from the file name. namelc = filename.lower() if namelc.endswith('....
python
def _guess_file_type(self, filename): """Attempt to guess the type of a MOC file. Returns "fits", "json" or "ascii" if successful and raised a ValueError otherwise. """ # First attempt to guess from the file name. namelc = filename.lower() if namelc.endswith('....
[ "def", "_guess_file_type", "(", "self", ",", "filename", ")", ":", "# First attempt to guess from the file name.", "namelc", "=", "filename", ".", "lower", "(", ")", "if", "namelc", ".", "endswith", "(", "'.fits'", ")", "or", "namelc", ".", "endswith", "(", "'...
Attempt to guess the type of a MOC file. Returns "fits", "json" or "ascii" if successful and raised a ValueError otherwise.
[ "Attempt", "to", "guess", "the", "type", "of", "a", "MOC", "file", "." ]
train
https://github.com/grahambell/pymoc/blob/0e2e57ce07ff3de6ac024627c1fb6ad30c2fde48/lib/pymoc/moc.py#L764-L793
grahambell/pymoc
lib/pymoc/moc.py
MOC._validate_order
def _validate_order(self, order): """Check that the given order is valid.""" try: order = int(order) except ValueError as e: raise TypeError('MOC order must be convertable to int') if not 0 <= order <= MAX_ORDER: raise ValueError( 'MO...
python
def _validate_order(self, order): """Check that the given order is valid.""" try: order = int(order) except ValueError as e: raise TypeError('MOC order must be convertable to int') if not 0 <= order <= MAX_ORDER: raise ValueError( 'MO...
[ "def", "_validate_order", "(", "self", ",", "order", ")", ":", "try", ":", "order", "=", "int", "(", "order", ")", "except", "ValueError", "as", "e", ":", "raise", "TypeError", "(", "'MOC order must be convertable to int'", ")", "if", "not", "0", "<=", "or...
Check that the given order is valid.
[ "Check", "that", "the", "given", "order", "is", "valid", "." ]
train
https://github.com/grahambell/pymoc/blob/0e2e57ce07ff3de6ac024627c1fb6ad30c2fde48/lib/pymoc/moc.py#L800-L812
grahambell/pymoc
lib/pymoc/moc.py
MOC._validate_cell
def _validate_cell(self, order, cell): """Check that the given cell is valid. The order is assumed already to have been validated. """ max_cells = self._order_num_cells(order) try: cell = int(cell) except ValueError as e: raise TypeError('MOC ce...
python
def _validate_cell(self, order, cell): """Check that the given cell is valid. The order is assumed already to have been validated. """ max_cells = self._order_num_cells(order) try: cell = int(cell) except ValueError as e: raise TypeError('MOC ce...
[ "def", "_validate_cell", "(", "self", ",", "order", ",", "cell", ")", ":", "max_cells", "=", "self", ".", "_order_num_cells", "(", "order", ")", "try", ":", "cell", "=", "int", "(", "cell", ")", "except", "ValueError", "as", "e", ":", "raise", "TypeErr...
Check that the given cell is valid. The order is assumed already to have been validated.
[ "Check", "that", "the", "given", "cell", "is", "valid", "." ]
train
https://github.com/grahambell/pymoc/blob/0e2e57ce07ff3de6ac024627c1fb6ad30c2fde48/lib/pymoc/moc.py#L814-L832
jantman/webhook2lambda2sqs
webhook2lambda2sqs/lambda_func.py
webhook2lambda2sqs_handler
def webhook2lambda2sqs_handler(event, context): """ Main entry point/handler for the lambda function. Wraps :py:func:`~.handle_event` to ensure that we log detailed information if it raises an exception. :param event: Lambda event that triggered the handler :type event: dict :param context:...
python
def webhook2lambda2sqs_handler(event, context): """ Main entry point/handler for the lambda function. Wraps :py:func:`~.handle_event` to ensure that we log detailed information if it raises an exception. :param event: Lambda event that triggered the handler :type event: dict :param context:...
[ "def", "webhook2lambda2sqs_handler", "(", "event", ",", "context", ")", ":", "# be sure we log full information about any error; if handle_event()", "# raises an exception, log a bunch of information at error level and then", "# re-raise the Exception", "try", ":", "res", "=", "handle_...
Main entry point/handler for the lambda function. Wraps :py:func:`~.handle_event` to ensure that we log detailed information if it raises an exception. :param event: Lambda event that triggered the handler :type event: dict :param context: Lambda function context - see http://docs.aws.amazon....
[ "Main", "entry", "point", "/", "handler", "for", "the", "lambda", "function", ".", "Wraps", ":", "py", ":", "func", ":", "~", ".", "handle_event", "to", "ensure", "that", "we", "log", "detailed", "information", "if", "it", "raises", "an", "exception", "....
train
https://github.com/jantman/webhook2lambda2sqs/blob/c80c18d5a908ba8b8ee624dc3a977c633fba2b7c/webhook2lambda2sqs/lambda_func.py#L34-L63
jantman/webhook2lambda2sqs
webhook2lambda2sqs/lambda_func.py
queues_for_endpoint
def queues_for_endpoint(event): """ Return the list of queues to publish to for a given endpoint. :param event: Lambda event that triggered the handler :type event: dict :return: list of queues for endpoint :rtype: :std:term:`list` :raises: Exception """ global endpoints # endpoint...
python
def queues_for_endpoint(event): """ Return the list of queues to publish to for a given endpoint. :param event: Lambda event that triggered the handler :type event: dict :return: list of queues for endpoint :rtype: :std:term:`list` :raises: Exception """ global endpoints # endpoint...
[ "def", "queues_for_endpoint", "(", "event", ")", ":", "global", "endpoints", "# endpoint config that's templated in by generator", "# get endpoint config", "try", ":", "ep_name", "=", "event", "[", "'context'", "]", "[", "'resource-path'", "]", ".", "lstrip", "(", "'/...
Return the list of queues to publish to for a given endpoint. :param event: Lambda event that triggered the handler :type event: dict :return: list of queues for endpoint :rtype: :std:term:`list` :raises: Exception
[ "Return", "the", "list", "of", "queues", "to", "publish", "to", "for", "a", "given", "endpoint", "." ]
train
https://github.com/jantman/webhook2lambda2sqs/blob/c80c18d5a908ba8b8ee624dc3a977c633fba2b7c/webhook2lambda2sqs/lambda_func.py#L66-L82
jantman/webhook2lambda2sqs
webhook2lambda2sqs/lambda_func.py
msg_body_for_event
def msg_body_for_event(event, context): """ Generate the JSON-serialized message body for an event. :param event: Lambda event that triggered the handler :type event: dict :param context: Lambda function context - see http://docs.aws.amazon.com/lambda/latest/dg/python-context-object.html ...
python
def msg_body_for_event(event, context): """ Generate the JSON-serialized message body for an event. :param event: Lambda event that triggered the handler :type event: dict :param context: Lambda function context - see http://docs.aws.amazon.com/lambda/latest/dg/python-context-object.html ...
[ "def", "msg_body_for_event", "(", "event", ",", "context", ")", ":", "# find the actual input data - this differs between GET and POST", "http_method", "=", "event", ".", "get", "(", "'context'", ",", "{", "}", ")", ".", "get", "(", "'http-method'", ",", "None", "...
Generate the JSON-serialized message body for an event. :param event: Lambda event that triggered the handler :type event: dict :param context: Lambda function context - see http://docs.aws.amazon.com/lambda/latest/dg/python-context-object.html :return: JSON-serialized success response :rtype...
[ "Generate", "the", "JSON", "-", "serialized", "message", "body", "for", "an", "event", "." ]
train
https://github.com/jantman/webhook2lambda2sqs/blob/c80c18d5a908ba8b8ee624dc3a977c633fba2b7c/webhook2lambda2sqs/lambda_func.py#L85-L110
jantman/webhook2lambda2sqs
webhook2lambda2sqs/lambda_func.py
handle_event
def handle_event(event, context): """ Do the actual event handling - try to enqueue the request. :param event: Lambda event that triggered the handler :type event: dict :param context: Lambda function context - see http://docs.aws.amazon.com/lambda/latest/dg/python-context-object.html :re...
python
def handle_event(event, context): """ Do the actual event handling - try to enqueue the request. :param event: Lambda event that triggered the handler :type event: dict :param context: Lambda function context - see http://docs.aws.amazon.com/lambda/latest/dg/python-context-object.html :re...
[ "def", "handle_event", "(", "event", ",", "context", ")", ":", "queues", "=", "queues_for_endpoint", "(", "event", ")", "# store some state", "msg_ids", "=", "[", "]", "failed", "=", "0", "# get the message to enqueue", "msg", "=", "msg_body_for_event", "(", "ev...
Do the actual event handling - try to enqueue the request. :param event: Lambda event that triggered the handler :type event: dict :param context: Lambda function context - see http://docs.aws.amazon.com/lambda/latest/dg/python-context-object.html :return: JSON-serialized success response :rt...
[ "Do", "the", "actual", "event", "handling", "-", "try", "to", "enqueue", "the", "request", "." ]
train
https://github.com/jantman/webhook2lambda2sqs/blob/c80c18d5a908ba8b8ee624dc3a977c633fba2b7c/webhook2lambda2sqs/lambda_func.py#L113-L149
jantman/webhook2lambda2sqs
webhook2lambda2sqs/lambda_func.py
try_enqueue
def try_enqueue(conn, queue_name, msg): """ Try to enqueue a message. If it succeeds, return the message ID. :param conn: SQS API connection :type conn: :py:class:`botocore:SQS.Client` :param queue_name: name of queue to put message in :type queue_name: str :param msg: JSON-serialized messa...
python
def try_enqueue(conn, queue_name, msg): """ Try to enqueue a message. If it succeeds, return the message ID. :param conn: SQS API connection :type conn: :py:class:`botocore:SQS.Client` :param queue_name: name of queue to put message in :type queue_name: str :param msg: JSON-serialized messa...
[ "def", "try_enqueue", "(", "conn", ",", "queue_name", ",", "msg", ")", ":", "logger", ".", "debug", "(", "'Getting Queue URL for queue %s'", ",", "queue_name", ")", "qurl", "=", "conn", ".", "get_queue_url", "(", "QueueName", "=", "queue_name", ")", "[", "'Q...
Try to enqueue a message. If it succeeds, return the message ID. :param conn: SQS API connection :type conn: :py:class:`botocore:SQS.Client` :param queue_name: name of queue to put message in :type queue_name: str :param msg: JSON-serialized message body :type msg: str :return: message ID ...
[ "Try", "to", "enqueue", "a", "message", ".", "If", "it", "succeeds", "return", "the", "message", "ID", "." ]
train
https://github.com/jantman/webhook2lambda2sqs/blob/c80c18d5a908ba8b8ee624dc3a977c633fba2b7c/webhook2lambda2sqs/lambda_func.py#L152-L175
jantman/webhook2lambda2sqs
webhook2lambda2sqs/lambda_func.py
serializable_dict
def serializable_dict(d): """ Return a dict like d, but with any un-json-serializable elements removed. """ newd = {} for k in d.keys(): if isinstance(d[k], type({})): newd[k] = serializable_dict(d[k]) continue try: json.dumps({'k': d[k]}) ...
python
def serializable_dict(d): """ Return a dict like d, but with any un-json-serializable elements removed. """ newd = {} for k in d.keys(): if isinstance(d[k], type({})): newd[k] = serializable_dict(d[k]) continue try: json.dumps({'k': d[k]}) ...
[ "def", "serializable_dict", "(", "d", ")", ":", "newd", "=", "{", "}", "for", "k", "in", "d", ".", "keys", "(", ")", ":", "if", "isinstance", "(", "d", "[", "k", "]", ",", "type", "(", "{", "}", ")", ")", ":", "newd", "[", "k", "]", "=", ...
Return a dict like d, but with any un-json-serializable elements removed.
[ "Return", "a", "dict", "like", "d", "but", "with", "any", "un", "-", "json", "-", "serializable", "elements", "removed", "." ]
train
https://github.com/jantman/webhook2lambda2sqs/blob/c80c18d5a908ba8b8ee624dc3a977c633fba2b7c/webhook2lambda2sqs/lambda_func.py#L178-L192
Fantomas42/mots-vides
mots_vides/scripts/rebaser.py
cmdline
def cmdline(argv=sys.argv[1:]): """ Script for rebasing a text file """ parser = ArgumentParser( description='Rebase a text from his stop words') parser.add_argument('language', help='The language used to rebase') parser.add_argument('source', help='Text file to rebase') options = pa...
python
def cmdline(argv=sys.argv[1:]): """ Script for rebasing a text file """ parser = ArgumentParser( description='Rebase a text from his stop words') parser.add_argument('language', help='The language used to rebase') parser.add_argument('source', help='Text file to rebase') options = pa...
[ "def", "cmdline", "(", "argv", "=", "sys", ".", "argv", "[", "1", ":", "]", ")", ":", "parser", "=", "ArgumentParser", "(", "description", "=", "'Rebase a text from his stop words'", ")", "parser", ".", "add_argument", "(", "'language'", ",", "help", "=", ...
Script for rebasing a text file
[ "Script", "for", "rebasing", "a", "text", "file" ]
train
https://github.com/Fantomas42/mots-vides/blob/eaeccf73bdb415d0c5559ccd74de360b37a2bbac/mots_vides/scripts/rebaser.py#L11-L25
Robin8Put/pmes
history/MongoDB/models.py
MongoStorage.create
def create(self, data): """Creates new entry in mongo database """ q = self.history.insert_one(data).inserted_id logging.debug(self.history.find_one({"_id":q}))
python
def create(self, data): """Creates new entry in mongo database """ q = self.history.insert_one(data).inserted_id logging.debug(self.history.find_one({"_id":q}))
[ "def", "create", "(", "self", ",", "data", ")", ":", "q", "=", "self", ".", "history", ".", "insert_one", "(", "data", ")", ".", "inserted_id", "logging", ".", "debug", "(", "self", ".", "history", ".", "find_one", "(", "{", "\"_id\"", ":", "q", "}...
Creates new entry in mongo database
[ "Creates", "new", "entry", "in", "mongo", "database" ]
train
https://github.com/Robin8Put/pmes/blob/338bec94162098f05b75bad035417317e1252fd2/history/MongoDB/models.py#L34-L38
adammck/djtables
lib/djtables/table.py
Table.get_url
def get_url(self, **kwargs): """ Return an url, relative to the request associated with this table. Any keywords arguments provided added to the query string, replacing existing values. """ return build( self._request.path, self._request.GET, ...
python
def get_url(self, **kwargs): """ Return an url, relative to the request associated with this table. Any keywords arguments provided added to the query string, replacing existing values. """ return build( self._request.path, self._request.GET, ...
[ "def", "get_url", "(", "self", ",", "*", "*", "kwargs", ")", ":", "return", "build", "(", "self", ".", "_request", ".", "path", ",", "self", ".", "_request", ".", "GET", ",", "self", ".", "_meta", ".", "prefix", ",", "*", "*", "kwargs", ")" ]
Return an url, relative to the request associated with this table. Any keywords arguments provided added to the query string, replacing existing values.
[ "Return", "an", "url", "relative", "to", "the", "request", "associated", "with", "this", "table", ".", "Any", "keywords", "arguments", "provided", "added", "to", "the", "query", "string", "replacing", "existing", "values", "." ]
train
https://github.com/adammck/djtables/blob/8fa279e7088123f00cca9c838fe028ebf327325e/lib/djtables/table.py#L27-L38
adammck/djtables
lib/djtables/table.py
Table.object_list
def object_list(self): """ Return this table's object_list, transformed (sorted, reversed, filtered, etc) according to its meta options. """ def _sort(ob, ol): reverse = ob.startswith("-") ob = ob[1:] if reverse else ob for column in self.colu...
python
def object_list(self): """ Return this table's object_list, transformed (sorted, reversed, filtered, etc) according to its meta options. """ def _sort(ob, ol): reverse = ob.startswith("-") ob = ob[1:] if reverse else ob for column in self.colu...
[ "def", "object_list", "(", "self", ")", ":", "def", "_sort", "(", "ob", ",", "ol", ")", ":", "reverse", "=", "ob", ".", "startswith", "(", "\"-\"", ")", "ob", "=", "ob", "[", "1", ":", "]", "if", "reverse", "else", "ob", "for", "column", "in", ...
Return this table's object_list, transformed (sorted, reversed, filtered, etc) according to its meta options.
[ "Return", "this", "table", "s", "object_list", "transformed", "(", "sorted", "reversed", "filtered", "etc", ")", "according", "to", "its", "meta", "options", "." ]
train
https://github.com/adammck/djtables/blob/8fa279e7088123f00cca9c838fe028ebf327325e/lib/djtables/table.py#L41-L66
adammck/djtables
lib/djtables/table.py
Table.rows
def rows(self): """Return the list of object on the active page.""" return map( lambda o: self._meta.row_class(self, o), self.paginator.page(self._meta.page).object_list )
python
def rows(self): """Return the list of object on the active page.""" return map( lambda o: self._meta.row_class(self, o), self.paginator.page(self._meta.page).object_list )
[ "def", "rows", "(", "self", ")", ":", "return", "map", "(", "lambda", "o", ":", "self", ".", "_meta", ".", "row_class", "(", "self", ",", "o", ")", ",", "self", ".", "paginator", ".", "page", "(", "self", ".", "_meta", ".", "page", ")", ".", "o...
Return the list of object on the active page.
[ "Return", "the", "list", "of", "object", "on", "the", "active", "page", "." ]
train
https://github.com/adammck/djtables/blob/8fa279e7088123f00cca9c838fe028ebf327325e/lib/djtables/table.py#L98-L103
welchbj/sublemon
sublemon/subprocess.py
SublemonSubprocess.spawn
async def spawn(self): """Spawn the command wrapped in this object as a subprocess.""" self._server._pending_set.add(self) await self._server._sem.acquire() self._subprocess = await asyncio.create_subprocess_shell( self._cmd, stdout=asyncio.subprocess.PIPE, ...
python
async def spawn(self): """Spawn the command wrapped in this object as a subprocess.""" self._server._pending_set.add(self) await self._server._sem.acquire() self._subprocess = await asyncio.create_subprocess_shell( self._cmd, stdout=asyncio.subprocess.PIPE, ...
[ "async", "def", "spawn", "(", "self", ")", ":", "self", ".", "_server", ".", "_pending_set", ".", "add", "(", "self", ")", "await", "self", ".", "_server", ".", "_sem", ".", "acquire", "(", ")", "self", ".", "_subprocess", "=", "await", "asyncio", "....
Spawn the command wrapped in this object as a subprocess.
[ "Spawn", "the", "command", "wrapped", "in", "this", "object", "as", "a", "subprocess", "." ]
train
https://github.com/welchbj/sublemon/blob/edbfd1ca2a0ce3de9470dfc88f8db1cadf4b6326/sublemon/subprocess.py#L49-L61
welchbj/sublemon
sublemon/subprocess.py
SublemonSubprocess.wait_done
async def wait_done(self) -> int: """Coroutine to wait for subprocess run completion. Returns: The exit code of the subprocess. """ await self._done_running_evt.wait() if self._exit_code is None: raise SublemonLifetimeError( 'Subprocess e...
python
async def wait_done(self) -> int: """Coroutine to wait for subprocess run completion. Returns: The exit code of the subprocess. """ await self._done_running_evt.wait() if self._exit_code is None: raise SublemonLifetimeError( 'Subprocess e...
[ "async", "def", "wait_done", "(", "self", ")", "->", "int", ":", "await", "self", ".", "_done_running_evt", ".", "wait", "(", ")", "if", "self", ".", "_exit_code", "is", "None", ":", "raise", "SublemonLifetimeError", "(", "'Subprocess exited abnormally with `Non...
Coroutine to wait for subprocess run completion. Returns: The exit code of the subprocess.
[ "Coroutine", "to", "wait", "for", "subprocess", "run", "completion", "." ]
train
https://github.com/welchbj/sublemon/blob/edbfd1ca2a0ce3de9470dfc88f8db1cadf4b6326/sublemon/subprocess.py#L67-L78
welchbj/sublemon
sublemon/subprocess.py
SublemonSubprocess._poll
def _poll(self) -> None: """Check the status of the wrapped running subprocess. Note: This should only be called on currently-running tasks. """ if self._subprocess is None: raise SublemonLifetimeError( 'Attempted to poll a non-active subprocess'...
python
def _poll(self) -> None: """Check the status of the wrapped running subprocess. Note: This should only be called on currently-running tasks. """ if self._subprocess is None: raise SublemonLifetimeError( 'Attempted to poll a non-active subprocess'...
[ "def", "_poll", "(", "self", ")", "->", "None", ":", "if", "self", ".", "_subprocess", "is", "None", ":", "raise", "SublemonLifetimeError", "(", "'Attempted to poll a non-active subprocess'", ")", "elif", "self", ".", "_subprocess", ".", "returncode", "is", "not...
Check the status of the wrapped running subprocess. Note: This should only be called on currently-running tasks.
[ "Check", "the", "status", "of", "the", "wrapped", "running", "subprocess", "." ]
train
https://github.com/welchbj/sublemon/blob/edbfd1ca2a0ce3de9470dfc88f8db1cadf4b6326/sublemon/subprocess.py#L80-L94
welchbj/sublemon
sublemon/subprocess.py
SublemonSubprocess.stdout
async def stdout(self) -> AsyncGenerator[str, None]: """Asynchronous generator for lines from subprocess stdout.""" await self.wait_running() async for line in self._subprocess.stdout: # type: ignore yield line
python
async def stdout(self) -> AsyncGenerator[str, None]: """Asynchronous generator for lines from subprocess stdout.""" await self.wait_running() async for line in self._subprocess.stdout: # type: ignore yield line
[ "async", "def", "stdout", "(", "self", ")", "->", "AsyncGenerator", "[", "str", ",", "None", "]", ":", "await", "self", ".", "wait_running", "(", ")", "async", "for", "line", "in", "self", ".", "_subprocess", ".", "stdout", ":", "# type: ignore", "yield"...
Asynchronous generator for lines from subprocess stdout.
[ "Asynchronous", "generator", "for", "lines", "from", "subprocess", "stdout", "." ]
train
https://github.com/welchbj/sublemon/blob/edbfd1ca2a0ce3de9470dfc88f8db1cadf4b6326/sublemon/subprocess.py#L97-L101
welchbj/sublemon
sublemon/subprocess.py
SublemonSubprocess.stderr
async def stderr(self) -> AsyncGenerator[str, None]: """Asynchronous generator for lines from subprocess stderr.""" await self.wait_running() async for line in self._subprocess.stderr: # type: ignore yield line
python
async def stderr(self) -> AsyncGenerator[str, None]: """Asynchronous generator for lines from subprocess stderr.""" await self.wait_running() async for line in self._subprocess.stderr: # type: ignore yield line
[ "async", "def", "stderr", "(", "self", ")", "->", "AsyncGenerator", "[", "str", ",", "None", "]", ":", "await", "self", ".", "wait_running", "(", ")", "async", "for", "line", "in", "self", ".", "_subprocess", ".", "stderr", ":", "# type: ignore", "yield"...
Asynchronous generator for lines from subprocess stderr.
[ "Asynchronous", "generator", "for", "lines", "from", "subprocess", "stderr", "." ]
train
https://github.com/welchbj/sublemon/blob/edbfd1ca2a0ce3de9470dfc88f8db1cadf4b6326/sublemon/subprocess.py#L104-L108
fchauvel/MAD
mad/simulation/tasks.py
Task._execute
def _execute(self, worker): """ This method is ASSIGNED during the evaluation to control how to resume it once it has been paused """ self._assert_status_is(TaskStatus.RUNNING) operation = worker.look_up(self.operation) operation.invoke(self, [], worker=worker)
python
def _execute(self, worker): """ This method is ASSIGNED during the evaluation to control how to resume it once it has been paused """ self._assert_status_is(TaskStatus.RUNNING) operation = worker.look_up(self.operation) operation.invoke(self, [], worker=worker)
[ "def", "_execute", "(", "self", ",", "worker", ")", ":", "self", ".", "_assert_status_is", "(", "TaskStatus", ".", "RUNNING", ")", "operation", "=", "worker", ".", "look_up", "(", "self", ".", "operation", ")", "operation", ".", "invoke", "(", "self", ",...
This method is ASSIGNED during the evaluation to control how to resume it once it has been paused
[ "This", "method", "is", "ASSIGNED", "during", "the", "evaluation", "to", "control", "how", "to", "resume", "it", "once", "it", "has", "been", "paused" ]
train
https://github.com/fchauvel/MAD/blob/806d5174848b1a502e5c683894995602478c448b/mad/simulation/tasks.py#L252-L258
adammck/djtables
lib/djtables/column.py
Column.bind_to
def bind_to(self, table, name): """ Bind this column to a table, and assign it a name. This method can only be called once per instance, because a Column cannot be bound to multiple tables. (The sort order would be ambiguous.) """ if self.bound_to is not None: ...
python
def bind_to(self, table, name): """ Bind this column to a table, and assign it a name. This method can only be called once per instance, because a Column cannot be bound to multiple tables. (The sort order would be ambiguous.) """ if self.bound_to is not None: ...
[ "def", "bind_to", "(", "self", ",", "table", ",", "name", ")", ":", "if", "self", ".", "bound_to", "is", "not", "None", ":", "raise", "AttributeError", "(", "\"Column is already bound to '%s' as '%s'\"", "%", "self", ".", "bound_to", ")", "self", ".", "bound...
Bind this column to a table, and assign it a name. This method can only be called once per instance, because a Column cannot be bound to multiple tables. (The sort order would be ambiguous.)
[ "Bind", "this", "column", "to", "a", "table", "and", "assign", "it", "a", "name", ".", "This", "method", "can", "only", "be", "called", "once", "per", "instance", "because", "a", "Column", "cannot", "be", "bound", "to", "multiple", "tables", ".", "(", ...
train
https://github.com/adammck/djtables/blob/8fa279e7088123f00cca9c838fe028ebf327325e/lib/djtables/column.py#L46-L57
adammck/djtables
lib/djtables/column.py
Column.value
def value(self, cell): """ Extract the value of ``cell``, ready to be rendered. If this Column was instantiated with a ``value`` attribute, it is called here to provide the value. (For example, to provide a calculated value.) Otherwise, ``cell.value`` is returned. """ ...
python
def value(self, cell): """ Extract the value of ``cell``, ready to be rendered. If this Column was instantiated with a ``value`` attribute, it is called here to provide the value. (For example, to provide a calculated value.) Otherwise, ``cell.value`` is returned. """ ...
[ "def", "value", "(", "self", ",", "cell", ")", ":", "if", "self", ".", "_value", "is", "not", "None", ":", "return", "self", ".", "_value", "(", "cell", ")", "else", ":", "return", "cell", ".", "value" ]
Extract the value of ``cell``, ready to be rendered. If this Column was instantiated with a ``value`` attribute, it is called here to provide the value. (For example, to provide a calculated value.) Otherwise, ``cell.value`` is returned.
[ "Extract", "the", "value", "of", "cell", "ready", "to", "be", "rendered", "." ]
train
https://github.com/adammck/djtables/blob/8fa279e7088123f00cca9c838fe028ebf327325e/lib/djtables/column.py#L81-L94
adammck/djtables
lib/djtables/column.py
Column.css_class
def css_class(self, cell): """Return the CSS class for this column.""" if isinstance(self._css_class, basestring): return self._css_class else: return self._css_class(cell)
python
def css_class(self, cell): """Return the CSS class for this column.""" if isinstance(self._css_class, basestring): return self._css_class else: return self._css_class(cell)
[ "def", "css_class", "(", "self", ",", "cell", ")", ":", "if", "isinstance", "(", "self", ".", "_css_class", ",", "basestring", ")", ":", "return", "self", ".", "_css_class", "else", ":", "return", "self", ".", "_css_class", "(", "cell", ")" ]
Return the CSS class for this column.
[ "Return", "the", "CSS", "class", "for", "this", "column", "." ]
train
https://github.com/adammck/djtables/blob/8fa279e7088123f00cca9c838fe028ebf327325e/lib/djtables/column.py#L141-L146
adammck/djtables
lib/djtables/column.py
WrappedColumn.sort_url
def sort_url(self): """ Return the URL to sort the linked table by this column. If the table is already sorted by this column, the order is reversed. Since there is no canonical URL for a table the current URL (via the HttpRequest linked to the Table instance) is reused, and any...
python
def sort_url(self): """ Return the URL to sort the linked table by this column. If the table is already sorted by this column, the order is reversed. Since there is no canonical URL for a table the current URL (via the HttpRequest linked to the Table instance) is reused, and any...
[ "def", "sort_url", "(", "self", ")", ":", "prefix", "=", "(", "self", ".", "sort_direction", "==", "\"asc\"", ")", "and", "\"-\"", "or", "\"\"", "return", "self", ".", "table", ".", "get_url", "(", "order_by", "=", "prefix", "+", "self", ".", "name", ...
Return the URL to sort the linked table by this column. If the table is already sorted by this column, the order is reversed. Since there is no canonical URL for a table the current URL (via the HttpRequest linked to the Table instance) is reused, and any unrelated parameters will be in...
[ "Return", "the", "URL", "to", "sort", "the", "linked", "table", "by", "this", "column", ".", "If", "the", "table", "is", "already", "sorted", "by", "this", "column", "the", "order", "is", "reversed", "." ]
train
https://github.com/adammck/djtables/blob/8fa279e7088123f00cca9c838fe028ebf327325e/lib/djtables/column.py#L191-L202
adammck/djtables
lib/djtables/column.py
WrappedColumn.sort_direction
def sort_direction(self): """ Return the direction in which the linked table is is sorted by this column ("asc" or "desc"), or None this column is unsorted. """ if self.table._meta.order_by == self.name: return "asc" elif self.table._meta.order_by == ("-" + ...
python
def sort_direction(self): """ Return the direction in which the linked table is is sorted by this column ("asc" or "desc"), or None this column is unsorted. """ if self.table._meta.order_by == self.name: return "asc" elif self.table._meta.order_by == ("-" + ...
[ "def", "sort_direction", "(", "self", ")", ":", "if", "self", ".", "table", ".", "_meta", ".", "order_by", "==", "self", ".", "name", ":", "return", "\"asc\"", "elif", "self", ".", "table", ".", "_meta", ".", "order_by", "==", "(", "\"-\"", "+", "sel...
Return the direction in which the linked table is is sorted by this column ("asc" or "desc"), or None this column is unsorted.
[ "Return", "the", "direction", "in", "which", "the", "linked", "table", "is", "is", "sorted", "by", "this", "column", "(", "asc", "or", "desc", ")", "or", "None", "this", "column", "is", "unsorted", "." ]
train
https://github.com/adammck/djtables/blob/8fa279e7088123f00cca9c838fe028ebf327325e/lib/djtables/column.py#L209-L222
grahame/sedge
sedge/cli.py
check_or_confirm_overwrite
def check_or_confirm_overwrite(file_name): """ Returns True if OK to proceed, False otherwise """ try: with open(file_name) as fd: header = next(fd) if header.find(':sedge:') == -1: okay = ask_overwrite(file_name) if okay: ...
python
def check_or_confirm_overwrite(file_name): """ Returns True if OK to proceed, False otherwise """ try: with open(file_name) as fd: header = next(fd) if header.find(':sedge:') == -1: okay = ask_overwrite(file_name) if okay: ...
[ "def", "check_or_confirm_overwrite", "(", "file_name", ")", ":", "try", ":", "with", "open", "(", "file_name", ")", "as", "fd", ":", "header", "=", "next", "(", "fd", ")", "if", "header", ".", "find", "(", "':sedge:'", ")", "==", "-", "1", ":", "okay...
Returns True if OK to proceed, False otherwise
[ "Returns", "True", "if", "OK", "to", "proceed", "False", "otherwise" ]
train
https://github.com/grahame/sedge/blob/60dc6a0c5ef3bf802fe48a2571a8524a6ea33878/sedge/cli.py#L32-L51
grahame/sedge
sedge/cli.py
cli
def cli(config, verbose, key_directory, no_verify, output_file, config_file): """ Template and share OpenSSH ssh_config(5) files. A preprocessor for OpenSSH configurations. """ config.verbose = verbose config.key_directory = key_directory config.config_file = config_file config.output_fi...
python
def cli(config, verbose, key_directory, no_verify, output_file, config_file): """ Template and share OpenSSH ssh_config(5) files. A preprocessor for OpenSSH configurations. """ config.verbose = verbose config.key_directory = key_directory config.config_file = config_file config.output_fi...
[ "def", "cli", "(", "config", ",", "verbose", ",", "key_directory", ",", "no_verify", ",", "output_file", ",", "config_file", ")", ":", "config", ".", "verbose", "=", "verbose", "config", ".", "key_directory", "=", "key_directory", "config", ".", "config_file",...
Template and share OpenSSH ssh_config(5) files. A preprocessor for OpenSSH configurations.
[ "Template", "and", "share", "OpenSSH", "ssh_config", "(", "5", ")", "files", ".", "A", "preprocessor", "for", "OpenSSH", "configurations", "." ]
train
https://github.com/grahame/sedge/blob/60dc6a0c5ef3bf802fe48a2571a8524a6ea33878/sedge/cli.py#L98-L107
grahame/sedge
sedge/cli.py
init
def init(config): """ Initialise ~./sedge/config file if none exists. Good for first time sedge usage """ from pkg_resources import resource_stream import shutil config_file = Path(config.config_file) if config_file.is_file(): click.echo('{} already exists, maybe you want $ sedg...
python
def init(config): """ Initialise ~./sedge/config file if none exists. Good for first time sedge usage """ from pkg_resources import resource_stream import shutil config_file = Path(config.config_file) if config_file.is_file(): click.echo('{} already exists, maybe you want $ sedg...
[ "def", "init", "(", "config", ")", ":", "from", "pkg_resources", "import", "resource_stream", "import", "shutil", "config_file", "=", "Path", "(", "config", ".", "config_file", ")", "if", "config_file", ".", "is_file", "(", ")", ":", "click", ".", "echo", ...
Initialise ~./sedge/config file if none exists. Good for first time sedge usage
[ "Initialise", "~", ".", "/", "sedge", "/", "config", "file", "if", "none", "exists", ".", "Good", "for", "first", "time", "sedge", "usage" ]
train
https://github.com/grahame/sedge/blob/60dc6a0c5ef3bf802fe48a2571a8524a6ea33878/sedge/cli.py#L112-L128
grahame/sedge
sedge/cli.py
update
def update(config): """ Update ssh config from sedge specification """ def write_to(out): engine.output(out) config_file = Path(config.config_file) if not config_file.is_file(): click.echo('No file {} '.format(config_file), err=True) sys.exit() library = KeyLibrary...
python
def update(config): """ Update ssh config from sedge specification """ def write_to(out): engine.output(out) config_file = Path(config.config_file) if not config_file.is_file(): click.echo('No file {} '.format(config_file), err=True) sys.exit() library = KeyLibrary...
[ "def", "update", "(", "config", ")", ":", "def", "write_to", "(", "out", ")", ":", "engine", ".", "output", "(", "out", ")", "config_file", "=", "Path", "(", "config", ".", "config_file", ")", "if", "not", "config_file", ".", "is_file", "(", ")", ":"...
Update ssh config from sedge specification
[ "Update", "ssh", "config", "from", "sedge", "specification" ]
train
https://github.com/grahame/sedge/blob/60dc6a0c5ef3bf802fe48a2571a8524a6ea33878/sedge/cli.py#L133-L168
1flow/python-ftr
ftr/config.py
ftr_get_config
def ftr_get_config(website_url, exact_host_match=False): """ Download the Five Filters config from centralized repositories. Repositories can be local if you need to override siteconfigs. The first entry found is returned. If no configuration is found, `None` is returned. If :mod:`cacheops` is install...
python
def ftr_get_config(website_url, exact_host_match=False): """ Download the Five Filters config from centralized repositories. Repositories can be local if you need to override siteconfigs. The first entry found is returned. If no configuration is found, `None` is returned. If :mod:`cacheops` is install...
[ "def", "ftr_get_config", "(", "website_url", ",", "exact_host_match", "=", "False", ")", ":", "def", "check_requests_result", "(", "result", ")", ":", "return", "(", "u'text/plain'", "in", "result", ".", "headers", ".", "get", "(", "'content-type'", ")", "and"...
Download the Five Filters config from centralized repositories. Repositories can be local if you need to override siteconfigs. The first entry found is returned. If no configuration is found, `None` is returned. If :mod:`cacheops` is installed, the result will be cached with a default expiration delay...
[ "Download", "the", "Five", "Filters", "config", "from", "centralized", "repositories", "." ]
train
https://github.com/1flow/python-ftr/blob/90a2108c5ee005f1bf66dbe8cce68f2b7051b839/ftr/config.py#L127-L255
1flow/python-ftr
ftr/config.py
ftr_string_to_instance
def ftr_string_to_instance(config_string): """ Return a :class:`SiteConfig` built from a ``config_string``. Simple syntax errors are just plainly ignored, and logged as warnings. :param config_string: a full site config file, raw-loaded from storage with something like ``config_string = op...
python
def ftr_string_to_instance(config_string): """ Return a :class:`SiteConfig` built from a ``config_string``. Simple syntax errors are just plainly ignored, and logged as warnings. :param config_string: a full site config file, raw-loaded from storage with something like ``config_string = op...
[ "def", "ftr_string_to_instance", "(", "config_string", ")", ":", "config", "=", "SiteConfig", "(", ")", "for", "line_number", ",", "line_content", "in", "enumerate", "(", "config_string", ".", "strip", "(", ")", ".", "split", "(", "u'\\n'", ")", ",", "start"...
Return a :class:`SiteConfig` built from a ``config_string``. Simple syntax errors are just plainly ignored, and logged as warnings. :param config_string: a full site config file, raw-loaded from storage with something like ``config_string = open('path/to/site/config.txt', 'r').read()``. :t...
[ "Return", "a", ":", "class", ":", "SiteConfig", "built", "from", "a", "config_string", "." ]
train
https://github.com/1flow/python-ftr/blob/90a2108c5ee005f1bf66dbe8cce68f2b7051b839/ftr/config.py#L258-L361
1flow/python-ftr
ftr/config.py
SiteConfig.reset
def reset(self): """ (re)set all attributes to defaults (eg. empty sets or ``None``). """ # Use first matching element as title (0 or more xpath expressions) self.title = OrderedSet() # Use first matching element as body (0 or more xpath expressions) self.body = OrderedSet() ...
python
def reset(self): """ (re)set all attributes to defaults (eg. empty sets or ``None``). """ # Use first matching element as title (0 or more xpath expressions) self.title = OrderedSet() # Use first matching element as body (0 or more xpath expressions) self.body = OrderedSet() ...
[ "def", "reset", "(", "self", ")", ":", "# Use first matching element as title (0 or more xpath expressions)", "self", ".", "title", "=", "OrderedSet", "(", ")", "# Use first matching element as body (0 or more xpath expressions)", "self", ".", "body", "=", "OrderedSet", "(", ...
(re)set all attributes to defaults (eg. empty sets or ``None``).
[ "(", "re", ")", "set", "all", "attributes", "to", "defaults", "(", "eg", ".", "empty", "sets", "or", "None", ")", "." ]
train
https://github.com/1flow/python-ftr/blob/90a2108c5ee005f1bf66dbe8cce68f2b7051b839/ftr/config.py#L408-L490
1flow/python-ftr
ftr/config.py
SiteConfig.load
def load(self, host, exact_host_match=False): """ Load a config for a hostname or url. This method calls :func:`ftr_get_config` and :meth`append` internally. Refer to their docs for details on parameters. """ # Can raise a SiteConfigNotFound, intentionally bubbled. conf...
python
def load(self, host, exact_host_match=False): """ Load a config for a hostname or url. This method calls :func:`ftr_get_config` and :meth`append` internally. Refer to their docs for details on parameters. """ # Can raise a SiteConfigNotFound, intentionally bubbled. conf...
[ "def", "load", "(", "self", ",", "host", ",", "exact_host_match", "=", "False", ")", ":", "# Can raise a SiteConfigNotFound, intentionally bubbled.", "config_string", ",", "host_string", "=", "ftr_get_config", "(", "host", ",", "exact_host_match", ")", "if", "config_s...
Load a config for a hostname or url. This method calls :func:`ftr_get_config` and :meth`append` internally. Refer to their docs for details on parameters.
[ "Load", "a", "config", "for", "a", "hostname", "or", "url", "." ]
train
https://github.com/1flow/python-ftr/blob/90a2108c5ee005f1bf66dbe8cce68f2b7051b839/ftr/config.py#L492-L507
1flow/python-ftr
ftr/config.py
SiteConfig.append
def append(self, newconfig): """ Append another site config to current instance. All ``newconfig`` attributes are appended one by one to ours. Order matters, eg. current instance values will come first when merging. Thus, if you plan to use some sort of global site config with ...
python
def append(self, newconfig): """ Append another site config to current instance. All ``newconfig`` attributes are appended one by one to ours. Order matters, eg. current instance values will come first when merging. Thus, if you plan to use some sort of global site config with ...
[ "def", "append", "(", "self", ",", "newconfig", ")", ":", "# Check for commands where we accept multiple statements (no test_url)", "for", "attr_name", "in", "(", "'title'", ",", "'body'", ",", "'author'", ",", "'date'", ",", "# `language` is fixed in reset() and", "# not...
Append another site config to current instance. All ``newconfig`` attributes are appended one by one to ours. Order matters, eg. current instance values will come first when merging. Thus, if you plan to use some sort of global site config with more generic directives, append i...
[ "Append", "another", "site", "config", "to", "current", "instance", "." ]
train
https://github.com/1flow/python-ftr/blob/90a2108c5ee005f1bf66dbe8cce68f2b7051b839/ftr/config.py#L509-L564
grahambell/pymoc
lib/pymoc/io/json.py
write_moc_json
def write_moc_json(moc, filename=None, file=None): """Write a MOC in JSON encoding. Either a filename, or an open file object can be specified. """ moc.normalize() obj = {} for (order, cells) in moc: obj['{0}'.format(order)] = sorted(cells) if file is not None: _write_js...
python
def write_moc_json(moc, filename=None, file=None): """Write a MOC in JSON encoding. Either a filename, or an open file object can be specified. """ moc.normalize() obj = {} for (order, cells) in moc: obj['{0}'.format(order)] = sorted(cells) if file is not None: _write_js...
[ "def", "write_moc_json", "(", "moc", ",", "filename", "=", "None", ",", "file", "=", "None", ")", ":", "moc", ".", "normalize", "(", ")", "obj", "=", "{", "}", "for", "(", "order", ",", "cells", ")", "in", "moc", ":", "obj", "[", "'{0}'", ".", ...
Write a MOC in JSON encoding. Either a filename, or an open file object can be specified.
[ "Write", "a", "MOC", "in", "JSON", "encoding", "." ]
train
https://github.com/grahambell/pymoc/blob/0e2e57ce07ff3de6ac024627c1fb6ad30c2fde48/lib/pymoc/io/json.py#L22-L39
grahambell/pymoc
lib/pymoc/io/json.py
read_moc_json
def read_moc_json(moc, filename=None, file=None): """Read JSON encoded data into a MOC. Either a filename, or an open file object can be specified. """ if file is not None: obj = _read_json(file) else: with open(filename, 'rb') as f: obj = _read_json(f) for (order,...
python
def read_moc_json(moc, filename=None, file=None): """Read JSON encoded data into a MOC. Either a filename, or an open file object can be specified. """ if file is not None: obj = _read_json(file) else: with open(filename, 'rb') as f: obj = _read_json(f) for (order,...
[ "def", "read_moc_json", "(", "moc", ",", "filename", "=", "None", ",", "file", "=", "None", ")", ":", "if", "file", "is", "not", "None", ":", "obj", "=", "_read_json", "(", "file", ")", "else", ":", "with", "open", "(", "filename", ",", "'rb'", ")"...
Read JSON encoded data into a MOC. Either a filename, or an open file object can be specified.
[ "Read", "JSON", "encoded", "data", "into", "a", "MOC", "." ]
train
https://github.com/grahambell/pymoc/blob/0e2e57ce07ff3de6ac024627c1fb6ad30c2fde48/lib/pymoc/io/json.py#L42-L55
chbrown/viz
viz/stats.py
normalize
def normalize(xs): ''' Restrict xs into the interval (0, 1) via a linear transformation as long as len(xs) > 1, 0 and 1 will be elements of the resulting array ''' x_min, x_max = np.min(xs), np.max(xs) return (xs - x_min) / (x_max - x_min)
python
def normalize(xs): ''' Restrict xs into the interval (0, 1) via a linear transformation as long as len(xs) > 1, 0 and 1 will be elements of the resulting array ''' x_min, x_max = np.min(xs), np.max(xs) return (xs - x_min) / (x_max - x_min)
[ "def", "normalize", "(", "xs", ")", ":", "x_min", ",", "x_max", "=", "np", ".", "min", "(", "xs", ")", ",", "np", ".", "max", "(", "xs", ")", "return", "(", "xs", "-", "x_min", ")", "/", "(", "x_max", "-", "x_min", ")" ]
Restrict xs into the interval (0, 1) via a linear transformation as long as len(xs) > 1, 0 and 1 will be elements of the resulting array
[ "Restrict", "xs", "into", "the", "interval", "(", "0", "1", ")", "via", "a", "linear", "transformation", "as", "long", "as", "len", "(", "xs", ")", ">", "1", "0", "and", "1", "will", "be", "elements", "of", "the", "resulting", "array" ]
train
https://github.com/chbrown/viz/blob/683a8f91630582d74250690a0e8ea7743ab94058/viz/stats.py#L8-L14
chbrown/viz
viz/gloss.py
gloss
def gloss(alignments, prefixes=None, postfixes=None, width=None, toksep=' ', linesep='\n', groupsep='\n'): ''' Creates an interlinear gloss (for pairs of tokens/types, POS-tags, labels, etc.) Take a list of [('a', 'DET'), ('beluga', 'N')] and return a string covering multiples lines, like: a belu...
python
def gloss(alignments, prefixes=None, postfixes=None, width=None, toksep=' ', linesep='\n', groupsep='\n'): ''' Creates an interlinear gloss (for pairs of tokens/types, POS-tags, labels, etc.) Take a list of [('a', 'DET'), ('beluga', 'N')] and return a string covering multiples lines, like: a belu...
[ "def", "gloss", "(", "alignments", ",", "prefixes", "=", "None", ",", "postfixes", "=", "None", ",", "width", "=", "None", ",", "toksep", "=", "' '", ",", "linesep", "=", "'\\n'", ",", "groupsep", "=", "'\\n'", ")", ":", "if", "width", "is", "None", ...
Creates an interlinear gloss (for pairs of tokens/types, POS-tags, labels, etc.) Take a list of [('a', 'DET'), ('beluga', 'N')] and return a string covering multiples lines, like: a beluga DET N each item in `alignments` should have the same length, N `prefixes`, if provided, should be N-...
[ "Creates", "an", "interlinear", "gloss", "(", "for", "pairs", "of", "tokens", "/", "types", "POS", "-", "tags", "labels", "etc", ".", ")" ]
train
https://github.com/chbrown/viz/blob/683a8f91630582d74250690a0e8ea7743ab94058/viz/gloss.py#L4-L51
seebass/drf-nested-fields
drf_nested_fields/views.py
CustomFieldsMixin.get_queryset
def get_queryset(self): """ For reducing the query count the queryset is expanded with `prefetch_related` and `select_related` depending on the specified fields and nested fields """ self.queryset = super(CustomFieldsMixin, self).get_queryset() serializer_class = self.get...
python
def get_queryset(self): """ For reducing the query count the queryset is expanded with `prefetch_related` and `select_related` depending on the specified fields and nested fields """ self.queryset = super(CustomFieldsMixin, self).get_queryset() serializer_class = self.get...
[ "def", "get_queryset", "(", "self", ")", ":", "self", ".", "queryset", "=", "super", "(", "CustomFieldsMixin", ",", "self", ")", ".", "get_queryset", "(", ")", "serializer_class", "=", "self", ".", "get_serializer_class", "(", ")", "if", "hasattr", "(", "s...
For reducing the query count the queryset is expanded with `prefetch_related` and `select_related` depending on the specified fields and nested fields
[ "For", "reducing", "the", "query", "count", "the", "queryset", "is", "expanded", "with", "prefetch_related", "and", "select_related", "depending", "on", "the", "specified", "fields", "and", "nested", "fields" ]
train
https://github.com/seebass/drf-nested-fields/blob/1c2516bf34790da699fc6f41ed39dd4a542e3905/drf_nested_fields/views.py#L30-L41
Robin8Put/pmes
ams/utils/tornado_components/mongo.py
Table.read
async def read(self, *_id): """Read data from database table. Accepts ids of entries. Returns list of results if success or string with error code and explanation. read(*id) => [(result), (result)] (if success) read(*id) => [] (if missed) read() => {"error":400, "reason":"Missed required fields"} """ ...
python
async def read(self, *_id): """Read data from database table. Accepts ids of entries. Returns list of results if success or string with error code and explanation. read(*id) => [(result), (result)] (if success) read(*id) => [] (if missed) read() => {"error":400, "reason":"Missed required fields"} """ ...
[ "async", "def", "read", "(", "self", ",", "*", "_id", ")", ":", "if", "not", "_id", ":", "return", "{", "\"error\"", ":", "400", ",", "\"reason\"", ":", "\"Missed required fields\"", "}", "result", "=", "[", "]", "for", "i", "in", "_id", ":", "docume...
Read data from database table. Accepts ids of entries. Returns list of results if success or string with error code and explanation. read(*id) => [(result), (result)] (if success) read(*id) => [] (if missed) read() => {"error":400, "reason":"Missed required fields"}
[ "Read", "data", "from", "database", "table", ".", "Accepts", "ids", "of", "entries", ".", "Returns", "list", "of", "results", "if", "success", "or", "string", "with", "error", "code", "and", "explanation", "." ]
train
https://github.com/Robin8Put/pmes/blob/338bec94162098f05b75bad035417317e1252fd2/ams/utils/tornado_components/mongo.py#L36-L58
Robin8Put/pmes
ams/utils/tornado_components/mongo.py
Table.insert
async def insert(self, **kwargs): """ Accepts request object, retrieves data from the one`s body and creates new account. """ if kwargs: # Create autoincrement for account pk = await self.autoincrement() kwargs.update({"id": pk}) # Create account with received data and autoincrement await ...
python
async def insert(self, **kwargs): """ Accepts request object, retrieves data from the one`s body and creates new account. """ if kwargs: # Create autoincrement for account pk = await self.autoincrement() kwargs.update({"id": pk}) # Create account with received data and autoincrement await ...
[ "async", "def", "insert", "(", "self", ",", "*", "*", "kwargs", ")", ":", "if", "kwargs", ":", "# Create autoincrement for account", "pk", "=", "await", "self", ".", "autoincrement", "(", ")", "kwargs", ".", "update", "(", "{", "\"id\"", ":", "pk", "}", ...
Accepts request object, retrieves data from the one`s body and creates new account.
[ "Accepts", "request", "object", "retrieves", "data", "from", "the", "one", "s", "body", "and", "creates", "new", "account", "." ]
train
https://github.com/Robin8Put/pmes/blob/338bec94162098f05b75bad035417317e1252fd2/ams/utils/tornado_components/mongo.py#L62-L85
Robin8Put/pmes
ams/utils/tornado_components/mongo.py
Table.find
async def find(self, **kwargs): """Find all entries with given search key. Accepts named parameter key and arbitrary values. Returns list of entry id`s. find(**kwargs) => document (if exist) find(**kwargs) => {"error":404,"reason":"Not found"} (if does not exist) find() => {"error":400, "reason":"Missed re...
python
async def find(self, **kwargs): """Find all entries with given search key. Accepts named parameter key and arbitrary values. Returns list of entry id`s. find(**kwargs) => document (if exist) find(**kwargs) => {"error":404,"reason":"Not found"} (if does not exist) find() => {"error":400, "reason":"Missed re...
[ "async", "def", "find", "(", "self", ",", "*", "*", "kwargs", ")", ":", "if", "not", "isinstance", "(", "kwargs", ",", "dict", ")", "and", "len", "(", "kwargs", ")", "!=", "1", ":", "return", "{", "\"error\"", ":", "400", ",", "\"reason\"", ":", ...
Find all entries with given search key. Accepts named parameter key and arbitrary values. Returns list of entry id`s. find(**kwargs) => document (if exist) find(**kwargs) => {"error":404,"reason":"Not found"} (if does not exist) find() => {"error":400, "reason":"Missed required fields"}
[ "Find", "all", "entries", "with", "given", "search", "key", ".", "Accepts", "named", "parameter", "key", "and", "arbitrary", "values", ".", "Returns", "list", "of", "entry", "id", "s", "." ]
train
https://github.com/Robin8Put/pmes/blob/338bec94162098f05b75bad035417317e1252fd2/ams/utils/tornado_components/mongo.py#L89-L105
Robin8Put/pmes
ams/utils/tornado_components/mongo.py
Table.update
async def update(self, _id=None, **new_data): """Updates fields values. Accepts id of sigle entry and fields with values. update(id, **kwargs) => {"success":200, "reason":"Updated"} (if success) update(id, **kwargs) => {"error":400, "reason":"Missed required fields"} (if error) """ if not _id or not ne...
python
async def update(self, _id=None, **new_data): """Updates fields values. Accepts id of sigle entry and fields with values. update(id, **kwargs) => {"success":200, "reason":"Updated"} (if success) update(id, **kwargs) => {"error":400, "reason":"Missed required fields"} (if error) """ if not _id or not ne...
[ "async", "def", "update", "(", "self", ",", "_id", "=", "None", ",", "*", "*", "new_data", ")", ":", "if", "not", "_id", "or", "not", "new_data", ":", "return", "{", "\"error\"", ":", "400", ",", "\"reason\"", ":", "\"Missed required fields\"", "}", "d...
Updates fields values. Accepts id of sigle entry and fields with values. update(id, **kwargs) => {"success":200, "reason":"Updated"} (if success) update(id, **kwargs) => {"error":400, "reason":"Missed required fields"} (if error)
[ "Updates", "fields", "values", ".", "Accepts", "id", "of", "sigle", "entry", "and", "fields", "with", "values", "." ]
train
https://github.com/Robin8Put/pmes/blob/338bec94162098f05b75bad035417317e1252fd2/ams/utils/tornado_components/mongo.py#L110-L133
Robin8Put/pmes
ams/utils/tornado_components/mongo.py
Table.delete
async def delete(self, _id=None): """Delete entry from database table. Accepts id. delete(id) => 1 (if exists) delete(id) => {"error":404, "reason":"Not found"} (if does not exist) delete() => {"error":400, "reason":"Missed required fields"} """ if not _id: return {"error":400, "reason":"Missed r...
python
async def delete(self, _id=None): """Delete entry from database table. Accepts id. delete(id) => 1 (if exists) delete(id) => {"error":404, "reason":"Not found"} (if does not exist) delete() => {"error":400, "reason":"Missed required fields"} """ if not _id: return {"error":400, "reason":"Missed r...
[ "async", "def", "delete", "(", "self", ",", "_id", "=", "None", ")", ":", "if", "not", "_id", ":", "return", "{", "\"error\"", ":", "400", ",", "\"reason\"", ":", "\"Missed required fields\"", "}", "document", "=", "await", "self", ".", "collection", "."...
Delete entry from database table. Accepts id. delete(id) => 1 (if exists) delete(id) => {"error":404, "reason":"Not found"} (if does not exist) delete() => {"error":400, "reason":"Missed required fields"}
[ "Delete", "entry", "from", "database", "table", ".", "Accepts", "id", ".", "delete", "(", "id", ")", "=", ">", "1", "(", "if", "exists", ")", "delete", "(", "id", ")", "=", ">", "{", "error", ":", "404", "reason", ":", "Not", "found", "}", "(", ...
train
https://github.com/Robin8Put/pmes/blob/338bec94162098f05b75bad035417317e1252fd2/ams/utils/tornado_components/mongo.py#L136-L156
svven/summary
summary/techniques.py
HTTPEquivRefreshTags.parse_refresh_header
def parse_refresh_header(self, refresh): """ >>> parse_refresh_header("1; url=http://example.com/") (1.0, 'http://example.com/') >>> parse_refresh_header("1; url='http://example.com/'") (1.0, 'http://example.com/') >>> parse_refresh_header("1") (1.0, None) ...
python
def parse_refresh_header(self, refresh): """ >>> parse_refresh_header("1; url=http://example.com/") (1.0, 'http://example.com/') >>> parse_refresh_header("1; url='http://example.com/'") (1.0, 'http://example.com/') >>> parse_refresh_header("1") (1.0, None) ...
[ "def", "parse_refresh_header", "(", "self", ",", "refresh", ")", ":", "ii", "=", "refresh", ".", "find", "(", "\";\"", ")", "if", "ii", "!=", "-", "1", ":", "pause", ",", "newurl_spec", "=", "float", "(", "refresh", "[", ":", "ii", "]", ")", ",", ...
>>> parse_refresh_header("1; url=http://example.com/") (1.0, 'http://example.com/') >>> parse_refresh_header("1; url='http://example.com/'") (1.0, 'http://example.com/') >>> parse_refresh_header("1") (1.0, None) >>> parse_refresh_header("blah") # doctest: +IGNORE_EXCEPTI...
[ ">>>", "parse_refresh_header", "(", "1", ";", "url", "=", "http", ":", "//", "example", ".", "com", "/", ")", "(", "1", ".", "0", "http", ":", "//", "example", ".", "com", "/", ")", ">>>", "parse_refresh_header", "(", "1", ";", "url", "=", "http", ...
train
https://github.com/svven/summary/blob/3a6c43d2da08a7452f6b76d1813aa70ba36b8a54/summary/techniques.py#L29-L53
svven/summary
summary/techniques.py
HTTPEquivRefreshTags.extract
def extract(self, html): "Extract http-equiv refresh url to follow." extracted = {} soup = BeautifulSoup(html, parser) for meta_tag in soup.find_all('meta'): if self.key_attr in meta_tag.attrs and 'content' in meta_tag.attrs and \ meta_tag[self.key_attr].lower...
python
def extract(self, html): "Extract http-equiv refresh url to follow." extracted = {} soup = BeautifulSoup(html, parser) for meta_tag in soup.find_all('meta'): if self.key_attr in meta_tag.attrs and 'content' in meta_tag.attrs and \ meta_tag[self.key_attr].lower...
[ "def", "extract", "(", "self", ",", "html", ")", ":", "extracted", "=", "{", "}", "soup", "=", "BeautifulSoup", "(", "html", ",", "parser", ")", "for", "meta_tag", "in", "soup", ".", "find_all", "(", "'meta'", ")", ":", "if", "self", ".", "key_attr",...
Extract http-equiv refresh url to follow.
[ "Extract", "http", "-", "equiv", "refresh", "url", "to", "follow", "." ]
train
https://github.com/svven/summary/blob/3a6c43d2da08a7452f6b76d1813aa70ba36b8a54/summary/techniques.py#L55-L70
Robin8Put/pmes
ams/utils/tornado_components/web.py
SignedHTTPClient.request
def request(self, *args, **kwargs): """Overrided method. Returns jsonrpc response or fetches exception? returns appropriate data to client and response mail to administrator. """ try: import settings with open(os.path.join(settings.BASE_DIR, "keys.json")) as f: keys = json.load(f) privkey = key...
python
def request(self, *args, **kwargs): """Overrided method. Returns jsonrpc response or fetches exception? returns appropriate data to client and response mail to administrator. """ try: import settings with open(os.path.join(settings.BASE_DIR, "keys.json")) as f: keys = json.load(f) privkey = key...
[ "def", "request", "(", "self", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "try", ":", "import", "settings", "with", "open", "(", "os", ".", "path", ".", "join", "(", "settings", ".", "BASE_DIR", ",", "\"keys.json\"", ")", ")", "as", "f", ...
Overrided method. Returns jsonrpc response or fetches exception? returns appropriate data to client and response mail to administrator.
[ "Overrided", "method", ".", "Returns", "jsonrpc", "response", "or", "fetches", "exception?", "returns", "appropriate", "data", "to", "client", "and", "response", "mail", "to", "administrator", "." ]
train
https://github.com/Robin8Put/pmes/blob/338bec94162098f05b75bad035417317e1252fd2/ams/utils/tornado_components/web.py#L23-L44
Robin8Put/pmes
ams/utils/tornado_components/web.py
ManagementSystemHandler.verify
def verify(self): """Abstract method. Signature verifying logic. """ logging.debug("\n\n") logging.debug("[+] -- Verify debugging") logging.debug("\n\n") if self.request.body: logging.debug("\n Request body") logging.debug(self.request.body) data = json.loads(self.request.body) message = jso...
python
def verify(self): """Abstract method. Signature verifying logic. """ logging.debug("\n\n") logging.debug("[+] -- Verify debugging") logging.debug("\n\n") if self.request.body: logging.debug("\n Request body") logging.debug(self.request.body) data = json.loads(self.request.body) message = jso...
[ "def", "verify", "(", "self", ")", ":", "logging", ".", "debug", "(", "\"\\n\\n\"", ")", "logging", ".", "debug", "(", "\"[+] -- Verify debugging\"", ")", "logging", ".", "debug", "(", "\"\\n\\n\"", ")", "if", "self", ".", "request", ".", "body", ":", "l...
Abstract method. Signature verifying logic.
[ "Abstract", "method", ".", "Signature", "verifying", "logic", "." ]
train
https://github.com/Robin8Put/pmes/blob/338bec94162098f05b75bad035417317e1252fd2/ams/utils/tornado_components/web.py#L100-L161
sveetch/boussole
boussole/cli/console_script.py
cli_frontend
def cli_frontend(ctx, verbose): """ Boussole is a commandline interface to build Sass projects using libsass. Every project will need a settings file containing all needed settings to build it. """ printout = True if verbose == 0: verbose = 1 printout = False # Verbosit...
python
def cli_frontend(ctx, verbose): """ Boussole is a commandline interface to build Sass projects using libsass. Every project will need a settings file containing all needed settings to build it. """ printout = True if verbose == 0: verbose = 1 printout = False # Verbosit...
[ "def", "cli_frontend", "(", "ctx", ",", "verbose", ")", ":", "printout", "=", "True", "if", "verbose", "==", "0", ":", "verbose", "=", "1", "printout", "=", "False", "# Verbosity is the inverse of logging levels", "levels", "=", "[", "item", "for", "item", "...
Boussole is a commandline interface to build Sass projects using libsass. Every project will need a settings file containing all needed settings to build it.
[ "Boussole", "is", "a", "commandline", "interface", "to", "build", "Sass", "projects", "using", "libsass", "." ]
train
https://github.com/sveetch/boussole/blob/22cc644e9d633f41ebfc167d427a71c1726cee21/boussole/cli/console_script.py#L27-L49
sveetch/boussole
boussole/project.py
ProjectBase.get_backend_engine
def get_backend_engine(self, name, **kwargs): """ Get backend engine from given name. Args: (string): Path to validate. Raises: boussole.exceptions.SettingsBackendError: If given backend name does not match any available engine. Returns:...
python
def get_backend_engine(self, name, **kwargs): """ Get backend engine from given name. Args: (string): Path to validate. Raises: boussole.exceptions.SettingsBackendError: If given backend name does not match any available engine. Returns:...
[ "def", "get_backend_engine", "(", "self", ",", "name", ",", "*", "*", "kwargs", ")", ":", "if", "name", "not", "in", "self", ".", "_engines", ":", "msg", "=", "\"Given settings backend is unknowed: {}\"", "raise", "SettingsBackendError", "(", "msg", ".", "form...
Get backend engine from given name. Args: (string): Path to validate. Raises: boussole.exceptions.SettingsBackendError: If given backend name does not match any available engine. Returns: object: Instance of selected backend engine.
[ "Get", "backend", "engine", "from", "given", "name", "." ]
train
https://github.com/sveetch/boussole/blob/22cc644e9d633f41ebfc167d427a71c1726cee21/boussole/project.py#L35-L53
sveetch/boussole
boussole/project.py
ProjectStarter.valid_paths
def valid_paths(self, *args): """ Validate that given paths are not the same. Args: (string): Path to validate. Raises: boussole.exceptions.SettingsInvalidError: If there is more than one occurence of the same path. Returns: ...
python
def valid_paths(self, *args): """ Validate that given paths are not the same. Args: (string): Path to validate. Raises: boussole.exceptions.SettingsInvalidError: If there is more than one occurence of the same path. Returns: ...
[ "def", "valid_paths", "(", "self", ",", "*", "args", ")", ":", "for", "i", ",", "path", "in", "enumerate", "(", "args", ",", "start", "=", "0", ")", ":", "cp", "=", "list", "(", "args", ")", "current", "=", "cp", ".", "pop", "(", "i", ")", "i...
Validate that given paths are not the same. Args: (string): Path to validate. Raises: boussole.exceptions.SettingsInvalidError: If there is more than one occurence of the same path. Returns: bool: ``True`` if paths are validated.
[ "Validate", "that", "given", "paths", "are", "not", "the", "same", "." ]
train
https://github.com/sveetch/boussole/blob/22cc644e9d633f41ebfc167d427a71c1726cee21/boussole/project.py#L60-L81
sveetch/boussole
boussole/project.py
ProjectStarter.expand
def expand(self, basedir, config, sourcedir, targetdir, cwd): """ Validate that given paths are not the same. Args: basedir (string): Project base directory used to prepend relative paths. If empty or equal to '.', it will be filled with current direc...
python
def expand(self, basedir, config, sourcedir, targetdir, cwd): """ Validate that given paths are not the same. Args: basedir (string): Project base directory used to prepend relative paths. If empty or equal to '.', it will be filled with current direc...
[ "def", "expand", "(", "self", ",", "basedir", ",", "config", ",", "sourcedir", ",", "targetdir", ",", "cwd", ")", ":", "# Expand home directory if any", "expanded_basedir", "=", "os", ".", "path", ".", "expanduser", "(", "basedir", ")", "expanded_config", "=",...
Validate that given paths are not the same. Args: basedir (string): Project base directory used to prepend relative paths. If empty or equal to '.', it will be filled with current directory path. config (string): Settings file path. sourcedir ...
[ "Validate", "that", "given", "paths", "are", "not", "the", "same", "." ]
train
https://github.com/sveetch/boussole/blob/22cc644e9d633f41ebfc167d427a71c1726cee21/boussole/project.py#L83-L127
sveetch/boussole
boussole/project.py
ProjectStarter.commit
def commit(self, sourcedir, targetdir, abs_config, abs_sourcedir, abs_targetdir): """ Commit project structure and configuration file Args: sourcedir (string): Source directory path. targetdir (string): Compiled files target directory path. abs...
python
def commit(self, sourcedir, targetdir, abs_config, abs_sourcedir, abs_targetdir): """ Commit project structure and configuration file Args: sourcedir (string): Source directory path. targetdir (string): Compiled files target directory path. abs...
[ "def", "commit", "(", "self", ",", "sourcedir", ",", "targetdir", ",", "abs_config", ",", "abs_sourcedir", ",", "abs_targetdir", ")", ":", "config_path", ",", "config_filename", "=", "os", ".", "path", ".", "split", "(", "abs_config", ")", "if", "not", "os...
Commit project structure and configuration file Args: sourcedir (string): Source directory path. targetdir (string): Compiled files target directory path. abs_config (string): Configuration file absolute path. abs_sourcedir (string): ``sourcedir`` expanded as abs...
[ "Commit", "project", "structure", "and", "configuration", "file" ]
train
https://github.com/sveetch/boussole/blob/22cc644e9d633f41ebfc167d427a71c1726cee21/boussole/project.py#L129-L158
sveetch/boussole
boussole/project.py
ProjectStarter.init
def init(self, basedir, config, sourcedir, targetdir, cwd='', commit=True): """ Init project structure and configuration from given arguments Args: basedir (string): Project base directory used to prepend relative paths. If empty or equal to '.', it will be filled wi...
python
def init(self, basedir, config, sourcedir, targetdir, cwd='', commit=True): """ Init project structure and configuration from given arguments Args: basedir (string): Project base directory used to prepend relative paths. If empty or equal to '.', it will be filled wi...
[ "def", "init", "(", "self", ",", "basedir", ",", "config", ",", "sourcedir", ",", "targetdir", ",", "cwd", "=", "''", ",", "commit", "=", "True", ")", ":", "if", "not", "basedir", ":", "basedir", "=", "'.'", "# Expand home directory if any", "abs_basedir",...
Init project structure and configuration from given arguments Args: basedir (string): Project base directory used to prepend relative paths. If empty or equal to '.', it will be filled with current directory path. config (string): Settings file path. ...
[ "Init", "project", "structure", "and", "configuration", "from", "given", "arguments" ]
train
https://github.com/sveetch/boussole/blob/22cc644e9d633f41ebfc167d427a71c1726cee21/boussole/project.py#L160-L203
anybox/selenium-configurator
selenium_configurator/drivers/remote.py
Grid.get_web_drivers
def get_web_drivers(cls, conf, global_capabilities=None): """Prepare 1 selenium driver instance per request browsers :param conf: :param global_capabilities: :return: """ web_drivers = [] if not global_capabilities: global_capabilities = {} el...
python
def get_web_drivers(cls, conf, global_capabilities=None): """Prepare 1 selenium driver instance per request browsers :param conf: :param global_capabilities: :return: """ web_drivers = [] if not global_capabilities: global_capabilities = {} el...
[ "def", "get_web_drivers", "(", "cls", ",", "conf", ",", "global_capabilities", "=", "None", ")", ":", "web_drivers", "=", "[", "]", "if", "not", "global_capabilities", ":", "global_capabilities", "=", "{", "}", "else", ":", "global_capabilities", "=", "deepcop...
Prepare 1 selenium driver instance per request browsers :param conf: :param global_capabilities: :return:
[ "Prepare", "1", "selenium", "driver", "instance", "per", "request", "browsers" ]
train
https://github.com/anybox/selenium-configurator/blob/6cd83d77583f52e86353b516f9bc235e853b7e33/selenium_configurator/drivers/remote.py#L44-L68
sveetch/boussole
boussole/logs.py
init_logger
def init_logger(level, printout=True): """ Initialize app logger to configure its level/handler/formatter/etc.. Todo: * A mean to raise click.Abort or sys.exit when CRITICAL is used; Args: level (str): Level name (``debug``, ``info``, etc..). Keyword Arguments: printout (b...
python
def init_logger(level, printout=True): """ Initialize app logger to configure its level/handler/formatter/etc.. Todo: * A mean to raise click.Abort or sys.exit when CRITICAL is used; Args: level (str): Level name (``debug``, ``info``, etc..). Keyword Arguments: printout (b...
[ "def", "init_logger", "(", "level", ",", "printout", "=", "True", ")", ":", "root_logger", "=", "logging", ".", "getLogger", "(", "\"boussole\"", ")", "root_logger", ".", "setLevel", "(", "level", ")", "# Redirect outputs to the void space, mostly for usage within uni...
Initialize app logger to configure its level/handler/formatter/etc.. Todo: * A mean to raise click.Abort or sys.exit when CRITICAL is used; Args: level (str): Level name (``debug``, ``info``, etc..). Keyword Arguments: printout (bool): If False, logs will never be outputed. R...
[ "Initialize", "app", "logger", "to", "configure", "its", "level", "/", "handler", "/", "formatter", "/", "etc", ".." ]
train
https://github.com/sveetch/boussole/blob/22cc644e9d633f41ebfc167d427a71c1726cee21/boussole/logs.py#L10-L46
royi1000/py-libhdate
hdate/htables.py
move_if_not_on_dow
def move_if_not_on_dow(original, replacement, dow_not_orig, dow_replacement): """ Return a lambda function. Lambda checks that either the original day does not fall on a given weekday, or that the replacement day does fall on the expected weekday. """ return lambda x: ( (x.hdate.day == ...
python
def move_if_not_on_dow(original, replacement, dow_not_orig, dow_replacement): """ Return a lambda function. Lambda checks that either the original day does not fall on a given weekday, or that the replacement day does fall on the expected weekday. """ return lambda x: ( (x.hdate.day == ...
[ "def", "move_if_not_on_dow", "(", "original", ",", "replacement", ",", "dow_not_orig", ",", "dow_replacement", ")", ":", "return", "lambda", "x", ":", "(", "(", "x", ".", "hdate", ".", "day", "==", "original", "and", "x", ".", "gdate", ".", "weekday", "(...
Return a lambda function. Lambda checks that either the original day does not fall on a given weekday, or that the replacement day does fall on the expected weekday.
[ "Return", "a", "lambda", "function", "." ]
train
https://github.com/royi1000/py-libhdate/blob/12af759fb69f1d6403abed3762beaf5ace16a34b/hdate/htables.py#L177-L186
Robin8Put/pmes
history/ClickHouse/clickhouse_queries.py
create_table
def create_table(table, data): """ Create table with defined name and fields :return: None """ fields = data['fields'] query = '(' indexed_fields = '' for key, value in fields.items(): non_case_field = value[0][0:value[0].find('(')] if non_case_field == 'int': ...
python
def create_table(table, data): """ Create table with defined name and fields :return: None """ fields = data['fields'] query = '(' indexed_fields = '' for key, value in fields.items(): non_case_field = value[0][0:value[0].find('(')] if non_case_field == 'int': ...
[ "def", "create_table", "(", "table", ",", "data", ")", ":", "fields", "=", "data", "[", "'fields'", "]", "query", "=", "'('", "indexed_fields", "=", "''", "for", "key", ",", "value", "in", "fields", ".", "items", "(", ")", ":", "non_case_field", "=", ...
Create table with defined name and fields :return: None
[ "Create", "table", "with", "defined", "name", "and", "fields", ":", "return", ":", "None" ]
train
https://github.com/Robin8Put/pmes/blob/338bec94162098f05b75bad035417317e1252fd2/history/ClickHouse/clickhouse_queries.py#L21-L61
Robin8Put/pmes
history/ClickHouse/clickhouse_queries.py
insert_into_table
def insert_into_table(table, data): """ SQL query for inserting data into table :return: None """ fields = data['fields'] fields['date'] = datetime.datetime.now().date() query = '(' for key in fields.keys(): query += key + ',' query = query[:-1:] + ")" client.execute...
python
def insert_into_table(table, data): """ SQL query for inserting data into table :return: None """ fields = data['fields'] fields['date'] = datetime.datetime.now().date() query = '(' for key in fields.keys(): query += key + ',' query = query[:-1:] + ")" client.execute...
[ "def", "insert_into_table", "(", "table", ",", "data", ")", ":", "fields", "=", "data", "[", "'fields'", "]", "fields", "[", "'date'", "]", "=", "datetime", ".", "datetime", ".", "now", "(", ")", ".", "date", "(", ")", "query", "=", "'('", "for", "...
SQL query for inserting data into table :return: None
[ "SQL", "query", "for", "inserting", "data", "into", "table", ":", "return", ":", "None" ]
train
https://github.com/Robin8Put/pmes/blob/338bec94162098f05b75bad035417317e1252fd2/history/ClickHouse/clickhouse_queries.py#L64-L80
Robin8Put/pmes
history/ClickHouse/clickhouse_queries.py
select_from_table
def select_from_table(fields, table, query): """ SQL query for selecting data from certain table :return: selected data """ select_data = client.execute(f"SELECT {fields} FROM {table} {query}", with_column_types=True) keys = [i[0] for i in select_data[1]] result = [] for i in range(l...
python
def select_from_table(fields, table, query): """ SQL query for selecting data from certain table :return: selected data """ select_data = client.execute(f"SELECT {fields} FROM {table} {query}", with_column_types=True) keys = [i[0] for i in select_data[1]] result = [] for i in range(l...
[ "def", "select_from_table", "(", "fields", ",", "table", ",", "query", ")", ":", "select_data", "=", "client", ".", "execute", "(", "f\"SELECT {fields} FROM {table} {query}\"", ",", "with_column_types", "=", "True", ")", "keys", "=", "[", "i", "[", "0", "]", ...
SQL query for selecting data from certain table :return: selected data
[ "SQL", "query", "for", "selecting", "data", "from", "certain", "table", ":", "return", ":", "selected", "data" ]
train
https://github.com/Robin8Put/pmes/blob/338bec94162098f05b75bad035417317e1252fd2/history/ClickHouse/clickhouse_queries.py#L83-L106
grahambell/pymoc
lib/pymoc/util/plot.py
plot_moc
def plot_moc(moc, order=None, antialias=0, filename=None, projection='cart', color='blue', title='', coord_sys='C', graticule=True, **kwargs): """Plot a MOC using Healpy. This generates a plot of the MOC at the specified order, or the MOC's current order if this is not specified. ...
python
def plot_moc(moc, order=None, antialias=0, filename=None, projection='cart', color='blue', title='', coord_sys='C', graticule=True, **kwargs): """Plot a MOC using Healpy. This generates a plot of the MOC at the specified order, or the MOC's current order if this is not specified. ...
[ "def", "plot_moc", "(", "moc", ",", "order", "=", "None", ",", "antialias", "=", "0", ",", "filename", "=", "None", ",", "projection", "=", "'cart'", ",", "color", "=", "'blue'", ",", "title", "=", "''", ",", "coord_sys", "=", "'C'", ",", "graticule"...
Plot a MOC using Healpy. This generates a plot of the MOC at the specified order, or the MOC's current order if this is not specified. The MOC is flattened at an order of `order + antialias` to generate intermediate color levels. :param order: HEALPix order at which to generate the plot. :param ...
[ "Plot", "a", "MOC", "using", "Healpy", "." ]
train
https://github.com/grahambell/pymoc/blob/0e2e57ce07ff3de6ac024627c1fb6ad30c2fde48/lib/pymoc/util/plot.py#L22-L127
transmogrifier/pidigits
pidigits/taudigits_lambert.py
getTauLambert
def getTauLambert(n): """Returns a list containing first n digits of Pi """ myTau = tauGenLambert() result = [] if n > 0: result += [next(myTau) for i in range(n)] myTau.close() return result
python
def getTauLambert(n): """Returns a list containing first n digits of Pi """ myTau = tauGenLambert() result = [] if n > 0: result += [next(myTau) for i in range(n)] myTau.close() return result
[ "def", "getTauLambert", "(", "n", ")", ":", "myTau", "=", "tauGenLambert", "(", ")", "result", "=", "[", "]", "if", "n", ">", "0", ":", "result", "+=", "[", "next", "(", "myTau", ")", "for", "i", "in", "range", "(", "n", ")", "]", "myTau", ".",...
Returns a list containing first n digits of Pi
[ "Returns", "a", "list", "containing", "first", "n", "digits", "of", "Pi" ]
train
https://github.com/transmogrifier/pidigits/blob/b12081126a76d30fb69839aa586420c5bb04feb8/pidigits/taudigits_lambert.py#L74-L82
Robin8Put/pmes
mail/index.py
HistoryHandler.post
def post(self): """Accepts jsorpc post request. Retrieves data from request body. """ # type(data) = dict data = json.loads(self.request.body.decode()) # type(method) = str method = data["method"] # type(params) = dict params = data["params"] ...
python
def post(self): """Accepts jsorpc post request. Retrieves data from request body. """ # type(data) = dict data = json.loads(self.request.body.decode()) # type(method) = str method = data["method"] # type(params) = dict params = data["params"] ...
[ "def", "post", "(", "self", ")", ":", "# type(data) = dict", "data", "=", "json", ".", "loads", "(", "self", ".", "request", ".", "body", ".", "decode", "(", ")", ")", "# type(method) = str", "method", "=", "data", "[", "\"method\"", "]", "# type(params) =...
Accepts jsorpc post request. Retrieves data from request body.
[ "Accepts", "jsorpc", "post", "request", ".", "Retrieves", "data", "from", "request", "body", "." ]
train
https://github.com/Robin8Put/pmes/blob/338bec94162098f05b75bad035417317e1252fd2/mail/index.py#L42-L56
cjw85/myriad
myriad/managers.py
make_server
def make_server(function, port, authkey, qsize=None): """Create a manager containing input and output queues, and a function to map inputs over. A connecting client can read the stored function, apply it to items in the input queue and post back to the output queue :param function: function to appl...
python
def make_server(function, port, authkey, qsize=None): """Create a manager containing input and output queues, and a function to map inputs over. A connecting client can read the stored function, apply it to items in the input queue and post back to the output queue :param function: function to appl...
[ "def", "make_server", "(", "function", ",", "port", ",", "authkey", ",", "qsize", "=", "None", ")", ":", "QueueManager", ".", "register", "(", "'get_job_q'", ",", "callable", "=", "partial", "(", "return_arg", ",", "Queue", "(", "maxsize", "=", "qsize", ...
Create a manager containing input and output queues, and a function to map inputs over. A connecting client can read the stored function, apply it to items in the input queue and post back to the output queue :param function: function to apply to inputs :param port: port over which to server :p...
[ "Create", "a", "manager", "containing", "input", "and", "output", "queues", "and", "a", "function", "to", "map", "inputs", "over", ".", "A", "connecting", "client", "can", "read", "the", "stored", "function", "apply", "it", "to", "items", "in", "the", "inp...
train
https://github.com/cjw85/myriad/blob/518124d431bf5cd2a7853489eb9c95d849d12346/myriad/managers.py#L38-L64
cjw85/myriad
myriad/managers.py
make_client
def make_client(ip, port, authkey): """Create a manager to connect to our server manager :param ip: ip address of server :param port: port over which to server :param authkey: authorization key """ QueueManager.register('get_job_q') QueueManager.register('get_result_q') QueueManager.re...
python
def make_client(ip, port, authkey): """Create a manager to connect to our server manager :param ip: ip address of server :param port: port over which to server :param authkey: authorization key """ QueueManager.register('get_job_q') QueueManager.register('get_result_q') QueueManager.re...
[ "def", "make_client", "(", "ip", ",", "port", ",", "authkey", ")", ":", "QueueManager", ".", "register", "(", "'get_job_q'", ")", "QueueManager", ".", "register", "(", "'get_result_q'", ")", "QueueManager", ".", "register", "(", "'get_function'", ")", "QueueMa...
Create a manager to connect to our server manager :param ip: ip address of server :param port: port over which to server :param authkey: authorization key
[ "Create", "a", "manager", "to", "connect", "to", "our", "server", "manager" ]
train
https://github.com/cjw85/myriad/blob/518124d431bf5cd2a7853489eb9c95d849d12346/myriad/managers.py#L67-L82
sveetch/boussole
boussole/cli/compile.py
compile_command
def compile_command(context, backend, config): """ Compile Sass project sources to CSS """ logger = logging.getLogger("boussole") logger.info(u"Building project") # Discover settings file try: discovering = Discover(backends=[SettingsBackendJson, ...
python
def compile_command(context, backend, config): """ Compile Sass project sources to CSS """ logger = logging.getLogger("boussole") logger.info(u"Building project") # Discover settings file try: discovering = Discover(backends=[SettingsBackendJson, ...
[ "def", "compile_command", "(", "context", ",", "backend", ",", "config", ")", ":", "logger", "=", "logging", ".", "getLogger", "(", "\"boussole\"", ")", "logger", ".", "info", "(", "u\"Building project\"", ")", "# Discover settings file", "try", ":", "discoverin...
Compile Sass project sources to CSS
[ "Compile", "Sass", "project", "sources", "to", "CSS" ]
train
https://github.com/sveetch/boussole/blob/22cc644e9d633f41ebfc167d427a71c1726cee21/boussole/cli/compile.py#L26-L86
eighthave/pyvendapin
vendapin.py
Vendapin._checksum
def _checksum(self, packet): '''calculate the XOR checksum of a packet in string format''' xorsum = 0 for s in packet: xorsum ^= ord(s) return xorsum
python
def _checksum(self, packet): '''calculate the XOR checksum of a packet in string format''' xorsum = 0 for s in packet: xorsum ^= ord(s) return xorsum
[ "def", "_checksum", "(", "self", ",", "packet", ")", ":", "xorsum", "=", "0", "for", "s", "in", "packet", ":", "xorsum", "^=", "ord", "(", "s", ")", "return", "xorsum" ]
calculate the XOR checksum of a packet in string format
[ "calculate", "the", "XOR", "checksum", "of", "a", "packet", "in", "string", "format" ]
train
https://github.com/eighthave/pyvendapin/blob/270c4da5c31ab4a0435660b25b655692fdffcf01/vendapin.py#L112-L117
eighthave/pyvendapin
vendapin.py
Vendapin.was_packet_accepted
def was_packet_accepted(self, packet): '''parse the "command" byte from the response packet to get a "response code"''' self._validatepacket(packet) cmd = ord(packet[2]) if cmd == Vendapin.ACK: # Accepted/Positive Status return True elif cmd == Vendapin.NAK: # Rejecte...
python
def was_packet_accepted(self, packet): '''parse the "command" byte from the response packet to get a "response code"''' self._validatepacket(packet) cmd = ord(packet[2]) if cmd == Vendapin.ACK: # Accepted/Positive Status return True elif cmd == Vendapin.NAK: # Rejecte...
[ "def", "was_packet_accepted", "(", "self", ",", "packet", ")", ":", "self", ".", "_validatepacket", "(", "packet", ")", "cmd", "=", "ord", "(", "packet", "[", "2", "]", ")", "if", "cmd", "==", "Vendapin", ".", "ACK", ":", "# Accepted/Positive Status", "r...
parse the "command" byte from the response packet to get a "response code"
[ "parse", "the", "command", "byte", "from", "the", "response", "packet", "to", "get", "a", "response", "code" ]
train
https://github.com/eighthave/pyvendapin/blob/270c4da5c31ab4a0435660b25b655692fdffcf01/vendapin.py#L161-L177
eighthave/pyvendapin
vendapin.py
Vendapin.parsedata
def parsedata(self, packet): '''parse the data section of a packet, it can range from 0 to many bytes''' data = [] datalength = ord(packet[3]) position = 4 while position < datalength + 4: data.append(packet[position]) position += 1 return data
python
def parsedata(self, packet): '''parse the data section of a packet, it can range from 0 to many bytes''' data = [] datalength = ord(packet[3]) position = 4 while position < datalength + 4: data.append(packet[position]) position += 1 return data
[ "def", "parsedata", "(", "self", ",", "packet", ")", ":", "data", "=", "[", "]", "datalength", "=", "ord", "(", "packet", "[", "3", "]", ")", "position", "=", "4", "while", "position", "<", "datalength", "+", "4", ":", "data", ".", "append", "(", ...
parse the data section of a packet, it can range from 0 to many bytes
[ "parse", "the", "data", "section", "of", "a", "packet", "it", "can", "range", "from", "0", "to", "many", "bytes" ]
train
https://github.com/eighthave/pyvendapin/blob/270c4da5c31ab4a0435660b25b655692fdffcf01/vendapin.py#L180-L188
eighthave/pyvendapin
vendapin.py
Vendapin.sendcommand
def sendcommand(self, command, datalength=0, data=None): '''send a packet in the vendapin format''' packet = chr(Vendapin.STX) + chr(Vendapin.ADD) + chr(command) + chr(datalength) if datalength > 0: packet += chr(data) packet += chr(Vendapin.ETX) sendpacket = packet +...
python
def sendcommand(self, command, datalength=0, data=None): '''send a packet in the vendapin format''' packet = chr(Vendapin.STX) + chr(Vendapin.ADD) + chr(command) + chr(datalength) if datalength > 0: packet += chr(data) packet += chr(Vendapin.ETX) sendpacket = packet +...
[ "def", "sendcommand", "(", "self", ",", "command", ",", "datalength", "=", "0", ",", "data", "=", "None", ")", ":", "packet", "=", "chr", "(", "Vendapin", ".", "STX", ")", "+", "chr", "(", "Vendapin", ".", "ADD", ")", "+", "chr", "(", "command", ...
send a packet in the vendapin format
[ "send", "a", "packet", "in", "the", "vendapin", "format" ]
train
https://github.com/eighthave/pyvendapin/blob/270c4da5c31ab4a0435660b25b655692fdffcf01/vendapin.py#L214-L222
eighthave/pyvendapin
vendapin.py
Vendapin.request_status
def request_status(self): '''request the status of the card dispenser and return the status code''' self.sendcommand(Vendapin.REQUEST_STATUS) # wait for the reply time.sleep(1) response = self.receivepacket() if self.was_packet_accepted(response): return Venda...
python
def request_status(self): '''request the status of the card dispenser and return the status code''' self.sendcommand(Vendapin.REQUEST_STATUS) # wait for the reply time.sleep(1) response = self.receivepacket() if self.was_packet_accepted(response): return Venda...
[ "def", "request_status", "(", "self", ")", ":", "self", ".", "sendcommand", "(", "Vendapin", ".", "REQUEST_STATUS", ")", "# wait for the reply", "time", ".", "sleep", "(", "1", ")", "response", "=", "self", ".", "receivepacket", "(", ")", "if", "self", "."...
request the status of the card dispenser and return the status code
[ "request", "the", "status", "of", "the", "card", "dispenser", "and", "return", "the", "status", "code" ]
train
https://github.com/eighthave/pyvendapin/blob/270c4da5c31ab4a0435660b25b655692fdffcf01/vendapin.py#L225-L234
eighthave/pyvendapin
vendapin.py
Vendapin.dispense
def dispense(self): '''dispense a card if ready, otherwise throw an Exception''' self.sendcommand(Vendapin.DISPENSE) # wait for the reply time.sleep(1) # parse the reply response = self.receivepacket() print('Vendapin.dispense(): ' + str(response)) if not ...
python
def dispense(self): '''dispense a card if ready, otherwise throw an Exception''' self.sendcommand(Vendapin.DISPENSE) # wait for the reply time.sleep(1) # parse the reply response = self.receivepacket() print('Vendapin.dispense(): ' + str(response)) if not ...
[ "def", "dispense", "(", "self", ")", ":", "self", ".", "sendcommand", "(", "Vendapin", ".", "DISPENSE", ")", "# wait for the reply", "time", ".", "sleep", "(", "1", ")", "# parse the reply", "response", "=", "self", ".", "receivepacket", "(", ")", "print", ...
dispense a card if ready, otherwise throw an Exception
[ "dispense", "a", "card", "if", "ready", "otherwise", "throw", "an", "Exception" ]
train
https://github.com/eighthave/pyvendapin/blob/270c4da5c31ab4a0435660b25b655692fdffcf01/vendapin.py#L237-L247