repository_name
stringlengths
7
55
func_path_in_repository
stringlengths
4
223
func_name
stringlengths
1
134
whole_func_string
stringlengths
75
104k
language
stringclasses
1 value
func_code_string
stringlengths
75
104k
func_code_tokens
listlengths
19
28.4k
func_documentation_string
stringlengths
1
46.9k
func_documentation_tokens
listlengths
1
1.97k
split_name
stringclasses
1 value
func_code_url
stringlengths
87
315
AaronWatters/jp_proxy_widget
jp_proxy_widget/js_context.py
load_if_not_loaded
def load_if_not_loaded(widget, filenames, verbose=False, delay=0.1, force=False, local=True, evaluator=None): """ Load a javascript file to the Jupyter notebook context, unless it was already loaded. """ if evaluator is None: evaluator = EVALUATOR # default if not specified. for filenam...
python
def load_if_not_loaded(widget, filenames, verbose=False, delay=0.1, force=False, local=True, evaluator=None): """ Load a javascript file to the Jupyter notebook context, unless it was already loaded. """ if evaluator is None: evaluator = EVALUATOR # default if not specified. for filenam...
[ "def", "load_if_not_loaded", "(", "widget", ",", "filenames", ",", "verbose", "=", "False", ",", "delay", "=", "0.1", ",", "force", "=", "False", ",", "local", "=", "True", ",", "evaluator", "=", "None", ")", ":", "if", "evaluator", "is", "None", ":", ...
Load a javascript file to the Jupyter notebook context, unless it was already loaded.
[ "Load", "a", "javascript", "file", "to", "the", "Jupyter", "notebook", "context", "unless", "it", "was", "already", "loaded", "." ]
train
https://github.com/AaronWatters/jp_proxy_widget/blob/e53789c9b8a587e2f6e768d16b68e0ae5b3790d9/jp_proxy_widget/js_context.py#L71-L93
AaronWatters/jp_proxy_widget
jp_proxy_widget/proxy_widget.py
ElementWrapper._set
def _set(self, name, value): "Proxy to set a property of the widget element." return self.widget(self.widget_element._set(name, value))
python
def _set(self, name, value): "Proxy to set a property of the widget element." return self.widget(self.widget_element._set(name, value))
[ "def", "_set", "(", "self", ",", "name", ",", "value", ")", ":", "return", "self", ".", "widget", "(", "self", ".", "widget_element", ".", "_set", "(", "name", ",", "value", ")", ")" ]
Proxy to set a property of the widget element.
[ "Proxy", "to", "set", "a", "property", "of", "the", "widget", "element", "." ]
train
https://github.com/AaronWatters/jp_proxy_widget/blob/e53789c9b8a587e2f6e768d16b68e0ae5b3790d9/jp_proxy_widget/proxy_widget.py#L855-L857
jmoiron/speedparser
speedparser/speedparser.py
strip_outer_tag
def strip_outer_tag(text): """Strips the outer tag, if text starts with a tag. Not entity aware; designed to quickly strip outer tags from lxml cleaner output. Only checks for <p> and <div> outer tags.""" if not text or not isinstance(text, basestring): return text stripped = text.strip() ...
python
def strip_outer_tag(text): """Strips the outer tag, if text starts with a tag. Not entity aware; designed to quickly strip outer tags from lxml cleaner output. Only checks for <p> and <div> outer tags.""" if not text or not isinstance(text, basestring): return text stripped = text.strip() ...
[ "def", "strip_outer_tag", "(", "text", ")", ":", "if", "not", "text", "or", "not", "isinstance", "(", "text", ",", "basestring", ")", ":", "return", "text", "stripped", "=", "text", ".", "strip", "(", ")", "if", "(", "stripped", ".", "startswith", "(",...
Strips the outer tag, if text starts with a tag. Not entity aware; designed to quickly strip outer tags from lxml cleaner output. Only checks for <p> and <div> outer tags.
[ "Strips", "the", "outer", "tag", "if", "text", "starts", "with", "a", "tag", ".", "Not", "entity", "aware", ";", "designed", "to", "quickly", "strip", "outer", "tags", "from", "lxml", "cleaner", "output", ".", "Only", "checks", "for", "<p", ">", "and", ...
train
https://github.com/jmoiron/speedparser/blob/e7e8d79daf73b35c9259695ad1e379476e1dfc77/speedparser/speedparser.py#L94-L104
jmoiron/speedparser
speedparser/speedparser.py
munge_author
def munge_author(author): """If an author contains an email and a name in it, make sure it is in the format: "name (email)".""" # this loveliness is from feedparser but was not usable as a function if '@' in author: emailmatch = re.search(r"(([a-zA-Z0-9\_\-\.\+]+)@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-...
python
def munge_author(author): """If an author contains an email and a name in it, make sure it is in the format: "name (email)".""" # this loveliness is from feedparser but was not usable as a function if '@' in author: emailmatch = re.search(r"(([a-zA-Z0-9\_\-\.\+]+)@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-...
[ "def", "munge_author", "(", "author", ")", ":", "# this loveliness is from feedparser but was not usable as a function", "if", "'@'", "in", "author", ":", "emailmatch", "=", "re", ".", "search", "(", "r\"(([a-zA-Z0-9\\_\\-\\.\\+]+)@((\\[[0-9]{1,3}\\.[0-9]{1,3}\\.[0-9]{1,3}\\.)|((...
If an author contains an email and a name in it, make sure it is in the format: "name (email)".
[ "If", "an", "author", "contains", "an", "email", "and", "a", "name", "in", "it", "make", "sure", "it", "is", "in", "the", "format", ":", "name", "(", "email", ")", "." ]
train
https://github.com/jmoiron/speedparser/blob/e7e8d79daf73b35c9259695ad1e379476e1dfc77/speedparser/speedparser.py#L121-L141
jmoiron/speedparser
speedparser/speedparser.py
base_url
def base_url(root): """Determine the base url for a root element.""" for attr, value in root.attrib.iteritems(): if attr.endswith('base') and 'http' in value: return value return None
python
def base_url(root): """Determine the base url for a root element.""" for attr, value in root.attrib.iteritems(): if attr.endswith('base') and 'http' in value: return value return None
[ "def", "base_url", "(", "root", ")", ":", "for", "attr", ",", "value", "in", "root", ".", "attrib", ".", "iteritems", "(", ")", ":", "if", "attr", ".", "endswith", "(", "'base'", ")", "and", "'http'", "in", "value", ":", "return", "value", "return", ...
Determine the base url for a root element.
[ "Determine", "the", "base", "url", "for", "a", "root", "element", "." ]
train
https://github.com/jmoiron/speedparser/blob/e7e8d79daf73b35c9259695ad1e379476e1dfc77/speedparser/speedparser.py#L152-L157
jmoiron/speedparser
speedparser/speedparser.py
clean_ns
def clean_ns(tag): """Return a tag and its namespace separately.""" if '}' in tag: split = tag.split('}') return split[0].strip('{'), split[-1] return '', tag
python
def clean_ns(tag): """Return a tag and its namespace separately.""" if '}' in tag: split = tag.split('}') return split[0].strip('{'), split[-1] return '', tag
[ "def", "clean_ns", "(", "tag", ")", ":", "if", "'}'", "in", "tag", ":", "split", "=", "tag", ".", "split", "(", "'}'", ")", "return", "split", "[", "0", "]", ".", "strip", "(", "'{'", ")", ",", "split", "[", "-", "1", "]", "return", "''", ","...
Return a tag and its namespace separately.
[ "Return", "a", "tag", "and", "its", "namespace", "separately", "." ]
train
https://github.com/jmoiron/speedparser/blob/e7e8d79daf73b35c9259695ad1e379476e1dfc77/speedparser/speedparser.py#L174-L179
jmoiron/speedparser
speedparser/speedparser.py
xpath
def xpath(node, query, namespaces={}): """A safe xpath that only uses namespaces if available.""" if namespaces and 'None' not in namespaces: return node.xpath(query, namespaces=namespaces) return node.xpath(query)
python
def xpath(node, query, namespaces={}): """A safe xpath that only uses namespaces if available.""" if namespaces and 'None' not in namespaces: return node.xpath(query, namespaces=namespaces) return node.xpath(query)
[ "def", "xpath", "(", "node", ",", "query", ",", "namespaces", "=", "{", "}", ")", ":", "if", "namespaces", "and", "'None'", "not", "in", "namespaces", ":", "return", "node", ".", "xpath", "(", "query", ",", "namespaces", "=", "namespaces", ")", "return...
A safe xpath that only uses namespaces if available.
[ "A", "safe", "xpath", "that", "only", "uses", "namespaces", "if", "available", "." ]
train
https://github.com/jmoiron/speedparser/blob/e7e8d79daf73b35c9259695ad1e379476e1dfc77/speedparser/speedparser.py#L182-L186
jmoiron/speedparser
speedparser/speedparser.py
innertext
def innertext(node): """Return the inner text of a node. If a node has no sub elements, this is just node.text. Otherwise, it's node.text + sub-element-text + node.tail.""" if not len(node): return node.text return (node.text or '') + ''.join([etree.tostring(c) for c in node]) + (node.tai...
python
def innertext(node): """Return the inner text of a node. If a node has no sub elements, this is just node.text. Otherwise, it's node.text + sub-element-text + node.tail.""" if not len(node): return node.text return (node.text or '') + ''.join([etree.tostring(c) for c in node]) + (node.tai...
[ "def", "innertext", "(", "node", ")", ":", "if", "not", "len", "(", "node", ")", ":", "return", "node", ".", "text", "return", "(", "node", ".", "text", "or", "''", ")", "+", "''", ".", "join", "(", "[", "etree", ".", "tostring", "(", "c", ")",...
Return the inner text of a node. If a node has no sub elements, this is just node.text. Otherwise, it's node.text + sub-element-text + node.tail.
[ "Return", "the", "inner", "text", "of", "a", "node", ".", "If", "a", "node", "has", "no", "sub", "elements", "this", "is", "just", "node", ".", "text", ".", "Otherwise", "it", "s", "node", ".", "text", "+", "sub", "-", "element", "-", "text", "+", ...
train
https://github.com/jmoiron/speedparser/blob/e7e8d79daf73b35c9259695ad1e379476e1dfc77/speedparser/speedparser.py#L189-L196
jmoiron/speedparser
speedparser/speedparser.py
parse
def parse(document, clean_html=True, unix_timestamp=False, encoding=None): """Parse a document and return a feedparser dictionary with attr key access. If clean_html is False, the html in the feed will not be cleaned. If clean_html is True, a sane version of lxml.html.clean.Cleaner will be used. If it ...
python
def parse(document, clean_html=True, unix_timestamp=False, encoding=None): """Parse a document and return a feedparser dictionary with attr key access. If clean_html is False, the html in the feed will not be cleaned. If clean_html is True, a sane version of lxml.html.clean.Cleaner will be used. If it ...
[ "def", "parse", "(", "document", ",", "clean_html", "=", "True", ",", "unix_timestamp", "=", "False", ",", "encoding", "=", "None", ")", ":", "if", "isinstance", "(", "clean_html", ",", "bool", ")", ":", "cleaner", "=", "default_cleaner", "if", "clean_html...
Parse a document and return a feedparser dictionary with attr key access. If clean_html is False, the html in the feed will not be cleaned. If clean_html is True, a sane version of lxml.html.clean.Cleaner will be used. If it is a Cleaner object, that cleaner will be used. If unix_timestamp is True, th...
[ "Parse", "a", "document", "and", "return", "a", "feedparser", "dictionary", "with", "attr", "key", "access", ".", "If", "clean_html", "is", "False", "the", "html", "in", "the", "feed", "will", "not", "be", "cleaned", ".", "If", "clean_html", "is", "True", ...
train
https://github.com/jmoiron/speedparser/blob/e7e8d79daf73b35c9259695ad1e379476e1dfc77/speedparser/speedparser.py#L671-L699
jmoiron/speedparser
speedparser/speedparser.py
SpeedParserEntriesRss20.parse_entry
def parse_entry(self, entry): """An attempt to parse pieces of an entry out w/o xpath, by looping over the entry root's children and slotting them into the right places. This is going to be way messier than SpeedParserEntries, and maybe less cleanly usable, but it should be faster.""" ...
python
def parse_entry(self, entry): """An attempt to parse pieces of an entry out w/o xpath, by looping over the entry root's children and slotting them into the right places. This is going to be way messier than SpeedParserEntries, and maybe less cleanly usable, but it should be faster.""" ...
[ "def", "parse_entry", "(", "self", ",", "entry", ")", ":", "e", "=", "feedparser", ".", "FeedParserDict", "(", ")", "tag_map", "=", "self", ".", "tag_map", "nslookup", "=", "self", ".", "nslookup", "for", "child", "in", "entry", ".", "getchildren", "(", ...
An attempt to parse pieces of an entry out w/o xpath, by looping over the entry root's children and slotting them into the right places. This is going to be way messier than SpeedParserEntries, and maybe less cleanly usable, but it should be faster.
[ "An", "attempt", "to", "parse", "pieces", "of", "an", "entry", "out", "w", "/", "o", "xpath", "by", "looping", "over", "the", "entry", "root", "s", "children", "and", "slotting", "them", "into", "the", "right", "places", ".", "This", "is", "going", "to...
train
https://github.com/jmoiron/speedparser/blob/e7e8d79daf73b35c9259695ad1e379476e1dfc77/speedparser/speedparser.py#L255-L298
AaronWatters/jp_proxy_widget
jp_proxy_widget/watcher.py
FileWatcherWidget.changed_path
def changed_path(self): "Find any changed path and update all changed modification times." result = None # default for path in self.paths_to_modification_times: lastmod = self.paths_to_modification_times[path] mod = os.path.getmtime(path) if mod > lastmod: ...
python
def changed_path(self): "Find any changed path and update all changed modification times." result = None # default for path in self.paths_to_modification_times: lastmod = self.paths_to_modification_times[path] mod = os.path.getmtime(path) if mod > lastmod: ...
[ "def", "changed_path", "(", "self", ")", ":", "result", "=", "None", "# default", "for", "path", "in", "self", ".", "paths_to_modification_times", ":", "lastmod", "=", "self", ".", "paths_to_modification_times", "[", "path", "]", "mod", "=", "os", ".", "path...
Find any changed path and update all changed modification times.
[ "Find", "any", "changed", "path", "and", "update", "all", "changed", "modification", "times", "." ]
train
https://github.com/AaronWatters/jp_proxy_widget/blob/e53789c9b8a587e2f6e768d16b68e0ae5b3790d9/jp_proxy_widget/watcher.py#L124-L144
jmoiron/speedparser
speedparser/feedparsercompat.py
_parse_date_iso8601
def _parse_date_iso8601(dateString): '''Parse a variety of ISO-8601-compatible formats like 20040105''' m = None for _iso8601_match in _iso8601_matches: m = _iso8601_match(dateString) if m: break if not m: return if m.span() == (0, 0): return params = ...
python
def _parse_date_iso8601(dateString): '''Parse a variety of ISO-8601-compatible formats like 20040105''' m = None for _iso8601_match in _iso8601_matches: m = _iso8601_match(dateString) if m: break if not m: return if m.span() == (0, 0): return params = ...
[ "def", "_parse_date_iso8601", "(", "dateString", ")", ":", "m", "=", "None", "for", "_iso8601_match", "in", "_iso8601_matches", ":", "m", "=", "_iso8601_match", "(", "dateString", ")", "if", "m", ":", "break", "if", "not", "m", ":", "return", "if", "m", ...
Parse a variety of ISO-8601-compatible formats like 20040105
[ "Parse", "a", "variety", "of", "ISO", "-", "8601", "-", "compatible", "formats", "like", "20040105" ]
train
https://github.com/jmoiron/speedparser/blob/e7e8d79daf73b35c9259695ad1e379476e1dfc77/speedparser/feedparsercompat.py#L205-L281
jmoiron/speedparser
speedparser/feedparsercompat.py
_parse_date_onblog
def _parse_date_onblog(dateString): '''Parse a string according to the OnBlog 8-bit date format''' m = _korean_onblog_date_re.match(dateString) if not m: return w3dtfdate = '%(year)s-%(month)s-%(day)sT%(hour)s:%(minute)s:%(second)s%(zonediff)s' % \ {'year': m.group(1), 'month': m...
python
def _parse_date_onblog(dateString): '''Parse a string according to the OnBlog 8-bit date format''' m = _korean_onblog_date_re.match(dateString) if not m: return w3dtfdate = '%(year)s-%(month)s-%(day)sT%(hour)s:%(minute)s:%(second)s%(zonediff)s' % \ {'year': m.group(1), 'month': m...
[ "def", "_parse_date_onblog", "(", "dateString", ")", ":", "m", "=", "_korean_onblog_date_re", ".", "match", "(", "dateString", ")", "if", "not", "m", ":", "return", "w3dtfdate", "=", "'%(year)s-%(month)s-%(day)sT%(hour)s:%(minute)s:%(second)s%(zonediff)s'", "%", "{", ...
Parse a string according to the OnBlog 8-bit date format
[ "Parse", "a", "string", "according", "to", "the", "OnBlog", "8", "-", "bit", "date", "format" ]
train
https://github.com/jmoiron/speedparser/blob/e7e8d79daf73b35c9259695ad1e379476e1dfc77/speedparser/feedparsercompat.py#L297-L306
jmoiron/speedparser
speedparser/feedparsercompat.py
_parse_date_nate
def _parse_date_nate(dateString): '''Parse a string according to the Nate 8-bit date format''' m = _korean_nate_date_re.match(dateString) if not m: return hour = int(m.group(5)) ampm = m.group(4) if (ampm == _korean_pm): hour += 12 hour = str(hour) if len(hour) == 1: ...
python
def _parse_date_nate(dateString): '''Parse a string according to the Nate 8-bit date format''' m = _korean_nate_date_re.match(dateString) if not m: return hour = int(m.group(5)) ampm = m.group(4) if (ampm == _korean_pm): hour += 12 hour = str(hour) if len(hour) == 1: ...
[ "def", "_parse_date_nate", "(", "dateString", ")", ":", "m", "=", "_korean_nate_date_re", ".", "match", "(", "dateString", ")", "if", "not", "m", ":", "return", "hour", "=", "int", "(", "m", ".", "group", "(", "5", ")", ")", "ampm", "=", "m", ".", ...
Parse a string according to the Nate 8-bit date format
[ "Parse", "a", "string", "according", "to", "the", "Nate", "8", "-", "bit", "date", "format" ]
train
https://github.com/jmoiron/speedparser/blob/e7e8d79daf73b35c9259695ad1e379476e1dfc77/speedparser/feedparsercompat.py#L309-L325
jmoiron/speedparser
speedparser/feedparsercompat.py
_parse_date_greek
def _parse_date_greek(dateString): '''Parse a string according to a Greek 8-bit date format.''' m = _greek_date_format_re.match(dateString) if not m: return wday = _greek_wdays[m.group(1)] month = _greek_months[m.group(3)] rfc822date = '%(wday)s, %(day)s %(month)s %(year)s %(hour)s:%(min...
python
def _parse_date_greek(dateString): '''Parse a string according to a Greek 8-bit date format.''' m = _greek_date_format_re.match(dateString) if not m: return wday = _greek_wdays[m.group(1)] month = _greek_months[m.group(3)] rfc822date = '%(wday)s, %(day)s %(month)s %(year)s %(hour)s:%(min...
[ "def", "_parse_date_greek", "(", "dateString", ")", ":", "m", "=", "_greek_date_format_re", ".", "match", "(", "dateString", ")", "if", "not", "m", ":", "return", "wday", "=", "_greek_wdays", "[", "m", ".", "group", "(", "1", ")", "]", "month", "=", "_...
Parse a string according to a Greek 8-bit date format.
[ "Parse", "a", "string", "according", "to", "a", "Greek", "8", "-", "bit", "date", "format", "." ]
train
https://github.com/jmoiron/speedparser/blob/e7e8d79daf73b35c9259695ad1e379476e1dfc77/speedparser/feedparsercompat.py#L366-L377
jmoiron/speedparser
speedparser/feedparsercompat.py
_parse_date_hungarian
def _parse_date_hungarian(dateString): '''Parse a string according to a Hungarian 8-bit date format.''' m = _hungarian_date_format_re.match(dateString) if not m or m.group(2) not in _hungarian_months: return None month = _hungarian_months[m.group(2)] day = m.group(3) if len(day) == 1: ...
python
def _parse_date_hungarian(dateString): '''Parse a string according to a Hungarian 8-bit date format.''' m = _hungarian_date_format_re.match(dateString) if not m or m.group(2) not in _hungarian_months: return None month = _hungarian_months[m.group(2)] day = m.group(3) if len(day) == 1: ...
[ "def", "_parse_date_hungarian", "(", "dateString", ")", ":", "m", "=", "_hungarian_date_format_re", ".", "match", "(", "dateString", ")", "if", "not", "m", "or", "m", ".", "group", "(", "2", ")", "not", "in", "_hungarian_months", ":", "return", "None", "mo...
Parse a string according to a Hungarian 8-bit date format.
[ "Parse", "a", "string", "according", "to", "a", "Hungarian", "8", "-", "bit", "date", "format", "." ]
train
https://github.com/jmoiron/speedparser/blob/e7e8d79daf73b35c9259695ad1e379476e1dfc77/speedparser/feedparsercompat.py#L400-L416
jmoiron/speedparser
speedparser/feedparsercompat.py
_parse_date_rfc822
def _parse_date_rfc822(dateString): '''Parse an RFC822, RFC1123, RFC2822, or asctime-style date''' data = dateString.split() if not data: return None if data[0][-1] in (',', '.') or data[0].lower() in rfc822._daynames: del data[0] if len(data) == 4: s = data[3] i = s....
python
def _parse_date_rfc822(dateString): '''Parse an RFC822, RFC1123, RFC2822, or asctime-style date''' data = dateString.split() if not data: return None if data[0][-1] in (',', '.') or data[0].lower() in rfc822._daynames: del data[0] if len(data) == 4: s = data[3] i = s....
[ "def", "_parse_date_rfc822", "(", "dateString", ")", ":", "data", "=", "dateString", ".", "split", "(", ")", "if", "not", "data", ":", "return", "None", "if", "data", "[", "0", "]", "[", "-", "1", "]", "in", "(", "','", ",", "'.'", ")", "or", "da...
Parse an RFC822, RFC1123, RFC2822, or asctime-style date
[ "Parse", "an", "RFC822", "RFC1123", "RFC2822", "or", "asctime", "-", "style", "date" ]
train
https://github.com/jmoiron/speedparser/blob/e7e8d79daf73b35c9259695ad1e379476e1dfc77/speedparser/feedparsercompat.py#L522-L550
jmoiron/speedparser
speedparser/feedparsercompat.py
_parse_date_perforce
def _parse_date_perforce(aDateString): """parse a date in yyyy/mm/dd hh:mm:ss TTT format""" # Fri, 2006/09/15 08:19:53 EDT _my_date_pattern = re.compile( \ r'(\w{,3}), (\d{,4})/(\d{,2})/(\d{2}) (\d{,2}):(\d{2}):(\d{2}) (\w{,3})') m = _my_date_pattern.search(aDateString) if m is None: ...
python
def _parse_date_perforce(aDateString): """parse a date in yyyy/mm/dd hh:mm:ss TTT format""" # Fri, 2006/09/15 08:19:53 EDT _my_date_pattern = re.compile( \ r'(\w{,3}), (\d{,4})/(\d{,2})/(\d{2}) (\d{,2}):(\d{2}):(\d{2}) (\w{,3})') m = _my_date_pattern.search(aDateString) if m is None: ...
[ "def", "_parse_date_perforce", "(", "aDateString", ")", ":", "# Fri, 2006/09/15 08:19:53 EDT", "_my_date_pattern", "=", "re", ".", "compile", "(", "r'(\\w{,3}), (\\d{,4})/(\\d{,2})/(\\d{2}) (\\d{,2}):(\\d{2}):(\\d{2}) (\\w{,3})'", ")", "m", "=", "_my_date_pattern", ".", "search...
parse a date in yyyy/mm/dd hh:mm:ss TTT format
[ "parse", "a", "date", "in", "yyyy", "/", "mm", "/", "dd", "hh", ":", "mm", ":", "ss", "TTT", "format" ]
train
https://github.com/jmoiron/speedparser/blob/e7e8d79daf73b35c9259695ad1e379476e1dfc77/speedparser/feedparsercompat.py#L557-L571
jmoiron/speedparser
speedparser/feedparsercompat.py
parse_date
def parse_date(dateString): '''Parses a variety of date formats into a 9-tuple in GMT''' if not dateString: return None for handler in _date_handlers: try: date9tuple = handler(dateString) except (KeyError, OverflowError, ValueError): continue if not d...
python
def parse_date(dateString): '''Parses a variety of date formats into a 9-tuple in GMT''' if not dateString: return None for handler in _date_handlers: try: date9tuple = handler(dateString) except (KeyError, OverflowError, ValueError): continue if not d...
[ "def", "parse_date", "(", "dateString", ")", ":", "if", "not", "dateString", ":", "return", "None", "for", "handler", "in", "_date_handlers", ":", "try", ":", "date9tuple", "=", "handler", "(", "dateString", ")", "except", "(", "KeyError", ",", "OverflowErro...
Parses a variety of date formats into a 9-tuple in GMT
[ "Parses", "a", "variety", "of", "date", "formats", "into", "a", "9", "-", "tuple", "in", "GMT" ]
train
https://github.com/jmoiron/speedparser/blob/e7e8d79daf73b35c9259695ad1e379476e1dfc77/speedparser/feedparsercompat.py#L574-L588
AaronWatters/jp_proxy_widget
jp_proxy_widget/uploader.py
UnicodeUploader.handle_chunk_wrapper
def handle_chunk_wrapper(self, status, name, content, file_info): """wrapper to allow output redirects for handle_chunk.""" out = self.output if out is not None: with out: print("handling chunk " + repr(type(content))) self.handle_chunk(status, name, c...
python
def handle_chunk_wrapper(self, status, name, content, file_info): """wrapper to allow output redirects for handle_chunk.""" out = self.output if out is not None: with out: print("handling chunk " + repr(type(content))) self.handle_chunk(status, name, c...
[ "def", "handle_chunk_wrapper", "(", "self", ",", "status", ",", "name", ",", "content", ",", "file_info", ")", ":", "out", "=", "self", ".", "output", "if", "out", "is", "not", "None", ":", "with", "out", ":", "print", "(", "\"handling chunk \"", "+", ...
wrapper to allow output redirects for handle_chunk.
[ "wrapper", "to", "allow", "output", "redirects", "for", "handle_chunk", "." ]
train
https://github.com/AaronWatters/jp_proxy_widget/blob/e53789c9b8a587e2f6e768d16b68e0ae5b3790d9/jp_proxy_widget/uploader.py#L106-L114
AaronWatters/jp_proxy_widget
jp_proxy_widget/uploader.py
UnicodeUploader.handle_chunk
def handle_chunk(self, status, name, content, file_info): "Handle one chunk of the file. Override this method for peicewise delivery or error handling." if status == "error": msg = repr(file_info.get("message")) exc = JavaScriptError(msg) exc.file_info = file_info ...
python
def handle_chunk(self, status, name, content, file_info): "Handle one chunk of the file. Override this method for peicewise delivery or error handling." if status == "error": msg = repr(file_info.get("message")) exc = JavaScriptError(msg) exc.file_info = file_info ...
[ "def", "handle_chunk", "(", "self", ",", "status", ",", "name", ",", "content", ",", "file_info", ")", ":", "if", "status", "==", "\"error\"", ":", "msg", "=", "repr", "(", "file_info", ".", "get", "(", "\"message\"", ")", ")", "exc", "=", "JavaScriptE...
Handle one chunk of the file. Override this method for peicewise delivery or error handling.
[ "Handle", "one", "chunk", "of", "the", "file", ".", "Override", "this", "method", "for", "peicewise", "delivery", "or", "error", "handling", "." ]
train
https://github.com/AaronWatters/jp_proxy_widget/blob/e53789c9b8a587e2f6e768d16b68e0ae5b3790d9/jp_proxy_widget/uploader.py#L116-L142
ORCID/python-orcid
orcid/orcid.py
PublicAPI.get_login_url
def get_login_url(self, scope, redirect_uri, state=None, family_names=None, given_names=None, email=None, lang=None, show_login=None): """Return a URL for a user to login/register with ORCID. Parameters ---------- :param scope: string or itera...
python
def get_login_url(self, scope, redirect_uri, state=None, family_names=None, given_names=None, email=None, lang=None, show_login=None): """Return a URL for a user to login/register with ORCID. Parameters ---------- :param scope: string or itera...
[ "def", "get_login_url", "(", "self", ",", "scope", ",", "redirect_uri", ",", "state", "=", "None", ",", "family_names", "=", "None", ",", "given_names", "=", "None", ",", "email", "=", "None", ",", "lang", "=", "None", ",", "show_login", "=", "None", "...
Return a URL for a user to login/register with ORCID. Parameters ---------- :param scope: string or iterable of strings The scope(s) of the authorization request. For example '/authenticate' :param redirect_uri: string The URI to which the user's brow...
[ "Return", "a", "URL", "for", "a", "user", "to", "login", "/", "register", "with", "ORCID", "." ]
train
https://github.com/ORCID/python-orcid/blob/217a56a905f53aef94811e54b4e651a1b09c1f76/orcid/orcid.py#L80-L130
ORCID/python-orcid
orcid/orcid.py
PublicAPI.search
def search(self, query, method="lucene", start=None, rows=None, access_token=None): """Search the ORCID database. Parameters ---------- :param query: string Query in line with the chosen method. :param method: string One of 'lucene', 'edism...
python
def search(self, query, method="lucene", start=None, rows=None, access_token=None): """Search the ORCID database. Parameters ---------- :param query: string Query in line with the chosen method. :param method: string One of 'lucene', 'edism...
[ "def", "search", "(", "self", ",", "query", ",", "method", "=", "\"lucene\"", ",", "start", "=", "None", ",", "rows", "=", "None", ",", "access_token", "=", "None", ")", ":", "if", "access_token", "is", "None", ":", "access_token", "=", "self", ".", ...
Search the ORCID database. Parameters ---------- :param query: string Query in line with the chosen method. :param method: string One of 'lucene', 'edismax', 'dismax' :param start: string Index of the first record requested. Use for pagination...
[ "Search", "the", "ORCID", "database", "." ]
train
https://github.com/ORCID/python-orcid/blob/217a56a905f53aef94811e54b4e651a1b09c1f76/orcid/orcid.py#L132-L166
ORCID/python-orcid
orcid/orcid.py
PublicAPI.search_generator
def search_generator(self, query, method="lucene", pagination=10, access_token=None): """Search the ORCID database with a generator. The generator will yield every result. Parameters ---------- :param query: string Query in line with the cho...
python
def search_generator(self, query, method="lucene", pagination=10, access_token=None): """Search the ORCID database with a generator. The generator will yield every result. Parameters ---------- :param query: string Query in line with the cho...
[ "def", "search_generator", "(", "self", ",", "query", ",", "method", "=", "\"lucene\"", ",", "pagination", "=", "10", ",", "access_token", "=", "None", ")", ":", "if", "access_token", "is", "None", ":", "access_token", "=", "self", ".", "get_search_token_fro...
Search the ORCID database with a generator. The generator will yield every result. Parameters ---------- :param query: string Query in line with the chosen method. :param method: string One of 'lucene', 'edismax', 'dismax' :param pagination: inte...
[ "Search", "the", "ORCID", "database", "with", "a", "generator", "." ]
train
https://github.com/ORCID/python-orcid/blob/217a56a905f53aef94811e54b4e651a1b09c1f76/orcid/orcid.py#L168-L209
ORCID/python-orcid
orcid/orcid.py
PublicAPI.get_search_token_from_orcid
def get_search_token_from_orcid(self, scope='/read-public'): """Get a token for searching ORCID records. Parameters ---------- :param scope: string /read-public or /read-member Returns ------- :returns: string The token. """ ...
python
def get_search_token_from_orcid(self, scope='/read-public'): """Get a token for searching ORCID records. Parameters ---------- :param scope: string /read-public or /read-member Returns ------- :returns: string The token. """ ...
[ "def", "get_search_token_from_orcid", "(", "self", ",", "scope", "=", "'/read-public'", ")", ":", "payload", "=", "{", "'client_id'", ":", "self", ".", "_key", ",", "'client_secret'", ":", "self", ".", "_secret", ",", "'scope'", ":", "scope", ",", "'grant_ty...
Get a token for searching ORCID records. Parameters ---------- :param scope: string /read-public or /read-member Returns ------- :returns: string The token.
[ "Get", "a", "token", "for", "searching", "ORCID", "records", "." ]
train
https://github.com/ORCID/python-orcid/blob/217a56a905f53aef94811e54b4e651a1b09c1f76/orcid/orcid.py#L211-L238
ORCID/python-orcid
orcid/orcid.py
PublicAPI.get_token
def get_token(self, user_id, password, redirect_uri, scope='/read-limited'): """Get the token. Parameters ---------- :param user_id: string The id of the user used for authentication. :param password: string The user password. :p...
python
def get_token(self, user_id, password, redirect_uri, scope='/read-limited'): """Get the token. Parameters ---------- :param user_id: string The id of the user used for authentication. :param password: string The user password. :p...
[ "def", "get_token", "(", "self", ",", "user_id", ",", "password", ",", "redirect_uri", ",", "scope", "=", "'/read-limited'", ")", ":", "response", "=", "self", ".", "_authenticate", "(", "user_id", ",", "password", ",", "redirect_uri", ",", "scope", ")", "...
Get the token. Parameters ---------- :param user_id: string The id of the user used for authentication. :param password: string The user password. :param redirect_uri: string The redirect uri of the institution. :param scope: string ...
[ "Get", "the", "token", "." ]
train
https://github.com/ORCID/python-orcid/blob/217a56a905f53aef94811e54b4e651a1b09c1f76/orcid/orcid.py#L240-L263
ORCID/python-orcid
orcid/orcid.py
PublicAPI.get_token_from_authorization_code
def get_token_from_authorization_code(self, authorization_code, redirect_uri): """Like `get_token`, but using an OAuth 2 authorization code. Use this method if you run a webserver that serves as an endpoint for the redirect URI. The webserver can retrie...
python
def get_token_from_authorization_code(self, authorization_code, redirect_uri): """Like `get_token`, but using an OAuth 2 authorization code. Use this method if you run a webserver that serves as an endpoint for the redirect URI. The webserver can retrie...
[ "def", "get_token_from_authorization_code", "(", "self", ",", "authorization_code", ",", "redirect_uri", ")", ":", "token_dict", "=", "{", "\"client_id\"", ":", "self", ".", "_key", ",", "\"client_secret\"", ":", "self", ".", "_secret", ",", "\"grant_type\"", ":",...
Like `get_token`, but using an OAuth 2 authorization code. Use this method if you run a webserver that serves as an endpoint for the redirect URI. The webserver can retrieve the authorization code from the URL that is requested by ORCID. Parameters ---------- :param red...
[ "Like", "get_token", "but", "using", "an", "OAuth", "2", "authorization", "code", "." ]
train
https://github.com/ORCID/python-orcid/blob/217a56a905f53aef94811e54b4e651a1b09c1f76/orcid/orcid.py#L265-L299
ORCID/python-orcid
orcid/orcid.py
PublicAPI.read_record_public
def read_record_public(self, orcid_id, request_type, token, put_code=None, accept_type='application/orcid+json'): """Get the public info about the researcher. Parameters ---------- :param orcid_id: string Id of the queried author. :param re...
python
def read_record_public(self, orcid_id, request_type, token, put_code=None, accept_type='application/orcid+json'): """Get the public info about the researcher. Parameters ---------- :param orcid_id: string Id of the queried author. :param re...
[ "def", "read_record_public", "(", "self", ",", "orcid_id", ",", "request_type", ",", "token", ",", "put_code", "=", "None", ",", "accept_type", "=", "'application/orcid+json'", ")", ":", "return", "self", ".", "_get_info", "(", "orcid_id", ",", "self", ".", ...
Get the public info about the researcher. Parameters ---------- :param orcid_id: string Id of the queried author. :param request_type: string For example: 'record'. See https://members.orcid.org/api/tutorial/read-orcid-records for possible...
[ "Get", "the", "public", "info", "about", "the", "researcher", "." ]
train
https://github.com/ORCID/python-orcid/blob/217a56a905f53aef94811e54b4e651a1b09c1f76/orcid/orcid.py#L301-L327
ORCID/python-orcid
orcid/orcid.py
MemberAPI.add_record
def add_record(self, orcid_id, token, request_type, data, content_type='application/orcid+json'): """Add a record to a profile. Parameters ---------- :param orcid_id: string Id of the author. :param token: string Token received from OAu...
python
def add_record(self, orcid_id, token, request_type, data, content_type='application/orcid+json'): """Add a record to a profile. Parameters ---------- :param orcid_id: string Id of the author. :param token: string Token received from OAu...
[ "def", "add_record", "(", "self", ",", "orcid_id", ",", "token", ",", "request_type", ",", "data", ",", "content_type", "=", "'application/orcid+json'", ")", ":", "return", "self", ".", "_update_activities", "(", "orcid_id", ",", "token", ",", "requests", ".",...
Add a record to a profile. Parameters ---------- :param orcid_id: string Id of the author. :param token: string Token received from OAuth 2 3-legged authorization. :param request_type: string One of 'activities', 'education', 'employment', 'fu...
[ "Add", "a", "record", "to", "a", "profile", "." ]
train
https://github.com/ORCID/python-orcid/blob/217a56a905f53aef94811e54b4e651a1b09c1f76/orcid/orcid.py#L475-L502
ORCID/python-orcid
orcid/orcid.py
MemberAPI.get_token
def get_token(self, user_id, password, redirect_uri, scope='/activities/update'): """Get the token. Parameters ---------- :param user_id: string The id of the user used for authentication. :param password: string The user password. ...
python
def get_token(self, user_id, password, redirect_uri, scope='/activities/update'): """Get the token. Parameters ---------- :param user_id: string The id of the user used for authentication. :param password: string The user password. ...
[ "def", "get_token", "(", "self", ",", "user_id", ",", "password", ",", "redirect_uri", ",", "scope", "=", "'/activities/update'", ")", ":", "return", "super", "(", "MemberAPI", ",", "self", ")", ".", "get_token", "(", "user_id", ",", "password", ",", "redi...
Get the token. Parameters ---------- :param user_id: string The id of the user used for authentication. :param password: string The user password. :param redirect_uri: string The redirect uri of the institution. :param scope: string ...
[ "Get", "the", "token", "." ]
train
https://github.com/ORCID/python-orcid/blob/217a56a905f53aef94811e54b4e651a1b09c1f76/orcid/orcid.py#L504-L527
ORCID/python-orcid
orcid/orcid.py
MemberAPI.get_user_orcid
def get_user_orcid(self, user_id, password, redirect_uri): """Get the user orcid from authentication process. Parameters ---------- :param user_id: string The id of the user used for authentication. :param password: string The user password. :para...
python
def get_user_orcid(self, user_id, password, redirect_uri): """Get the user orcid from authentication process. Parameters ---------- :param user_id: string The id of the user used for authentication. :param password: string The user password. :para...
[ "def", "get_user_orcid", "(", "self", ",", "user_id", ",", "password", ",", "redirect_uri", ")", ":", "response", "=", "self", ".", "_authenticate", "(", "user_id", ",", "password", ",", "redirect_uri", ",", "'/authenticate'", ")", "return", "response", "[", ...
Get the user orcid from authentication process. Parameters ---------- :param user_id: string The id of the user used for authentication. :param password: string The user password. :param redirect_uri: string The redirect uri of the institution...
[ "Get", "the", "user", "orcid", "from", "authentication", "process", "." ]
train
https://github.com/ORCID/python-orcid/blob/217a56a905f53aef94811e54b4e651a1b09c1f76/orcid/orcid.py#L529-L549
ORCID/python-orcid
orcid/orcid.py
MemberAPI.read_record_member
def read_record_member(self, orcid_id, request_type, token, put_code=None, accept_type='application/orcid+json'): """Get the member info about the researcher. Parameters ---------- :param orcid_id: string Id of the queried author. :param re...
python
def read_record_member(self, orcid_id, request_type, token, put_code=None, accept_type='application/orcid+json'): """Get the member info about the researcher. Parameters ---------- :param orcid_id: string Id of the queried author. :param re...
[ "def", "read_record_member", "(", "self", ",", "orcid_id", ",", "request_type", ",", "token", ",", "put_code", "=", "None", ",", "accept_type", "=", "'application/orcid+json'", ")", ":", "return", "self", ".", "_get_info", "(", "orcid_id", ",", "self", ".", ...
Get the member info about the researcher. Parameters ---------- :param orcid_id: string Id of the queried author. :param request_type: string For example: 'record'. See https://members.orcid.org/api/tutorial/read-orcid-records for possible...
[ "Get", "the", "member", "info", "about", "the", "researcher", "." ]
train
https://github.com/ORCID/python-orcid/blob/217a56a905f53aef94811e54b4e651a1b09c1f76/orcid/orcid.py#L551-L579
ORCID/python-orcid
orcid/orcid.py
MemberAPI.remove_record
def remove_record(self, orcid_id, token, request_type, put_code): """Add a record to a profile. Parameters ---------- :param orcid_id: string Id of the author. :param token: string Token received from OAuth 2 3-legged authorization. :param request...
python
def remove_record(self, orcid_id, token, request_type, put_code): """Add a record to a profile. Parameters ---------- :param orcid_id: string Id of the author. :param token: string Token received from OAuth 2 3-legged authorization. :param request...
[ "def", "remove_record", "(", "self", ",", "orcid_id", ",", "token", ",", "request_type", ",", "put_code", ")", ":", "self", ".", "_update_activities", "(", "orcid_id", ",", "token", ",", "requests", ".", "delete", ",", "request_type", ",", "put_code", "=", ...
Add a record to a profile. Parameters ---------- :param orcid_id: string Id of the author. :param token: string Token received from OAuth 2 3-legged authorization. :param request_type: string One of 'activities', 'education', 'employment', 'fu...
[ "Add", "a", "record", "to", "a", "profile", "." ]
train
https://github.com/ORCID/python-orcid/blob/217a56a905f53aef94811e54b4e651a1b09c1f76/orcid/orcid.py#L581-L598
ORCID/python-orcid
orcid/orcid.py
MemberAPI.update_record
def update_record(self, orcid_id, token, request_type, data, put_code, content_type='application/orcid+json'): """Add a record to a profile. Parameters ---------- :param orcid_id: string Id of the author. :param token: string Token r...
python
def update_record(self, orcid_id, token, request_type, data, put_code, content_type='application/orcid+json'): """Add a record to a profile. Parameters ---------- :param orcid_id: string Id of the author. :param token: string Token r...
[ "def", "update_record", "(", "self", ",", "orcid_id", ",", "token", ",", "request_type", ",", "data", ",", "put_code", ",", "content_type", "=", "'application/orcid+json'", ")", ":", "self", ".", "_update_activities", "(", "orcid_id", ",", "token", ",", "reque...
Add a record to a profile. Parameters ---------- :param orcid_id: string Id of the author. :param token: string Token received from OAuth 2 3-legged authorization. :param request_type: string One of 'activities', 'education', 'employment', 'fu...
[ "Add", "a", "record", "to", "a", "profile", "." ]
train
https://github.com/ORCID/python-orcid/blob/217a56a905f53aef94811e54b4e651a1b09c1f76/orcid/orcid.py#L674-L698
ambitioninc/django-entity
entity/migrations/0006_entity_relationship_unique.py
remove_duplicates
def remove_duplicates(apps, schema_editor): """ Remove any duplicates from the entity relationship table :param apps: :param schema_editor: :return: """ # Get the model EntityRelationship = apps.get_model('entity', 'EntityRelationship') # Find the duplicates duplicates = Entity...
python
def remove_duplicates(apps, schema_editor): """ Remove any duplicates from the entity relationship table :param apps: :param schema_editor: :return: """ # Get the model EntityRelationship = apps.get_model('entity', 'EntityRelationship') # Find the duplicates duplicates = Entity...
[ "def", "remove_duplicates", "(", "apps", ",", "schema_editor", ")", ":", "# Get the model", "EntityRelationship", "=", "apps", ".", "get_model", "(", "'entity'", ",", "'EntityRelationship'", ")", "# Find the duplicates", "duplicates", "=", "EntityRelationship", ".", "...
Remove any duplicates from the entity relationship table :param apps: :param schema_editor: :return:
[ "Remove", "any", "duplicates", "from", "the", "entity", "relationship", "table", ":", "param", "apps", ":", ":", "param", "schema_editor", ":", ":", "return", ":" ]
train
https://github.com/ambitioninc/django-entity/blob/ebc61f34313c52f4ef5819eb1da25b2ad837e80c/entity/migrations/0006_entity_relationship_unique.py#L42-L75
wesleyfr/boxpython
boxpython/auth.py
BoxAuthenticateFlow.get_access_tokens
def get_access_tokens(self, authorization_code): """From the authorization code, get the "access token" and the "refresh token" from Box. Args: authorization_code (str). Authorisation code emitted by Box at the url provided by the function :func:`get_authorization_url`. Returns: ...
python
def get_access_tokens(self, authorization_code): """From the authorization code, get the "access token" and the "refresh token" from Box. Args: authorization_code (str). Authorisation code emitted by Box at the url provided by the function :func:`get_authorization_url`. Returns: ...
[ "def", "get_access_tokens", "(", "self", ",", "authorization_code", ")", ":", "response", "=", "self", ".", "box_request", ".", "get_access_token", "(", "authorization_code", ")", "try", ":", "att", "=", "response", ".", "json", "(", ")", "except", "Exception"...
From the authorization code, get the "access token" and the "refresh token" from Box. Args: authorization_code (str). Authorisation code emitted by Box at the url provided by the function :func:`get_authorization_url`. Returns: tuple. (access_token, refresh_token) Rais...
[ "From", "the", "authorization", "code", "get", "the", "access", "token", "and", "the", "refresh", "token", "from", "Box", "." ]
train
https://github.com/wesleyfr/boxpython/blob/f00a8ada6dff2c7ffc88bf89d4e15965c5adb422/boxpython/auth.py#L39-L64
oisinmulvihill/stomper
lib/stomper/stomp_10.py
unpack_frame
def unpack_frame(message): """Called to unpack a STOMP message into a dictionary. returned = { # STOMP Command: 'cmd' : '...', # Headers e.g. 'headers' : { 'destination' : 'xyz', 'message-id' : 'some event', : etc, } ...
python
def unpack_frame(message): """Called to unpack a STOMP message into a dictionary. returned = { # STOMP Command: 'cmd' : '...', # Headers e.g. 'headers' : { 'destination' : 'xyz', 'message-id' : 'some event', : etc, } ...
[ "def", "unpack_frame", "(", "message", ")", ":", "body", "=", "[", "]", "returned", "=", "dict", "(", "cmd", "=", "''", ",", "headers", "=", "{", "}", ",", "body", "=", "''", ")", "breakdown", "=", "message", ".", "split", "(", "'\\n'", ")", "# G...
Called to unpack a STOMP message into a dictionary. returned = { # STOMP Command: 'cmd' : '...', # Headers e.g. 'headers' : { 'destination' : 'xyz', 'message-id' : 'some event', : etc, } # Body: 'body' : '...1...
[ "Called", "to", "unpack", "a", "STOMP", "message", "into", "a", "dictionary", "." ]
train
https://github.com/oisinmulvihill/stomper/blob/842ed2353a4ddd638d35929ae5b7b70eb298305c/lib/stomper/stomp_10.py#L174-L236
oisinmulvihill/stomper
lib/stomper/stomp_10.py
ack
def ack(messageid, transactionid=None): """STOMP acknowledge command. Acknowledge receipt of a specific message from the server. messageid: This is the id of the message we are acknowledging, what else could it be? ;) transactionid: This is the id that all actions in this tran...
python
def ack(messageid, transactionid=None): """STOMP acknowledge command. Acknowledge receipt of a specific message from the server. messageid: This is the id of the message we are acknowledging, what else could it be? ;) transactionid: This is the id that all actions in this tran...
[ "def", "ack", "(", "messageid", ",", "transactionid", "=", "None", ")", ":", "header", "=", "'message-id: %s'", "%", "messageid", "if", "transactionid", ":", "header", "=", "'message-id: %s\\ntransaction: %s'", "%", "(", "messageid", ",", "transactionid", ")", "...
STOMP acknowledge command. Acknowledge receipt of a specific message from the server. messageid: This is the id of the message we are acknowledging, what else could it be? ;) transactionid: This is the id that all actions in this transaction will have. If this is not given...
[ "STOMP", "acknowledge", "command", "." ]
train
https://github.com/oisinmulvihill/stomper/blob/842ed2353a4ddd638d35929ae5b7b70eb298305c/lib/stomper/stomp_10.py#L251-L271
oisinmulvihill/stomper
lib/stomper/stomp_10.py
send
def send(dest, msg, transactionid=None): """STOMP send command. dest: This is the channel we wish to subscribe to msg: This is the message body to be sent. transactionid: This is an optional field and is not needed by default. """ transheader = '' if tran...
python
def send(dest, msg, transactionid=None): """STOMP send command. dest: This is the channel we wish to subscribe to msg: This is the message body to be sent. transactionid: This is an optional field and is not needed by default. """ transheader = '' if tran...
[ "def", "send", "(", "dest", ",", "msg", ",", "transactionid", "=", "None", ")", ":", "transheader", "=", "''", "if", "transactionid", ":", "transheader", "=", "'transaction: %s\\n'", "%", "transactionid", "return", "\"SEND\\ndestination: %s\\n%s\\n%s\\x00\\n\"", "%"...
STOMP send command. dest: This is the channel we wish to subscribe to msg: This is the message body to be sent. transactionid: This is an optional field and is not needed by default.
[ "STOMP", "send", "command", "." ]
train
https://github.com/oisinmulvihill/stomper/blob/842ed2353a4ddd638d35929ae5b7b70eb298305c/lib/stomper/stomp_10.py#L329-L348
oisinmulvihill/stomper
lib/stomper/stomp_10.py
Frame.setCmd
def setCmd(self, cmd): """Check the cmd is valid, FrameError will be raised if its not.""" cmd = cmd.upper() if cmd not in VALID_COMMANDS: raise FrameError("The cmd '%s' is not valid! It must be one of '%s' (STOMP v%s)." % ( cmd, VALID_COMMANDS, STOMP_VERSION) ...
python
def setCmd(self, cmd): """Check the cmd is valid, FrameError will be raised if its not.""" cmd = cmd.upper() if cmd not in VALID_COMMANDS: raise FrameError("The cmd '%s' is not valid! It must be one of '%s' (STOMP v%s)." % ( cmd, VALID_COMMANDS, STOMP_VERSION) ...
[ "def", "setCmd", "(", "self", ",", "cmd", ")", ":", "cmd", "=", "cmd", ".", "upper", "(", ")", "if", "cmd", "not", "in", "VALID_COMMANDS", ":", "raise", "FrameError", "(", "\"The cmd '%s' is not valid! It must be one of '%s' (STOMP v%s).\"", "%", "(", "cmd", "...
Check the cmd is valid, FrameError will be raised if its not.
[ "Check", "the", "cmd", "is", "valid", "FrameError", "will", "be", "raised", "if", "its", "not", "." ]
train
https://github.com/oisinmulvihill/stomper/blob/842ed2353a4ddd638d35929ae5b7b70eb298305c/lib/stomper/stomp_10.py#L119-L127
oisinmulvihill/stomper
lib/stomper/stomp_10.py
Frame.pack
def pack(self): """Called to create a STOMP message from the internal values. """ headers = ''.join( ['%s:%s\n' % (f, v) for f, v in sorted(self.headers.items())] ) stomp_message = "%s\n%s\n%s%s\n" % (self._cmd, headers, self.body, NULL) # import pprint # ...
python
def pack(self): """Called to create a STOMP message from the internal values. """ headers = ''.join( ['%s:%s\n' % (f, v) for f, v in sorted(self.headers.items())] ) stomp_message = "%s\n%s\n%s%s\n" % (self._cmd, headers, self.body, NULL) # import pprint # ...
[ "def", "pack", "(", "self", ")", ":", "headers", "=", "''", ".", "join", "(", "[", "'%s:%s\\n'", "%", "(", "f", ",", "v", ")", "for", "f", ",", "v", "in", "sorted", "(", "self", ".", "headers", ".", "items", "(", ")", ")", "]", ")", "stomp_me...
Called to create a STOMP message from the internal values.
[ "Called", "to", "create", "a", "STOMP", "message", "from", "the", "internal", "values", "." ]
train
https://github.com/oisinmulvihill/stomper/blob/842ed2353a4ddd638d35929ae5b7b70eb298305c/lib/stomper/stomp_10.py#L131-L142
oisinmulvihill/stomper
lib/stomper/stomp_10.py
Frame.unpack
def unpack(self, message): """Called to extract a STOMP message into this instance. message: This is a text string representing a valid STOMP (v1.0) message. This method uses unpack_frame(...) to extract the information, before it is assigned internally. ...
python
def unpack(self, message): """Called to extract a STOMP message into this instance. message: This is a text string representing a valid STOMP (v1.0) message. This method uses unpack_frame(...) to extract the information, before it is assigned internally. ...
[ "def", "unpack", "(", "self", ",", "message", ")", ":", "if", "not", "message", ":", "raise", "FrameError", "(", "\"Unpack error! The given message isn't valid '%s'!\"", "%", "message", ")", "msg", "=", "unpack_frame", "(", "message", ")", "self", ".", "cmd", ...
Called to extract a STOMP message into this instance. message: This is a text string representing a valid STOMP (v1.0) message. This method uses unpack_frame(...) to extract the information, before it is assigned internally. retuned: The result of t...
[ "Called", "to", "extract", "a", "STOMP", "message", "into", "this", "instance", "." ]
train
https://github.com/oisinmulvihill/stomper/blob/842ed2353a4ddd638d35929ae5b7b70eb298305c/lib/stomper/stomp_10.py#L145-L171
oisinmulvihill/stomper
lib/stomper/stomp_10.py
Engine.react
def react(self, msg): """Called to provide a response to a message if needed. msg: This is a dictionary as returned by unpack_frame(...) or it can be a straight STOMP message. This function will attempt to determine which an deal with it. returned: ...
python
def react(self, msg): """Called to provide a response to a message if needed. msg: This is a dictionary as returned by unpack_frame(...) or it can be a straight STOMP message. This function will attempt to determine which an deal with it. returned: ...
[ "def", "react", "(", "self", ",", "msg", ")", ":", "returned", "=", "\"\"", "# If its not a string assume its a dict.", "mtype", "=", "type", "(", "msg", ")", "if", "mtype", "in", "stringTypes", ":", "msg", "=", "unpack_frame", "(", "msg", ")", "elif", "mt...
Called to provide a response to a message if needed. msg: This is a dictionary as returned by unpack_frame(...) or it can be a straight STOMP message. This function will attempt to determine which an deal with it. returned: A message to return or an empt...
[ "Called", "to", "provide", "a", "response", "to", "a", "message", "if", "needed", "." ]
train
https://github.com/oisinmulvihill/stomper/blob/842ed2353a4ddd638d35929ae5b7b70eb298305c/lib/stomper/stomp_10.py#L403-L430
oisinmulvihill/stomper
lib/stomper/stomp_10.py
Engine.error
def error(self, msg): """Called to handle an error message received from the server. This method just logs the error message returned: NO_RESPONSE_NEEDED """ body = msg['body'].replace(NULL, '') brief_msg = "" if 'message' in msg['headers']: ...
python
def error(self, msg): """Called to handle an error message received from the server. This method just logs the error message returned: NO_RESPONSE_NEEDED """ body = msg['body'].replace(NULL, '') brief_msg = "" if 'message' in msg['headers']: ...
[ "def", "error", "(", "self", ",", "msg", ")", ":", "body", "=", "msg", "[", "'body'", "]", ".", "replace", "(", "NULL", ",", "''", ")", "brief_msg", "=", "\"\"", "if", "'message'", "in", "msg", "[", "'headers'", "]", ":", "brief_msg", "=", "msg", ...
Called to handle an error message received from the server. This method just logs the error message returned: NO_RESPONSE_NEEDED
[ "Called", "to", "handle", "an", "error", "message", "received", "from", "the", "server", "." ]
train
https://github.com/oisinmulvihill/stomper/blob/842ed2353a4ddd638d35929ae5b7b70eb298305c/lib/stomper/stomp_10.py#L469-L490
oisinmulvihill/stomper
lib/stomper/stomp_10.py
Engine.receipt
def receipt(self, msg): """Called to handle a receipt message received from the server. This method just logs the receipt message returned: NO_RESPONSE_NEEDED """ body = msg['body'].replace(NULL, '') brief_msg = "" if 'receipt-id' in msg['headers']...
python
def receipt(self, msg): """Called to handle a receipt message received from the server. This method just logs the receipt message returned: NO_RESPONSE_NEEDED """ body = msg['body'].replace(NULL, '') brief_msg = "" if 'receipt-id' in msg['headers']...
[ "def", "receipt", "(", "self", ",", "msg", ")", ":", "body", "=", "msg", "[", "'body'", "]", ".", "replace", "(", "NULL", ",", "''", ")", "brief_msg", "=", "\"\"", "if", "'receipt-id'", "in", "msg", "[", "'headers'", "]", ":", "brief_msg", "=", "ms...
Called to handle a receipt message received from the server. This method just logs the receipt message returned: NO_RESPONSE_NEEDED
[ "Called", "to", "handle", "a", "receipt", "message", "received", "from", "the", "server", "." ]
train
https://github.com/oisinmulvihill/stomper/blob/842ed2353a4ddd638d35929ae5b7b70eb298305c/lib/stomper/stomp_10.py#L493-L514
oisinmulvihill/stomper
lib/stomper/utils.py
log_init
def log_init(level): """Set up a logger that catches all channels and logs it to stdout. This is used to set up logging when testing. """ log = logging.getLogger() hdlr = logging.StreamHandler() formatter = logging.Formatter('%(asctime)s %(name)s %(levelname)s %(message)s') hdlr.se...
python
def log_init(level): """Set up a logger that catches all channels and logs it to stdout. This is used to set up logging when testing. """ log = logging.getLogger() hdlr = logging.StreamHandler() formatter = logging.Formatter('%(asctime)s %(name)s %(levelname)s %(message)s') hdlr.se...
[ "def", "log_init", "(", "level", ")", ":", "log", "=", "logging", ".", "getLogger", "(", ")", "hdlr", "=", "logging", ".", "StreamHandler", "(", ")", "formatter", "=", "logging", ".", "Formatter", "(", "'%(asctime)s %(name)s %(levelname)s %(message)s'", ")", "...
Set up a logger that catches all channels and logs it to stdout. This is used to set up logging when testing.
[ "Set", "up", "a", "logger", "that", "catches", "all", "channels", "and", "logs", "it", "to", "stdout", ".", "This", "is", "used", "to", "set", "up", "logging", "when", "testing", "." ]
train
https://github.com/oisinmulvihill/stomper/blob/842ed2353a4ddd638d35929ae5b7b70eb298305c/lib/stomper/utils.py#L11-L22
oisinmulvihill/stomper
lib/stomper/examples/stomper_usage.py
Pong.ack
def ack(self, msg): """Override this and do some customer message handler. """ print("Got a message:\n%s\n" % msg['body']) # do something with the message... # Generate the ack or not if you subscribed with ack='auto' return super(Pong, self).ack(msg)
python
def ack(self, msg): """Override this and do some customer message handler. """ print("Got a message:\n%s\n" % msg['body']) # do something with the message... # Generate the ack or not if you subscribed with ack='auto' return super(Pong, self).ack(msg)
[ "def", "ack", "(", "self", ",", "msg", ")", ":", "print", "(", "\"Got a message:\\n%s\\n\"", "%", "msg", "[", "'body'", "]", ")", "# do something with the message...", "# Generate the ack or not if you subscribed with ack='auto'", "return", "super", "(", "Pong", ",", ...
Override this and do some customer message handler.
[ "Override", "this", "and", "do", "some", "customer", "message", "handler", "." ]
train
https://github.com/oisinmulvihill/stomper/blob/842ed2353a4ddd638d35929ae5b7b70eb298305c/lib/stomper/examples/stomper_usage.py#L87-L95
ambitioninc/django-entity
entity/sync.py
transaction_atomic_with_retry
def transaction_atomic_with_retry(num_retries=5, backoff=0.1): """ This is a decorator that will wrap the decorated method in an atomic transaction and retry the transaction a given number of times :param num_retries: How many times should we retry before we give up :param backoff: How long should ...
python
def transaction_atomic_with_retry(num_retries=5, backoff=0.1): """ This is a decorator that will wrap the decorated method in an atomic transaction and retry the transaction a given number of times :param num_retries: How many times should we retry before we give up :param backoff: How long should ...
[ "def", "transaction_atomic_with_retry", "(", "num_retries", "=", "5", ",", "backoff", "=", "0.1", ")", ":", "# Create the decorator", "@", "wrapt", ".", "decorator", "def", "wrapper", "(", "wrapped", ",", "instance", ",", "args", ",", "kwargs", ")", ":", "# ...
This is a decorator that will wrap the decorated method in an atomic transaction and retry the transaction a given number of times :param num_retries: How many times should we retry before we give up :param backoff: How long should we wait after each try
[ "This", "is", "a", "decorator", "that", "will", "wrap", "the", "decorated", "method", "in", "an", "atomic", "transaction", "and", "retry", "the", "transaction", "a", "given", "number", "of", "times" ]
train
https://github.com/ambitioninc/django-entity/blob/ebc61f34313c52f4ef5819eb1da25b2ad837e80c/entity/sync.py#L23-L55
ambitioninc/django-entity
entity/sync.py
defer_entity_syncing
def defer_entity_syncing(wrapped, instance, args, kwargs): """ A decorator that can be used to defer the syncing of entities until after the method has been run This is being introduced to help avoid deadlocks in the meantime as we attempt to better understand why they are happening """ # Defer...
python
def defer_entity_syncing(wrapped, instance, args, kwargs): """ A decorator that can be used to defer the syncing of entities until after the method has been run This is being introduced to help avoid deadlocks in the meantime as we attempt to better understand why they are happening """ # Defer...
[ "def", "defer_entity_syncing", "(", "wrapped", ",", "instance", ",", "args", ",", "kwargs", ")", ":", "# Defer entity syncing while we run our method", "sync_entities", ".", "defer", "=", "True", "# Run the method", "try", ":", "return", "wrapped", "(", "*", "args",...
A decorator that can be used to defer the syncing of entities until after the method has been run This is being introduced to help avoid deadlocks in the meantime as we attempt to better understand why they are happening
[ "A", "decorator", "that", "can", "be", "used", "to", "defer", "the", "syncing", "of", "entities", "until", "after", "the", "method", "has", "been", "run", "This", "is", "being", "introduced", "to", "help", "avoid", "deadlocks", "in", "the", "meantime", "as...
train
https://github.com/ambitioninc/django-entity/blob/ebc61f34313c52f4ef5819eb1da25b2ad837e80c/entity/sync.py#L59-L91
ambitioninc/django-entity
entity/sync.py
_get_super_entities_by_ctype
def _get_super_entities_by_ctype(model_objs_by_ctype, model_ids_to_sync, sync_all): """ Given model objects organized by content type and a dictionary of all model IDs that need to be synced, organize all super entity relationships that need to be synced. Ensure that the model_ids_to_sync dict is updat...
python
def _get_super_entities_by_ctype(model_objs_by_ctype, model_ids_to_sync, sync_all): """ Given model objects organized by content type and a dictionary of all model IDs that need to be synced, organize all super entity relationships that need to be synced. Ensure that the model_ids_to_sync dict is updat...
[ "def", "_get_super_entities_by_ctype", "(", "model_objs_by_ctype", ",", "model_ids_to_sync", ",", "sync_all", ")", ":", "super_entities_by_ctype", "=", "defaultdict", "(", "lambda", ":", "defaultdict", "(", "list", ")", ")", "# pragma: no cover", "for", "ctype", ",", ...
Given model objects organized by content type and a dictionary of all model IDs that need to be synced, organize all super entity relationships that need to be synced. Ensure that the model_ids_to_sync dict is updated with any new super entities that need to be part of the overall entity sync
[ "Given", "model", "objects", "organized", "by", "content", "type", "and", "a", "dictionary", "of", "all", "model", "IDs", "that", "need", "to", "be", "synced", "organize", "all", "super", "entity", "relationships", "that", "need", "to", "be", "synced", "." ]
train
https://github.com/ambitioninc/django-entity/blob/ebc61f34313c52f4ef5819eb1da25b2ad837e80c/entity/sync.py#L94-L117
ambitioninc/django-entity
entity/sync.py
_get_model_objs_to_sync
def _get_model_objs_to_sync(model_ids_to_sync, model_objs_map, sync_all): """ Given the model IDs to sync, fetch all model objects to sync """ model_objs_to_sync = {} for ctype, model_ids_to_sync_for_ctype in model_ids_to_sync.items(): model_qset = entity_registry.entity_registry.get(ctype.m...
python
def _get_model_objs_to_sync(model_ids_to_sync, model_objs_map, sync_all): """ Given the model IDs to sync, fetch all model objects to sync """ model_objs_to_sync = {} for ctype, model_ids_to_sync_for_ctype in model_ids_to_sync.items(): model_qset = entity_registry.entity_registry.get(ctype.m...
[ "def", "_get_model_objs_to_sync", "(", "model_ids_to_sync", ",", "model_objs_map", ",", "sync_all", ")", ":", "model_objs_to_sync", "=", "{", "}", "for", "ctype", ",", "model_ids_to_sync_for_ctype", "in", "model_ids_to_sync", ".", "items", "(", ")", ":", "model_qset...
Given the model IDs to sync, fetch all model objects to sync
[ "Given", "the", "model", "IDs", "to", "sync", "fetch", "all", "model", "objects", "to", "sync" ]
train
https://github.com/ambitioninc/django-entity/blob/ebc61f34313c52f4ef5819eb1da25b2ad837e80c/entity/sync.py#L120-L135
ambitioninc/django-entity
entity/sync.py
sync_entities
def sync_entities(*model_objs): """ Syncs entities Args: model_objs (List[Model]): The model objects to sync. If empty, all entities will be synced """ # Check if we are deferring processing if sync_entities.defer: # If we dont have any model objects passed add a none to let us...
python
def sync_entities(*model_objs): """ Syncs entities Args: model_objs (List[Model]): The model objects to sync. If empty, all entities will be synced """ # Check if we are deferring processing if sync_entities.defer: # If we dont have any model objects passed add a none to let us...
[ "def", "sync_entities", "(", "*", "model_objs", ")", ":", "# Check if we are deferring processing", "if", "sync_entities", ".", "defer", ":", "# If we dont have any model objects passed add a none to let us know that we need to sync all", "if", "not", "model_objs", ":", "sync_ent...
Syncs entities Args: model_objs (List[Model]): The model objects to sync. If empty, all entities will be synced
[ "Syncs", "entities" ]
train
https://github.com/ambitioninc/django-entity/blob/ebc61f34313c52f4ef5819eb1da25b2ad837e80c/entity/sync.py#L138-L160
ambitioninc/django-entity
entity/sync.py
sync_entities_watching
def sync_entities_watching(instance): """ Syncs entities watching changes of a model instance. """ for entity_model, entity_model_getter in entity_registry.entity_watching[instance.__class__]: model_objs = list(entity_model_getter(instance)) if model_objs: sync_entities(*mode...
python
def sync_entities_watching(instance): """ Syncs entities watching changes of a model instance. """ for entity_model, entity_model_getter in entity_registry.entity_watching[instance.__class__]: model_objs = list(entity_model_getter(instance)) if model_objs: sync_entities(*mode...
[ "def", "sync_entities_watching", "(", "instance", ")", ":", "for", "entity_model", ",", "entity_model_getter", "in", "entity_registry", ".", "entity_watching", "[", "instance", ".", "__class__", "]", ":", "model_objs", "=", "list", "(", "entity_model_getter", "(", ...
Syncs entities watching changes of a model instance.
[ "Syncs", "entities", "watching", "changes", "of", "a", "model", "instance", "." ]
train
https://github.com/ambitioninc/django-entity/blob/ebc61f34313c52f4ef5819eb1da25b2ad837e80c/entity/sync.py#L169-L176
ambitioninc/django-entity
entity/sync.py
EntitySyncer.upsert_entity_kinds
def upsert_entity_kinds(self, entity_kinds): """ Given a list of entity kinds ensure they are synced properly to the database. This will ensure that only unchanged entity kinds are synced and will still return all updated entity kinds :param entity_kinds: The list of entity kind...
python
def upsert_entity_kinds(self, entity_kinds): """ Given a list of entity kinds ensure they are synced properly to the database. This will ensure that only unchanged entity kinds are synced and will still return all updated entity kinds :param entity_kinds: The list of entity kind...
[ "def", "upsert_entity_kinds", "(", "self", ",", "entity_kinds", ")", ":", "# Filter out unchanged entity kinds", "unchanged_entity_kinds", "=", "{", "}", "if", "entity_kinds", ":", "unchanged_entity_kinds", "=", "{", "(", "entity_kind", ".", "name", ",", "entity_kind"...
Given a list of entity kinds ensure they are synced properly to the database. This will ensure that only unchanged entity kinds are synced and will still return all updated entity kinds :param entity_kinds: The list of entity kinds to sync
[ "Given", "a", "list", "of", "entity", "kinds", "ensure", "they", "are", "synced", "properly", "to", "the", "database", ".", "This", "will", "ensure", "that", "only", "unchanged", "entity", "kinds", "are", "synced", "and", "will", "still", "return", "all", ...
train
https://github.com/ambitioninc/django-entity/blob/ebc61f34313c52f4ef5819eb1da25b2ad837e80c/entity/sync.py#L323-L373
ambitioninc/django-entity
entity/sync.py
EntitySyncer.upsert_entities
def upsert_entities(self, entities, sync=False): """ Upsert a list of entities to the database :param entities: The entities to sync :param sync: Do a sync instead of an upsert """ # Select the entities we are upserting for update to reduce deadlocks if entities:...
python
def upsert_entities(self, entities, sync=False): """ Upsert a list of entities to the database :param entities: The entities to sync :param sync: Do a sync instead of an upsert """ # Select the entities we are upserting for update to reduce deadlocks if entities:...
[ "def", "upsert_entities", "(", "self", ",", "entities", ",", "sync", "=", "False", ")", ":", "# Select the entities we are upserting for update to reduce deadlocks", "if", "entities", ":", "# Default select for update query when syncing all", "select_for_update_query", "=", "("...
Upsert a list of entities to the database :param entities: The entities to sync :param sync: Do a sync instead of an upsert
[ "Upsert", "a", "list", "of", "entities", "to", "the", "database", ":", "param", "entities", ":", "The", "entities", "to", "sync", ":", "param", "sync", ":", "Do", "a", "sync", "instead", "of", "an", "upsert" ]
train
https://github.com/ambitioninc/django-entity/blob/ebc61f34313c52f4ef5819eb1da25b2ad837e80c/entity/sync.py#L376-L435
ambitioninc/django-entity
entity/sync.py
EntitySyncer.upsert_entity_relationships
def upsert_entity_relationships(self, queryset, entity_relationships): """ Upsert entity relationships to the database :param queryset: The base queryset to use :param entity_relationships: The entity relationships to ensure exist in the database """ # Select the relatio...
python
def upsert_entity_relationships(self, queryset, entity_relationships): """ Upsert entity relationships to the database :param queryset: The base queryset to use :param entity_relationships: The entity relationships to ensure exist in the database """ # Select the relatio...
[ "def", "upsert_entity_relationships", "(", "self", ",", "queryset", ",", "entity_relationships", ")", ":", "# Select the relationships for update", "if", "entity_relationships", ":", "list", "(", "queryset", ".", "select_for_update", "(", ")", ".", "values_list", "(", ...
Upsert entity relationships to the database :param queryset: The base queryset to use :param entity_relationships: The entity relationships to ensure exist in the database
[ "Upsert", "entity", "relationships", "to", "the", "database", ":", "param", "queryset", ":", "The", "base", "queryset", "to", "use", ":", "param", "entity_relationships", ":", "The", "entity", "relationships", "to", "ensure", "exist", "in", "the", "database" ]
train
https://github.com/ambitioninc/django-entity/blob/ebc61f34313c52f4ef5819eb1da25b2ad837e80c/entity/sync.py#L438-L459
ambitioninc/django-entity
entity/config.py
EntityConfig.get_entity_kind
def get_entity_kind(self, model_obj): """ Returns a tuple for a kind name and kind display name of an entity. By default, uses the app_label and model of the model object's content type as the kind. """ model_obj_ctype = ContentType.objects.get_for_model(self.queryset.mod...
python
def get_entity_kind(self, model_obj): """ Returns a tuple for a kind name and kind display name of an entity. By default, uses the app_label and model of the model object's content type as the kind. """ model_obj_ctype = ContentType.objects.get_for_model(self.queryset.mod...
[ "def", "get_entity_kind", "(", "self", ",", "model_obj", ")", ":", "model_obj_ctype", "=", "ContentType", ".", "objects", ".", "get_for_model", "(", "self", ".", "queryset", ".", "model", ")", "return", "(", "u'{0}.{1}'", ".", "format", "(", "model_obj_ctype",...
Returns a tuple for a kind name and kind display name of an entity. By default, uses the app_label and model of the model object's content type as the kind.
[ "Returns", "a", "tuple", "for", "a", "kind", "name", "and", "kind", "display", "name", "of", "an", "entity", ".", "By", "default", "uses", "the", "app_label", "and", "model", "of", "the", "model", "object", "s", "content", "type", "as", "the", "kind", ...
train
https://github.com/ambitioninc/django-entity/blob/ebc61f34313c52f4ef5819eb1da25b2ad837e80c/entity/config.py#L36-L43
ambitioninc/django-entity
entity/config.py
EntityRegistry.register_entity
def register_entity(self, entity_config): """ Registers an entity config """ if not issubclass(entity_config, EntityConfig): raise ValueError('Must register entity config class of subclass EntityConfig') if entity_config.queryset is None: raise ValueError...
python
def register_entity(self, entity_config): """ Registers an entity config """ if not issubclass(entity_config, EntityConfig): raise ValueError('Must register entity config class of subclass EntityConfig') if entity_config.queryset is None: raise ValueError...
[ "def", "register_entity", "(", "self", ",", "entity_config", ")", ":", "if", "not", "issubclass", "(", "entity_config", ",", "EntityConfig", ")", ":", "raise", "ValueError", "(", "'Must register entity config class of subclass EntityConfig'", ")", "if", "entity_config",...
Registers an entity config
[ "Registers", "an", "entity", "config" ]
train
https://github.com/ambitioninc/django-entity/blob/ebc61f34313c52f4ef5819eb1da25b2ad837e80c/entity/config.py#L96-L112
oisinmulvihill/stomper
lib/stomper/examples/stompbuffer-tx.py
start
def start(host='localhost', port=61613, username='', password=''): """Start twisted event loop and the fun should begin... """ StompClientFactory.username = username StompClientFactory.password = password reactor.connectTCP(host, port, StompClientFactory()) reactor.run()
python
def start(host='localhost', port=61613, username='', password=''): """Start twisted event loop and the fun should begin... """ StompClientFactory.username = username StompClientFactory.password = password reactor.connectTCP(host, port, StompClientFactory()) reactor.run()
[ "def", "start", "(", "host", "=", "'localhost'", ",", "port", "=", "61613", ",", "username", "=", "''", ",", "password", "=", "''", ")", ":", "StompClientFactory", ".", "username", "=", "username", "StompClientFactory", ".", "password", "=", "password", "r...
Start twisted event loop and the fun should begin...
[ "Start", "twisted", "event", "loop", "and", "the", "fun", "should", "begin", "..." ]
train
https://github.com/oisinmulvihill/stomper/blob/842ed2353a4ddd638d35929ae5b7b70eb298305c/lib/stomper/examples/stompbuffer-tx.py#L131-L137
oisinmulvihill/stomper
lib/stomper/examples/stompbuffer-tx.py
StompProtocol.connected
def connected(self, msg): """Once I've connected I want to subscribe to my the message queue. """ stomper.Engine.connected(self, msg) self.log.info("Connected: session %s. Beginning say hello." % msg['headers']['session']) def setup_looping_call(): lc = Loop...
python
def connected(self, msg): """Once I've connected I want to subscribe to my the message queue. """ stomper.Engine.connected(self, msg) self.log.info("Connected: session %s. Beginning say hello." % msg['headers']['session']) def setup_looping_call(): lc = Loop...
[ "def", "connected", "(", "self", ",", "msg", ")", ":", "stomper", ".", "Engine", ".", "connected", "(", "self", ",", "msg", ")", "self", ".", "log", ".", "info", "(", "\"Connected: session %s. Beginning say hello.\"", "%", "msg", "[", "'headers'", "]", "["...
Once I've connected I want to subscribe to my the message queue.
[ "Once", "I", "ve", "connected", "I", "want", "to", "subscribe", "to", "my", "the", "message", "queue", "." ]
train
https://github.com/oisinmulvihill/stomper/blob/842ed2353a4ddd638d35929ae5b7b70eb298305c/lib/stomper/examples/stompbuffer-tx.py#L35-L56
oisinmulvihill/stomper
lib/stomper/examples/stompbuffer-tx.py
StompProtocol.send
def send(self): """Send out a hello message periodically. """ self.log.info("Saying hello (%d)." % self.counter) f = stomper.Frame() f.unpack(stomper.send(DESTINATION, 'hello there (%d)' % self.counter)) self.counter += 1 # ActiveMQ specific headers: ...
python
def send(self): """Send out a hello message periodically. """ self.log.info("Saying hello (%d)." % self.counter) f = stomper.Frame() f.unpack(stomper.send(DESTINATION, 'hello there (%d)' % self.counter)) self.counter += 1 # ActiveMQ specific headers: ...
[ "def", "send", "(", "self", ")", ":", "self", ".", "log", ".", "info", "(", "\"Saying hello (%d).\"", "%", "self", ".", "counter", ")", "f", "=", "stomper", ".", "Frame", "(", ")", "f", ".", "unpack", "(", "stomper", ".", "send", "(", "DESTINATION", ...
Send out a hello message periodically.
[ "Send", "out", "a", "hello", "message", "periodically", "." ]
train
https://github.com/oisinmulvihill/stomper/blob/842ed2353a4ddd638d35929ae5b7b70eb298305c/lib/stomper/examples/stompbuffer-tx.py#L68-L82
oisinmulvihill/stomper
lib/stomper/examples/stompbuffer-tx.py
StompProtocol.connectionMade
def connectionMade(self): """Register with stomp server. """ cmd = stomper.connect(self.username, self.password) self.transport.write(cmd)
python
def connectionMade(self): """Register with stomp server. """ cmd = stomper.connect(self.username, self.password) self.transport.write(cmd)
[ "def", "connectionMade", "(", "self", ")", ":", "cmd", "=", "stomper", ".", "connect", "(", "self", ".", "username", ",", "self", ".", "password", ")", "self", ".", "transport", ".", "write", "(", "cmd", ")" ]
Register with stomp server.
[ "Register", "with", "stomp", "server", "." ]
train
https://github.com/oisinmulvihill/stomper/blob/842ed2353a4ddd638d35929ae5b7b70eb298305c/lib/stomper/examples/stompbuffer-tx.py#L85-L89
oisinmulvihill/stomper
lib/stomper/examples/stompbuffer-tx.py
StompProtocol.dataReceived
def dataReceived(self, data): """Use stompbuffer to determine when a complete message has been received. """ self.stompBuffer.appendData(data) while True: msg = self.stompBuffer.getOneMessage() if msg is None: break returned = self.react...
python
def dataReceived(self, data): """Use stompbuffer to determine when a complete message has been received. """ self.stompBuffer.appendData(data) while True: msg = self.stompBuffer.getOneMessage() if msg is None: break returned = self.react...
[ "def", "dataReceived", "(", "self", ",", "data", ")", ":", "self", ".", "stompBuffer", ".", "appendData", "(", "data", ")", "while", "True", ":", "msg", "=", "self", ".", "stompBuffer", ".", "getOneMessage", "(", ")", "if", "msg", "is", "None", ":", ...
Use stompbuffer to determine when a complete message has been received.
[ "Use", "stompbuffer", "to", "determine", "when", "a", "complete", "message", "has", "been", "received", "." ]
train
https://github.com/oisinmulvihill/stomper/blob/842ed2353a4ddd638d35929ae5b7b70eb298305c/lib/stomper/examples/stompbuffer-tx.py#L92-L104
oisinmulvihill/stomper
lib/stomper/examples/stompbuffer-tx.py
StompClientFactory.clientConnectionFailed
def clientConnectionFailed(self, connector, reason): """Connection failed """ print('Connection failed. Reason:', reason) ReconnectingClientFactory.clientConnectionFailed(self, connector, reason)
python
def clientConnectionFailed(self, connector, reason): """Connection failed """ print('Connection failed. Reason:', reason) ReconnectingClientFactory.clientConnectionFailed(self, connector, reason)
[ "def", "clientConnectionFailed", "(", "self", ",", "connector", ",", "reason", ")", ":", "print", "(", "'Connection failed. Reason:'", ",", "reason", ")", "ReconnectingClientFactory", ".", "clientConnectionFailed", "(", "self", ",", "connector", ",", "reason", ")" ]
Connection failed
[ "Connection", "failed" ]
train
https://github.com/oisinmulvihill/stomper/blob/842ed2353a4ddd638d35929ae5b7b70eb298305c/lib/stomper/examples/stompbuffer-tx.py#L124-L128
oisinmulvihill/stomper
lib/stomper/examples/receiver.py
MyStomp.ack
def ack(self, msg): """Process the message and determine what to do with it. """ self.log.info("receiverId <%s> Received: <%s> " % (self.receiverId, msg['body'])) #return super(MyStomp, self).ack(msg) return stomper.NO_REPONSE_NEEDED
python
def ack(self, msg): """Process the message and determine what to do with it. """ self.log.info("receiverId <%s> Received: <%s> " % (self.receiverId, msg['body'])) #return super(MyStomp, self).ack(msg) return stomper.NO_REPONSE_NEEDED
[ "def", "ack", "(", "self", ",", "msg", ")", ":", "self", ".", "log", ".", "info", "(", "\"receiverId <%s> Received: <%s> \"", "%", "(", "self", ".", "receiverId", ",", "msg", "[", "'body'", "]", ")", ")", "#return super(MyStomp, self).ack(msg) ", "return", "...
Process the message and determine what to do with it.
[ "Process", "the", "message", "and", "determine", "what", "to", "do", "with", "it", "." ]
train
https://github.com/oisinmulvihill/stomper/blob/842ed2353a4ddd638d35929ae5b7b70eb298305c/lib/stomper/examples/receiver.py#L51-L57
oisinmulvihill/stomper
lib/stomper/examples/receiver.py
StompProtocol.connectionMade
def connectionMade(self): """Register with the stomp server. """ cmd = self.sm.connect() self.transport.write(cmd)
python
def connectionMade(self): """Register with the stomp server. """ cmd = self.sm.connect() self.transport.write(cmd)
[ "def", "connectionMade", "(", "self", ")", ":", "cmd", "=", "self", ".", "sm", ".", "connect", "(", ")", "self", ".", "transport", ".", "write", "(", "cmd", ")" ]
Register with the stomp server.
[ "Register", "with", "the", "stomp", "server", "." ]
train
https://github.com/oisinmulvihill/stomper/blob/842ed2353a4ddd638d35929ae5b7b70eb298305c/lib/stomper/examples/receiver.py#L67-L71
oisinmulvihill/stomper
lib/stomper/examples/receiver.py
StompProtocol.dataReceived
def dataReceived(self, data): """Data received, react to it and respond if needed. """ # print "receiver dataReceived: <%s>" % data msg = stomper.unpack_frame(data) returned = self.sm.react(msg) # print "receiver returned <%s>" % returned ...
python
def dataReceived(self, data): """Data received, react to it and respond if needed. """ # print "receiver dataReceived: <%s>" % data msg = stomper.unpack_frame(data) returned = self.sm.react(msg) # print "receiver returned <%s>" % returned ...
[ "def", "dataReceived", "(", "self", ",", "data", ")", ":", "# print \"receiver dataReceived: <%s>\" % data", "msg", "=", "stomper", ".", "unpack_frame", "(", "data", ")", "returned", "=", "self", ".", "sm", ".", "react", "(", "msg", ")", "# print \...
Data received, react to it and respond if needed.
[ "Data", "received", "react", "to", "it", "and", "respond", "if", "needed", "." ]
train
https://github.com/oisinmulvihill/stomper/blob/842ed2353a4ddd638d35929ae5b7b70eb298305c/lib/stomper/examples/receiver.py#L74-L86
wesleyfr/boxpython
boxpython/session.py
BoxSession.find_id_in_folder
def find_id_in_folder(self, name, parent_folder_id=0): """Find a folder or a file ID from its name, inside a given folder. Args: name (str): Name of the folder or the file to find. parent_folder_id (int): ID of the folder where to search. Returns: int. ID o...
python
def find_id_in_folder(self, name, parent_folder_id=0): """Find a folder or a file ID from its name, inside a given folder. Args: name (str): Name of the folder or the file to find. parent_folder_id (int): ID of the folder where to search. Returns: int. ID o...
[ "def", "find_id_in_folder", "(", "self", ",", "name", ",", "parent_folder_id", "=", "0", ")", ":", "if", "name", "is", "None", "or", "len", "(", "name", ")", "==", "0", ":", "return", "parent_folder_id", "offset", "=", "0", "resp", "=", "self", ".", ...
Find a folder or a file ID from its name, inside a given folder. Args: name (str): Name of the folder or the file to find. parent_folder_id (int): ID of the folder where to search. Returns: int. ID of the file or folder found. None if not found. Raises: ...
[ "Find", "a", "folder", "or", "a", "file", "ID", "from", "its", "name", "inside", "a", "given", "folder", "." ]
train
https://github.com/wesleyfr/boxpython/blob/f00a8ada6dff2c7ffc88bf89d4e15965c5adb422/boxpython/session.py#L135-L169
wesleyfr/boxpython
boxpython/session.py
BoxSession.create_folder
def create_folder(self, name, parent_folder_id=0): """Create a folder If the folder exists, a BoxError will be raised. Args: folder_id (int): Name of the folder. parent_folder_id (int): ID of the folder where to create the new one. Returns: dict. R...
python
def create_folder(self, name, parent_folder_id=0): """Create a folder If the folder exists, a BoxError will be raised. Args: folder_id (int): Name of the folder. parent_folder_id (int): ID of the folder where to create the new one. Returns: dict. R...
[ "def", "create_folder", "(", "self", ",", "name", ",", "parent_folder_id", "=", "0", ")", ":", "return", "self", ".", "__request", "(", "\"POST\"", ",", "\"folders\"", ",", "data", "=", "{", "\"name\"", ":", "name", ",", "\"parent\"", ":", "{", "\"id\"",...
Create a folder If the folder exists, a BoxError will be raised. Args: folder_id (int): Name of the folder. parent_folder_id (int): ID of the folder where to create the new one. Returns: dict. Response from Box. Raises: BoxError: An er...
[ "Create", "a", "folder" ]
train
https://github.com/wesleyfr/boxpython/blob/f00a8ada6dff2c7ffc88bf89d4e15965c5adb422/boxpython/session.py#L195-L217
wesleyfr/boxpython
boxpython/session.py
BoxSession.delete_folder
def delete_folder(self, folder_id, recursive=True): """Delete an existing folder Args: folder_id (int): ID of the folder to delete. recursive (bool): Delete all subfolder if True. Returns: dict. Response from Box. Raises: BoxError: An er...
python
def delete_folder(self, folder_id, recursive=True): """Delete an existing folder Args: folder_id (int): ID of the folder to delete. recursive (bool): Delete all subfolder if True. Returns: dict. Response from Box. Raises: BoxError: An er...
[ "def", "delete_folder", "(", "self", ",", "folder_id", ",", "recursive", "=", "True", ")", ":", "return", "self", ".", "__request", "(", "\"DELETE\"", ",", "\"folders/%s\"", "%", "(", "folder_id", ",", ")", ",", "querystring", "=", "{", "'recursive'", ":",...
Delete an existing folder Args: folder_id (int): ID of the folder to delete. recursive (bool): Delete all subfolder if True. Returns: dict. Response from Box. Raises: BoxError: An error response is returned from Box (status_code >= 400). ...
[ "Delete", "an", "existing", "folder" ]
train
https://github.com/wesleyfr/boxpython/blob/f00a8ada6dff2c7ffc88bf89d4e15965c5adb422/boxpython/session.py#L219-L237
wesleyfr/boxpython
boxpython/session.py
BoxSession.get_folder_items
def get_folder_items(self, folder_id, limit=100, offset=0, fields_list=None): """Get files and folders inside a given folder Args: folder_id (int): Where to get files and folders info. limit (int): The number of items to return. offset (...
python
def get_folder_items(self, folder_id, limit=100, offset=0, fields_list=None): """Get files and folders inside a given folder Args: folder_id (int): Where to get files and folders info. limit (int): The number of items to return. offset (...
[ "def", "get_folder_items", "(", "self", ",", "folder_id", ",", "limit", "=", "100", ",", "offset", "=", "0", ",", "fields_list", "=", "None", ")", ":", "qs", "=", "{", "\"limit\"", ":", "limit", ",", "\"offset\"", ":", "offset", "}", "if", "fields_list...
Get files and folders inside a given folder Args: folder_id (int): Where to get files and folders info. limit (int): The number of items to return. offset (int): The item at which to begin the response. fields_list (list): List of attributes to get. All attrib...
[ "Get", "files", "and", "folders", "inside", "a", "given", "folder" ]
train
https://github.com/wesleyfr/boxpython/blob/f00a8ada6dff2c7ffc88bf89d4e15965c5adb422/boxpython/session.py#L239-L267
wesleyfr/boxpython
boxpython/session.py
BoxSession.upload_file
def upload_file(self, name, folder_id, file_path): """Upload a file into a folder. Use function for small file otherwise there is the chunk_upload_file() function Args:: name (str): Name of the file on your Box storage. folder_id (int): ID of the folder where to upload...
python
def upload_file(self, name, folder_id, file_path): """Upload a file into a folder. Use function for small file otherwise there is the chunk_upload_file() function Args:: name (str): Name of the file on your Box storage. folder_id (int): ID of the folder where to upload...
[ "def", "upload_file", "(", "self", ",", "name", ",", "folder_id", ",", "file_path", ")", ":", "try", ":", "return", "self", ".", "__do_upload_file", "(", "name", ",", "folder_id", ",", "file_path", ")", "except", "BoxError", ",", "ex", ":", "if", "ex", ...
Upload a file into a folder. Use function for small file otherwise there is the chunk_upload_file() function Args:: name (str): Name of the file on your Box storage. folder_id (int): ID of the folder where to upload the file. file_path (str): Local path of the fil...
[ "Upload", "a", "file", "into", "a", "folder", "." ]
train
https://github.com/wesleyfr/boxpython/blob/f00a8ada6dff2c7ffc88bf89d4e15965c5adb422/boxpython/session.py#L269-L297
wesleyfr/boxpython
boxpython/session.py
BoxSession.upload_new_file_version
def upload_new_file_version(self, name, folder_id, file_id, file_path): """Upload a new version of a file into a folder. Use function for small file otherwise there is the chunk_upload_file() function. Args:: name (str): Name of the file on your Box storage. folder_id ...
python
def upload_new_file_version(self, name, folder_id, file_id, file_path): """Upload a new version of a file into a folder. Use function for small file otherwise there is the chunk_upload_file() function. Args:: name (str): Name of the file on your Box storage. folder_id ...
[ "def", "upload_new_file_version", "(", "self", ",", "name", ",", "folder_id", ",", "file_id", ",", "file_path", ")", ":", "try", ":", "return", "self", ".", "__do_upload_file", "(", "name", ",", "folder_id", ",", "file_path", ",", "file_id", ")", "except", ...
Upload a new version of a file into a folder. Use function for small file otherwise there is the chunk_upload_file() function. Args:: name (str): Name of the file on your Box storage. folder_id (int): ID of the folder where to upload the file. file_id (int): ID of...
[ "Upload", "a", "new", "version", "of", "a", "file", "into", "a", "folder", "." ]
train
https://github.com/wesleyfr/boxpython/blob/f00a8ada6dff2c7ffc88bf89d4e15965c5adb422/boxpython/session.py#L299-L329
wesleyfr/boxpython
boxpython/session.py
BoxSession.chunk_upload_file
def chunk_upload_file(self, name, folder_id, file_path, progress_callback=None, chunk_size=1024*1024*1): """Upload a file chunk by chunk. The whole file is never loaded in memory. Use this function for big file. The callback(trans...
python
def chunk_upload_file(self, name, folder_id, file_path, progress_callback=None, chunk_size=1024*1024*1): """Upload a file chunk by chunk. The whole file is never loaded in memory. Use this function for big file. The callback(trans...
[ "def", "chunk_upload_file", "(", "self", ",", "name", ",", "folder_id", ",", "file_path", ",", "progress_callback", "=", "None", ",", "chunk_size", "=", "1024", "*", "1024", "*", "1", ")", ":", "try", ":", "return", "self", ".", "__do_chunk_upload_file", "...
Upload a file chunk by chunk. The whole file is never loaded in memory. Use this function for big file. The callback(transferred, total) to let you know the upload progress. Upload can be cancelled if the callback raise an Exception. >>> def progress_callback(transferred, tota...
[ "Upload", "a", "file", "chunk", "by", "chunk", "." ]
train
https://github.com/wesleyfr/boxpython/blob/f00a8ada6dff2c7ffc88bf89d4e15965c5adb422/boxpython/session.py#L346-L394
wesleyfr/boxpython
boxpython/session.py
BoxSession.copy_file
def copy_file(self, file_id, dest_folder_id): """Copy file to new destination Args: file_id (int): ID of the folder. dest_folder_id (int): ID of parent folder you are copying to. Returns: dict. Response from Box. Raises: BoxError: An er...
python
def copy_file(self, file_id, dest_folder_id): """Copy file to new destination Args: file_id (int): ID of the folder. dest_folder_id (int): ID of parent folder you are copying to. Returns: dict. Response from Box. Raises: BoxError: An er...
[ "def", "copy_file", "(", "self", ",", "file_id", ",", "dest_folder_id", ")", ":", "return", "self", ".", "__request", "(", "\"POST\"", ",", "\"/files/\"", "+", "unicode", "(", "file_id", ")", "+", "\"/copy\"", ",", "data", "=", "{", "\"parent\"", ":", "{...
Copy file to new destination Args: file_id (int): ID of the folder. dest_folder_id (int): ID of parent folder you are copying to. Returns: dict. Response from Box. Raises: BoxError: An error response is returned from Box (status_code >= 400). ...
[ "Copy", "file", "to", "new", "destination" ]
train
https://github.com/wesleyfr/boxpython/blob/f00a8ada6dff2c7ffc88bf89d4e15965c5adb422/boxpython/session.py#L432-L456
wesleyfr/boxpython
boxpython/session.py
BoxSession.download_file
def download_file(self, file_id, dest_file_path, progress_callback=None, chunk_size=1024*1024*1): """Download a file. The whole file is never loaded in memory. The callback(transferred, total) to let you know the download progress. ...
python
def download_file(self, file_id, dest_file_path, progress_callback=None, chunk_size=1024*1024*1): """Download a file. The whole file is never loaded in memory. The callback(transferred, total) to let you know the download progress. ...
[ "def", "download_file", "(", "self", ",", "file_id", ",", "dest_file_path", ",", "progress_callback", "=", "None", ",", "chunk_size", "=", "1024", "*", "1024", "*", "1", ")", ":", "with", "open", "(", "dest_file_path", ",", "'wb'", ")", "as", "fp", ":", ...
Download a file. The whole file is never loaded in memory. The callback(transferred, total) to let you know the download progress. Download can be cancelled if the callback raise an Exception. >>> def progress_callback(transferred, total): ... print 'Downloaded %i bytes of ...
[ "Download", "a", "file", "." ]
train
https://github.com/wesleyfr/boxpython/blob/f00a8ada6dff2c7ffc88bf89d4e15965c5adb422/boxpython/session.py#L458-L509
wesleyfr/boxpython
boxpython/session.py
BoxSession.search
def search(self, **kwargs): """Searches for files/folders Args: \*\*kwargs (dict): A dictionary containing necessary parameters (check https://developers.box.com/docs/#search for list of parameters) Returns: dict. ...
python
def search(self, **kwargs): """Searches for files/folders Args: \*\*kwargs (dict): A dictionary containing necessary parameters (check https://developers.box.com/docs/#search for list of parameters) Returns: dict. ...
[ "def", "search", "(", "self", ",", "*", "*", "kwargs", ")", ":", "query_string", "=", "{", "}", "for", "key", ",", "value", "in", "kwargs", ".", "iteritems", "(", ")", ":", "query_string", "[", "key", "]", "=", "value", "return", "self", ".", "__re...
Searches for files/folders Args: \*\*kwargs (dict): A dictionary containing necessary parameters (check https://developers.box.com/docs/#search for list of parameters) Returns: dict. Response from Box. Raises: ...
[ "Searches", "for", "files", "/", "folders" ]
train
https://github.com/wesleyfr/boxpython/blob/f00a8ada6dff2c7ffc88bf89d4e15965c5adb422/boxpython/session.py#L529-L550
honzajavorek/redis-collections
redis_collections/dicts.py
Dict.getmany
def getmany(self, *keys): """ Return a list of values corresponding to the keys in the iterable of *keys*. If a key is not present in the collection, its corresponding value will be :obj:`None`. .. note:: This method is not implemented by standard Python dict...
python
def getmany(self, *keys): """ Return a list of values corresponding to the keys in the iterable of *keys*. If a key is not present in the collection, its corresponding value will be :obj:`None`. .. note:: This method is not implemented by standard Python dict...
[ "def", "getmany", "(", "self", ",", "*", "keys", ")", ":", "pickled_keys", "=", "(", "self", ".", "_pickle_key", "(", "k", ")", "for", "k", "in", "keys", ")", "pickled_values", "=", "self", ".", "redis", ".", "hmget", "(", "self", ".", "key", ",", ...
Return a list of values corresponding to the keys in the iterable of *keys*. If a key is not present in the collection, its corresponding value will be :obj:`None`. .. note:: This method is not implemented by standard Python dictionary classes.
[ "Return", "a", "list", "of", "values", "corresponding", "to", "the", "keys", "in", "the", "iterable", "of", "*", "keys", "*", ".", "If", "a", "key", "is", "not", "present", "in", "the", "collection", "its", "corresponding", "value", "will", "be", ":", ...
train
https://github.com/honzajavorek/redis-collections/blob/07ca8efe88fb128f7dc7319dfa6a26cd39b3776b/redis_collections/dicts.py#L125-L144
honzajavorek/redis-collections
redis_collections/dicts.py
Dict._data
def _data(self, pipe=None): """ Returns a Python dictionary with the same values as this object (without checking the local cache). """ pipe = self.redis if pipe is None else pipe items = pipe.hgetall(self.key).items() return {self._unpickle_key(k): self._unpickl...
python
def _data(self, pipe=None): """ Returns a Python dictionary with the same values as this object (without checking the local cache). """ pipe = self.redis if pipe is None else pipe items = pipe.hgetall(self.key).items() return {self._unpickle_key(k): self._unpickl...
[ "def", "_data", "(", "self", ",", "pipe", "=", "None", ")", ":", "pipe", "=", "self", ".", "redis", "if", "pipe", "is", "None", "else", "pipe", "items", "=", "pipe", ".", "hgetall", "(", "self", ".", "key", ")", ".", "items", "(", ")", "return", ...
Returns a Python dictionary with the same values as this object (without checking the local cache).
[ "Returns", "a", "Python", "dictionary", "with", "the", "same", "values", "as", "this", "object", "(", "without", "checking", "the", "local", "cache", ")", "." ]
train
https://github.com/honzajavorek/redis-collections/blob/07ca8efe88fb128f7dc7319dfa6a26cd39b3776b/redis_collections/dicts.py#L192-L200
honzajavorek/redis-collections
redis_collections/dicts.py
Dict.iteritems
def iteritems(self, pipe=None): """Return an iterator over the dictionary's ``(key, value)`` pairs.""" pipe = self.redis if pipe is None else pipe for k, v in self._data(pipe).items(): yield k, self.cache.get(k, v)
python
def iteritems(self, pipe=None): """Return an iterator over the dictionary's ``(key, value)`` pairs.""" pipe = self.redis if pipe is None else pipe for k, v in self._data(pipe).items(): yield k, self.cache.get(k, v)
[ "def", "iteritems", "(", "self", ",", "pipe", "=", "None", ")", ":", "pipe", "=", "self", ".", "redis", "if", "pipe", "is", "None", "else", "pipe", "for", "k", ",", "v", "in", "self", ".", "_data", "(", "pipe", ")", ".", "items", "(", ")", ":",...
Return an iterator over the dictionary's ``(key, value)`` pairs.
[ "Return", "an", "iterator", "over", "the", "dictionary", "s", "(", "key", "value", ")", "pairs", "." ]
train
https://github.com/honzajavorek/redis-collections/blob/07ca8efe88fb128f7dc7319dfa6a26cd39b3776b/redis_collections/dicts.py#L206-L210
honzajavorek/redis-collections
redis_collections/dicts.py
Dict.pop
def pop(self, key, default=__marker): """If *key* is in the dictionary, remove it and return its value, else return *default*. If *default* is not given and *key* is not in the dictionary, a :exc:`KeyError` is raised. """ pickled_key = self._pickle_key(key) if key in sel...
python
def pop(self, key, default=__marker): """If *key* is in the dictionary, remove it and return its value, else return *default*. If *default* is not given and *key* is not in the dictionary, a :exc:`KeyError` is raised. """ pickled_key = self._pickle_key(key) if key in sel...
[ "def", "pop", "(", "self", ",", "key", ",", "default", "=", "__marker", ")", ":", "pickled_key", "=", "self", ".", "_pickle_key", "(", "key", ")", "if", "key", "in", "self", ".", "cache", ":", "self", ".", "redis", ".", "hdel", "(", "self", ".", ...
If *key* is in the dictionary, remove it and return its value, else return *default*. If *default* is not given and *key* is not in the dictionary, a :exc:`KeyError` is raised.
[ "If", "*", "key", "*", "is", "in", "the", "dictionary", "remove", "it", "and", "return", "its", "value", "else", "return", "*", "default", "*", ".", "If", "*", "default", "*", "is", "not", "given", "and", "*", "key", "*", "is", "not", "in", "the", ...
train
https://github.com/honzajavorek/redis-collections/blob/07ca8efe88fb128f7dc7319dfa6a26cd39b3776b/redis_collections/dicts.py#L234-L258
honzajavorek/redis-collections
redis_collections/dicts.py
Dict.popitem
def popitem(self): """Remove and return an arbitrary ``(key, value)`` pair from the dictionary. :func:`popitem` is useful to destructively iterate over a dictionary, as often used in set algorithms. If the dictionary is empty, calling :func:`popitem` raises a :exc:`KeyEr...
python
def popitem(self): """Remove and return an arbitrary ``(key, value)`` pair from the dictionary. :func:`popitem` is useful to destructively iterate over a dictionary, as often used in set algorithms. If the dictionary is empty, calling :func:`popitem` raises a :exc:`KeyEr...
[ "def", "popitem", "(", "self", ")", ":", "def", "popitem_trans", "(", "pipe", ")", ":", "try", ":", "pickled_key", "=", "pipe", ".", "hkeys", "(", "self", ".", "key", ")", "[", "0", "]", "except", "IndexError", ":", "raise", "KeyError", "# pop its valu...
Remove and return an arbitrary ``(key, value)`` pair from the dictionary. :func:`popitem` is useful to destructively iterate over a dictionary, as often used in set algorithms. If the dictionary is empty, calling :func:`popitem` raises a :exc:`KeyError`.
[ "Remove", "and", "return", "an", "arbitrary", "(", "key", "value", ")", "pair", "from", "the", "dictionary", "." ]
train
https://github.com/honzajavorek/redis-collections/blob/07ca8efe88fb128f7dc7319dfa6a26cd39b3776b/redis_collections/dicts.py#L260-L287
honzajavorek/redis-collections
redis_collections/dicts.py
Dict.setdefault
def setdefault(self, key, default=None): """If *key* is in the dictionary, return its value. If not, insert *key* with a value of *default* and return *default*. *default* defaults to :obj:`None`. """ if key in self.cache: return self.cache[key] def setdefaul...
python
def setdefault(self, key, default=None): """If *key* is in the dictionary, return its value. If not, insert *key* with a value of *default* and return *default*. *default* defaults to :obj:`None`. """ if key in self.cache: return self.cache[key] def setdefaul...
[ "def", "setdefault", "(", "self", ",", "key", ",", "default", "=", "None", ")", ":", "if", "key", "in", "self", ".", "cache", ":", "return", "self", ".", "cache", "[", "key", "]", "def", "setdefault_trans", "(", "pipe", ")", ":", "pickled_key", "=", ...
If *key* is in the dictionary, return its value. If not, insert *key* with a value of *default* and return *default*. *default* defaults to :obj:`None`.
[ "If", "*", "key", "*", "is", "in", "the", "dictionary", "return", "its", "value", ".", "If", "not", "insert", "*", "key", "*", "with", "a", "value", "of", "*", "default", "*", "and", "return", "*", "default", "*", ".", "*", "default", "*", "default...
train
https://github.com/honzajavorek/redis-collections/blob/07ca8efe88fb128f7dc7319dfa6a26cd39b3776b/redis_collections/dicts.py#L289-L312
honzajavorek/redis-collections
redis_collections/dicts.py
Dict.update
def update(self, other=None, **kwargs): """Update the dictionary with the key/value pairs from *other*, overwriting existing keys. Return :obj:`None`. :func:`update` accepts either another dictionary object or an iterable of key/value pairs (as tuples or other iterables of lengt...
python
def update(self, other=None, **kwargs): """Update the dictionary with the key/value pairs from *other*, overwriting existing keys. Return :obj:`None`. :func:`update` accepts either another dictionary object or an iterable of key/value pairs (as tuples or other iterables of lengt...
[ "def", "update", "(", "self", ",", "other", "=", "None", ",", "*", "*", "kwargs", ")", ":", "if", "other", "is", "not", "None", ":", "if", "self", ".", "_same_redis", "(", "other", ",", "RedisCollection", ")", ":", "self", ".", "_update_helper", "(",...
Update the dictionary with the key/value pairs from *other*, overwriting existing keys. Return :obj:`None`. :func:`update` accepts either another dictionary object or an iterable of key/value pairs (as tuples or other iterables of length two). If keyword arguments are specified, the ...
[ "Update", "the", "dictionary", "with", "the", "key", "/", "value", "pairs", "from", "*", "other", "*", "overwriting", "existing", "keys", ".", "Return", ":", "obj", ":", "None", "." ]
train
https://github.com/honzajavorek/redis-collections/blob/07ca8efe88fb128f7dc7319dfa6a26cd39b3776b/redis_collections/dicts.py#L341-L360
honzajavorek/redis-collections
redis_collections/dicts.py
Dict.copy
def copy(self, key=None): """ Return a new collection with the same items as this one. If *key* is specified, create the new collection with the given Redis key. """ other = self.__class__(redis=self.redis, key=key) other.update(self) return other
python
def copy(self, key=None): """ Return a new collection with the same items as this one. If *key* is specified, create the new collection with the given Redis key. """ other = self.__class__(redis=self.redis, key=key) other.update(self) return other
[ "def", "copy", "(", "self", ",", "key", "=", "None", ")", ":", "other", "=", "self", ".", "__class__", "(", "redis", "=", "self", ".", "redis", ",", "key", "=", "key", ")", "other", ".", "update", "(", "self", ")", "return", "other" ]
Return a new collection with the same items as this one. If *key* is specified, create the new collection with the given Redis key.
[ "Return", "a", "new", "collection", "with", "the", "same", "items", "as", "this", "one", ".", "If", "*", "key", "*", "is", "specified", "create", "the", "new", "collection", "with", "the", "given", "Redis", "key", "." ]
train
https://github.com/honzajavorek/redis-collections/blob/07ca8efe88fb128f7dc7319dfa6a26cd39b3776b/redis_collections/dicts.py#L362-L371
honzajavorek/redis-collections
redis_collections/dicts.py
Dict.fromkeys
def fromkeys(cls, seq, value=None, **kwargs): """Create a new dictionary with keys from *seq* and values set to *value*. .. note:: :func:`fromkeys` is a class method that returns a new dictionary. It is possible to specify additional keyword arguments to be passed ...
python
def fromkeys(cls, seq, value=None, **kwargs): """Create a new dictionary with keys from *seq* and values set to *value*. .. note:: :func:`fromkeys` is a class method that returns a new dictionary. It is possible to specify additional keyword arguments to be passed ...
[ "def", "fromkeys", "(", "cls", ",", "seq", ",", "value", "=", "None", ",", "*", "*", "kwargs", ")", ":", "values", "=", "(", "(", "key", ",", "value", ")", "for", "key", "in", "seq", ")", "return", "cls", "(", "values", ",", "*", "*", "kwargs",...
Create a new dictionary with keys from *seq* and values set to *value*. .. note:: :func:`fromkeys` is a class method that returns a new dictionary. It is possible to specify additional keyword arguments to be passed to :func:`__init__` of the new object.
[ "Create", "a", "new", "dictionary", "with", "keys", "from", "*", "seq", "*", "and", "values", "set", "to", "*", "value", "*", "." ]
train
https://github.com/honzajavorek/redis-collections/blob/07ca8efe88fb128f7dc7319dfa6a26cd39b3776b/redis_collections/dicts.py#L380-L390
honzajavorek/redis-collections
redis_collections/dicts.py
Dict.scan_items
def scan_items(self): """ Yield each of the ``(key, value)`` pairs from the collection, without pulling them all into memory. .. warning:: This method is not available on the dictionary collections provided by Python. This method may return the same ...
python
def scan_items(self): """ Yield each of the ``(key, value)`` pairs from the collection, without pulling them all into memory. .. warning:: This method is not available on the dictionary collections provided by Python. This method may return the same ...
[ "def", "scan_items", "(", "self", ")", ":", "for", "k", ",", "v", "in", "self", ".", "redis", ".", "hscan_iter", "(", "self", ".", "key", ")", ":", "yield", "self", ".", "_unpickle_key", "(", "k", ")", ",", "self", ".", "_unpickle", "(", "v", ")"...
Yield each of the ``(key, value)`` pairs from the collection, without pulling them all into memory. .. warning:: This method is not available on the dictionary collections provided by Python. This method may return the same (key, value) pair multiple times. ...
[ "Yield", "each", "of", "the", "(", "key", "value", ")", "pairs", "from", "the", "collection", "without", "pulling", "them", "all", "into", "memory", "." ]
train
https://github.com/honzajavorek/redis-collections/blob/07ca8efe88fb128f7dc7319dfa6a26cd39b3776b/redis_collections/dicts.py#L392-L406
honzajavorek/redis-collections
redis_collections/dicts.py
Counter.update
def update(self, other=None, **kwargs): """Elements are counted from an *iterable* or added-in from another *mapping* (or counter). Like :func:`dict.update` but adds counts instead of replacing them. Also, the *iterable* is expected to be a sequence of elements, not a sequence of ``(key,...
python
def update(self, other=None, **kwargs): """Elements are counted from an *iterable* or added-in from another *mapping* (or counter). Like :func:`dict.update` but adds counts instead of replacing them. Also, the *iterable* is expected to be a sequence of elements, not a sequence of ``(key,...
[ "def", "update", "(", "self", ",", "other", "=", "None", ",", "*", "*", "kwargs", ")", ":", "if", "other", "is", "not", "None", ":", "if", "self", ".", "_same_redis", "(", "other", ",", "RedisCollection", ")", ":", "self", ".", "_update_helper", "(",...
Elements are counted from an *iterable* or added-in from another *mapping* (or counter). Like :func:`dict.update` but adds counts instead of replacing them. Also, the *iterable* is expected to be a sequence of elements, not a sequence of ``(key, value)`` pairs.
[ "Elements", "are", "counted", "from", "an", "*", "iterable", "*", "or", "added", "-", "in", "from", "another", "*", "mapping", "*", "(", "or", "counter", ")", ".", "Like", ":", "func", ":", "dict", ".", "update", "but", "adds", "counts", "instead", "...
train
https://github.com/honzajavorek/redis-collections/blob/07ca8efe88fb128f7dc7319dfa6a26cd39b3776b/redis_collections/dicts.py#L519-L534
honzajavorek/redis-collections
redis_collections/dicts.py
Counter.subtract
def subtract(self, other=None, **kwargs): """Elements are subtracted from an *iterable* or from another *mapping* (or counter). Like :func:`dict.update` but subtracts counts instead of replacing them. """ if other is not None: if self._same_redis(other, RedisCollectio...
python
def subtract(self, other=None, **kwargs): """Elements are subtracted from an *iterable* or from another *mapping* (or counter). Like :func:`dict.update` but subtracts counts instead of replacing them. """ if other is not None: if self._same_redis(other, RedisCollectio...
[ "def", "subtract", "(", "self", ",", "other", "=", "None", ",", "*", "*", "kwargs", ")", ":", "if", "other", "is", "not", "None", ":", "if", "self", ".", "_same_redis", "(", "other", ",", "RedisCollection", ")", ":", "self", ".", "_update_helper", "(...
Elements are subtracted from an *iterable* or from another *mapping* (or counter). Like :func:`dict.update` but subtracts counts instead of replacing them.
[ "Elements", "are", "subtracted", "from", "an", "*", "iterable", "*", "or", "from", "another", "*", "mapping", "*", "(", "or", "counter", ")", ".", "Like", ":", "func", ":", "dict", ".", "update", "but", "subtracts", "counts", "instead", "of", "replacing"...
train
https://github.com/honzajavorek/redis-collections/blob/07ca8efe88fb128f7dc7319dfa6a26cd39b3776b/redis_collections/dicts.py#L536-L550
oisinmulvihill/stomper
lib/stomper/examples/sender.py
StompProtocol.ack
def ack(self, msg): """Processes the received message. I don't need to generate an ack message. """ self.log.info("senderID:%s Received: %s " % (self.senderID, msg['body'])) return stomper.NO_REPONSE_NEEDED
python
def ack(self, msg): """Processes the received message. I don't need to generate an ack message. """ self.log.info("senderID:%s Received: %s " % (self.senderID, msg['body'])) return stomper.NO_REPONSE_NEEDED
[ "def", "ack", "(", "self", ",", "msg", ")", ":", "self", ".", "log", ".", "info", "(", "\"senderID:%s Received: %s \"", "%", "(", "self", ".", "senderID", ",", "msg", "[", "'body'", "]", ")", ")", "return", "stomper", ".", "NO_REPONSE_NEEDED" ]
Processes the received message. I don't need to generate an ack message.
[ "Processes", "the", "received", "message", ".", "I", "don", "t", "need", "to", "generate", "an", "ack", "message", "." ]
train
https://github.com/oisinmulvihill/stomper/blob/842ed2353a4ddd638d35929ae5b7b70eb298305c/lib/stomper/examples/sender.py#L68-L74
honzajavorek/redis-collections
redis_collections/base.py
RedisCollection._clear
def _clear(self, pipe=None): """Helper for clear operations. :param pipe: Redis pipe in case update is performed as a part of transaction. :type pipe: :class:`redis.client.StrictPipeline` or :class:`redis.client.StrictRedis` """ redis = s...
python
def _clear(self, pipe=None): """Helper for clear operations. :param pipe: Redis pipe in case update is performed as a part of transaction. :type pipe: :class:`redis.client.StrictPipeline` or :class:`redis.client.StrictRedis` """ redis = s...
[ "def", "_clear", "(", "self", ",", "pipe", "=", "None", ")", ":", "redis", "=", "self", ".", "redis", "if", "pipe", "is", "None", "else", "pipe", "redis", ".", "delete", "(", "self", ".", "key", ")" ]
Helper for clear operations. :param pipe: Redis pipe in case update is performed as a part of transaction. :type pipe: :class:`redis.client.StrictPipeline` or :class:`redis.client.StrictRedis`
[ "Helper", "for", "clear", "operations", "." ]
train
https://github.com/honzajavorek/redis-collections/blob/07ca8efe88fb128f7dc7319dfa6a26cd39b3776b/redis_collections/base.py#L116-L125
honzajavorek/redis-collections
redis_collections/base.py
RedisCollection._normalize_index
def _normalize_index(self, index, pipe=None): """Convert negative indexes into their positive equivalents.""" pipe = self.redis if pipe is None else pipe len_self = self.__len__(pipe) positive_index = index if index >= 0 else len_self + index return len_self, positive_index
python
def _normalize_index(self, index, pipe=None): """Convert negative indexes into their positive equivalents.""" pipe = self.redis if pipe is None else pipe len_self = self.__len__(pipe) positive_index = index if index >= 0 else len_self + index return len_self, positive_index
[ "def", "_normalize_index", "(", "self", ",", "index", ",", "pipe", "=", "None", ")", ":", "pipe", "=", "self", ".", "redis", "if", "pipe", "is", "None", "else", "pipe", "len_self", "=", "self", ".", "__len__", "(", "pipe", ")", "positive_index", "=", ...
Convert negative indexes into their positive equivalents.
[ "Convert", "negative", "indexes", "into", "their", "positive", "equivalents", "." ]
train
https://github.com/honzajavorek/redis-collections/blob/07ca8efe88fb128f7dc7319dfa6a26cd39b3776b/redis_collections/base.py#L152-L158
honzajavorek/redis-collections
redis_collections/base.py
RedisCollection._normalize_slice
def _normalize_slice(self, index, pipe=None): """Given a :obj:`slice` *index*, return a 4-tuple ``(start, stop, step, fowrward)``. The first three items can be used with the ``range`` function to retrieve the values associated with the slice; the last item indicates the direction. ...
python
def _normalize_slice(self, index, pipe=None): """Given a :obj:`slice` *index*, return a 4-tuple ``(start, stop, step, fowrward)``. The first three items can be used with the ``range`` function to retrieve the values associated with the slice; the last item indicates the direction. ...
[ "def", "_normalize_slice", "(", "self", ",", "index", ",", "pipe", "=", "None", ")", ":", "if", "index", ".", "step", "==", "0", ":", "raise", "ValueError", "pipe", "=", "self", ".", "redis", "if", "pipe", "is", "None", "else", "pipe", "len_self", "=...
Given a :obj:`slice` *index*, return a 4-tuple ``(start, stop, step, fowrward)``. The first three items can be used with the ``range`` function to retrieve the values associated with the slice; the last item indicates the direction.
[ "Given", "a", ":", "obj", ":", "slice", "*", "index", "*", "return", "a", "4", "-", "tuple", "(", "start", "stop", "step", "fowrward", ")", ".", "The", "first", "three", "items", "can", "be", "used", "with", "the", "range", "function", "to", "retriev...
train
https://github.com/honzajavorek/redis-collections/blob/07ca8efe88fb128f7dc7319dfa6a26cd39b3776b/redis_collections/base.py#L160-L193
honzajavorek/redis-collections
redis_collections/base.py
RedisCollection._transaction
def _transaction(self, fn, *extra_keys): """Helper simplifying code within watched transaction. Takes *fn*, function treated as a transaction. Returns whatever *fn* returns. ``self.key`` is watched. *fn* takes *pipe* as the only argument. :param fn: Closure treated as a transac...
python
def _transaction(self, fn, *extra_keys): """Helper simplifying code within watched transaction. Takes *fn*, function treated as a transaction. Returns whatever *fn* returns. ``self.key`` is watched. *fn* takes *pipe* as the only argument. :param fn: Closure treated as a transac...
[ "def", "_transaction", "(", "self", ",", "fn", ",", "*", "extra_keys", ")", ":", "results", "=", "[", "]", "def", "trans", "(", "pipe", ")", ":", "results", ".", "append", "(", "fn", "(", "pipe", ")", ")", "self", ".", "redis", ".", "transaction", ...
Helper simplifying code within watched transaction. Takes *fn*, function treated as a transaction. Returns whatever *fn* returns. ``self.key`` is watched. *fn* takes *pipe* as the only argument. :param fn: Closure treated as a transaction. :type fn: function *fn(pipe)* ...
[ "Helper", "simplifying", "code", "within", "watched", "transaction", "." ]
train
https://github.com/honzajavorek/redis-collections/blob/07ca8efe88fb128f7dc7319dfa6a26cd39b3776b/redis_collections/base.py#L195-L214
JoaoFelipe/ipython-unittest
setup.py
recursive_path
def recursive_path(pack, path): """Find paths recursively""" matches = [] for root, _, filenames in os.walk(os.path.join(pack, path)): for filename in filenames: matches.append(os.path.join(root, filename)[len(pack) + 1:]) return matches
python
def recursive_path(pack, path): """Find paths recursively""" matches = [] for root, _, filenames in os.walk(os.path.join(pack, path)): for filename in filenames: matches.append(os.path.join(root, filename)[len(pack) + 1:]) return matches
[ "def", "recursive_path", "(", "pack", ",", "path", ")", ":", "matches", "=", "[", "]", "for", "root", ",", "_", ",", "filenames", "in", "os", ".", "walk", "(", "os", ".", "path", ".", "join", "(", "pack", ",", "path", ")", ")", ":", "for", "fil...
Find paths recursively
[ "Find", "paths", "recursively" ]
train
https://github.com/JoaoFelipe/ipython-unittest/blob/2a1708e1fa575ce80e0ee2092d280979c1a77885/setup.py#L7-L13
oisinmulvihill/stomper
lib/stomper/stomp_11.py
nack
def nack(messageid, subscriptionid, transactionid=None): """STOMP negative acknowledge command. NACK is the opposite of ACK. It is used to tell the server that the client did not consume the message. The server can then either send the message to a different client, discard it, or put it in a dead lett...
python
def nack(messageid, subscriptionid, transactionid=None): """STOMP negative acknowledge command. NACK is the opposite of ACK. It is used to tell the server that the client did not consume the message. The server can then either send the message to a different client, discard it, or put it in a dead lett...
[ "def", "nack", "(", "messageid", ",", "subscriptionid", ",", "transactionid", "=", "None", ")", ":", "header", "=", "'subscription:%s\\nmessage-id:%s'", "%", "(", "subscriptionid", ",", "messageid", ")", "if", "transactionid", ":", "header", "+=", "'\\ntransaction...
STOMP negative acknowledge command. NACK is the opposite of ACK. It is used to tell the server that the client did not consume the message. The server can then either send the message to a different client, discard it, or put it in a dead letter queue. The exact behavior is server specific. messag...
[ "STOMP", "negative", "acknowledge", "command", "." ]
train
https://github.com/oisinmulvihill/stomper/blob/842ed2353a4ddd638d35929ae5b7b70eb298305c/lib/stomper/stomp_11.py#L275-L301
oisinmulvihill/stomper
lib/stomper/stomp_11.py
connect
def connect(username, password, host, heartbeats=(0,0)): """STOMP connect command. username, password: These are the needed auth details to connect to the message server. After sending this we will receive a CONNECTED message which will contain our session id. """ if len(heart...
python
def connect(username, password, host, heartbeats=(0,0)): """STOMP connect command. username, password: These are the needed auth details to connect to the message server. After sending this we will receive a CONNECTED message which will contain our session id. """ if len(heart...
[ "def", "connect", "(", "username", ",", "password", ",", "host", ",", "heartbeats", "=", "(", "0", ",", "0", ")", ")", ":", "if", "len", "(", "heartbeats", ")", "!=", "2", ":", "raise", "ValueError", "(", "'Invalid heartbeat %r'", "%", "heartbeats", ")...
STOMP connect command. username, password: These are the needed auth details to connect to the message server. After sending this we will receive a CONNECTED message which will contain our session id.
[ "STOMP", "connect", "command", "." ]
train
https://github.com/oisinmulvihill/stomper/blob/842ed2353a4ddd638d35929ae5b7b70eb298305c/lib/stomper/stomp_11.py#L335-L349
oisinmulvihill/stomper
lib/stomper/stomp_11.py
Engine.ack
def ack(self, msg): """Called when a MESSAGE has been received. Override this method to handle received messages. This function will generate an acknowledge message for the given message and transaction (if present). """ message_id = msg['headers']['message-id'] ...
python
def ack(self, msg): """Called when a MESSAGE has been received. Override this method to handle received messages. This function will generate an acknowledge message for the given message and transaction (if present). """ message_id = msg['headers']['message-id'] ...
[ "def", "ack", "(", "self", ",", "msg", ")", ":", "message_id", "=", "msg", "[", "'headers'", "]", "[", "'message-id'", "]", "subscription", "=", "msg", "[", "'headers'", "]", "[", "'subscription'", "]", "transaction_id", "=", "None", "if", "'transaction-id...
Called when a MESSAGE has been received. Override this method to handle received messages. This function will generate an acknowledge message for the given message and transaction (if present).
[ "Called", "when", "a", "MESSAGE", "has", "been", "received", "." ]
train
https://github.com/oisinmulvihill/stomper/blob/842ed2353a4ddd638d35929ae5b7b70eb298305c/lib/stomper/stomp_11.py#L489-L507
oisinmulvihill/stomper
lib/stomper/stompbuffer.py
StompBuffer.getOneMessage
def getOneMessage ( self ): """ I pull one complete message off the buffer and return it decoded as a dict. If there is no complete message in the buffer, I return None. Note that the buffer can contain more than once message. You should therefore call me in a loop until...
python
def getOneMessage ( self ): """ I pull one complete message off the buffer and return it decoded as a dict. If there is no complete message in the buffer, I return None. Note that the buffer can contain more than once message. You should therefore call me in a loop until...
[ "def", "getOneMessage", "(", "self", ")", ":", "(", "mbytes", ",", "hbytes", ")", "=", "self", ".", "_findMessageBytes", "(", "self", ".", "buffer", ")", "if", "not", "mbytes", ":", "return", "None", "msgdata", "=", "self", ".", "buffer", "[", ":", "...
I pull one complete message off the buffer and return it decoded as a dict. If there is no complete message in the buffer, I return None. Note that the buffer can contain more than once message. You should therefore call me in a loop until I return None.
[ "I", "pull", "one", "complete", "message", "off", "the", "buffer", "and", "return", "it", "decoded", "as", "a", "dict", ".", "If", "there", "is", "no", "complete", "message", "in", "the", "buffer", "I", "return", "None", "." ]
train
https://github.com/oisinmulvihill/stomper/blob/842ed2353a4ddd638d35929ae5b7b70eb298305c/lib/stomper/stompbuffer.py#L69-L109
oisinmulvihill/stomper
lib/stomper/stompbuffer.py
StompBuffer._findMessageBytes
def _findMessageBytes ( self, data ): """ I examine the data passed to me and return a 2-tuple of the form: ( message_length, header_length ) where message_length is the length in bytes of the first complete message, if it contains at least one message, or 0...
python
def _findMessageBytes ( self, data ): """ I examine the data passed to me and return a 2-tuple of the form: ( message_length, header_length ) where message_length is the length in bytes of the first complete message, if it contains at least one message, or 0...
[ "def", "_findMessageBytes", "(", "self", ",", "data", ")", ":", "# Sanity check. See the docstring for the method to see what it", "# does an why we need it.", "self", ".", "syncBuffer", "(", ")", "# If the string '\\n\\n' does not exist, we don't even have the complete", "# header y...
I examine the data passed to me and return a 2-tuple of the form: ( message_length, header_length ) where message_length is the length in bytes of the first complete message, if it contains at least one message, or 0 if it contains no message. If me...
[ "I", "examine", "the", "data", "passed", "to", "me", "and", "return", "a", "2", "-", "tuple", "of", "the", "form", ":", "(", "message_length", "header_length", ")", "where", "message_length", "is", "the", "length", "in", "bytes", "of", "the", "first", "c...
train
https://github.com/oisinmulvihill/stomper/blob/842ed2353a4ddd638d35929ae5b7b70eb298305c/lib/stomper/stompbuffer.py#L112-L195