repo
stringlengths
7
55
path
stringlengths
4
127
func_name
stringlengths
1
88
original_string
stringlengths
75
19.8k
language
stringclasses
1 value
code
stringlengths
75
19.8k
code_tokens
listlengths
20
707
docstring
stringlengths
3
17.3k
docstring_tokens
listlengths
3
222
sha
stringlengths
40
40
url
stringlengths
87
242
partition
stringclasses
1 value
idx
int64
0
252k
henocdz/workon
workon/script.py
WorkOn.list
def list(self, **kwargs): """displays all projects on database """ projects = Project.select().order_by(Project.name) if len(projects) == 0: self._print('No projects available', 'yellow') return for project in projects: project_repr = self._PR...
python
def list(self, **kwargs): """displays all projects on database """ projects = Project.select().order_by(Project.name) if len(projects) == 0: self._print('No projects available', 'yellow') return for project in projects: project_repr = self._PR...
[ "def", "list", "(", "self", ",", "*", "*", "kwargs", ")", ":", "projects", "=", "Project", ".", "select", "(", ")", ".", "order_by", "(", "Project", ".", "name", ")", "if", "len", "(", "projects", ")", "==", "0", ":", "self", ".", "_print", "(", ...
displays all projects on database
[ "displays", "all", "projects", "on", "database" ]
46f1f6dc4ea95d8efd10adf93a06737237a6874d
https://github.com/henocdz/workon/blob/46f1f6dc4ea95d8efd10adf93a06737237a6874d/workon/script.py#L97-L108
train
56,800
honzajavorek/tipi
tipi/html.py
HTMLString.parent_tags
def parent_tags(self): """Provides tags of all parent HTML elements.""" tags = set() for addr in self._addresses: if addr.attr == 'text': tags.add(addr.element.tag) tags.update(el.tag for el in addr.element.iterancestors()) tags.discard(HTMLFragm...
python
def parent_tags(self): """Provides tags of all parent HTML elements.""" tags = set() for addr in self._addresses: if addr.attr == 'text': tags.add(addr.element.tag) tags.update(el.tag for el in addr.element.iterancestors()) tags.discard(HTMLFragm...
[ "def", "parent_tags", "(", "self", ")", ":", "tags", "=", "set", "(", ")", "for", "addr", "in", "self", ".", "_addresses", ":", "if", "addr", ".", "attr", "==", "'text'", ":", "tags", ".", "add", "(", "addr", ".", "element", ".", "tag", ")", "tag...
Provides tags of all parent HTML elements.
[ "Provides", "tags", "of", "all", "parent", "HTML", "elements", "." ]
cbe51192725608b6fba1244a48610ae231b13e08
https://github.com/honzajavorek/tipi/blob/cbe51192725608b6fba1244a48610ae231b13e08/tipi/html.py#L39-L49
train
56,801
honzajavorek/tipi
tipi/html.py
HTMLString.involved_tags
def involved_tags(self): """Provides all HTML tags directly involved in this string.""" if len(self._addresses) < 2: # there can't be a tag boundary if there's only 1 or 0 characters return frozenset() # creating 'parent_sets' mapping, where the first item in tuple ...
python
def involved_tags(self): """Provides all HTML tags directly involved in this string.""" if len(self._addresses) < 2: # there can't be a tag boundary if there's only 1 or 0 characters return frozenset() # creating 'parent_sets' mapping, where the first item in tuple ...
[ "def", "involved_tags", "(", "self", ")", ":", "if", "len", "(", "self", ".", "_addresses", ")", "<", "2", ":", "# there can't be a tag boundary if there's only 1 or 0 characters", "return", "frozenset", "(", ")", "# creating 'parent_sets' mapping, where the first item in t...
Provides all HTML tags directly involved in this string.
[ "Provides", "all", "HTML", "tags", "directly", "involved", "in", "this", "string", "." ]
cbe51192725608b6fba1244a48610ae231b13e08
https://github.com/honzajavorek/tipi/blob/cbe51192725608b6fba1244a48610ae231b13e08/tipi/html.py#L52-L100
train
56,802
honzajavorek/tipi
tipi/html.py
HTMLFragment._parse
def _parse(self, html): """Parse given string as HTML and return it's etree representation.""" if self._has_body_re.search(html): tree = lxml.html.document_fromstring(html).find('.//body') self.has_body = True else: tree = lxml.html.fragment_fromstring(html, ...
python
def _parse(self, html): """Parse given string as HTML and return it's etree representation.""" if self._has_body_re.search(html): tree = lxml.html.document_fromstring(html).find('.//body') self.has_body = True else: tree = lxml.html.fragment_fromstring(html, ...
[ "def", "_parse", "(", "self", ",", "html", ")", ":", "if", "self", ".", "_has_body_re", ".", "search", "(", "html", ")", ":", "tree", "=", "lxml", ".", "html", ".", "document_fromstring", "(", "html", ")", ".", "find", "(", "'.//body'", ")", "self", ...
Parse given string as HTML and return it's etree representation.
[ "Parse", "given", "string", "as", "HTML", "and", "return", "it", "s", "etree", "representation", "." ]
cbe51192725608b6fba1244a48610ae231b13e08
https://github.com/honzajavorek/tipi/blob/cbe51192725608b6fba1244a48610ae231b13e08/tipi/html.py#L133-L149
train
56,803
honzajavorek/tipi
tipi/html.py
HTMLFragment._iter_texts
def _iter_texts(self, tree): """Iterates over texts in given HTML tree.""" skip = ( not isinstance(tree, lxml.html.HtmlElement) # comments, etc. or tree.tag in self.skipped_tags ) if not skip: if tree.text: yield Text(tree.text, tree, ...
python
def _iter_texts(self, tree): """Iterates over texts in given HTML tree.""" skip = ( not isinstance(tree, lxml.html.HtmlElement) # comments, etc. or tree.tag in self.skipped_tags ) if not skip: if tree.text: yield Text(tree.text, tree, ...
[ "def", "_iter_texts", "(", "self", ",", "tree", ")", ":", "skip", "=", "(", "not", "isinstance", "(", "tree", ",", "lxml", ".", "html", ".", "HtmlElement", ")", "# comments, etc.", "or", "tree", ".", "tag", "in", "self", ".", "skipped_tags", ")", "if",...
Iterates over texts in given HTML tree.
[ "Iterates", "over", "texts", "in", "given", "HTML", "tree", "." ]
cbe51192725608b6fba1244a48610ae231b13e08
https://github.com/honzajavorek/tipi/blob/cbe51192725608b6fba1244a48610ae231b13e08/tipi/html.py#L151-L164
train
56,804
honzajavorek/tipi
tipi/html.py
HTMLFragment._analyze_tree
def _analyze_tree(self, tree): """Analyze given tree and create mapping of indexes to character addresses. """ addresses = [] for text in self._iter_texts(tree): for i, char in enumerate(text.content): if char in whitespace: char = ...
python
def _analyze_tree(self, tree): """Analyze given tree and create mapping of indexes to character addresses. """ addresses = [] for text in self._iter_texts(tree): for i, char in enumerate(text.content): if char in whitespace: char = ...
[ "def", "_analyze_tree", "(", "self", ",", "tree", ")", ":", "addresses", "=", "[", "]", "for", "text", "in", "self", ".", "_iter_texts", "(", "tree", ")", ":", "for", "i", ",", "char", "in", "enumerate", "(", "text", ".", "content", ")", ":", "if",...
Analyze given tree and create mapping of indexes to character addresses.
[ "Analyze", "given", "tree", "and", "create", "mapping", "of", "indexes", "to", "character", "addresses", "." ]
cbe51192725608b6fba1244a48610ae231b13e08
https://github.com/honzajavorek/tipi/blob/cbe51192725608b6fba1244a48610ae231b13e08/tipi/html.py#L166-L183
train
56,805
honzajavorek/tipi
tipi/html.py
HTMLFragment._validate_index
def _validate_index(self, index): """Validates given index, eventually raises errors.""" if isinstance(index, slice): if index.step and index.step != 1: raise IndexError('Step is not allowed.') indexes = (index.start, index.stop) else: indexes ...
python
def _validate_index(self, index): """Validates given index, eventually raises errors.""" if isinstance(index, slice): if index.step and index.step != 1: raise IndexError('Step is not allowed.') indexes = (index.start, index.stop) else: indexes ...
[ "def", "_validate_index", "(", "self", ",", "index", ")", ":", "if", "isinstance", "(", "index", ",", "slice", ")", ":", "if", "index", ".", "step", "and", "index", ".", "step", "!=", "1", ":", "raise", "IndexError", "(", "'Step is not allowed.'", ")", ...
Validates given index, eventually raises errors.
[ "Validates", "given", "index", "eventually", "raises", "errors", "." ]
cbe51192725608b6fba1244a48610ae231b13e08
https://github.com/honzajavorek/tipi/blob/cbe51192725608b6fba1244a48610ae231b13e08/tipi/html.py#L189-L199
train
56,806
honzajavorek/tipi
tipi/html.py
HTMLFragment._find_pivot_addr
def _find_pivot_addr(self, index): """Inserting by slicing can lead into situation where no addresses are selected. In that case a pivot address has to be chosen so we know where to add characters. """ if not self.addresses or index.start == 0: return CharAddress('', ...
python
def _find_pivot_addr(self, index): """Inserting by slicing can lead into situation where no addresses are selected. In that case a pivot address has to be chosen so we know where to add characters. """ if not self.addresses or index.start == 0: return CharAddress('', ...
[ "def", "_find_pivot_addr", "(", "self", ",", "index", ")", ":", "if", "not", "self", ".", "addresses", "or", "index", ".", "start", "==", "0", ":", "return", "CharAddress", "(", "''", ",", "self", ".", "tree", ",", "'text'", ",", "-", "1", ")", "# ...
Inserting by slicing can lead into situation where no addresses are selected. In that case a pivot address has to be chosen so we know where to add characters.
[ "Inserting", "by", "slicing", "can", "lead", "into", "situation", "where", "no", "addresses", "are", "selected", ".", "In", "that", "case", "a", "pivot", "address", "has", "to", "be", "chosen", "so", "we", "know", "where", "to", "add", "characters", "." ]
cbe51192725608b6fba1244a48610ae231b13e08
https://github.com/honzajavorek/tipi/blob/cbe51192725608b6fba1244a48610ae231b13e08/tipi/html.py#L210-L219
train
56,807
blockadeio/analyst_toolbench
blockade/aws/lambda-scripts/Blockade-Add-Indicators.py
check_api_key
def check_api_key(email, api_key): """Check the API key of the user.""" table = boto3.resource("dynamodb").Table(os.environ['people']) user = table.get_item(Key={'email': email}) if not user: return False user = user.get("Item") if api_key != user.get('api_key', None): return Fal...
python
def check_api_key(email, api_key): """Check the API key of the user.""" table = boto3.resource("dynamodb").Table(os.environ['people']) user = table.get_item(Key={'email': email}) if not user: return False user = user.get("Item") if api_key != user.get('api_key', None): return Fal...
[ "def", "check_api_key", "(", "email", ",", "api_key", ")", ":", "table", "=", "boto3", ".", "resource", "(", "\"dynamodb\"", ")", ".", "Table", "(", "os", ".", "environ", "[", "'people'", "]", ")", "user", "=", "table", ".", "get_item", "(", "Key", "...
Check the API key of the user.
[ "Check", "the", "API", "key", "of", "the", "user", "." ]
159b6f8cf8a91c5ff050f1579636ea90ab269863
https://github.com/blockadeio/analyst_toolbench/blob/159b6f8cf8a91c5ff050f1579636ea90ab269863/blockade/aws/lambda-scripts/Blockade-Add-Indicators.py#L12-L21
train
56,808
honzajavorek/tipi
tipi/repl.py
replace
def replace(html, replacements=None): """Performs replacements on given HTML string.""" if not replacements: return html # no replacements html = HTMLFragment(html) for r in replacements: r.replace(html) return unicode(html)
python
def replace(html, replacements=None): """Performs replacements on given HTML string.""" if not replacements: return html # no replacements html = HTMLFragment(html) for r in replacements: r.replace(html) return unicode(html)
[ "def", "replace", "(", "html", ",", "replacements", "=", "None", ")", ":", "if", "not", "replacements", ":", "return", "html", "# no replacements", "html", "=", "HTMLFragment", "(", "html", ")", "for", "r", "in", "replacements", ":", "r", ".", "replace", ...
Performs replacements on given HTML string.
[ "Performs", "replacements", "on", "given", "HTML", "string", "." ]
cbe51192725608b6fba1244a48610ae231b13e08
https://github.com/honzajavorek/tipi/blob/cbe51192725608b6fba1244a48610ae231b13e08/tipi/repl.py#L65-L74
train
56,809
honzajavorek/tipi
tipi/repl.py
Replacement._is_replacement_allowed
def _is_replacement_allowed(self, s): """Tests whether replacement is allowed on given piece of HTML text.""" if any(tag in s.parent_tags for tag in self.skipped_tags): return False if any(tag not in self.textflow_tags for tag in s.involved_tags): return False ret...
python
def _is_replacement_allowed(self, s): """Tests whether replacement is allowed on given piece of HTML text.""" if any(tag in s.parent_tags for tag in self.skipped_tags): return False if any(tag not in self.textflow_tags for tag in s.involved_tags): return False ret...
[ "def", "_is_replacement_allowed", "(", "self", ",", "s", ")", ":", "if", "any", "(", "tag", "in", "s", ".", "parent_tags", "for", "tag", "in", "self", ".", "skipped_tags", ")", ":", "return", "False", "if", "any", "(", "tag", "not", "in", "self", "."...
Tests whether replacement is allowed on given piece of HTML text.
[ "Tests", "whether", "replacement", "is", "allowed", "on", "given", "piece", "of", "HTML", "text", "." ]
cbe51192725608b6fba1244a48610ae231b13e08
https://github.com/honzajavorek/tipi/blob/cbe51192725608b6fba1244a48610ae231b13e08/tipi/repl.py#L28-L34
train
56,810
honzajavorek/tipi
tipi/repl.py
Replacement.replace
def replace(self, html): """Perform replacements on given HTML fragment.""" self.html = html text = html.text() positions = [] def perform_replacement(match): offset = sum(positions) start, stop = match.start() + offset, match.end() + offset ...
python
def replace(self, html): """Perform replacements on given HTML fragment.""" self.html = html text = html.text() positions = [] def perform_replacement(match): offset = sum(positions) start, stop = match.start() + offset, match.end() + offset ...
[ "def", "replace", "(", "self", ",", "html", ")", ":", "self", ".", "html", "=", "html", "text", "=", "html", ".", "text", "(", ")", "positions", "=", "[", "]", "def", "perform_replacement", "(", "match", ")", ":", "offset", "=", "sum", "(", "positi...
Perform replacements on given HTML fragment.
[ "Perform", "replacements", "on", "given", "HTML", "fragment", "." ]
cbe51192725608b6fba1244a48610ae231b13e08
https://github.com/honzajavorek/tipi/blob/cbe51192725608b6fba1244a48610ae231b13e08/tipi/repl.py#L36-L62
train
56,811
benoitbryon/rst2rst
rst2rst/utils/__init__.py
read_relative_file
def read_relative_file(filename, relative_to=None): """Returns contents of the given file, which path is supposed relative to this package.""" if relative_to is None: relative_to = os.path.dirname(__file__) with open(os.path.join(os.path.dirname(relative_to), filename)) as f: return f.re...
python
def read_relative_file(filename, relative_to=None): """Returns contents of the given file, which path is supposed relative to this package.""" if relative_to is None: relative_to = os.path.dirname(__file__) with open(os.path.join(os.path.dirname(relative_to), filename)) as f: return f.re...
[ "def", "read_relative_file", "(", "filename", ",", "relative_to", "=", "None", ")", ":", "if", "relative_to", "is", "None", ":", "relative_to", "=", "os", ".", "path", ".", "dirname", "(", "__file__", ")", "with", "open", "(", "os", ".", "path", ".", "...
Returns contents of the given file, which path is supposed relative to this package.
[ "Returns", "contents", "of", "the", "given", "file", "which", "path", "is", "supposed", "relative", "to", "this", "package", "." ]
976eef709aacb1facc8dca87cf7032f01d53adfe
https://github.com/benoitbryon/rst2rst/blob/976eef709aacb1facc8dca87cf7032f01d53adfe/rst2rst/utils/__init__.py#L54-L60
train
56,812
blockadeio/analyst_toolbench
blockade/libs/events.py
EventsClient.get_events
def get_events(self): """Get events from the cloud node.""" to_send = {'limit': 50} response = self._send_data('POST', 'admin', 'get-events', to_send) output = {'message': ""} for event in response['events']: desc = "Source IP: {ip}\n" desc += "Datetime: ...
python
def get_events(self): """Get events from the cloud node.""" to_send = {'limit': 50} response = self._send_data('POST', 'admin', 'get-events', to_send) output = {'message': ""} for event in response['events']: desc = "Source IP: {ip}\n" desc += "Datetime: ...
[ "def", "get_events", "(", "self", ")", ":", "to_send", "=", "{", "'limit'", ":", "50", "}", "response", "=", "self", ".", "_send_data", "(", "'POST'", ",", "'admin'", ",", "'get-events'", ",", "to_send", ")", "output", "=", "{", "'message'", ":", "\"\"...
Get events from the cloud node.
[ "Get", "events", "from", "the", "cloud", "node", "." ]
159b6f8cf8a91c5ff050f1579636ea90ab269863
https://github.com/blockadeio/analyst_toolbench/blob/159b6f8cf8a91c5ff050f1579636ea90ab269863/blockade/libs/events.py#L18-L36
train
56,813
blockadeio/analyst_toolbench
blockade/libs/events.py
EventsClient.flush_events
def flush_events(self): """Flush events from the cloud node.""" response = self._send_data('DELETE', 'admin', 'flush-events', {}) if response['success']: msg = "Events flushed" else: msg = "Flushing of events failed" output = {'message': msg} ret...
python
def flush_events(self): """Flush events from the cloud node.""" response = self._send_data('DELETE', 'admin', 'flush-events', {}) if response['success']: msg = "Events flushed" else: msg = "Flushing of events failed" output = {'message': msg} ret...
[ "def", "flush_events", "(", "self", ")", ":", "response", "=", "self", ".", "_send_data", "(", "'DELETE'", ",", "'admin'", ",", "'flush-events'", ",", "{", "}", ")", "if", "response", "[", "'success'", "]", ":", "msg", "=", "\"Events flushed\"", "else", ...
Flush events from the cloud node.
[ "Flush", "events", "from", "the", "cloud", "node", "." ]
159b6f8cf8a91c5ff050f1579636ea90ab269863
https://github.com/blockadeio/analyst_toolbench/blob/159b6f8cf8a91c5ff050f1579636ea90ab269863/blockade/libs/events.py#L38-L48
train
56,814
RescueTime/cwmon
src/cwmon/metrics.py
Metric.put
def put(self): """Push the info represented by this ``Metric`` to CloudWatch.""" try: self.cloudwatch.put_metric_data( Namespace=self.namespace, MetricData=[{ 'MetricName': self.name, 'Value': self.value,...
python
def put(self): """Push the info represented by this ``Metric`` to CloudWatch.""" try: self.cloudwatch.put_metric_data( Namespace=self.namespace, MetricData=[{ 'MetricName': self.name, 'Value': self.value,...
[ "def", "put", "(", "self", ")", ":", "try", ":", "self", ".", "cloudwatch", ".", "put_metric_data", "(", "Namespace", "=", "self", ".", "namespace", ",", "MetricData", "=", "[", "{", "'MetricName'", ":", "self", ".", "name", ",", "'Value'", ":", "self"...
Push the info represented by this ``Metric`` to CloudWatch.
[ "Push", "the", "info", "represented", "by", "this", "Metric", "to", "CloudWatch", "." ]
1b6713ec700fdebb292099d9f493c8f97ed4ec51
https://github.com/RescueTime/cwmon/blob/1b6713ec700fdebb292099d9f493c8f97ed4ec51/src/cwmon/metrics.py#L57-L69
train
56,815
cdumay/kser
src/kser/sequencing/task.py
Task.log
def log(self, message, level=logging.INFO, *args, **kwargs): """ Send log entry :param str message: log message :param int level: `Logging level <https://docs.python.org/3/library/logging.html#levels>`_ :param list args: log record arguments :param dict kwargs: log record key ar...
python
def log(self, message, level=logging.INFO, *args, **kwargs): """ Send log entry :param str message: log message :param int level: `Logging level <https://docs.python.org/3/library/logging.html#levels>`_ :param list args: log record arguments :param dict kwargs: log record key ar...
[ "def", "log", "(", "self", ",", "message", ",", "level", "=", "logging", ".", "INFO", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "msg", "=", "\"{}.{}: {}[{}]: {}\"", ".", "format", "(", "self", ".", "__class__", ".", "__name__", ",", "self"...
Send log entry :param str message: log message :param int level: `Logging level <https://docs.python.org/3/library/logging.html#levels>`_ :param list args: log record arguments :param dict kwargs: log record key argument
[ "Send", "log", "entry" ]
fbd6fe9ab34b8b89d9937e5ff727614304af48c1
https://github.com/cdumay/kser/blob/fbd6fe9ab34b8b89d9937e5ff727614304af48c1/src/kser/sequencing/task.py#L42-L62
train
56,816
ONSdigital/sdc-rabbit
sdc/rabbit/publishers.py
Publisher._connect
def _connect(self): """ Connect to a RabbitMQ instance :returns: Boolean corresponding to success of connection :rtype: bool """ logger.info("Connecting to rabbit") for url in self._urls: try: self._connection = pika.BlockingConnectio...
python
def _connect(self): """ Connect to a RabbitMQ instance :returns: Boolean corresponding to success of connection :rtype: bool """ logger.info("Connecting to rabbit") for url in self._urls: try: self._connection = pika.BlockingConnectio...
[ "def", "_connect", "(", "self", ")", ":", "logger", ".", "info", "(", "\"Connecting to rabbit\"", ")", "for", "url", "in", "self", ".", "_urls", ":", "try", ":", "self", ".", "_connection", "=", "pika", ".", "BlockingConnection", "(", "pika", ".", "URLPa...
Connect to a RabbitMQ instance :returns: Boolean corresponding to success of connection :rtype: bool
[ "Connect", "to", "a", "RabbitMQ", "instance" ]
985adfdb09cf1b263a1f311438baeb42cbcb503a
https://github.com/ONSdigital/sdc-rabbit/blob/985adfdb09cf1b263a1f311438baeb42cbcb503a/sdc/rabbit/publishers.py#L38-L65
train
56,817
ONSdigital/sdc-rabbit
sdc/rabbit/publishers.py
Publisher._disconnect
def _disconnect(self): """ Cleanly close a RabbitMQ connection. :returns: None """ try: self._connection.close() logger.debug("Disconnected from rabbit") except Exception: logger.exception("Unable to close connection")
python
def _disconnect(self): """ Cleanly close a RabbitMQ connection. :returns: None """ try: self._connection.close() logger.debug("Disconnected from rabbit") except Exception: logger.exception("Unable to close connection")
[ "def", "_disconnect", "(", "self", ")", ":", "try", ":", "self", ".", "_connection", ".", "close", "(", ")", "logger", ".", "debug", "(", "\"Disconnected from rabbit\"", ")", "except", "Exception", ":", "logger", ".", "exception", "(", "\"Unable to close conne...
Cleanly close a RabbitMQ connection. :returns: None
[ "Cleanly", "close", "a", "RabbitMQ", "connection", "." ]
985adfdb09cf1b263a1f311438baeb42cbcb503a
https://github.com/ONSdigital/sdc-rabbit/blob/985adfdb09cf1b263a1f311438baeb42cbcb503a/sdc/rabbit/publishers.py#L67-L78
train
56,818
ONSdigital/sdc-rabbit
sdc/rabbit/publishers.py
Publisher.publish_message
def publish_message(self, message, content_type=None, headers=None, mandatory=False, immediate=False): """ Publish a response message to a RabbitMQ instance. :param message: Response message :param content_type: Pika BasicProperties content_type value :param headers: Message hea...
python
def publish_message(self, message, content_type=None, headers=None, mandatory=False, immediate=False): """ Publish a response message to a RabbitMQ instance. :param message: Response message :param content_type: Pika BasicProperties content_type value :param headers: Message hea...
[ "def", "publish_message", "(", "self", ",", "message", ",", "content_type", "=", "None", ",", "headers", "=", "None", ",", "mandatory", "=", "False", ",", "immediate", "=", "False", ")", ":", "logger", ".", "debug", "(", "\"Publishing message\"", ")", "try...
Publish a response message to a RabbitMQ instance. :param message: Response message :param content_type: Pika BasicProperties content_type value :param headers: Message header properties :param mandatory: The mandatory flag :param immediate: The immediate flag :returns:...
[ "Publish", "a", "response", "message", "to", "a", "RabbitMQ", "instance", "." ]
985adfdb09cf1b263a1f311438baeb42cbcb503a
https://github.com/ONSdigital/sdc-rabbit/blob/985adfdb09cf1b263a1f311438baeb42cbcb503a/sdc/rabbit/publishers.py#L83-L120
train
56,819
LREN-CHUV/data-tracking
data_tracking/files_recording.py
visit
def visit(folder, provenance_id, step_name, previous_step_id=None, config=None, db_url=None, is_organised=True): """Record all files from a folder into the database. Note: If a file has been copied from a previous processing step without any transformation, it will be detected and marked in the DB. The...
python
def visit(folder, provenance_id, step_name, previous_step_id=None, config=None, db_url=None, is_organised=True): """Record all files from a folder into the database. Note: If a file has been copied from a previous processing step without any transformation, it will be detected and marked in the DB. The...
[ "def", "visit", "(", "folder", ",", "provenance_id", ",", "step_name", ",", "previous_step_id", "=", "None", ",", "config", "=", "None", ",", "db_url", "=", "None", ",", "is_organised", "=", "True", ")", ":", "config", "=", "config", "if", "config", "els...
Record all files from a folder into the database. Note: If a file has been copied from a previous processing step without any transformation, it will be detected and marked in the DB. The type of file will be detected and stored in the DB (NIFTI, DICOM, ...). If a files (e.g. a DICOM file) contains som...
[ "Record", "all", "files", "from", "a", "folder", "into", "the", "database", "." ]
f645a0d6426e6019c92d5aaf4be225cff2864417
https://github.com/LREN-CHUV/data-tracking/blob/f645a0d6426e6019c92d5aaf4be225cff2864417/data_tracking/files_recording.py#L33-L121
train
56,820
sci-bots/dmf-device-ui
dmf_device_ui/plugin.py
DevicePlugin.check_sockets
def check_sockets(self): ''' Check for new messages on sockets and respond accordingly. .. versionchanged:: 0.11.3 Update routes table by setting ``df_routes`` property of :attr:`parent.canvas_slave`. .. versionchanged:: 0.12 Update ``dynamic_electr...
python
def check_sockets(self): ''' Check for new messages on sockets and respond accordingly. .. versionchanged:: 0.11.3 Update routes table by setting ``df_routes`` property of :attr:`parent.canvas_slave`. .. versionchanged:: 0.12 Update ``dynamic_electr...
[ "def", "check_sockets", "(", "self", ")", ":", "try", ":", "msg_frames", "=", "(", "self", ".", "command_socket", ".", "recv_multipart", "(", "zmq", ".", "NOBLOCK", ")", ")", "except", "zmq", ".", "Again", ":", "pass", "else", ":", "self", ".", "on_com...
Check for new messages on sockets and respond accordingly. .. versionchanged:: 0.11.3 Update routes table by setting ``df_routes`` property of :attr:`parent.canvas_slave`. .. versionchanged:: 0.12 Update ``dynamic_electrode_state_shapes`` layer of :attr...
[ "Check", "for", "new", "messages", "on", "sockets", "and", "respond", "accordingly", "." ]
05b480683c9fa43f91ce5a58de2fa90cdf363fc8
https://github.com/sci-bots/dmf-device-ui/blob/05b480683c9fa43f91ce5a58de2fa90cdf363fc8/dmf_device_ui/plugin.py#L24-L119
train
56,821
Titan-C/slaveparticles
examples/crystal_field.py
follow_cf
def follow_cf(save, Uspan, target_cf, nup, n_tot=5.0, slsp=None): """Calculates the quasiparticle weight in single site spin hamiltonian under with N degenerate half-filled orbitals """ if slsp == None: slsp = Spinon(slaves=6, orbitals=3, avg_particles=n_tot, hopping=[0.5]...
python
def follow_cf(save, Uspan, target_cf, nup, n_tot=5.0, slsp=None): """Calculates the quasiparticle weight in single site spin hamiltonian under with N degenerate half-filled orbitals """ if slsp == None: slsp = Spinon(slaves=6, orbitals=3, avg_particles=n_tot, hopping=[0.5]...
[ "def", "follow_cf", "(", "save", ",", "Uspan", ",", "target_cf", ",", "nup", ",", "n_tot", "=", "5.0", ",", "slsp", "=", "None", ")", ":", "if", "slsp", "==", "None", ":", "slsp", "=", "Spinon", "(", "slaves", "=", "6", ",", "orbitals", "=", "3",...
Calculates the quasiparticle weight in single site spin hamiltonian under with N degenerate half-filled orbitals
[ "Calculates", "the", "quasiparticle", "weight", "in", "single", "site", "spin", "hamiltonian", "under", "with", "N", "degenerate", "half", "-", "filled", "orbitals" ]
e4c2f5afb1a7b195517ef2f1b5cc758965036aab
https://github.com/Titan-C/slaveparticles/blob/e4c2f5afb1a7b195517ef2f1b5cc758965036aab/examples/crystal_field.py#L15-L43
train
56,822
Titan-C/slaveparticles
examples/crystal_field.py
targetpop
def targetpop(upper_density, coul, target_cf, slsp, n_tot): """restriction on finding the right populations that leave the crystal field same""" if upper_density < 0.503: return 0. trypops=population_distri(upper_density, n_tot) slsp.set_filling(trypops) slsp.selfconsistency(coul,0) efm_free...
python
def targetpop(upper_density, coul, target_cf, slsp, n_tot): """restriction on finding the right populations that leave the crystal field same""" if upper_density < 0.503: return 0. trypops=population_distri(upper_density, n_tot) slsp.set_filling(trypops) slsp.selfconsistency(coul,0) efm_free...
[ "def", "targetpop", "(", "upper_density", ",", "coul", ",", "target_cf", ",", "slsp", ",", "n_tot", ")", ":", "if", "upper_density", "<", "0.503", ":", "return", "0.", "trypops", "=", "population_distri", "(", "upper_density", ",", "n_tot", ")", "slsp", "....
restriction on finding the right populations that leave the crystal field same
[ "restriction", "on", "finding", "the", "right", "populations", "that", "leave", "the", "crystal", "field", "same" ]
e4c2f5afb1a7b195517ef2f1b5cc758965036aab
https://github.com/Titan-C/slaveparticles/blob/e4c2f5afb1a7b195517ef2f1b5cc758965036aab/examples/crystal_field.py#L46-L56
train
56,823
trevisanj/f311
f311/filetypes/filespectrum.py
FileSpectrum.load
def load(self, filename=None): """Method was overriden to set spectrum.filename as well""" DataFile.load(self, filename) self.spectrum.filename = filename
python
def load(self, filename=None): """Method was overriden to set spectrum.filename as well""" DataFile.load(self, filename) self.spectrum.filename = filename
[ "def", "load", "(", "self", ",", "filename", "=", "None", ")", ":", "DataFile", ".", "load", "(", "self", ",", "filename", ")", "self", ".", "spectrum", ".", "filename", "=", "filename" ]
Method was overriden to set spectrum.filename as well
[ "Method", "was", "overriden", "to", "set", "spectrum", ".", "filename", "as", "well" ]
9e502a3d1e1f74d4290a8a0bae9a34ef8d7b29f7
https://github.com/trevisanj/f311/blob/9e502a3d1e1f74d4290a8a0bae9a34ef8d7b29f7/f311/filetypes/filespectrum.py#L25-L28
train
56,824
trevisanj/f311
f311/filetypes/filespectrum.py
FileSpectrumFits._do_save_as
def _do_save_as(self, filename): """Saves spectrum back to FITS file.""" if len(self.spectrum.x) < 2: raise RuntimeError("Spectrum must have at least two points") if os.path.isfile(filename): os.unlink(filename) # PyFITS does not overwrite file hdu = self.spect...
python
def _do_save_as(self, filename): """Saves spectrum back to FITS file.""" if len(self.spectrum.x) < 2: raise RuntimeError("Spectrum must have at least two points") if os.path.isfile(filename): os.unlink(filename) # PyFITS does not overwrite file hdu = self.spect...
[ "def", "_do_save_as", "(", "self", ",", "filename", ")", ":", "if", "len", "(", "self", ".", "spectrum", ".", "x", ")", "<", "2", ":", "raise", "RuntimeError", "(", "\"Spectrum must have at least two points\"", ")", "if", "os", ".", "path", ".", "isfile", ...
Saves spectrum back to FITS file.
[ "Saves", "spectrum", "back", "to", "FITS", "file", "." ]
9e502a3d1e1f74d4290a8a0bae9a34ef8d7b29f7
https://github.com/trevisanj/f311/blob/9e502a3d1e1f74d4290a8a0bae9a34ef8d7b29f7/f311/filetypes/filespectrum.py#L74-L83
train
56,825
hackedd/gw2api
gw2api/wvw.py
matches
def matches(): """This resource returns a list of the currently running WvW matches, with the participating worlds included in the result. Further details about a match can be requested using the ``match_details`` function. The response is a list of match objects, each of which contains the followi...
python
def matches(): """This resource returns a list of the currently running WvW matches, with the participating worlds included in the result. Further details about a match can be requested using the ``match_details`` function. The response is a list of match objects, each of which contains the followi...
[ "def", "matches", "(", ")", ":", "wvw_matches", "=", "get_cached", "(", "\"wvw/matches.json\"", ",", "False", ")", ".", "get", "(", "\"wvw_matches\"", ")", "for", "match", "in", "wvw_matches", ":", "match", "[", "\"start_time\"", "]", "=", "parse_datetime", ...
This resource returns a list of the currently running WvW matches, with the participating worlds included in the result. Further details about a match can be requested using the ``match_details`` function. The response is a list of match objects, each of which contains the following properties: wv...
[ "This", "resource", "returns", "a", "list", "of", "the", "currently", "running", "WvW", "matches", "with", "the", "participating", "worlds", "included", "in", "the", "result", ".", "Further", "details", "about", "a", "match", "can", "be", "requested", "using",...
5543a78e6e3ed0573b7e84c142c44004b4779eac
https://github.com/hackedd/gw2api/blob/5543a78e6e3ed0573b7e84c142c44004b4779eac/gw2api/wvw.py#L20-L51
train
56,826
hackedd/gw2api
gw2api/wvw.py
objective_names
def objective_names(lang="en"): """This resource returns a list of the localized WvW objective names for the specified language. :param lang: The language to query the names for. :return: A dictionary mapping the objective Ids to the names. *Note that these are not the names displayed in the game,...
python
def objective_names(lang="en"): """This resource returns a list of the localized WvW objective names for the specified language. :param lang: The language to query the names for. :return: A dictionary mapping the objective Ids to the names. *Note that these are not the names displayed in the game,...
[ "def", "objective_names", "(", "lang", "=", "\"en\"", ")", ":", "params", "=", "{", "\"lang\"", ":", "lang", "}", "cache_name", "=", "\"objective_names.%(lang)s.json\"", "%", "params", "data", "=", "get_cached", "(", "\"wvw/objective_names.json\"", ",", "cache_nam...
This resource returns a list of the localized WvW objective names for the specified language. :param lang: The language to query the names for. :return: A dictionary mapping the objective Ids to the names. *Note that these are not the names displayed in the game, but rather the abstract type.*
[ "This", "resource", "returns", "a", "list", "of", "the", "localized", "WvW", "objective", "names", "for", "the", "specified", "language", "." ]
5543a78e6e3ed0573b7e84c142c44004b4779eac
https://github.com/hackedd/gw2api/blob/5543a78e6e3ed0573b7e84c142c44004b4779eac/gw2api/wvw.py#L117-L131
train
56,827
wuher/devil
devil/mappers/xmlmapper.py
XmlMapper._parse_data
def _parse_data(self, data, charset): """ Parse the xml data into dictionary. """ builder = TreeBuilder(numbermode=self._numbermode) if isinstance(data,basestring): xml.sax.parseString(data, builder) else: xml.sax.parse(data, builder) return builder.root[...
python
def _parse_data(self, data, charset): """ Parse the xml data into dictionary. """ builder = TreeBuilder(numbermode=self._numbermode) if isinstance(data,basestring): xml.sax.parseString(data, builder) else: xml.sax.parse(data, builder) return builder.root[...
[ "def", "_parse_data", "(", "self", ",", "data", ",", "charset", ")", ":", "builder", "=", "TreeBuilder", "(", "numbermode", "=", "self", ".", "_numbermode", ")", "if", "isinstance", "(", "data", ",", "basestring", ")", ":", "xml", ".", "sax", ".", "par...
Parse the xml data into dictionary.
[ "Parse", "the", "xml", "data", "into", "dictionary", "." ]
a8834d4f88d915a21754c6b96f99d0ad9123ad4d
https://github.com/wuher/devil/blob/a8834d4f88d915a21754c6b96f99d0ad9123ad4d/devil/mappers/xmlmapper.py#L68-L76
train
56,828
wuher/devil
devil/mappers/xmlmapper.py
XmlMapper._format_data
def _format_data(self, data, charset): """ Format data into XML. """ if data is None or data == '': return u'' stream = StringIO.StringIO() xml = SimplerXMLGenerator(stream, charset) xml.startDocument() xml.startElement(self._root_element_name(), {}) ...
python
def _format_data(self, data, charset): """ Format data into XML. """ if data is None or data == '': return u'' stream = StringIO.StringIO() xml = SimplerXMLGenerator(stream, charset) xml.startDocument() xml.startElement(self._root_element_name(), {}) ...
[ "def", "_format_data", "(", "self", ",", "data", ",", "charset", ")", ":", "if", "data", "is", "None", "or", "data", "==", "''", ":", "return", "u''", "stream", "=", "StringIO", ".", "StringIO", "(", ")", "xml", "=", "SimplerXMLGenerator", "(", "stream...
Format data into XML.
[ "Format", "data", "into", "XML", "." ]
a8834d4f88d915a21754c6b96f99d0ad9123ad4d
https://github.com/wuher/devil/blob/a8834d4f88d915a21754c6b96f99d0ad9123ad4d/devil/mappers/xmlmapper.py#L78-L91
train
56,829
wuher/devil
devil/mappers/xmlmapper.py
XmlMapper._to_xml
def _to_xml(self, xml, data, key=None): """ Recursively convert the data into xml. This function was originally copied from the `Piston project <https://bitbucket.org/jespern/django-piston/>`_ It has been modified since. :param xml: the xml document :type xml: SimplerXM...
python
def _to_xml(self, xml, data, key=None): """ Recursively convert the data into xml. This function was originally copied from the `Piston project <https://bitbucket.org/jespern/django-piston/>`_ It has been modified since. :param xml: the xml document :type xml: SimplerXM...
[ "def", "_to_xml", "(", "self", ",", "xml", ",", "data", ",", "key", "=", "None", ")", ":", "if", "isinstance", "(", "data", ",", "(", "list", ",", "tuple", ")", ")", ":", "for", "item", "in", "data", ":", "elemname", "=", "self", ".", "_list_item...
Recursively convert the data into xml. This function was originally copied from the `Piston project <https://bitbucket.org/jespern/django-piston/>`_ It has been modified since. :param xml: the xml document :type xml: SimplerXMLGenerator :param data: data to be formatted...
[ "Recursively", "convert", "the", "data", "into", "xml", "." ]
a8834d4f88d915a21754c6b96f99d0ad9123ad4d
https://github.com/wuher/devil/blob/a8834d4f88d915a21754c6b96f99d0ad9123ad4d/devil/mappers/xmlmapper.py#L93-L118
train
56,830
wuher/devil
devil/mappers/xmlmapper.py
TreeBuilder.startElement
def startElement(self, name, attrs): """ Initialize new node and store current node into stack. """ self.stack.append((self.current, self.chardata)) self.current = {} self.chardata = []
python
def startElement(self, name, attrs): """ Initialize new node and store current node into stack. """ self.stack.append((self.current, self.chardata)) self.current = {} self.chardata = []
[ "def", "startElement", "(", "self", ",", "name", ",", "attrs", ")", ":", "self", ".", "stack", ".", "append", "(", "(", "self", ".", "current", ",", "self", ".", "chardata", ")", ")", "self", ".", "current", "=", "{", "}", "self", ".", "chardata", ...
Initialize new node and store current node into stack.
[ "Initialize", "new", "node", "and", "store", "current", "node", "into", "stack", "." ]
a8834d4f88d915a21754c6b96f99d0ad9123ad4d
https://github.com/wuher/devil/blob/a8834d4f88d915a21754c6b96f99d0ad9123ad4d/devil/mappers/xmlmapper.py#L163-L167
train
56,831
wuher/devil
devil/mappers/xmlmapper.py
TreeBuilder.endElement
def endElement(self, name): """ End current xml element, parse and add to to parent node. """ if self.current: # we have nested elements obj = self.current else: # text only node text = ''.join(self.chardata).strip() obj = self._parse_n...
python
def endElement(self, name): """ End current xml element, parse and add to to parent node. """ if self.current: # we have nested elements obj = self.current else: # text only node text = ''.join(self.chardata).strip() obj = self._parse_n...
[ "def", "endElement", "(", "self", ",", "name", ")", ":", "if", "self", ".", "current", ":", "# we have nested elements", "obj", "=", "self", ".", "current", "else", ":", "# text only node", "text", "=", "''", ".", "join", "(", "self", ".", "chardata", ")...
End current xml element, parse and add to to parent node.
[ "End", "current", "xml", "element", "parse", "and", "add", "to", "to", "parent", "node", "." ]
a8834d4f88d915a21754c6b96f99d0ad9123ad4d
https://github.com/wuher/devil/blob/a8834d4f88d915a21754c6b96f99d0ad9123ad4d/devil/mappers/xmlmapper.py#L169-L179
train
56,832
wuher/devil
devil/mappers/xmlmapper.py
TreeBuilder._parse_node_data
def _parse_node_data(self, data): """ Parse the value of a node. Override to provide your own parsing. """ data = data or '' if self.numbermode == 'basic': return self._try_parse_basic_number(data) elif self.numbermode == 'decimal': return self._try_parse_decimal(...
python
def _parse_node_data(self, data): """ Parse the value of a node. Override to provide your own parsing. """ data = data or '' if self.numbermode == 'basic': return self._try_parse_basic_number(data) elif self.numbermode == 'decimal': return self._try_parse_decimal(...
[ "def", "_parse_node_data", "(", "self", ",", "data", ")", ":", "data", "=", "data", "or", "''", "if", "self", ".", "numbermode", "==", "'basic'", ":", "return", "self", ".", "_try_parse_basic_number", "(", "data", ")", "elif", "self", ".", "numbermode", ...
Parse the value of a node. Override to provide your own parsing.
[ "Parse", "the", "value", "of", "a", "node", ".", "Override", "to", "provide", "your", "own", "parsing", "." ]
a8834d4f88d915a21754c6b96f99d0ad9123ad4d
https://github.com/wuher/devil/blob/a8834d4f88d915a21754c6b96f99d0ad9123ad4d/devil/mappers/xmlmapper.py#L185-L193
train
56,833
wuher/devil
devil/mappers/xmlmapper.py
TreeBuilder._try_parse_basic_number
def _try_parse_basic_number(self, data): """ Try to convert the data into ``int`` or ``float``. :returns: ``Decimal`` or ``data`` if conversion fails. """ # try int first try: return int(data) except ValueError: pass # try float next ...
python
def _try_parse_basic_number(self, data): """ Try to convert the data into ``int`` or ``float``. :returns: ``Decimal`` or ``data`` if conversion fails. """ # try int first try: return int(data) except ValueError: pass # try float next ...
[ "def", "_try_parse_basic_number", "(", "self", ",", "data", ")", ":", "# try int first", "try", ":", "return", "int", "(", "data", ")", "except", "ValueError", ":", "pass", "# try float next", "try", ":", "return", "float", "(", "data", ")", "except", "Value...
Try to convert the data into ``int`` or ``float``. :returns: ``Decimal`` or ``data`` if conversion fails.
[ "Try", "to", "convert", "the", "data", "into", "int", "or", "float", "." ]
a8834d4f88d915a21754c6b96f99d0ad9123ad4d
https://github.com/wuher/devil/blob/a8834d4f88d915a21754c6b96f99d0ad9123ad4d/devil/mappers/xmlmapper.py#L195-L212
train
56,834
herrersystem/apize
apize/decorators.py
apize_raw
def apize_raw(url, method='GET'): """ Convert data and params dict -> json. """ def decorator(func): def wrapper(*args, **kwargs): elem = func(*args, **kwargs) if type(elem) is not dict: raise BadReturnVarType(func.__name__) response = send_request(url, method, elem.get('data', {}), elem.g...
python
def apize_raw(url, method='GET'): """ Convert data and params dict -> json. """ def decorator(func): def wrapper(*args, **kwargs): elem = func(*args, **kwargs) if type(elem) is not dict: raise BadReturnVarType(func.__name__) response = send_request(url, method, elem.get('data', {}), elem.g...
[ "def", "apize_raw", "(", "url", ",", "method", "=", "'GET'", ")", ":", "def", "decorator", "(", "func", ")", ":", "def", "wrapper", "(", "*", "args", ",", "*", "*", "kwargs", ")", ":", "elem", "=", "func", "(", "*", "args", ",", "*", "*", "kwar...
Convert data and params dict -> json.
[ "Convert", "data", "and", "params", "dict", "-", ">", "json", "." ]
cf491660f0ee1c89a1e87a574eb8cd3c10257597
https://github.com/herrersystem/apize/blob/cf491660f0ee1c89a1e87a574eb8cd3c10257597/apize/decorators.py#L9-L34
train
56,835
Bernardo-MG/tox-test-command
setup.py
extract_version
def extract_version(path): """ Reads the file at the specified path and returns the version contained in it. This is meant for reading the __init__.py file inside a package, and so it expects a version field like: __version__ = '1.0.0' :param path: path to the Python file :return: the ver...
python
def extract_version(path): """ Reads the file at the specified path and returns the version contained in it. This is meant for reading the __init__.py file inside a package, and so it expects a version field like: __version__ = '1.0.0' :param path: path to the Python file :return: the ver...
[ "def", "extract_version", "(", "path", ")", ":", "# Regular expression for the version", "_version_re", "=", "re", ".", "compile", "(", "r'__version__\\s+=\\s+(.*)'", ")", "with", "open", "(", "path", "+", "'__init__.py'", ",", "'r'", ",", "encoding", "=", "'utf-8...
Reads the file at the specified path and returns the version contained in it. This is meant for reading the __init__.py file inside a package, and so it expects a version field like: __version__ = '1.0.0' :param path: path to the Python file :return: the version inside the file
[ "Reads", "the", "file", "at", "the", "specified", "path", "and", "returns", "the", "version", "contained", "in", "it", "." ]
b8412adae08fa4399fc8b1a33b277aa96dec35c8
https://github.com/Bernardo-MG/tox-test-command/blob/b8412adae08fa4399fc8b1a33b277aa96dec35c8/setup.py#L35-L65
train
56,836
kgaughan/dbkit
dbkit.py
_make_connect
def _make_connect(module, args, kwargs): """ Returns a function capable of making connections with a particular driver given the supplied credentials. """ # pylint: disable-msg=W0142 return functools.partial(module.connect, *args, **kwargs)
python
def _make_connect(module, args, kwargs): """ Returns a function capable of making connections with a particular driver given the supplied credentials. """ # pylint: disable-msg=W0142 return functools.partial(module.connect, *args, **kwargs)
[ "def", "_make_connect", "(", "module", ",", "args", ",", "kwargs", ")", ":", "# pylint: disable-msg=W0142", "return", "functools", ".", "partial", "(", "module", ".", "connect", ",", "*", "args", ",", "*", "*", "kwargs", ")" ]
Returns a function capable of making connections with a particular driver given the supplied credentials.
[ "Returns", "a", "function", "capable", "of", "making", "connections", "with", "a", "particular", "driver", "given", "the", "supplied", "credentials", "." ]
2aef6376a60965d7820c91692046f4bcf7d43640
https://github.com/kgaughan/dbkit/blob/2aef6376a60965d7820c91692046f4bcf7d43640/dbkit.py#L565-L571
train
56,837
kgaughan/dbkit
dbkit.py
create_pool
def create_pool(module, max_conns, *args, **kwargs): """ Create a connection pool appropriate to the driver module's capabilities. """ if not hasattr(module, 'threadsafety'): raise NotSupported("Cannot determine driver threadsafety.") if max_conns < 1: raise ValueError("Minimum numbe...
python
def create_pool(module, max_conns, *args, **kwargs): """ Create a connection pool appropriate to the driver module's capabilities. """ if not hasattr(module, 'threadsafety'): raise NotSupported("Cannot determine driver threadsafety.") if max_conns < 1: raise ValueError("Minimum numbe...
[ "def", "create_pool", "(", "module", ",", "max_conns", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "if", "not", "hasattr", "(", "module", ",", "'threadsafety'", ")", ":", "raise", "NotSupported", "(", "\"Cannot determine driver threadsafety.\"", ")", ...
Create a connection pool appropriate to the driver module's capabilities.
[ "Create", "a", "connection", "pool", "appropriate", "to", "the", "driver", "module", "s", "capabilities", "." ]
2aef6376a60965d7820c91692046f4bcf7d43640
https://github.com/kgaughan/dbkit/blob/2aef6376a60965d7820c91692046f4bcf7d43640/dbkit.py#L585-L597
train
56,838
kgaughan/dbkit
dbkit.py
transactional
def transactional(wrapped): """ A decorator to denote that the content of the decorated function or method is to be ran in a transaction. The following code is equivalent to the example for :py:func:`dbkit.transaction`:: import sqlite3 import sys from dbkit import connect, ...
python
def transactional(wrapped): """ A decorator to denote that the content of the decorated function or method is to be ran in a transaction. The following code is equivalent to the example for :py:func:`dbkit.transaction`:: import sqlite3 import sys from dbkit import connect, ...
[ "def", "transactional", "(", "wrapped", ")", ":", "# pylint: disable-msg=C0111", "def", "wrapper", "(", "*", "args", ",", "*", "*", "kwargs", ")", ":", "with", "Context", ".", "current", "(", ")", ".", "transaction", "(", ")", ":", "return", "wrapped", "...
A decorator to denote that the content of the decorated function or method is to be ran in a transaction. The following code is equivalent to the example for :py:func:`dbkit.transaction`:: import sqlite3 import sys from dbkit import connect, transactional, query_value, execute ...
[ "A", "decorator", "to", "denote", "that", "the", "content", "of", "the", "decorated", "function", "or", "method", "is", "to", "be", "ran", "in", "a", "transaction", "." ]
2aef6376a60965d7820c91692046f4bcf7d43640
https://github.com/kgaughan/dbkit/blob/2aef6376a60965d7820c91692046f4bcf7d43640/dbkit.py#L644-L683
train
56,839
kgaughan/dbkit
dbkit.py
execute
def execute(stmt, args=()): """ Execute an SQL statement. Returns the number of affected rows. """ ctx = Context.current() with ctx.mdr: cursor = ctx.execute(stmt, args) row_count = cursor.rowcount _safe_close(cursor) return row_count
python
def execute(stmt, args=()): """ Execute an SQL statement. Returns the number of affected rows. """ ctx = Context.current() with ctx.mdr: cursor = ctx.execute(stmt, args) row_count = cursor.rowcount _safe_close(cursor) return row_count
[ "def", "execute", "(", "stmt", ",", "args", "=", "(", ")", ")", ":", "ctx", "=", "Context", ".", "current", "(", ")", "with", "ctx", ".", "mdr", ":", "cursor", "=", "ctx", ".", "execute", "(", "stmt", ",", "args", ")", "row_count", "=", "cursor",...
Execute an SQL statement. Returns the number of affected rows.
[ "Execute", "an", "SQL", "statement", ".", "Returns", "the", "number", "of", "affected", "rows", "." ]
2aef6376a60965d7820c91692046f4bcf7d43640
https://github.com/kgaughan/dbkit/blob/2aef6376a60965d7820c91692046f4bcf7d43640/dbkit.py#L693-L702
train
56,840
kgaughan/dbkit
dbkit.py
query
def query(stmt, args=(), factory=None): """ Execute a query. This returns an iterator of the result set. """ ctx = Context.current() factory = ctx.default_factory if factory is None else factory with ctx.mdr: return factory(ctx.execute(stmt, args), ctx.mdr)
python
def query(stmt, args=(), factory=None): """ Execute a query. This returns an iterator of the result set. """ ctx = Context.current() factory = ctx.default_factory if factory is None else factory with ctx.mdr: return factory(ctx.execute(stmt, args), ctx.mdr)
[ "def", "query", "(", "stmt", ",", "args", "=", "(", ")", ",", "factory", "=", "None", ")", ":", "ctx", "=", "Context", ".", "current", "(", ")", "factory", "=", "ctx", ".", "default_factory", "if", "factory", "is", "None", "else", "factory", "with", ...
Execute a query. This returns an iterator of the result set.
[ "Execute", "a", "query", ".", "This", "returns", "an", "iterator", "of", "the", "result", "set", "." ]
2aef6376a60965d7820c91692046f4bcf7d43640
https://github.com/kgaughan/dbkit/blob/2aef6376a60965d7820c91692046f4bcf7d43640/dbkit.py#L705-L712
train
56,841
kgaughan/dbkit
dbkit.py
query_row
def query_row(stmt, args=(), factory=None): """ Execute a query. Returns the first row of the result set, or `None`. """ for row in query(stmt, args, factory): return row return None
python
def query_row(stmt, args=(), factory=None): """ Execute a query. Returns the first row of the result set, or `None`. """ for row in query(stmt, args, factory): return row return None
[ "def", "query_row", "(", "stmt", ",", "args", "=", "(", ")", ",", "factory", "=", "None", ")", ":", "for", "row", "in", "query", "(", "stmt", ",", "args", ",", "factory", ")", ":", "return", "row", "return", "None" ]
Execute a query. Returns the first row of the result set, or `None`.
[ "Execute", "a", "query", ".", "Returns", "the", "first", "row", "of", "the", "result", "set", "or", "None", "." ]
2aef6376a60965d7820c91692046f4bcf7d43640
https://github.com/kgaughan/dbkit/blob/2aef6376a60965d7820c91692046f4bcf7d43640/dbkit.py#L715-L721
train
56,842
kgaughan/dbkit
dbkit.py
query_value
def query_value(stmt, args=(), default=None): """ Execute a query, returning the first value in the first row of the result set. If the query returns no result set, a default value is returned, which is `None` by default. """ for row in query(stmt, args, TupleFactory): return row[0] ...
python
def query_value(stmt, args=(), default=None): """ Execute a query, returning the first value in the first row of the result set. If the query returns no result set, a default value is returned, which is `None` by default. """ for row in query(stmt, args, TupleFactory): return row[0] ...
[ "def", "query_value", "(", "stmt", ",", "args", "=", "(", ")", ",", "default", "=", "None", ")", ":", "for", "row", "in", "query", "(", "stmt", ",", "args", ",", "TupleFactory", ")", ":", "return", "row", "[", "0", "]", "return", "default" ]
Execute a query, returning the first value in the first row of the result set. If the query returns no result set, a default value is returned, which is `None` by default.
[ "Execute", "a", "query", "returning", "the", "first", "value", "in", "the", "first", "row", "of", "the", "result", "set", ".", "If", "the", "query", "returns", "no", "result", "set", "a", "default", "value", "is", "returned", "which", "is", "None", "by",...
2aef6376a60965d7820c91692046f4bcf7d43640
https://github.com/kgaughan/dbkit/blob/2aef6376a60965d7820c91692046f4bcf7d43640/dbkit.py#L724-L732
train
56,843
kgaughan/dbkit
dbkit.py
execute_proc
def execute_proc(procname, args=()): """ Execute a stored procedure. Returns the number of affected rows. """ ctx = Context.current() with ctx.mdr: cursor = ctx.execute_proc(procname, args) row_count = cursor.rowcount _safe_close(cursor) return row_count
python
def execute_proc(procname, args=()): """ Execute a stored procedure. Returns the number of affected rows. """ ctx = Context.current() with ctx.mdr: cursor = ctx.execute_proc(procname, args) row_count = cursor.rowcount _safe_close(cursor) return row_count
[ "def", "execute_proc", "(", "procname", ",", "args", "=", "(", ")", ")", ":", "ctx", "=", "Context", ".", "current", "(", ")", "with", "ctx", ".", "mdr", ":", "cursor", "=", "ctx", ".", "execute_proc", "(", "procname", ",", "args", ")", "row_count", ...
Execute a stored procedure. Returns the number of affected rows.
[ "Execute", "a", "stored", "procedure", ".", "Returns", "the", "number", "of", "affected", "rows", "." ]
2aef6376a60965d7820c91692046f4bcf7d43640
https://github.com/kgaughan/dbkit/blob/2aef6376a60965d7820c91692046f4bcf7d43640/dbkit.py#L742-L751
train
56,844
kgaughan/dbkit
dbkit.py
query_proc
def query_proc(procname, args=(), factory=None): """ Execute a stored procedure. This returns an iterator of the result set. """ ctx = Context.current() factory = ctx.default_factory if factory is None else factory with ctx.mdr: return factory(ctx.execute_proc(procname, args), ctx.mdr)
python
def query_proc(procname, args=(), factory=None): """ Execute a stored procedure. This returns an iterator of the result set. """ ctx = Context.current() factory = ctx.default_factory if factory is None else factory with ctx.mdr: return factory(ctx.execute_proc(procname, args), ctx.mdr)
[ "def", "query_proc", "(", "procname", ",", "args", "=", "(", ")", ",", "factory", "=", "None", ")", ":", "ctx", "=", "Context", ".", "current", "(", ")", "factory", "=", "ctx", ".", "default_factory", "if", "factory", "is", "None", "else", "factory", ...
Execute a stored procedure. This returns an iterator of the result set.
[ "Execute", "a", "stored", "procedure", ".", "This", "returns", "an", "iterator", "of", "the", "result", "set", "." ]
2aef6376a60965d7820c91692046f4bcf7d43640
https://github.com/kgaughan/dbkit/blob/2aef6376a60965d7820c91692046f4bcf7d43640/dbkit.py#L754-L761
train
56,845
kgaughan/dbkit
dbkit.py
query_proc_row
def query_proc_row(procname, args=(), factory=None): """ Execute a stored procedure. Returns the first row of the result set, or `None`. """ for row in query_proc(procname, args, factory): return row return None
python
def query_proc_row(procname, args=(), factory=None): """ Execute a stored procedure. Returns the first row of the result set, or `None`. """ for row in query_proc(procname, args, factory): return row return None
[ "def", "query_proc_row", "(", "procname", ",", "args", "=", "(", ")", ",", "factory", "=", "None", ")", ":", "for", "row", "in", "query_proc", "(", "procname", ",", "args", ",", "factory", ")", ":", "return", "row", "return", "None" ]
Execute a stored procedure. Returns the first row of the result set, or `None`.
[ "Execute", "a", "stored", "procedure", ".", "Returns", "the", "first", "row", "of", "the", "result", "set", "or", "None", "." ]
2aef6376a60965d7820c91692046f4bcf7d43640
https://github.com/kgaughan/dbkit/blob/2aef6376a60965d7820c91692046f4bcf7d43640/dbkit.py#L764-L771
train
56,846
kgaughan/dbkit
dbkit.py
query_proc_value
def query_proc_value(procname, args=(), default=None): """ Execute a stored procedure, returning the first value in the first row of the result set. If it returns no result set, a default value is returned, which is `None` by default. """ for row in query_proc(procname, args, TupleFactory): ...
python
def query_proc_value(procname, args=(), default=None): """ Execute a stored procedure, returning the first value in the first row of the result set. If it returns no result set, a default value is returned, which is `None` by default. """ for row in query_proc(procname, args, TupleFactory): ...
[ "def", "query_proc_value", "(", "procname", ",", "args", "=", "(", ")", ",", "default", "=", "None", ")", ":", "for", "row", "in", "query_proc", "(", "procname", ",", "args", ",", "TupleFactory", ")", ":", "return", "row", "[", "0", "]", "return", "d...
Execute a stored procedure, returning the first value in the first row of the result set. If it returns no result set, a default value is returned, which is `None` by default.
[ "Execute", "a", "stored", "procedure", "returning", "the", "first", "value", "in", "the", "first", "row", "of", "the", "result", "set", ".", "If", "it", "returns", "no", "result", "set", "a", "default", "value", "is", "returned", "which", "is", "None", "...
2aef6376a60965d7820c91692046f4bcf7d43640
https://github.com/kgaughan/dbkit/blob/2aef6376a60965d7820c91692046f4bcf7d43640/dbkit.py#L774-L782
train
56,847
kgaughan/dbkit
dbkit.py
make_placeholders
def make_placeholders(seq, start=1): """ Generate placeholders for the given sequence. """ if len(seq) == 0: raise ValueError('Sequence must have at least one element.') param_style = Context.current().param_style placeholders = None if isinstance(seq, dict): if param_style i...
python
def make_placeholders(seq, start=1): """ Generate placeholders for the given sequence. """ if len(seq) == 0: raise ValueError('Sequence must have at least one element.') param_style = Context.current().param_style placeholders = None if isinstance(seq, dict): if param_style i...
[ "def", "make_placeholders", "(", "seq", ",", "start", "=", "1", ")", ":", "if", "len", "(", "seq", ")", "==", "0", ":", "raise", "ValueError", "(", "'Sequence must have at least one element.'", ")", "param_style", "=", "Context", ".", "current", "(", ")", ...
Generate placeholders for the given sequence.
[ "Generate", "placeholders", "for", "the", "given", "sequence", "." ]
2aef6376a60965d7820c91692046f4bcf7d43640
https://github.com/kgaughan/dbkit/blob/2aef6376a60965d7820c91692046f4bcf7d43640/dbkit.py#L957-L982
train
56,848
kgaughan/dbkit
dbkit.py
make_file_object_logger
def make_file_object_logger(fh): """ Make a logger that logs to the given file object. """ def logger_func(stmt, args, fh=fh): """ A logger that logs everything sent to a file object. """ now = datetime.datetime.now() six.print_("Executing (%s):" % now.isoformat()...
python
def make_file_object_logger(fh): """ Make a logger that logs to the given file object. """ def logger_func(stmt, args, fh=fh): """ A logger that logs everything sent to a file object. """ now = datetime.datetime.now() six.print_("Executing (%s):" % now.isoformat()...
[ "def", "make_file_object_logger", "(", "fh", ")", ":", "def", "logger_func", "(", "stmt", ",", "args", ",", "fh", "=", "fh", ")", ":", "\"\"\"\n A logger that logs everything sent to a file object.\n \"\"\"", "now", "=", "datetime", ".", "datetime", ".",...
Make a logger that logs to the given file object.
[ "Make", "a", "logger", "that", "logs", "to", "the", "given", "file", "object", "." ]
2aef6376a60965d7820c91692046f4bcf7d43640
https://github.com/kgaughan/dbkit/blob/2aef6376a60965d7820c91692046f4bcf7d43640/dbkit.py#L992-L1005
train
56,849
kgaughan/dbkit
dbkit.py
Context.current
def current(cls, with_exception=True): """ Returns the current database context. """ if with_exception and len(cls.stack) == 0: raise NoContext() return cls.stack.top()
python
def current(cls, with_exception=True): """ Returns the current database context. """ if with_exception and len(cls.stack) == 0: raise NoContext() return cls.stack.top()
[ "def", "current", "(", "cls", ",", "with_exception", "=", "True", ")", ":", "if", "with_exception", "and", "len", "(", "cls", ".", "stack", ")", "==", "0", ":", "raise", "NoContext", "(", ")", "return", "cls", ".", "stack", ".", "top", "(", ")" ]
Returns the current database context.
[ "Returns", "the", "current", "database", "context", "." ]
2aef6376a60965d7820c91692046f4bcf7d43640
https://github.com/kgaughan/dbkit/blob/2aef6376a60965d7820c91692046f4bcf7d43640/dbkit.py#L146-L152
train
56,850
kgaughan/dbkit
dbkit.py
Context.transaction
def transaction(self): """ Sets up a context where all the statements within it are ran within a single database transaction. For internal use only. """ # The idea here is to fake the nesting of transactions. Only when # we've gotten back to the topmost transaction contex...
python
def transaction(self): """ Sets up a context where all the statements within it are ran within a single database transaction. For internal use only. """ # The idea here is to fake the nesting of transactions. Only when # we've gotten back to the topmost transaction contex...
[ "def", "transaction", "(", "self", ")", ":", "# The idea here is to fake the nesting of transactions. Only when", "# we've gotten back to the topmost transaction context do we actually", "# commit or rollback.", "with", "self", ".", "mdr", ":", "try", ":", "self", ".", "_depth", ...
Sets up a context where all the statements within it are ran within a single database transaction. For internal use only.
[ "Sets", "up", "a", "context", "where", "all", "the", "statements", "within", "it", "are", "ran", "within", "a", "single", "database", "transaction", ".", "For", "internal", "use", "only", "." ]
2aef6376a60965d7820c91692046f4bcf7d43640
https://github.com/kgaughan/dbkit/blob/2aef6376a60965d7820c91692046f4bcf7d43640/dbkit.py#L155-L179
train
56,851
kgaughan/dbkit
dbkit.py
Context.cursor
def cursor(self): """ Get a cursor for the current connection. For internal use only. """ cursor = self.mdr.cursor() with self.transaction(): try: yield cursor if cursor.rowcount != -1: self.last_row_count = cursor.r...
python
def cursor(self): """ Get a cursor for the current connection. For internal use only. """ cursor = self.mdr.cursor() with self.transaction(): try: yield cursor if cursor.rowcount != -1: self.last_row_count = cursor.r...
[ "def", "cursor", "(", "self", ")", ":", "cursor", "=", "self", ".", "mdr", ".", "cursor", "(", ")", "with", "self", ".", "transaction", "(", ")", ":", "try", ":", "yield", "cursor", "if", "cursor", ".", "rowcount", "!=", "-", "1", ":", "self", "....
Get a cursor for the current connection. For internal use only.
[ "Get", "a", "cursor", "for", "the", "current", "connection", ".", "For", "internal", "use", "only", "." ]
2aef6376a60965d7820c91692046f4bcf7d43640
https://github.com/kgaughan/dbkit/blob/2aef6376a60965d7820c91692046f4bcf7d43640/dbkit.py#L182-L197
train
56,852
kgaughan/dbkit
dbkit.py
Context.execute
def execute(self, stmt, args): """ Execute a statement, returning a cursor. For internal use only. """ self.logger(stmt, args) with self.cursor() as cursor: cursor.execute(stmt, args) return cursor
python
def execute(self, stmt, args): """ Execute a statement, returning a cursor. For internal use only. """ self.logger(stmt, args) with self.cursor() as cursor: cursor.execute(stmt, args) return cursor
[ "def", "execute", "(", "self", ",", "stmt", ",", "args", ")", ":", "self", ".", "logger", "(", "stmt", ",", "args", ")", "with", "self", ".", "cursor", "(", ")", "as", "cursor", ":", "cursor", ".", "execute", "(", "stmt", ",", "args", ")", "retur...
Execute a statement, returning a cursor. For internal use only.
[ "Execute", "a", "statement", "returning", "a", "cursor", ".", "For", "internal", "use", "only", "." ]
2aef6376a60965d7820c91692046f4bcf7d43640
https://github.com/kgaughan/dbkit/blob/2aef6376a60965d7820c91692046f4bcf7d43640/dbkit.py#L199-L206
train
56,853
kgaughan/dbkit
dbkit.py
Context.execute_proc
def execute_proc(self, procname, args): """ Execute a stored procedure, returning a cursor. For internal use only. """ self.logger(procname, args) with self.cursor() as cursor: cursor.callproc(procname, args) return cursor
python
def execute_proc(self, procname, args): """ Execute a stored procedure, returning a cursor. For internal use only. """ self.logger(procname, args) with self.cursor() as cursor: cursor.callproc(procname, args) return cursor
[ "def", "execute_proc", "(", "self", ",", "procname", ",", "args", ")", ":", "self", ".", "logger", "(", "procname", ",", "args", ")", "with", "self", ".", "cursor", "(", ")", "as", "cursor", ":", "cursor", ".", "callproc", "(", "procname", ",", "args...
Execute a stored procedure, returning a cursor. For internal use only.
[ "Execute", "a", "stored", "procedure", "returning", "a", "cursor", ".", "For", "internal", "use", "only", "." ]
2aef6376a60965d7820c91692046f4bcf7d43640
https://github.com/kgaughan/dbkit/blob/2aef6376a60965d7820c91692046f4bcf7d43640/dbkit.py#L208-L216
train
56,854
kgaughan/dbkit
dbkit.py
Context.close
def close(self): """ Close the connection this context wraps. """ self.logger = None for exc in _EXCEPTIONS: setattr(self, exc, None) try: self.mdr.close() finally: self.mdr = None
python
def close(self): """ Close the connection this context wraps. """ self.logger = None for exc in _EXCEPTIONS: setattr(self, exc, None) try: self.mdr.close() finally: self.mdr = None
[ "def", "close", "(", "self", ")", ":", "self", ".", "logger", "=", "None", "for", "exc", "in", "_EXCEPTIONS", ":", "setattr", "(", "self", ",", "exc", ",", "None", ")", "try", ":", "self", ".", "mdr", ".", "close", "(", ")", "finally", ":", "self...
Close the connection this context wraps.
[ "Close", "the", "connection", "this", "context", "wraps", "." ]
2aef6376a60965d7820c91692046f4bcf7d43640
https://github.com/kgaughan/dbkit/blob/2aef6376a60965d7820c91692046f4bcf7d43640/dbkit.py#L218-L228
train
56,855
kgaughan/dbkit
dbkit.py
PoolBase.connect
def connect(self): """ Returns a context that uses this pool as a connection source. """ ctx = Context(self.module, self.create_mediator()) ctx.logger = self.logger ctx.default_factory = self.default_factory return ctx
python
def connect(self): """ Returns a context that uses this pool as a connection source. """ ctx = Context(self.module, self.create_mediator()) ctx.logger = self.logger ctx.default_factory = self.default_factory return ctx
[ "def", "connect", "(", "self", ")", ":", "ctx", "=", "Context", "(", "self", ".", "module", ",", "self", ".", "create_mediator", "(", ")", ")", "ctx", ".", "logger", "=", "self", ".", "logger", "ctx", ".", "default_factory", "=", "self", ".", "defaul...
Returns a context that uses this pool as a connection source.
[ "Returns", "a", "context", "that", "uses", "this", "pool", "as", "a", "connection", "source", "." ]
2aef6376a60965d7820c91692046f4bcf7d43640
https://github.com/kgaughan/dbkit/blob/2aef6376a60965d7820c91692046f4bcf7d43640/dbkit.py#L452-L459
train
56,856
kgaughan/dbkit
dbkit.py
FactoryBase.close
def close(self): """ Release all resources associated with this factory. """ if self.mdr is None: return exc = (None, None, None) try: self.cursor.close() except: exc = sys.exc_info() try: if self.mdr.__exit_...
python
def close(self): """ Release all resources associated with this factory. """ if self.mdr is None: return exc = (None, None, None) try: self.cursor.close() except: exc = sys.exc_info() try: if self.mdr.__exit_...
[ "def", "close", "(", "self", ")", ":", "if", "self", ".", "mdr", "is", "None", ":", "return", "exc", "=", "(", "None", ",", "None", ",", "None", ")", "try", ":", "self", ".", "cursor", ".", "close", "(", ")", "except", ":", "exc", "=", "sys", ...
Release all resources associated with this factory.
[ "Release", "all", "resources", "associated", "with", "this", "factory", "." ]
2aef6376a60965d7820c91692046f4bcf7d43640
https://github.com/kgaughan/dbkit/blob/2aef6376a60965d7820c91692046f4bcf7d43640/dbkit.py#L811-L830
train
56,857
tradenity/python-sdk
tradenity/resources/shopping_cart.py
ShoppingCart.add_item
def add_item(cls, item, **kwargs): """Add item. Add new item to the shopping cart. This method makes a synchronous HTTP request by default. To make an asynchronous HTTP request, please pass async=True >>> thread = api.add_item(item, async=True) >>> result = thread.get() ...
python
def add_item(cls, item, **kwargs): """Add item. Add new item to the shopping cart. This method makes a synchronous HTTP request by default. To make an asynchronous HTTP request, please pass async=True >>> thread = api.add_item(item, async=True) >>> result = thread.get() ...
[ "def", "add_item", "(", "cls", ",", "item", ",", "*", "*", "kwargs", ")", ":", "kwargs", "[", "'_return_http_data_only'", "]", "=", "True", "if", "kwargs", ".", "get", "(", "'async'", ")", ":", "return", "cls", ".", "_add_item_with_http_info", "(", "item...
Add item. Add new item to the shopping cart. This method makes a synchronous HTTP request by default. To make an asynchronous HTTP request, please pass async=True >>> thread = api.add_item(item, async=True) >>> result = thread.get() :param async bool :param Line...
[ "Add", "item", "." ]
d13fbe23f4d6ff22554c6d8d2deaf209371adaf1
https://github.com/tradenity/python-sdk/blob/d13fbe23f4d6ff22554c6d8d2deaf209371adaf1/tradenity/resources/shopping_cart.py#L318-L338
train
56,858
tradenity/python-sdk
tradenity/resources/shopping_cart.py
ShoppingCart.checkout
def checkout(cls, order, **kwargs): """Checkout cart. Checkout cart, Making an order. This method makes a synchronous HTTP request by default. To make an asynchronous HTTP request, please pass async=True >>> thread = api.checkout(order, async=True) >>> result = thread.ge...
python
def checkout(cls, order, **kwargs): """Checkout cart. Checkout cart, Making an order. This method makes a synchronous HTTP request by default. To make an asynchronous HTTP request, please pass async=True >>> thread = api.checkout(order, async=True) >>> result = thread.ge...
[ "def", "checkout", "(", "cls", ",", "order", ",", "*", "*", "kwargs", ")", ":", "kwargs", "[", "'_return_http_data_only'", "]", "=", "True", "if", "kwargs", ".", "get", "(", "'async'", ")", ":", "return", "cls", ".", "_checkout_with_http_info", "(", "ord...
Checkout cart. Checkout cart, Making an order. This method makes a synchronous HTTP request by default. To make an asynchronous HTTP request, please pass async=True >>> thread = api.checkout(order, async=True) >>> result = thread.get() :param async bool :param O...
[ "Checkout", "cart", "." ]
d13fbe23f4d6ff22554c6d8d2deaf209371adaf1
https://github.com/tradenity/python-sdk/blob/d13fbe23f4d6ff22554c6d8d2deaf209371adaf1/tradenity/resources/shopping_cart.py#L417-L437
train
56,859
tradenity/python-sdk
tradenity/resources/shopping_cart.py
ShoppingCart.delete_item
def delete_item(cls, item_id, **kwargs): """Remove item. Remove item from shopping cart This method makes a synchronous HTTP request by default. To make an asynchronous HTTP request, please pass async=True >>> thread = api.delete_item(item_id, async=True) >>> result = th...
python
def delete_item(cls, item_id, **kwargs): """Remove item. Remove item from shopping cart This method makes a synchronous HTTP request by default. To make an asynchronous HTTP request, please pass async=True >>> thread = api.delete_item(item_id, async=True) >>> result = th...
[ "def", "delete_item", "(", "cls", ",", "item_id", ",", "*", "*", "kwargs", ")", ":", "kwargs", "[", "'_return_http_data_only'", "]", "=", "True", "if", "kwargs", ".", "get", "(", "'async'", ")", ":", "return", "cls", ".", "_delete_item_with_http_info", "("...
Remove item. Remove item from shopping cart This method makes a synchronous HTTP request by default. To make an asynchronous HTTP request, please pass async=True >>> thread = api.delete_item(item_id, async=True) >>> result = thread.get() :param async bool :param...
[ "Remove", "item", "." ]
d13fbe23f4d6ff22554c6d8d2deaf209371adaf1
https://github.com/tradenity/python-sdk/blob/d13fbe23f4d6ff22554c6d8d2deaf209371adaf1/tradenity/resources/shopping_cart.py#L516-L536
train
56,860
tradenity/python-sdk
tradenity/resources/shopping_cart.py
ShoppingCart.empty
def empty(cls, **kwargs): """Empty cart. Empty the shopping cart. This method makes a synchronous HTTP request by default. To make an asynchronous HTTP request, please pass async=True >>> thread = api.empty(async=True) >>> result = thread.get() :param async bool...
python
def empty(cls, **kwargs): """Empty cart. Empty the shopping cart. This method makes a synchronous HTTP request by default. To make an asynchronous HTTP request, please pass async=True >>> thread = api.empty(async=True) >>> result = thread.get() :param async bool...
[ "def", "empty", "(", "cls", ",", "*", "*", "kwargs", ")", ":", "kwargs", "[", "'_return_http_data_only'", "]", "=", "True", "if", "kwargs", ".", "get", "(", "'async'", ")", ":", "return", "cls", ".", "_empty_with_http_info", "(", "*", "*", "kwargs", ")...
Empty cart. Empty the shopping cart. This method makes a synchronous HTTP request by default. To make an asynchronous HTTP request, please pass async=True >>> thread = api.empty(async=True) >>> result = thread.get() :param async bool :return: ShoppingCart ...
[ "Empty", "cart", "." ]
d13fbe23f4d6ff22554c6d8d2deaf209371adaf1
https://github.com/tradenity/python-sdk/blob/d13fbe23f4d6ff22554c6d8d2deaf209371adaf1/tradenity/resources/shopping_cart.py#L615-L634
train
56,861
tradenity/python-sdk
tradenity/resources/shopping_cart.py
ShoppingCart.get
def get(cls, **kwargs): """Get cart. Retrieve the shopping cart of the current session. This method makes a synchronous HTTP request by default. To make an asynchronous HTTP request, please pass async=True >>> thread = api.get(async=True) >>> result = thread.get() ...
python
def get(cls, **kwargs): """Get cart. Retrieve the shopping cart of the current session. This method makes a synchronous HTTP request by default. To make an asynchronous HTTP request, please pass async=True >>> thread = api.get(async=True) >>> result = thread.get() ...
[ "def", "get", "(", "cls", ",", "*", "*", "kwargs", ")", ":", "kwargs", "[", "'_return_http_data_only'", "]", "=", "True", "if", "kwargs", ".", "get", "(", "'async'", ")", ":", "return", "cls", ".", "_get_with_http_info", "(", "*", "*", "kwargs", ")", ...
Get cart. Retrieve the shopping cart of the current session. This method makes a synchronous HTTP request by default. To make an asynchronous HTTP request, please pass async=True >>> thread = api.get(async=True) >>> result = thread.get() :param async bool :retur...
[ "Get", "cart", "." ]
d13fbe23f4d6ff22554c6d8d2deaf209371adaf1
https://github.com/tradenity/python-sdk/blob/d13fbe23f4d6ff22554c6d8d2deaf209371adaf1/tradenity/resources/shopping_cart.py#L706-L725
train
56,862
tradenity/python-sdk
tradenity/resources/shopping_cart.py
ShoppingCart.update_item
def update_item(cls, item_id, item, **kwargs): """Update cart. Update cart item. This method makes a synchronous HTTP request by default. To make an asynchronous HTTP request, please pass async=True >>> thread = api.update_item(item_id, item, async=True) >>> result = thr...
python
def update_item(cls, item_id, item, **kwargs): """Update cart. Update cart item. This method makes a synchronous HTTP request by default. To make an asynchronous HTTP request, please pass async=True >>> thread = api.update_item(item_id, item, async=True) >>> result = thr...
[ "def", "update_item", "(", "cls", ",", "item_id", ",", "item", ",", "*", "*", "kwargs", ")", ":", "kwargs", "[", "'_return_http_data_only'", "]", "=", "True", "if", "kwargs", ".", "get", "(", "'async'", ")", ":", "return", "cls", ".", "_update_item_with_...
Update cart. Update cart item. This method makes a synchronous HTTP request by default. To make an asynchronous HTTP request, please pass async=True >>> thread = api.update_item(item_id, item, async=True) >>> result = thread.get() :param async bool :param str it...
[ "Update", "cart", "." ]
d13fbe23f4d6ff22554c6d8d2deaf209371adaf1
https://github.com/tradenity/python-sdk/blob/d13fbe23f4d6ff22554c6d8d2deaf209371adaf1/tradenity/resources/shopping_cart.py#L797-L818
train
56,863
wuher/devil
devil/perm/acl.py
PermissionController.get_perm_names
def get_perm_names(cls, resource): """ Return all permissions supported by the resource. This is used for auto-generating missing permissions rows into database in syncdb. """ return [cls.get_perm_name(resource, method) for method in cls.METHODS]
python
def get_perm_names(cls, resource): """ Return all permissions supported by the resource. This is used for auto-generating missing permissions rows into database in syncdb. """ return [cls.get_perm_name(resource, method) for method in cls.METHODS]
[ "def", "get_perm_names", "(", "cls", ",", "resource", ")", ":", "return", "[", "cls", ".", "get_perm_name", "(", "resource", ",", "method", ")", "for", "method", "in", "cls", ".", "METHODS", "]" ]
Return all permissions supported by the resource. This is used for auto-generating missing permissions rows into database in syncdb.
[ "Return", "all", "permissions", "supported", "by", "the", "resource", "." ]
a8834d4f88d915a21754c6b96f99d0ad9123ad4d
https://github.com/wuher/devil/blob/a8834d4f88d915a21754c6b96f99d0ad9123ad4d/devil/perm/acl.py#L19-L26
train
56,864
wuher/devil
devil/perm/acl.py
PermissionController.get_perm_name
def get_perm_name(cls, resource, method): """ Compose permission name @param resource the resource @param method the request method (case doesn't matter). """ return '%s_%s_%s' % ( cls.PREFIX, cls._get_resource_name(resource), method.lower())
python
def get_perm_name(cls, resource, method): """ Compose permission name @param resource the resource @param method the request method (case doesn't matter). """ return '%s_%s_%s' % ( cls.PREFIX, cls._get_resource_name(resource), method.lower())
[ "def", "get_perm_name", "(", "cls", ",", "resource", ",", "method", ")", ":", "return", "'%s_%s_%s'", "%", "(", "cls", ".", "PREFIX", ",", "cls", ".", "_get_resource_name", "(", "resource", ")", ",", "method", ".", "lower", "(", ")", ")" ]
Compose permission name @param resource the resource @param method the request method (case doesn't matter).
[ "Compose", "permission", "name" ]
a8834d4f88d915a21754c6b96f99d0ad9123ad4d
https://github.com/wuher/devil/blob/a8834d4f88d915a21754c6b96f99d0ad9123ad4d/devil/perm/acl.py#L29-L39
train
56,865
wuher/devil
devil/perm/acl.py
PermissionController._has_perm
def _has_perm(self, user, permission): """ Check whether the user has the given permission @return True if user is granted with access, False if not. """ if user.is_superuser: return True if user.is_active: perms = [perm.split('.')[1] for perm in user.ge...
python
def _has_perm(self, user, permission): """ Check whether the user has the given permission @return True if user is granted with access, False if not. """ if user.is_superuser: return True if user.is_active: perms = [perm.split('.')[1] for perm in user.ge...
[ "def", "_has_perm", "(", "self", ",", "user", ",", "permission", ")", ":", "if", "user", ".", "is_superuser", ":", "return", "True", "if", "user", ".", "is_active", ":", "perms", "=", "[", "perm", ".", "split", "(", "'.'", ")", "[", "1", "]", "for"...
Check whether the user has the given permission @return True if user is granted with access, False if not.
[ "Check", "whether", "the", "user", "has", "the", "given", "permission" ]
a8834d4f88d915a21754c6b96f99d0ad9123ad4d
https://github.com/wuher/devil/blob/a8834d4f88d915a21754c6b96f99d0ad9123ad4d/devil/perm/acl.py#L53-L64
train
56,866
inveniosoftware-attic/invenio-utils
invenio_utils/url.py
is_local_url
def is_local_url(target): """Determine if URL is a local.""" ref_url = urlparse(cfg.get('CFG_SITE_SECURE_URL')) test_url = urlparse(urljoin(cfg.get('CFG_SITE_SECURE_URL'), target)) return test_url.scheme in ('http', 'https') and \ ref_url.netloc == test_url.netloc
python
def is_local_url(target): """Determine if URL is a local.""" ref_url = urlparse(cfg.get('CFG_SITE_SECURE_URL')) test_url = urlparse(urljoin(cfg.get('CFG_SITE_SECURE_URL'), target)) return test_url.scheme in ('http', 'https') and \ ref_url.netloc == test_url.netloc
[ "def", "is_local_url", "(", "target", ")", ":", "ref_url", "=", "urlparse", "(", "cfg", ".", "get", "(", "'CFG_SITE_SECURE_URL'", ")", ")", "test_url", "=", "urlparse", "(", "urljoin", "(", "cfg", ".", "get", "(", "'CFG_SITE_SECURE_URL'", ")", ",", "target...
Determine if URL is a local.
[ "Determine", "if", "URL", "is", "a", "local", "." ]
9a1c6db4e3f1370901f329f510480dd8df188296
https://github.com/inveniosoftware-attic/invenio-utils/blob/9a1c6db4e3f1370901f329f510480dd8df188296/invenio_utils/url.py#L115-L120
train
56,867
inveniosoftware-attic/invenio-utils
invenio_utils/url.py
rewrite_to_secure_url
def rewrite_to_secure_url(url, secure_base=None): """ Rewrite URL to a Secure URL @param url URL to be rewritten to a secure URL. @param secure_base: Base URL of secure site (defaults to CFG_SITE_SECURE_URL). """ if secure_base is None: secure_base = cfg.get('CFG_SITE_SECURE_URL') u...
python
def rewrite_to_secure_url(url, secure_base=None): """ Rewrite URL to a Secure URL @param url URL to be rewritten to a secure URL. @param secure_base: Base URL of secure site (defaults to CFG_SITE_SECURE_URL). """ if secure_base is None: secure_base = cfg.get('CFG_SITE_SECURE_URL') u...
[ "def", "rewrite_to_secure_url", "(", "url", ",", "secure_base", "=", "None", ")", ":", "if", "secure_base", "is", "None", ":", "secure_base", "=", "cfg", ".", "get", "(", "'CFG_SITE_SECURE_URL'", ")", "url_parts", "=", "list", "(", "urlparse", "(", "url", ...
Rewrite URL to a Secure URL @param url URL to be rewritten to a secure URL. @param secure_base: Base URL of secure site (defaults to CFG_SITE_SECURE_URL).
[ "Rewrite", "URL", "to", "a", "Secure", "URL" ]
9a1c6db4e3f1370901f329f510480dd8df188296
https://github.com/inveniosoftware-attic/invenio-utils/blob/9a1c6db4e3f1370901f329f510480dd8df188296/invenio_utils/url.py#L207-L220
train
56,868
inveniosoftware-attic/invenio-utils
invenio_utils/url.py
create_html_link
def create_html_link(urlbase, urlargd, link_label, linkattrd=None, escape_urlargd=True, escape_linkattrd=True, urlhash=None): """Creates a W3C compliant link. @param urlbase: base url (e.g. config.CFG_SITE_URL/search) @param urlargd: dictionary of parameters. (e.g. ...
python
def create_html_link(urlbase, urlargd, link_label, linkattrd=None, escape_urlargd=True, escape_linkattrd=True, urlhash=None): """Creates a W3C compliant link. @param urlbase: base url (e.g. config.CFG_SITE_URL/search) @param urlargd: dictionary of parameters. (e.g. ...
[ "def", "create_html_link", "(", "urlbase", ",", "urlargd", ",", "link_label", ",", "linkattrd", "=", "None", ",", "escape_urlargd", "=", "True", ",", "escape_linkattrd", "=", "True", ",", "urlhash", "=", "None", ")", ":", "attributes_separator", "=", "' '", ...
Creates a W3C compliant link. @param urlbase: base url (e.g. config.CFG_SITE_URL/search) @param urlargd: dictionary of parameters. (e.g. p={'recid':3, 'of'='hb'}) @param link_label: text displayed in a browser (has to be already escaped) @param linkattrd: dictionary of attributes (e.g. a={'class': 'img'...
[ "Creates", "a", "W3C", "compliant", "link", "." ]
9a1c6db4e3f1370901f329f510480dd8df188296
https://github.com/inveniosoftware-attic/invenio-utils/blob/9a1c6db4e3f1370901f329f510480dd8df188296/invenio_utils/url.py#L291-L320
train
56,869
inveniosoftware-attic/invenio-utils
invenio_utils/url.py
get_canonical_and_alternates_urls
def get_canonical_and_alternates_urls( url, drop_ln=True, washed_argd=None, quote_path=False): """ Given an Invenio URL returns a tuple with two elements. The first is the canonical URL, that is the original URL with CFG_SITE_URL prefix, and where the ln= argument strippe...
python
def get_canonical_and_alternates_urls( url, drop_ln=True, washed_argd=None, quote_path=False): """ Given an Invenio URL returns a tuple with two elements. The first is the canonical URL, that is the original URL with CFG_SITE_URL prefix, and where the ln= argument strippe...
[ "def", "get_canonical_and_alternates_urls", "(", "url", ",", "drop_ln", "=", "True", ",", "washed_argd", "=", "None", ",", "quote_path", "=", "False", ")", ":", "dummy_scheme", ",", "dummy_netloc", ",", "path", ",", "dummy_params", ",", "query", ",", "fragment...
Given an Invenio URL returns a tuple with two elements. The first is the canonical URL, that is the original URL with CFG_SITE_URL prefix, and where the ln= argument stripped. The second element element is mapping, language code -> alternate URL @param quote_path: if True, the path section of the given...
[ "Given", "an", "Invenio", "URL", "returns", "a", "tuple", "with", "two", "elements", ".", "The", "first", "is", "the", "canonical", "URL", "that", "is", "the", "original", "URL", "with", "CFG_SITE_URL", "prefix", "and", "where", "the", "ln", "=", "argument...
9a1c6db4e3f1370901f329f510480dd8df188296
https://github.com/inveniosoftware-attic/invenio-utils/blob/9a1c6db4e3f1370901f329f510480dd8df188296/invenio_utils/url.py#L470-L515
train
56,870
inveniosoftware-attic/invenio-utils
invenio_utils/url.py
same_urls_p
def same_urls_p(a, b): """ Compare two URLs, ignoring reorganizing of query arguments """ ua = list(urlparse(a)) ub = list(urlparse(b)) ua[4] = parse_qs(ua[4]) ub[4] = parse_qs(ub[4]) return ua == ub
python
def same_urls_p(a, b): """ Compare two URLs, ignoring reorganizing of query arguments """ ua = list(urlparse(a)) ub = list(urlparse(b)) ua[4] = parse_qs(ua[4]) ub[4] = parse_qs(ub[4]) return ua == ub
[ "def", "same_urls_p", "(", "a", ",", "b", ")", ":", "ua", "=", "list", "(", "urlparse", "(", "a", ")", ")", "ub", "=", "list", "(", "urlparse", "(", "b", ")", ")", "ua", "[", "4", "]", "=", "parse_qs", "(", "ua", "[", "4", "]", ")", "ub", ...
Compare two URLs, ignoring reorganizing of query arguments
[ "Compare", "two", "URLs", "ignoring", "reorganizing", "of", "query", "arguments" ]
9a1c6db4e3f1370901f329f510480dd8df188296
https://github.com/inveniosoftware-attic/invenio-utils/blob/9a1c6db4e3f1370901f329f510480dd8df188296/invenio_utils/url.py#L544-L553
train
56,871
inveniosoftware-attic/invenio-utils
invenio_utils/url.py
make_user_agent_string
def make_user_agent_string(component=None): """ Return a nice and uniform user-agent string to be used when Invenio act as a client in HTTP requests. """ ret = "Invenio-%s (+%s; \"%s\")" % (cfg.get('CFG_VERSION'), cfg.get('CFG_SITE_URL'), cfg.get('CFG_SITE_NAM...
python
def make_user_agent_string(component=None): """ Return a nice and uniform user-agent string to be used when Invenio act as a client in HTTP requests. """ ret = "Invenio-%s (+%s; \"%s\")" % (cfg.get('CFG_VERSION'), cfg.get('CFG_SITE_URL'), cfg.get('CFG_SITE_NAM...
[ "def", "make_user_agent_string", "(", "component", "=", "None", ")", ":", "ret", "=", "\"Invenio-%s (+%s; \\\"%s\\\")\"", "%", "(", "cfg", ".", "get", "(", "'CFG_VERSION'", ")", ",", "cfg", ".", "get", "(", "'CFG_SITE_URL'", ")", ",", "cfg", ".", "get", "(...
Return a nice and uniform user-agent string to be used when Invenio act as a client in HTTP requests.
[ "Return", "a", "nice", "and", "uniform", "user", "-", "agent", "string", "to", "be", "used", "when", "Invenio", "act", "as", "a", "client", "in", "HTTP", "requests", "." ]
9a1c6db4e3f1370901f329f510480dd8df188296
https://github.com/inveniosoftware-attic/invenio-utils/blob/9a1c6db4e3f1370901f329f510480dd8df188296/invenio_utils/url.py#L605-L614
train
56,872
inveniosoftware-attic/invenio-utils
invenio_utils/url.py
make_invenio_opener
def make_invenio_opener(component=None): """ Return an urllib2 opener with the useragent already set in the appropriate way. """ opener = urllib2.build_opener() opener.addheaders = [('User-agent', make_user_agent_string(component))] return opener
python
def make_invenio_opener(component=None): """ Return an urllib2 opener with the useragent already set in the appropriate way. """ opener = urllib2.build_opener() opener.addheaders = [('User-agent', make_user_agent_string(component))] return opener
[ "def", "make_invenio_opener", "(", "component", "=", "None", ")", ":", "opener", "=", "urllib2", ".", "build_opener", "(", ")", "opener", ".", "addheaders", "=", "[", "(", "'User-agent'", ",", "make_user_agent_string", "(", "component", ")", ")", "]", "retur...
Return an urllib2 opener with the useragent already set in the appropriate way.
[ "Return", "an", "urllib2", "opener", "with", "the", "useragent", "already", "set", "in", "the", "appropriate", "way", "." ]
9a1c6db4e3f1370901f329f510480dd8df188296
https://github.com/inveniosoftware-attic/invenio-utils/blob/9a1c6db4e3f1370901f329f510480dd8df188296/invenio_utils/url.py#L633-L640
train
56,873
inveniosoftware-attic/invenio-utils
invenio_utils/url.py
create_Indico_request_url
def create_Indico_request_url( base_url, indico_what, indico_loc, indico_id, indico_type, indico_params, indico_key, indico_sig, _timestamp=None): """ Create a signed Indico request URL to access Indico HTTP Export APIs. See U{http://i...
python
def create_Indico_request_url( base_url, indico_what, indico_loc, indico_id, indico_type, indico_params, indico_key, indico_sig, _timestamp=None): """ Create a signed Indico request URL to access Indico HTTP Export APIs. See U{http://i...
[ "def", "create_Indico_request_url", "(", "base_url", ",", "indico_what", ",", "indico_loc", ",", "indico_id", ",", "indico_type", ",", "indico_params", ",", "indico_key", ",", "indico_sig", ",", "_timestamp", "=", "None", ")", ":", "url", "=", "'/export/'", "+",...
Create a signed Indico request URL to access Indico HTTP Export APIs. See U{http://indico.cern.ch/ihelp/html/ExportAPI/index.html} for more information. Example: >> create_Indico_request_url("https://indico.cern.ch", "categ", "", ...
[ "Create", "a", "signed", "Indico", "request", "URL", "to", "access", "Indico", "HTTP", "Export", "APIs", "." ]
9a1c6db4e3f1370901f329f510480dd8df188296
https://github.com/inveniosoftware-attic/invenio-utils/blob/9a1c6db4e3f1370901f329f510480dd8df188296/invenio_utils/url.py#L770-L852
train
56,874
inveniosoftware-attic/invenio-utils
invenio_utils/url.py
auto_version_url
def auto_version_url(file_path): """ Appends modification time of the file to the request URL in order for the browser to refresh the cache when file changes @param file_path: path to the file, e.g js/foo.js @return: file_path with modification time appended to URL """ file_md5 = ""...
python
def auto_version_url(file_path): """ Appends modification time of the file to the request URL in order for the browser to refresh the cache when file changes @param file_path: path to the file, e.g js/foo.js @return: file_path with modification time appended to URL """ file_md5 = ""...
[ "def", "auto_version_url", "(", "file_path", ")", ":", "file_md5", "=", "\"\"", "try", ":", "file_md5", "=", "md5", "(", "open", "(", "cfg", ".", "get", "(", "'CFG_WEBDIR'", ")", "+", "os", ".", "sep", "+", "file_path", ")", ".", "read", "(", ")", ...
Appends modification time of the file to the request URL in order for the browser to refresh the cache when file changes @param file_path: path to the file, e.g js/foo.js @return: file_path with modification time appended to URL
[ "Appends", "modification", "time", "of", "the", "file", "to", "the", "request", "URL", "in", "order", "for", "the", "browser", "to", "refresh", "the", "cache", "when", "file", "changes" ]
9a1c6db4e3f1370901f329f510480dd8df188296
https://github.com/inveniosoftware-attic/invenio-utils/blob/9a1c6db4e3f1370901f329f510480dd8df188296/invenio_utils/url.py#L922-L935
train
56,875
CodyKochmann/generators
generators/map.py
function_arg_count
def function_arg_count(fn): """ returns how many arguments a funciton has """ assert callable(fn), 'function_arg_count needed a callable function, not {0}'.format(repr(fn)) if hasattr(fn, '__code__') and hasattr(fn.__code__, 'co_argcount'): return fn.__code__.co_argcount else: return 1
python
def function_arg_count(fn): """ returns how many arguments a funciton has """ assert callable(fn), 'function_arg_count needed a callable function, not {0}'.format(repr(fn)) if hasattr(fn, '__code__') and hasattr(fn.__code__, 'co_argcount'): return fn.__code__.co_argcount else: return 1
[ "def", "function_arg_count", "(", "fn", ")", ":", "assert", "callable", "(", "fn", ")", ",", "'function_arg_count needed a callable function, not {0}'", ".", "format", "(", "repr", "(", "fn", ")", ")", "if", "hasattr", "(", "fn", ",", "'__code__'", ")", "and",...
returns how many arguments a funciton has
[ "returns", "how", "many", "arguments", "a", "funciton", "has" ]
e4ca4dd25d5023a94b0349c69d6224070cc2526f
https://github.com/CodyKochmann/generators/blob/e4ca4dd25d5023a94b0349c69d6224070cc2526f/generators/map.py#L20-L26
train
56,876
soaxelbrooke/join
join/_core.py
merge
def merge(left, right, how='inner', key=None, left_key=None, right_key=None, left_as='left', right_as='right'): """ Performs a join using the union join function. """ return join(left, right, how, key, left_key, right_key, join_fn=make_union_join(left_as, right_as))
python
def merge(left, right, how='inner', key=None, left_key=None, right_key=None, left_as='left', right_as='right'): """ Performs a join using the union join function. """ return join(left, right, how, key, left_key, right_key, join_fn=make_union_join(left_as, right_as))
[ "def", "merge", "(", "left", ",", "right", ",", "how", "=", "'inner'", ",", "key", "=", "None", ",", "left_key", "=", "None", ",", "right_key", "=", "None", ",", "left_as", "=", "'left'", ",", "right_as", "=", "'right'", ")", ":", "return", "join", ...
Performs a join using the union join function.
[ "Performs", "a", "join", "using", "the", "union", "join", "function", "." ]
c84fca68ab6a52b1cee526065dc9f5a691764e69
https://github.com/soaxelbrooke/join/blob/c84fca68ab6a52b1cee526065dc9f5a691764e69/join/_core.py#L7-L11
train
56,877
soaxelbrooke/join
join/_core.py
_inner_join
def _inner_join(left, right, left_key_fn, right_key_fn, join_fn=union_join): """ Inner join using left and right key functions :param left: left iterable to be joined :param right: right iterable to be joined :param function left_key_fn: function that produces hashable value from left objects :para...
python
def _inner_join(left, right, left_key_fn, right_key_fn, join_fn=union_join): """ Inner join using left and right key functions :param left: left iterable to be joined :param right: right iterable to be joined :param function left_key_fn: function that produces hashable value from left objects :para...
[ "def", "_inner_join", "(", "left", ",", "right", ",", "left_key_fn", ",", "right_key_fn", ",", "join_fn", "=", "union_join", ")", ":", "joiner", "=", "defaultdict", "(", "list", ")", "for", "ele", "in", "right", ":", "joiner", "[", "right_key_fn", "(", "...
Inner join using left and right key functions :param left: left iterable to be joined :param right: right iterable to be joined :param function left_key_fn: function that produces hashable value from left objects :param function right_key_fn: function that produces hashable value from right objects ...
[ "Inner", "join", "using", "left", "and", "right", "key", "functions" ]
c84fca68ab6a52b1cee526065dc9f5a691764e69
https://github.com/soaxelbrooke/join/blob/c84fca68ab6a52b1cee526065dc9f5a691764e69/join/_core.py#L47-L64
train
56,878
soaxelbrooke/join
join/_core.py
group
def group(iterable, key=lambda ele: ele): """ Groups an iterable by a specified attribute, or using a specified key access function. Returns tuples of grouped elements. >>> dogs = [Dog('gatsby', 'Rruff!', 15), Dog('william', 'roof', 12), Dog('edward', 'hi', 15)] >>> groupby(dogs, 'weight') [(Dog('gats...
python
def group(iterable, key=lambda ele: ele): """ Groups an iterable by a specified attribute, or using a specified key access function. Returns tuples of grouped elements. >>> dogs = [Dog('gatsby', 'Rruff!', 15), Dog('william', 'roof', 12), Dog('edward', 'hi', 15)] >>> groupby(dogs, 'weight') [(Dog('gats...
[ "def", "group", "(", "iterable", ",", "key", "=", "lambda", "ele", ":", "ele", ")", ":", "if", "callable", "(", "key", ")", ":", "return", "_group", "(", "iterable", ",", "key", ")", "else", ":", "return", "_group", "(", "iterable", ",", "make_key_fn...
Groups an iterable by a specified attribute, or using a specified key access function. Returns tuples of grouped elements. >>> dogs = [Dog('gatsby', 'Rruff!', 15), Dog('william', 'roof', 12), Dog('edward', 'hi', 15)] >>> groupby(dogs, 'weight') [(Dog('gatsby', 'Rruff!', 15), Dog('edward', 'hi', 15)), (Dog...
[ "Groups", "an", "iterable", "by", "a", "specified", "attribute", "or", "using", "a", "specified", "key", "access", "function", ".", "Returns", "tuples", "of", "grouped", "elements", "." ]
c84fca68ab6a52b1cee526065dc9f5a691764e69
https://github.com/soaxelbrooke/join/blob/c84fca68ab6a52b1cee526065dc9f5a691764e69/join/_core.py#L125-L138
train
56,879
wdbm/megaparsex
megaparsex.py
trigger_keyphrases
def trigger_keyphrases( text = None, # input text to parse keyphrases = None, # keyphrases for parsing input text response = None, # optional text response on trigger function = None, # optional function on trigger...
python
def trigger_keyphrases( text = None, # input text to parse keyphrases = None, # keyphrases for parsing input text response = None, # optional text response on trigger function = None, # optional function on trigger...
[ "def", "trigger_keyphrases", "(", "text", "=", "None", ",", "# input text to parse", "keyphrases", "=", "None", ",", "# keyphrases for parsing input text", "response", "=", "None", ",", "# optional text response on trigger", "function", "=", "None", ",", "# optional funct...
Parse input text for keyphrases. If any keyphrases are found, respond with text or by seeking confirmation or by engaging a function with optional keyword arguments. Return text or True if triggered and return False if not triggered. If confirmation is required, a confirmation object is returned, encaps...
[ "Parse", "input", "text", "for", "keyphrases", ".", "If", "any", "keyphrases", "are", "found", "respond", "with", "text", "or", "by", "seeking", "confirmation", "or", "by", "engaging", "a", "function", "with", "optional", "keyword", "arguments", ".", "Return",...
59da05410aa1cf8682dcee2bf0bd0572fa42bd29
https://github.com/wdbm/megaparsex/blob/59da05410aa1cf8682dcee2bf0bd0572fa42bd29/megaparsex.py#L51-L91
train
56,880
wdbm/megaparsex
megaparsex.py
parse
def parse( text = None, humour = 75 ): """ Parse input text using various triggers, some returning text and some for engaging functions. If triggered, a trigger returns text or True if and if not triggered, returns False. If no triggers are triggered, return False, if one trigger is tr...
python
def parse( text = None, humour = 75 ): """ Parse input text using various triggers, some returning text and some for engaging functions. If triggered, a trigger returns text or True if and if not triggered, returns False. If no triggers are triggered, return False, if one trigger is tr...
[ "def", "parse", "(", "text", "=", "None", ",", "humour", "=", "75", ")", ":", "triggers", "=", "[", "]", "# general", "if", "humour", ">=", "75", ":", "triggers", ".", "extend", "(", "[", "trigger_keyphrases", "(", "text", "=", "text", ",", "keyphras...
Parse input text using various triggers, some returning text and some for engaging functions. If triggered, a trigger returns text or True if and if not triggered, returns False. If no triggers are triggered, return False, if one trigger is triggered, return the value returned by that trigger, and if mu...
[ "Parse", "input", "text", "using", "various", "triggers", "some", "returning", "text", "and", "some", "for", "engaging", "functions", ".", "If", "triggered", "a", "trigger", "returns", "text", "or", "True", "if", "and", "if", "not", "triggered", "returns", "...
59da05410aa1cf8682dcee2bf0bd0572fa42bd29
https://github.com/wdbm/megaparsex/blob/59da05410aa1cf8682dcee2bf0bd0572fa42bd29/megaparsex.py#L93-L230
train
56,881
wdbm/megaparsex
megaparsex.py
multiparse
def multiparse( text = None, parsers = [parse], help_message = None ): """ Parse input text by looping over a list of multiple parsers. If one trigger is triggered, return the value returned by that trigger, if multiple triggers are triggered, return a list of the values ret...
python
def multiparse( text = None, parsers = [parse], help_message = None ): """ Parse input text by looping over a list of multiple parsers. If one trigger is triggered, return the value returned by that trigger, if multiple triggers are triggered, return a list of the values ret...
[ "def", "multiparse", "(", "text", "=", "None", ",", "parsers", "=", "[", "parse", "]", ",", "help_message", "=", "None", ")", ":", "responses", "=", "[", "]", "for", "_parser", "in", "parsers", ":", "response", "=", "_parser", "(", "text", "=", "text...
Parse input text by looping over a list of multiple parsers. If one trigger is triggered, return the value returned by that trigger, if multiple triggers are triggered, return a list of the values returned by those triggers. If no triggers are triggered, return False or an optional help message.
[ "Parse", "input", "text", "by", "looping", "over", "a", "list", "of", "multiple", "parsers", ".", "If", "one", "trigger", "is", "triggered", "return", "the", "value", "returned", "by", "that", "trigger", "if", "multiple", "triggers", "are", "triggered", "ret...
59da05410aa1cf8682dcee2bf0bd0572fa42bd29
https://github.com/wdbm/megaparsex/blob/59da05410aa1cf8682dcee2bf0bd0572fa42bd29/megaparsex.py#L273-L299
train
56,882
wdbm/megaparsex
megaparsex.py
confirmation.run
def run( self ): """ Engage contained function with optional keyword arguments. """ if self._function and not self._kwargs: return self._function() if self._function and self._kwargs: return self._function(**self._kwargs)
python
def run( self ): """ Engage contained function with optional keyword arguments. """ if self._function and not self._kwargs: return self._function() if self._function and self._kwargs: return self._function(**self._kwargs)
[ "def", "run", "(", "self", ")", ":", "if", "self", ".", "_function", "and", "not", "self", ".", "_kwargs", ":", "return", "self", ".", "_function", "(", ")", "if", "self", ".", "_function", "and", "self", ".", "_kwargs", ":", "return", "self", ".", ...
Engage contained function with optional keyword arguments.
[ "Engage", "contained", "function", "with", "optional", "keyword", "arguments", "." ]
59da05410aa1cf8682dcee2bf0bd0572fa42bd29
https://github.com/wdbm/megaparsex/blob/59da05410aa1cf8682dcee2bf0bd0572fa42bd29/megaparsex.py#L373-L382
train
56,883
tradenity/python-sdk
tradenity/resources/tax_settings.py
TaxSettings.tax_class_based_on
def tax_class_based_on(self, tax_class_based_on): """Sets the tax_class_based_on of this TaxSettings. :param tax_class_based_on: The tax_class_based_on of this TaxSettings. :type: str """ allowed_values = ["shippingAddress", "billingAddress"] # noqa: E501 if tax_class_...
python
def tax_class_based_on(self, tax_class_based_on): """Sets the tax_class_based_on of this TaxSettings. :param tax_class_based_on: The tax_class_based_on of this TaxSettings. :type: str """ allowed_values = ["shippingAddress", "billingAddress"] # noqa: E501 if tax_class_...
[ "def", "tax_class_based_on", "(", "self", ",", "tax_class_based_on", ")", ":", "allowed_values", "=", "[", "\"shippingAddress\"", ",", "\"billingAddress\"", "]", "# noqa: E501", "if", "tax_class_based_on", "is", "not", "None", "and", "tax_class_based_on", "not", "in",...
Sets the tax_class_based_on of this TaxSettings. :param tax_class_based_on: The tax_class_based_on of this TaxSettings. :type: str
[ "Sets", "the", "tax_class_based_on", "of", "this", "TaxSettings", "." ]
d13fbe23f4d6ff22554c6d8d2deaf209371adaf1
https://github.com/tradenity/python-sdk/blob/d13fbe23f4d6ff22554c6d8d2deaf209371adaf1/tradenity/resources/tax_settings.py#L78-L92
train
56,884
alexcepoi/cake
cake/lib.py
recurse_up
def recurse_up(directory, filename): """ Recursive walk a directory up to root until it contains `filename` """ directory = osp.abspath(directory) while True: searchfile = osp.join(directory, filename) if osp.isfile(searchfile): return directory if directory == '/': break else: directory = osp.dirna...
python
def recurse_up(directory, filename): """ Recursive walk a directory up to root until it contains `filename` """ directory = osp.abspath(directory) while True: searchfile = osp.join(directory, filename) if osp.isfile(searchfile): return directory if directory == '/': break else: directory = osp.dirna...
[ "def", "recurse_up", "(", "directory", ",", "filename", ")", ":", "directory", "=", "osp", ".", "abspath", "(", "directory", ")", "while", "True", ":", "searchfile", "=", "osp", ".", "join", "(", "directory", ",", "filename", ")", "if", "osp", ".", "is...
Recursive walk a directory up to root until it contains `filename`
[ "Recursive", "walk", "a", "directory", "up", "to", "root", "until", "it", "contains", "filename" ]
0fde58dfea1fdbfd632816d5850b47cb0f9ece64
https://github.com/alexcepoi/cake/blob/0fde58dfea1fdbfd632816d5850b47cb0f9ece64/cake/lib.py#L73-L88
train
56,885
inveniosoftware-attic/invenio-utils
invenio_utils/xmlhelpers.py
etree_to_dict
def etree_to_dict(tree): """Translate etree into dictionary. :param tree: etree dictionary object :type tree: <http://lxml.de/api/lxml.etree-module.html> """ d = {tree.tag.split('}')[1]: map( etree_to_dict, tree.iterchildren() ) or tree.text} return d
python
def etree_to_dict(tree): """Translate etree into dictionary. :param tree: etree dictionary object :type tree: <http://lxml.de/api/lxml.etree-module.html> """ d = {tree.tag.split('}')[1]: map( etree_to_dict, tree.iterchildren() ) or tree.text} return d
[ "def", "etree_to_dict", "(", "tree", ")", ":", "d", "=", "{", "tree", ".", "tag", ".", "split", "(", "'}'", ")", "[", "1", "]", ":", "map", "(", "etree_to_dict", ",", "tree", ".", "iterchildren", "(", ")", ")", "or", "tree", ".", "text", "}", "...
Translate etree into dictionary. :param tree: etree dictionary object :type tree: <http://lxml.de/api/lxml.etree-module.html>
[ "Translate", "etree", "into", "dictionary", "." ]
9a1c6db4e3f1370901f329f510480dd8df188296
https://github.com/inveniosoftware-attic/invenio-utils/blob/9a1c6db4e3f1370901f329f510480dd8df188296/invenio_utils/xmlhelpers.py#L23-L34
train
56,886
inveniosoftware-attic/invenio-utils
invenio_utils/filedownload.py
finalize_download
def finalize_download(url, download_to_file, content_type, request): """ Finalizes the download operation by doing various checks, such as format type, size check etc. """ # If format is given, a format check is performed. if content_type and content_type not in request.headers['content-type']: ...
python
def finalize_download(url, download_to_file, content_type, request): """ Finalizes the download operation by doing various checks, such as format type, size check etc. """ # If format is given, a format check is performed. if content_type and content_type not in request.headers['content-type']: ...
[ "def", "finalize_download", "(", "url", ",", "download_to_file", ",", "content_type", ",", "request", ")", ":", "# If format is given, a format check is performed.", "if", "content_type", "and", "content_type", "not", "in", "request", ".", "headers", "[", "'content-type...
Finalizes the download operation by doing various checks, such as format type, size check etc.
[ "Finalizes", "the", "download", "operation", "by", "doing", "various", "checks", "such", "as", "format", "type", "size", "check", "etc", "." ]
9a1c6db4e3f1370901f329f510480dd8df188296
https://github.com/inveniosoftware-attic/invenio-utils/blob/9a1c6db4e3f1370901f329f510480dd8df188296/invenio_utils/filedownload.py#L218-L250
train
56,887
inveniosoftware-attic/invenio-utils
invenio_utils/filedownload.py
download_local_file
def download_local_file(filename, download_to_file): """ Copies a local file to Invenio's temporary directory. @param filename: the name of the file to copy @type filename: string @param download_to_file: the path to save the file to @type download_to_file: string @return: the path of the...
python
def download_local_file(filename, download_to_file): """ Copies a local file to Invenio's temporary directory. @param filename: the name of the file to copy @type filename: string @param download_to_file: the path to save the file to @type download_to_file: string @return: the path of the...
[ "def", "download_local_file", "(", "filename", ",", "download_to_file", ")", ":", "# Try to copy.", "try", ":", "path", "=", "urllib2", ".", "urlparse", ".", "urlsplit", "(", "urllib", ".", "unquote", "(", "filename", ")", ")", "[", "2", "]", "if", "os", ...
Copies a local file to Invenio's temporary directory. @param filename: the name of the file to copy @type filename: string @param download_to_file: the path to save the file to @type download_to_file: string @return: the path of the temporary file created @rtype: string @raise StandardErr...
[ "Copies", "a", "local", "file", "to", "Invenio", "s", "temporary", "directory", "." ]
9a1c6db4e3f1370901f329f510480dd8df188296
https://github.com/inveniosoftware-attic/invenio-utils/blob/9a1c6db4e3f1370901f329f510480dd8df188296/invenio_utils/filedownload.py#L253-L295
train
56,888
inveniosoftware-attic/invenio-utils
invenio_utils/filedownload.py
safe_mkstemp
def safe_mkstemp(suffix, prefix='filedownloadutils_'): """Create a temporary filename that don't have any '.' inside a part from the suffix.""" tmpfd, tmppath = tempfile.mkstemp( suffix=suffix, prefix=prefix, dir=current_app.config['CFG_TMPSHAREDDIR'] ) # Close the file and l...
python
def safe_mkstemp(suffix, prefix='filedownloadutils_'): """Create a temporary filename that don't have any '.' inside a part from the suffix.""" tmpfd, tmppath = tempfile.mkstemp( suffix=suffix, prefix=prefix, dir=current_app.config['CFG_TMPSHAREDDIR'] ) # Close the file and l...
[ "def", "safe_mkstemp", "(", "suffix", ",", "prefix", "=", "'filedownloadutils_'", ")", ":", "tmpfd", ",", "tmppath", "=", "tempfile", ".", "mkstemp", "(", "suffix", "=", "suffix", ",", "prefix", "=", "prefix", ",", "dir", "=", "current_app", ".", "config",...
Create a temporary filename that don't have any '.' inside a part from the suffix.
[ "Create", "a", "temporary", "filename", "that", "don", "t", "have", "any", ".", "inside", "a", "part", "from", "the", "suffix", "." ]
9a1c6db4e3f1370901f329f510480dd8df188296
https://github.com/inveniosoftware-attic/invenio-utils/blob/9a1c6db4e3f1370901f329f510480dd8df188296/invenio_utils/filedownload.py#L304-L327
train
56,889
inveniosoftware-attic/invenio-utils
invenio_utils/filedownload.py
open_url
def open_url(url, headers=None): """ Opens a URL. If headers are passed as argument, no check is performed and the URL will be opened. @param url: the URL to open @type url: string @param headers: the headers to use @type headers: dictionary @return: a file-like object as returned by ...
python
def open_url(url, headers=None): """ Opens a URL. If headers are passed as argument, no check is performed and the URL will be opened. @param url: the URL to open @type url: string @param headers: the headers to use @type headers: dictionary @return: a file-like object as returned by ...
[ "def", "open_url", "(", "url", ",", "headers", "=", "None", ")", ":", "request", "=", "urllib2", ".", "Request", "(", "url", ")", "if", "headers", ":", "for", "key", ",", "value", "in", "headers", ".", "items", "(", ")", ":", "request", ".", "add_h...
Opens a URL. If headers are passed as argument, no check is performed and the URL will be opened. @param url: the URL to open @type url: string @param headers: the headers to use @type headers: dictionary @return: a file-like object as returned by urllib2.urlopen.
[ "Opens", "a", "URL", ".", "If", "headers", "are", "passed", "as", "argument", "no", "check", "is", "performed", "and", "the", "URL", "will", "be", "opened", "." ]
9a1c6db4e3f1370901f329f510480dd8df188296
https://github.com/inveniosoftware-attic/invenio-utils/blob/9a1c6db4e3f1370901f329f510480dd8df188296/invenio_utils/filedownload.py#L330-L347
train
56,890
kellerza/pyqwikswitch
pyqwikswitch/async_.py
QSUsb.get_json
async def get_json(self, url, timeout=30, astext=False, exceptions=False): """Get URL and parse JSON from text.""" try: with async_timeout.timeout(timeout): res = await self._aio_session.get(url) if res.status != 200: _LOGGER.error("QSUSB r...
python
async def get_json(self, url, timeout=30, astext=False, exceptions=False): """Get URL and parse JSON from text.""" try: with async_timeout.timeout(timeout): res = await self._aio_session.get(url) if res.status != 200: _LOGGER.error("QSUSB r...
[ "async", "def", "get_json", "(", "self", ",", "url", ",", "timeout", "=", "30", ",", "astext", "=", "False", ",", "exceptions", "=", "False", ")", ":", "try", ":", "with", "async_timeout", ".", "timeout", "(", "timeout", ")", ":", "res", "=", "await"...
Get URL and parse JSON from text.
[ "Get", "URL", "and", "parse", "JSON", "from", "text", "." ]
9d4f080048221eaee93e3eefcf641919ff1af586
https://github.com/kellerza/pyqwikswitch/blob/9d4f080048221eaee93e3eefcf641919ff1af586/pyqwikswitch/async_.py#L38-L61
train
56,891
kellerza/pyqwikswitch
pyqwikswitch/async_.py
QSUsb.stop
def stop(self): """Stop listening.""" self._running = False if self._sleep_task: self._sleep_task.cancel() self._sleep_task = None
python
def stop(self): """Stop listening.""" self._running = False if self._sleep_task: self._sleep_task.cancel() self._sleep_task = None
[ "def", "stop", "(", "self", ")", ":", "self", ".", "_running", "=", "False", "if", "self", ".", "_sleep_task", ":", "self", ".", "_sleep_task", ".", "cancel", "(", ")", "self", ".", "_sleep_task", "=", "None" ]
Stop listening.
[ "Stop", "listening", "." ]
9d4f080048221eaee93e3eefcf641919ff1af586
https://github.com/kellerza/pyqwikswitch/blob/9d4f080048221eaee93e3eefcf641919ff1af586/pyqwikswitch/async_.py#L63-L68
train
56,892
kellerza/pyqwikswitch
pyqwikswitch/async_.py
QSUsb._async_listen
async def _async_listen(self, callback=None): """Listen loop.""" while True: if not self._running: return try: packet = await self.get_json( URL_LISTEN.format(self._url), timeout=30, exceptions=True) except asyncio....
python
async def _async_listen(self, callback=None): """Listen loop.""" while True: if not self._running: return try: packet = await self.get_json( URL_LISTEN.format(self._url), timeout=30, exceptions=True) except asyncio....
[ "async", "def", "_async_listen", "(", "self", ",", "callback", "=", "None", ")", ":", "while", "True", ":", "if", "not", "self", ".", "_running", ":", "return", "try", ":", "packet", "=", "await", "self", ".", "get_json", "(", "URL_LISTEN", ".", "forma...
Listen loop.
[ "Listen", "loop", "." ]
9d4f080048221eaee93e3eefcf641919ff1af586
https://github.com/kellerza/pyqwikswitch/blob/9d4f080048221eaee93e3eefcf641919ff1af586/pyqwikswitch/async_.py#L79-L108
train
56,893
ThomasChiroux/attowiki
src/attowiki/tools.py
attowiki_distro_path
def attowiki_distro_path(): """return the absolute complete path where attowiki is located .. todo:: use pkg_resources ? """ attowiki_path = os.path.abspath(__file__) if attowiki_path[-1] != '/': attowiki_path = attowiki_path[:attowiki_path.rfind('/')] else: attowiki_path = atto...
python
def attowiki_distro_path(): """return the absolute complete path where attowiki is located .. todo:: use pkg_resources ? """ attowiki_path = os.path.abspath(__file__) if attowiki_path[-1] != '/': attowiki_path = attowiki_path[:attowiki_path.rfind('/')] else: attowiki_path = atto...
[ "def", "attowiki_distro_path", "(", ")", ":", "attowiki_path", "=", "os", ".", "path", ".", "abspath", "(", "__file__", ")", "if", "attowiki_path", "[", "-", "1", "]", "!=", "'/'", ":", "attowiki_path", "=", "attowiki_path", "[", ":", "attowiki_path", ".",...
return the absolute complete path where attowiki is located .. todo:: use pkg_resources ?
[ "return", "the", "absolute", "complete", "path", "where", "attowiki", "is", "located" ]
6c93c420305490d324fdc95a7b40b2283a222183
https://github.com/ThomasChiroux/attowiki/blob/6c93c420305490d324fdc95a7b40b2283a222183/src/attowiki/tools.py#L30-L40
train
56,894
claymcleod/celcius
lib/celcius/unix/commands/crontab.py
crontab.build_command
def build_command(self): """Build out the crontab command""" return cron_utils.cronify("crontab -l | {{ cat; echo \"{} {} {} {} {} CJOBID='{}' MAILTO='' {}\"; }} | crontab - > /dev/null".format(self._minute, self._hour, self._day_of_month, self._month_of_year, self._day_of_week, self._jobid, self._comma...
python
def build_command(self): """Build out the crontab command""" return cron_utils.cronify("crontab -l | {{ cat; echo \"{} {} {} {} {} CJOBID='{}' MAILTO='' {}\"; }} | crontab - > /dev/null".format(self._minute, self._hour, self._day_of_month, self._month_of_year, self._day_of_week, self._jobid, self._comma...
[ "def", "build_command", "(", "self", ")", ":", "return", "cron_utils", ".", "cronify", "(", "\"crontab -l | {{ cat; echo \\\"{} {} {} {} {} CJOBID='{}' MAILTO='' {}\\\"; }} | crontab - > /dev/null\"", ".", "format", "(", "self", ".", "_minute", ",", "self", ".", "_hour", ...
Build out the crontab command
[ "Build", "out", "the", "crontab", "command" ]
e46a3c1ba112af9de23360d1455ab1e037a38ea1
https://github.com/claymcleod/celcius/blob/e46a3c1ba112af9de23360d1455ab1e037a38ea1/lib/celcius/unix/commands/crontab.py#L37-L39
train
56,895
Aluriak/bubble-tools
bubbletools/utils.py
infer_format
def infer_format(filename:str) -> str: """Return extension identifying format of given filename""" _, ext = os.path.splitext(filename) return ext
python
def infer_format(filename:str) -> str: """Return extension identifying format of given filename""" _, ext = os.path.splitext(filename) return ext
[ "def", "infer_format", "(", "filename", ":", "str", ")", "->", "str", ":", "_", ",", "ext", "=", "os", ".", "path", ".", "splitext", "(", "filename", ")", "return", "ext" ]
Return extension identifying format of given filename
[ "Return", "extension", "identifying", "format", "of", "given", "filename" ]
f014f4a1986abefc80dc418feaa05ed258c2221a
https://github.com/Aluriak/bubble-tools/blob/f014f4a1986abefc80dc418feaa05ed258c2221a/bubbletools/utils.py#L19-L22
train
56,896
Aluriak/bubble-tools
bubbletools/utils.py
reversed_graph
def reversed_graph(graph:dict) -> dict: """Return given graph reversed""" ret = defaultdict(set) for node, succs in graph.items(): for succ in succs: ret[succ].add(node) return dict(ret)
python
def reversed_graph(graph:dict) -> dict: """Return given graph reversed""" ret = defaultdict(set) for node, succs in graph.items(): for succ in succs: ret[succ].add(node) return dict(ret)
[ "def", "reversed_graph", "(", "graph", ":", "dict", ")", "->", "dict", ":", "ret", "=", "defaultdict", "(", "set", ")", "for", "node", ",", "succs", "in", "graph", ".", "items", "(", ")", ":", "for", "succ", "in", "succs", ":", "ret", "[", "succ", ...
Return given graph reversed
[ "Return", "given", "graph", "reversed" ]
f014f4a1986abefc80dc418feaa05ed258c2221a
https://github.com/Aluriak/bubble-tools/blob/f014f4a1986abefc80dc418feaa05ed258c2221a/bubbletools/utils.py#L25-L31
train
56,897
Aluriak/bubble-tools
bubbletools/utils.py
have_cycle
def have_cycle(graph:dict) -> frozenset: """Perform a topologic sort to detect any cycle. Return the set of unsortable nodes. If at least one item, then there is cycle in given graph. """ # topological sort walked = set() # walked nodes nodes = frozenset(it.chain(it.chain.from_iterable(gr...
python
def have_cycle(graph:dict) -> frozenset: """Perform a topologic sort to detect any cycle. Return the set of unsortable nodes. If at least one item, then there is cycle in given graph. """ # topological sort walked = set() # walked nodes nodes = frozenset(it.chain(it.chain.from_iterable(gr...
[ "def", "have_cycle", "(", "graph", ":", "dict", ")", "->", "frozenset", ":", "# topological sort", "walked", "=", "set", "(", ")", "# walked nodes", "nodes", "=", "frozenset", "(", "it", ".", "chain", "(", "it", ".", "chain", ".", "from_iterable", "(", "...
Perform a topologic sort to detect any cycle. Return the set of unsortable nodes. If at least one item, then there is cycle in given graph.
[ "Perform", "a", "topologic", "sort", "to", "detect", "any", "cycle", "." ]
f014f4a1986abefc80dc418feaa05ed258c2221a
https://github.com/Aluriak/bubble-tools/blob/f014f4a1986abefc80dc418feaa05ed258c2221a/bubbletools/utils.py#L64-L81
train
56,898
Aluriak/bubble-tools
bubbletools/utils.py
file_lines
def file_lines(bblfile:str) -> iter: """Yield lines found in given file""" with open(bblfile) as fd: yield from (line.rstrip() for line in fd if line.rstrip())
python
def file_lines(bblfile:str) -> iter: """Yield lines found in given file""" with open(bblfile) as fd: yield from (line.rstrip() for line in fd if line.rstrip())
[ "def", "file_lines", "(", "bblfile", ":", "str", ")", "->", "iter", ":", "with", "open", "(", "bblfile", ")", "as", "fd", ":", "yield", "from", "(", "line", ".", "rstrip", "(", ")", "for", "line", "in", "fd", "if", "line", ".", "rstrip", "(", ")"...
Yield lines found in given file
[ "Yield", "lines", "found", "in", "given", "file" ]
f014f4a1986abefc80dc418feaa05ed258c2221a
https://github.com/Aluriak/bubble-tools/blob/f014f4a1986abefc80dc418feaa05ed258c2221a/bubbletools/utils.py#L84-L87
train
56,899