id int32 0 252k | repo stringlengths 7 55 | path stringlengths 4 127 | func_name stringlengths 1 88 | original_string stringlengths 75 19.8k | language stringclasses 1
value | code stringlengths 75 19.8k | code_tokens list | docstring stringlengths 3 17.3k | docstring_tokens list | sha stringlengths 40 40 | url stringlengths 87 242 |
|---|---|---|---|---|---|---|---|---|---|---|---|
50,700 | mlenzen/collections-extended | collections_extended/indexed_dict.py | IndexedDict.fast_pop | def fast_pop(self, key=NOT_SET, index=NOT_SET):
"""Pop a specific item quickly by swapping it to the end.
Remove value with given key or index (last item by default) fast
by swapping it to the last place first.
Changes order of the remaining items (item that used to be last goes to
the popped location).
R... | python | def fast_pop(self, key=NOT_SET, index=NOT_SET):
"""Pop a specific item quickly by swapping it to the end.
Remove value with given key or index (last item by default) fast
by swapping it to the last place first.
Changes order of the remaining items (item that used to be last goes to
the popped location).
R... | [
"def",
"fast_pop",
"(",
"self",
",",
"key",
"=",
"NOT_SET",
",",
"index",
"=",
"NOT_SET",
")",
":",
"if",
"index",
"is",
"NOT_SET",
"and",
"key",
"is",
"not",
"NOT_SET",
":",
"index",
",",
"popped_value",
"=",
"self",
".",
"_dict",
".",
"pop",
"(",
... | Pop a specific item quickly by swapping it to the end.
Remove value with given key or index (last item by default) fast
by swapping it to the last place first.
Changes order of the remaining items (item that used to be last goes to
the popped location).
Returns tuple of (poped_value, new_moved_index, moved_... | [
"Pop",
"a",
"specific",
"item",
"quickly",
"by",
"swapping",
"it",
"to",
"the",
"end",
"."
] | ee9e86f6bbef442dbebcb3a5970642c5c969e2cf | https://github.com/mlenzen/collections-extended/blob/ee9e86f6bbef442dbebcb3a5970642c5c969e2cf/collections_extended/indexed_dict.py#L115-L155 |
50,701 | justinabrahms/imhotep | imhotep/shas.py | get_pr_info | def get_pr_info(requester, reponame, number):
"Returns the PullRequest as a PRInfo object"
resp = requester.get(
'https://api.github.com/repos/%s/pulls/%s' % (reponame, number))
return PRInfo(resp.json()) | python | def get_pr_info(requester, reponame, number):
"Returns the PullRequest as a PRInfo object"
resp = requester.get(
'https://api.github.com/repos/%s/pulls/%s' % (reponame, number))
return PRInfo(resp.json()) | [
"def",
"get_pr_info",
"(",
"requester",
",",
"reponame",
",",
"number",
")",
":",
"resp",
"=",
"requester",
".",
"get",
"(",
"'https://api.github.com/repos/%s/pulls/%s'",
"%",
"(",
"reponame",
",",
"number",
")",
")",
"return",
"PRInfo",
"(",
"resp",
".",
"j... | Returns the PullRequest as a PRInfo object | [
"Returns",
"the",
"PullRequest",
"as",
"a",
"PRInfo",
"object"
] | c6dc365ef34505d7b6837187900e59b00e5fab08 | https://github.com/justinabrahms/imhotep/blob/c6dc365ef34505d7b6837187900e59b00e5fab08/imhotep/shas.py#L45-L49 |
50,702 | andresriancho/docker-tag-naming | docker_tag_naming/utils.py | get_all_tags_no_auth | def get_all_tags_no_auth(image_name, branch=None):
"""
Try to get the tags without any authentication, this does work only for
public images.
GET /v1/repositories/<namespace>/<repository_name>/tags
:param image_name: The docker image name
:param branch: The branch to filter by
:return: A l... | python | def get_all_tags_no_auth(image_name, branch=None):
"""
Try to get the tags without any authentication, this does work only for
public images.
GET /v1/repositories/<namespace>/<repository_name>/tags
:param image_name: The docker image name
:param branch: The branch to filter by
:return: A l... | [
"def",
"get_all_tags_no_auth",
"(",
"image_name",
",",
"branch",
"=",
"None",
")",
":",
"output",
"=",
"[",
"]",
"logging",
".",
"debug",
"(",
"'Getting %s without authentication'",
"%",
"image_name",
")",
"spec",
"=",
"'/%s/tags'",
"%",
"image_name",
"headers",... | Try to get the tags without any authentication, this does work only for
public images.
GET /v1/repositories/<namespace>/<repository_name>/tags
:param image_name: The docker image name
:param branch: The branch to filter by
:return: A list of Version instances, latest first | [
"Try",
"to",
"get",
"the",
"tags",
"without",
"any",
"authentication",
"this",
"does",
"work",
"only",
"for",
"public",
"images",
"."
] | 8c043d69a63fb2fa9f38eda5bee1c0d7a3fd1b2b | https://github.com/andresriancho/docker-tag-naming/blob/8c043d69a63fb2fa9f38eda5bee1c0d7a3fd1b2b/docker_tag_naming/utils.py#L138-L205 |
50,703 | tarzanjw/python-mysql-binlog-to-blinker | mysqlbinlog2blinker/__init__.py | start_publishing | def start_publishing(mysql_settings, **kwargs):
"""Start publishing MySQL row-based binlog events to blinker signals
Args:
mysql_settings (dict): information to connect to mysql via pymysql
**kwargs: The additional kwargs will be passed to
:py:class:`pymysqlreplication.BinLogStreamReade... | python | def start_publishing(mysql_settings, **kwargs):
"""Start publishing MySQL row-based binlog events to blinker signals
Args:
mysql_settings (dict): information to connect to mysql via pymysql
**kwargs: The additional kwargs will be passed to
:py:class:`pymysqlreplication.BinLogStreamReade... | [
"def",
"start_publishing",
"(",
"mysql_settings",
",",
"*",
"*",
"kwargs",
")",
":",
"_logger",
".",
"info",
"(",
"'Start publishing from %s with:\\n%s'",
"%",
"(",
"mysql_settings",
",",
"kwargs",
")",
")",
"kwargs",
".",
"setdefault",
"(",
"'server_id'",
",",
... | Start publishing MySQL row-based binlog events to blinker signals
Args:
mysql_settings (dict): information to connect to mysql via pymysql
**kwargs: The additional kwargs will be passed to
:py:class:`pymysqlreplication.BinLogStreamReader`. | [
"Start",
"publishing",
"MySQL",
"row",
"-",
"based",
"binlog",
"events",
"to",
"blinker",
"signals"
] | d61ab5962345377e142a225b16f731ab4196fc26 | https://github.com/tarzanjw/python-mysql-binlog-to-blinker/blob/d61ab5962345377e142a225b16f731ab4196fc26/mysqlbinlog2blinker/__init__.py#L18-L53 |
50,704 | chrisspen/webarticle2text | webarticle2text/webarticle2text.py | extractFromHTML | def extractFromHTML(html, blur=5):
"""
Extracts text from HTML content.
"""
#html = html.encode('utf-8', errors='ignore')
try:
html = unicode(html, errors='ignore')
except TypeError:
pass
assert isinstance(html, unicode)
# Create memory file.
_file = StringIO()
... | python | def extractFromHTML(html, blur=5):
"""
Extracts text from HTML content.
"""
#html = html.encode('utf-8', errors='ignore')
try:
html = unicode(html, errors='ignore')
except TypeError:
pass
assert isinstance(html, unicode)
# Create memory file.
_file = StringIO()
... | [
"def",
"extractFromHTML",
"(",
"html",
",",
"blur",
"=",
"5",
")",
":",
"#html = html.encode('utf-8', errors='ignore')",
"try",
":",
"html",
"=",
"unicode",
"(",
"html",
",",
"errors",
"=",
"'ignore'",
")",
"except",
"TypeError",
":",
"pass",
"assert",
"isinst... | Extracts text from HTML content. | [
"Extracts",
"text",
"from",
"HTML",
"content",
"."
] | 3c88e948e31aedf1eccfea2106e5848d224771eb | https://github.com/chrisspen/webarticle2text/blob/3c88e948e31aedf1eccfea2106e5848d224771eb/webarticle2text/webarticle2text.py#L300-L335 |
50,705 | chrisspen/webarticle2text | webarticle2text/webarticle2text.py | tidyHTML | def tidyHTML(dirtyHTML):
"""
Runs an arbitrary HTML string through Tidy.
"""
try:
from tidylib import tidy_document
except ImportError as e:
raise ImportError(("%s\nYou need to install pytidylib.\n" +
"e.g. sudo pip install pytidylib") % e)
options = {
'outpu... | python | def tidyHTML(dirtyHTML):
"""
Runs an arbitrary HTML string through Tidy.
"""
try:
from tidylib import tidy_document
except ImportError as e:
raise ImportError(("%s\nYou need to install pytidylib.\n" +
"e.g. sudo pip install pytidylib") % e)
options = {
'outpu... | [
"def",
"tidyHTML",
"(",
"dirtyHTML",
")",
":",
"try",
":",
"from",
"tidylib",
"import",
"tidy_document",
"except",
"ImportError",
"as",
"e",
":",
"raise",
"ImportError",
"(",
"(",
"\"%s\\nYou need to install pytidylib.\\n\"",
"+",
"\"e.g. sudo pip install pytidylib\"",
... | Runs an arbitrary HTML string through Tidy. | [
"Runs",
"an",
"arbitrary",
"HTML",
"string",
"through",
"Tidy",
"."
] | 3c88e948e31aedf1eccfea2106e5848d224771eb | https://github.com/chrisspen/webarticle2text/blob/3c88e948e31aedf1eccfea2106e5848d224771eb/webarticle2text/webarticle2text.py#L337-L355 |
50,706 | chrisspen/webarticle2text | webarticle2text/webarticle2text.py | generate_key | def generate_key(s, pattern="%s.txt"):
"""
Generates the cache key for the given string using the content in pattern
to format the output string
"""
h = hashlib.sha1()
#h.update(s)
h.update(s.encode('utf-8'))
return pattern % h.hexdigest() | python | def generate_key(s, pattern="%s.txt"):
"""
Generates the cache key for the given string using the content in pattern
to format the output string
"""
h = hashlib.sha1()
#h.update(s)
h.update(s.encode('utf-8'))
return pattern % h.hexdigest() | [
"def",
"generate_key",
"(",
"s",
",",
"pattern",
"=",
"\"%s.txt\"",
")",
":",
"h",
"=",
"hashlib",
".",
"sha1",
"(",
")",
"#h.update(s)",
"h",
".",
"update",
"(",
"s",
".",
"encode",
"(",
"'utf-8'",
")",
")",
"return",
"pattern",
"%",
"h",
".",
"he... | Generates the cache key for the given string using the content in pattern
to format the output string | [
"Generates",
"the",
"cache",
"key",
"for",
"the",
"given",
"string",
"using",
"the",
"content",
"in",
"pattern",
"to",
"format",
"the",
"output",
"string"
] | 3c88e948e31aedf1eccfea2106e5848d224771eb | https://github.com/chrisspen/webarticle2text/blob/3c88e948e31aedf1eccfea2106e5848d224771eb/webarticle2text/webarticle2text.py#L357-L365 |
50,707 | chrisspen/webarticle2text | webarticle2text/webarticle2text.py | cache_get | def cache_get(cache_dir, cache_key, default=None):
"""
Returns the content of a cache item or the given default
"""
filename = os.path.join(cache_dir, cache_key)
if os.path.isfile(filename):
with open(filename, 'r') as f:
return f.read()
return default | python | def cache_get(cache_dir, cache_key, default=None):
"""
Returns the content of a cache item or the given default
"""
filename = os.path.join(cache_dir, cache_key)
if os.path.isfile(filename):
with open(filename, 'r') as f:
return f.read()
return default | [
"def",
"cache_get",
"(",
"cache_dir",
",",
"cache_key",
",",
"default",
"=",
"None",
")",
":",
"filename",
"=",
"os",
".",
"path",
".",
"join",
"(",
"cache_dir",
",",
"cache_key",
")",
"if",
"os",
".",
"path",
".",
"isfile",
"(",
"filename",
")",
":"... | Returns the content of a cache item or the given default | [
"Returns",
"the",
"content",
"of",
"a",
"cache",
"item",
"or",
"the",
"given",
"default"
] | 3c88e948e31aedf1eccfea2106e5848d224771eb | https://github.com/chrisspen/webarticle2text/blob/3c88e948e31aedf1eccfea2106e5848d224771eb/webarticle2text/webarticle2text.py#L367-L377 |
50,708 | chrisspen/webarticle2text | webarticle2text/webarticle2text.py | cache_set | def cache_set(cache_dir, cache_key, content):
"""
Creates a new cache file in the cache directory
"""
filename = os.path.join(cache_dir, cache_key)
with open(filename, 'w') as f:
f.write(content) | python | def cache_set(cache_dir, cache_key, content):
"""
Creates a new cache file in the cache directory
"""
filename = os.path.join(cache_dir, cache_key)
with open(filename, 'w') as f:
f.write(content) | [
"def",
"cache_set",
"(",
"cache_dir",
",",
"cache_key",
",",
"content",
")",
":",
"filename",
"=",
"os",
".",
"path",
".",
"join",
"(",
"cache_dir",
",",
"cache_key",
")",
"with",
"open",
"(",
"filename",
",",
"'w'",
")",
"as",
"f",
":",
"f",
".",
... | Creates a new cache file in the cache directory | [
"Creates",
"a",
"new",
"cache",
"file",
"in",
"the",
"cache",
"directory"
] | 3c88e948e31aedf1eccfea2106e5848d224771eb | https://github.com/chrisspen/webarticle2text/blob/3c88e948e31aedf1eccfea2106e5848d224771eb/webarticle2text/webarticle2text.py#L379-L386 |
50,709 | chrisspen/webarticle2text | webarticle2text/webarticle2text.py | cache_info | def cache_info(cache_dir, cache_key):
"""
Returns the cache files mtime or 0 if it does not exists
"""
filename = os.path.join(cache_dir, cache_key)
return os.path.getmtime(filename) if os.path.exists(filename) else 0 | python | def cache_info(cache_dir, cache_key):
"""
Returns the cache files mtime or 0 if it does not exists
"""
filename = os.path.join(cache_dir, cache_key)
return os.path.getmtime(filename) if os.path.exists(filename) else 0 | [
"def",
"cache_info",
"(",
"cache_dir",
",",
"cache_key",
")",
":",
"filename",
"=",
"os",
".",
"path",
".",
"join",
"(",
"cache_dir",
",",
"cache_key",
")",
"return",
"os",
".",
"path",
".",
"getmtime",
"(",
"filename",
")",
"if",
"os",
".",
"path",
... | Returns the cache files mtime or 0 if it does not exists | [
"Returns",
"the",
"cache",
"files",
"mtime",
"or",
"0",
"if",
"it",
"does",
"not",
"exists"
] | 3c88e948e31aedf1eccfea2106e5848d224771eb | https://github.com/chrisspen/webarticle2text/blob/3c88e948e31aedf1eccfea2106e5848d224771eb/webarticle2text/webarticle2text.py#L388-L393 |
50,710 | chrisspen/webarticle2text | webarticle2text/webarticle2text.py | fetch | def fetch(url, timeout=5, userAgent=None, only_mime_types=None):
"""
Retrieves the raw content of the URL.
"""
headers = {}
if userAgent:
headers['User-agent'] = str(userAgent)
else:
headers['User-agent'] = ua.random
#request = Request(url=url, headers=headers)
#response... | python | def fetch(url, timeout=5, userAgent=None, only_mime_types=None):
"""
Retrieves the raw content of the URL.
"""
headers = {}
if userAgent:
headers['User-agent'] = str(userAgent)
else:
headers['User-agent'] = ua.random
#request = Request(url=url, headers=headers)
#response... | [
"def",
"fetch",
"(",
"url",
",",
"timeout",
"=",
"5",
",",
"userAgent",
"=",
"None",
",",
"only_mime_types",
"=",
"None",
")",
":",
"headers",
"=",
"{",
"}",
"if",
"userAgent",
":",
"headers",
"[",
"'User-agent'",
"]",
"=",
"str",
"(",
"userAgent",
"... | Retrieves the raw content of the URL. | [
"Retrieves",
"the",
"raw",
"content",
"of",
"the",
"URL",
"."
] | 3c88e948e31aedf1eccfea2106e5848d224771eb | https://github.com/chrisspen/webarticle2text/blob/3c88e948e31aedf1eccfea2106e5848d224771eb/webarticle2text/webarticle2text.py#L395-L431 |
50,711 | chrisspen/webarticle2text | webarticle2text/webarticle2text.py | extractFromURL | def extractFromURL(url,
cache=False,
cacheDir='_cache',
verbose=False,
encoding=None,
filters=None,
userAgent=None,
timeout=5,
blur=5,
ignore_robotstxt=False,
only_mime_types=None,
raw=False):
"""
Extracts text from a URL.
Parameters:
url := string
Re... | python | def extractFromURL(url,
cache=False,
cacheDir='_cache',
verbose=False,
encoding=None,
filters=None,
userAgent=None,
timeout=5,
blur=5,
ignore_robotstxt=False,
only_mime_types=None,
raw=False):
"""
Extracts text from a URL.
Parameters:
url := string
Re... | [
"def",
"extractFromURL",
"(",
"url",
",",
"cache",
"=",
"False",
",",
"cacheDir",
"=",
"'_cache'",
",",
"verbose",
"=",
"False",
",",
"encoding",
"=",
"None",
",",
"filters",
"=",
"None",
",",
"userAgent",
"=",
"None",
",",
"timeout",
"=",
"5",
",",
... | Extracts text from a URL.
Parameters:
url := string
Remote URL or local filename where HTML will be read.
cache := bool
True=store and retrieve url from cache
False=always retrieve url from the web
cacheDir := str
Directory where cached url contents will be stored.
v... | [
"Extracts",
"text",
"from",
"a",
"URL",
"."
] | 3c88e948e31aedf1eccfea2106e5848d224771eb | https://github.com/chrisspen/webarticle2text/blob/3c88e948e31aedf1eccfea2106e5848d224771eb/webarticle2text/webarticle2text.py#L477-L595 |
50,712 | mlenzen/collections-extended | collections_extended/bags.py | _basebag.copy | def copy(self):
"""Create a shallow copy of self.
This runs in O(len(self.num_unique_elements()))
"""
out = self._from_iterable(None)
out._dict = self._dict.copy()
out._size = self._size
return out | python | def copy(self):
"""Create a shallow copy of self.
This runs in O(len(self.num_unique_elements()))
"""
out = self._from_iterable(None)
out._dict = self._dict.copy()
out._size = self._size
return out | [
"def",
"copy",
"(",
"self",
")",
":",
"out",
"=",
"self",
".",
"_from_iterable",
"(",
"None",
")",
"out",
".",
"_dict",
"=",
"self",
".",
"_dict",
".",
"copy",
"(",
")",
"out",
".",
"_size",
"=",
"self",
".",
"_size",
"return",
"out"
] | Create a shallow copy of self.
This runs in O(len(self.num_unique_elements())) | [
"Create",
"a",
"shallow",
"copy",
"of",
"self",
"."
] | ee9e86f6bbef442dbebcb3a5970642c5c969e2cf | https://github.com/mlenzen/collections-extended/blob/ee9e86f6bbef442dbebcb3a5970642c5c969e2cf/collections_extended/bags.py#L105-L113 |
50,713 | mlenzen/collections-extended | collections_extended/bags.py | _basebag.nlargest | def nlargest(self, n=None):
"""List the n most common elements and their counts.
List is from the most
common to the least. If n is None, the list all element counts.
Run time should be O(m log m) where m is len(self)
Args:
n (int): The number of elements to return
"""
if n is None:
return sorted... | python | def nlargest(self, n=None):
"""List the n most common elements and their counts.
List is from the most
common to the least. If n is None, the list all element counts.
Run time should be O(m log m) where m is len(self)
Args:
n (int): The number of elements to return
"""
if n is None:
return sorted... | [
"def",
"nlargest",
"(",
"self",
",",
"n",
"=",
"None",
")",
":",
"if",
"n",
"is",
"None",
":",
"return",
"sorted",
"(",
"self",
".",
"counts",
"(",
")",
",",
"key",
"=",
"itemgetter",
"(",
"1",
")",
",",
"reverse",
"=",
"True",
")",
"else",
":"... | List the n most common elements and their counts.
List is from the most
common to the least. If n is None, the list all element counts.
Run time should be O(m log m) where m is len(self)
Args:
n (int): The number of elements to return | [
"List",
"the",
"n",
"most",
"common",
"elements",
"and",
"their",
"counts",
"."
] | ee9e86f6bbef442dbebcb3a5970642c5c969e2cf | https://github.com/mlenzen/collections-extended/blob/ee9e86f6bbef442dbebcb3a5970642c5c969e2cf/collections_extended/bags.py#L171-L184 |
50,714 | mlenzen/collections-extended | collections_extended/bags.py | _basebag.from_mapping | def from_mapping(cls, mapping):
"""Create a bag from a dict of elem->count.
Each key in the dict is added if the value is > 0.
Raises:
ValueError: If any count is < 0.
"""
out = cls()
for elem, count in mapping.items():
out._set_count(elem, count)
return out | python | def from_mapping(cls, mapping):
"""Create a bag from a dict of elem->count.
Each key in the dict is added if the value is > 0.
Raises:
ValueError: If any count is < 0.
"""
out = cls()
for elem, count in mapping.items():
out._set_count(elem, count)
return out | [
"def",
"from_mapping",
"(",
"cls",
",",
"mapping",
")",
":",
"out",
"=",
"cls",
"(",
")",
"for",
"elem",
",",
"count",
"in",
"mapping",
".",
"items",
"(",
")",
":",
"out",
".",
"_set_count",
"(",
"elem",
",",
"count",
")",
"return",
"out"
] | Create a bag from a dict of elem->count.
Each key in the dict is added if the value is > 0.
Raises:
ValueError: If any count is < 0. | [
"Create",
"a",
"bag",
"from",
"a",
"dict",
"of",
"elem",
"-",
">",
"count",
"."
] | ee9e86f6bbef442dbebcb3a5970642c5c969e2cf | https://github.com/mlenzen/collections-extended/blob/ee9e86f6bbef442dbebcb3a5970642c5c969e2cf/collections_extended/bags.py#L194-L205 |
50,715 | mlenzen/collections-extended | collections_extended/bags.py | _basebag.is_subset | def is_subset(self, other):
"""Check that every element in self has a count <= in other.
Args:
other (Set)
"""
if isinstance(other, _basebag):
for elem, count in self.counts():
if not count <= other.count(elem):
return False
else:
for elem in self:
if self.count(elem) > 1 or elem not in... | python | def is_subset(self, other):
"""Check that every element in self has a count <= in other.
Args:
other (Set)
"""
if isinstance(other, _basebag):
for elem, count in self.counts():
if not count <= other.count(elem):
return False
else:
for elem in self:
if self.count(elem) > 1 or elem not in... | [
"def",
"is_subset",
"(",
"self",
",",
"other",
")",
":",
"if",
"isinstance",
"(",
"other",
",",
"_basebag",
")",
":",
"for",
"elem",
",",
"count",
"in",
"self",
".",
"counts",
"(",
")",
":",
"if",
"not",
"count",
"<=",
"other",
".",
"count",
"(",
... | Check that every element in self has a count <= in other.
Args:
other (Set) | [
"Check",
"that",
"every",
"element",
"in",
"self",
"has",
"a",
"count",
"<",
"=",
"in",
"other",
"."
] | ee9e86f6bbef442dbebcb3a5970642c5c969e2cf | https://github.com/mlenzen/collections-extended/blob/ee9e86f6bbef442dbebcb3a5970642c5c969e2cf/collections_extended/bags.py#L238-L252 |
50,716 | mlenzen/collections-extended | collections_extended/bags.py | _basebag._iadd | def _iadd(self, other):
"""Add all of the elements of other to self.
if isinstance(it, _basebag):
This runs in O(it.num_unique_elements())
else:
This runs in O(len(it))
"""
if isinstance(other, _basebag):
for elem, count in other.counts():
self._increment_count(elem, count)
else:
for elem... | python | def _iadd(self, other):
"""Add all of the elements of other to self.
if isinstance(it, _basebag):
This runs in O(it.num_unique_elements())
else:
This runs in O(len(it))
"""
if isinstance(other, _basebag):
for elem, count in other.counts():
self._increment_count(elem, count)
else:
for elem... | [
"def",
"_iadd",
"(",
"self",
",",
"other",
")",
":",
"if",
"isinstance",
"(",
"other",
",",
"_basebag",
")",
":",
"for",
"elem",
",",
"count",
"in",
"other",
".",
"counts",
"(",
")",
":",
"self",
".",
"_increment_count",
"(",
"elem",
",",
"count",
... | Add all of the elements of other to self.
if isinstance(it, _basebag):
This runs in O(it.num_unique_elements())
else:
This runs in O(len(it)) | [
"Add",
"all",
"of",
"the",
"elements",
"of",
"other",
"to",
"self",
"."
] | ee9e86f6bbef442dbebcb3a5970642c5c969e2cf | https://github.com/mlenzen/collections-extended/blob/ee9e86f6bbef442dbebcb3a5970642c5c969e2cf/collections_extended/bags.py#L307-L321 |
50,717 | mlenzen/collections-extended | collections_extended/bags.py | _basebag._iand | def _iand(self, other):
"""Set multiplicity of each element to the minimum of the two collections.
if isinstance(other, _basebag):
This runs in O(other.num_unique_elements())
else:
This runs in O(len(other))
"""
# TODO do we have to create a bag from the other first?
if not isinstance(other, _basebag... | python | def _iand(self, other):
"""Set multiplicity of each element to the minimum of the two collections.
if isinstance(other, _basebag):
This runs in O(other.num_unique_elements())
else:
This runs in O(len(other))
"""
# TODO do we have to create a bag from the other first?
if not isinstance(other, _basebag... | [
"def",
"_iand",
"(",
"self",
",",
"other",
")",
":",
"# TODO do we have to create a bag from the other first?",
"if",
"not",
"isinstance",
"(",
"other",
",",
"_basebag",
")",
":",
"other",
"=",
"self",
".",
"_from_iterable",
"(",
"other",
")",
"for",
"elem",
"... | Set multiplicity of each element to the minimum of the two collections.
if isinstance(other, _basebag):
This runs in O(other.num_unique_elements())
else:
This runs in O(len(other)) | [
"Set",
"multiplicity",
"of",
"each",
"element",
"to",
"the",
"minimum",
"of",
"the",
"two",
"collections",
"."
] | ee9e86f6bbef442dbebcb3a5970642c5c969e2cf | https://github.com/mlenzen/collections-extended/blob/ee9e86f6bbef442dbebcb3a5970642c5c969e2cf/collections_extended/bags.py#L323-L338 |
50,718 | mlenzen/collections-extended | collections_extended/bags.py | _basebag._ior | def _ior(self, other):
"""Set multiplicity of each element to the maximum of the two collections.
if isinstance(other, _basebag):
This runs in O(other.num_unique_elements())
else:
This runs in O(len(other))
"""
# TODO do we have to create a bag from the other first?
if not isinstance(other, _basebag)... | python | def _ior(self, other):
"""Set multiplicity of each element to the maximum of the two collections.
if isinstance(other, _basebag):
This runs in O(other.num_unique_elements())
else:
This runs in O(len(other))
"""
# TODO do we have to create a bag from the other first?
if not isinstance(other, _basebag)... | [
"def",
"_ior",
"(",
"self",
",",
"other",
")",
":",
"# TODO do we have to create a bag from the other first?",
"if",
"not",
"isinstance",
"(",
"other",
",",
"_basebag",
")",
":",
"other",
"=",
"self",
".",
"_from_iterable",
"(",
"other",
")",
"for",
"elem",
",... | Set multiplicity of each element to the maximum of the two collections.
if isinstance(other, _basebag):
This runs in O(other.num_unique_elements())
else:
This runs in O(len(other)) | [
"Set",
"multiplicity",
"of",
"each",
"element",
"to",
"the",
"maximum",
"of",
"the",
"two",
"collections",
"."
] | ee9e86f6bbef442dbebcb3a5970642c5c969e2cf | https://github.com/mlenzen/collections-extended/blob/ee9e86f6bbef442dbebcb3a5970642c5c969e2cf/collections_extended/bags.py#L340-L355 |
50,719 | mlenzen/collections-extended | collections_extended/bags.py | _basebag._ixor | def _ixor(self, other):
"""Set self to the symmetric difference between the sets.
if isinstance(other, _basebag):
This runs in O(other.num_unique_elements())
else:
This runs in O(len(other))
"""
if isinstance(other, _basebag):
for elem, other_count in other.counts():
count = abs(self.count(elem)... | python | def _ixor(self, other):
"""Set self to the symmetric difference between the sets.
if isinstance(other, _basebag):
This runs in O(other.num_unique_elements())
else:
This runs in O(len(other))
"""
if isinstance(other, _basebag):
for elem, other_count in other.counts():
count = abs(self.count(elem)... | [
"def",
"_ixor",
"(",
"self",
",",
"other",
")",
":",
"if",
"isinstance",
"(",
"other",
",",
"_basebag",
")",
":",
"for",
"elem",
",",
"other_count",
"in",
"other",
".",
"counts",
"(",
")",
":",
"count",
"=",
"abs",
"(",
"self",
".",
"count",
"(",
... | Set self to the symmetric difference between the sets.
if isinstance(other, _basebag):
This runs in O(other.num_unique_elements())
else:
This runs in O(len(other)) | [
"Set",
"self",
"to",
"the",
"symmetric",
"difference",
"between",
"the",
"sets",
"."
] | ee9e86f6bbef442dbebcb3a5970642c5c969e2cf | https://github.com/mlenzen/collections-extended/blob/ee9e86f6bbef442dbebcb3a5970642c5c969e2cf/collections_extended/bags.py#L357-L379 |
50,720 | mlenzen/collections-extended | collections_extended/bags.py | _basebag._isub | def _isub(self, other):
"""Discard the elements of other from self.
if isinstance(it, _basebag):
This runs in O(it.num_unique_elements())
else:
This runs in O(len(it))
"""
if isinstance(other, _basebag):
for elem, other_count in other.counts():
try:
self._increment_count(elem, -other_count)... | python | def _isub(self, other):
"""Discard the elements of other from self.
if isinstance(it, _basebag):
This runs in O(it.num_unique_elements())
else:
This runs in O(len(it))
"""
if isinstance(other, _basebag):
for elem, other_count in other.counts():
try:
self._increment_count(elem, -other_count)... | [
"def",
"_isub",
"(",
"self",
",",
"other",
")",
":",
"if",
"isinstance",
"(",
"other",
",",
"_basebag",
")",
":",
"for",
"elem",
",",
"other_count",
"in",
"other",
".",
"counts",
"(",
")",
":",
"try",
":",
"self",
".",
"_increment_count",
"(",
"elem"... | Discard the elements of other from self.
if isinstance(it, _basebag):
This runs in O(it.num_unique_elements())
else:
This runs in O(len(it)) | [
"Discard",
"the",
"elements",
"of",
"other",
"from",
"self",
"."
] | ee9e86f6bbef442dbebcb3a5970642c5c969e2cf | https://github.com/mlenzen/collections-extended/blob/ee9e86f6bbef442dbebcb3a5970642c5c969e2cf/collections_extended/bags.py#L381-L401 |
50,721 | mlenzen/collections-extended | collections_extended/bags.py | bag.remove_all | def remove_all(self, other):
"""Remove all of the elems from other.
Raises a ValueError if the multiplicity of any elem in other is greater
than in self.
"""
if not self.is_superset(other):
raise ValueError('Passed collection is not a subset of this bag')
self.discard_all(other) | python | def remove_all(self, other):
"""Remove all of the elems from other.
Raises a ValueError if the multiplicity of any elem in other is greater
than in self.
"""
if not self.is_superset(other):
raise ValueError('Passed collection is not a subset of this bag')
self.discard_all(other) | [
"def",
"remove_all",
"(",
"self",
",",
"other",
")",
":",
"if",
"not",
"self",
".",
"is_superset",
"(",
"other",
")",
":",
"raise",
"ValueError",
"(",
"'Passed collection is not a subset of this bag'",
")",
"self",
".",
"discard_all",
"(",
"other",
")"
] | Remove all of the elems from other.
Raises a ValueError if the multiplicity of any elem in other is greater
than in self. | [
"Remove",
"all",
"of",
"the",
"elems",
"from",
"other",
"."
] | ee9e86f6bbef442dbebcb3a5970642c5c969e2cf | https://github.com/mlenzen/collections-extended/blob/ee9e86f6bbef442dbebcb3a5970642c5c969e2cf/collections_extended/bags.py#L546-L554 |
50,722 | wwwtyro/python-ovrsdk | ovrsdk/linux/wrapper.py | LibraryLoader.load | def load(self,path):
"""Given a path to a library, load it."""
try:
# Darwin requires dlopen to be called with mode RTLD_GLOBAL instead
# of the default RTLD_LOCAL. Without this, you end up with
# libraries not being loadable, resulting in "Symbol not found"
... | python | def load(self,path):
"""Given a path to a library, load it."""
try:
# Darwin requires dlopen to be called with mode RTLD_GLOBAL instead
# of the default RTLD_LOCAL. Without this, you end up with
# libraries not being loadable, resulting in "Symbol not found"
... | [
"def",
"load",
"(",
"self",
",",
"path",
")",
":",
"try",
":",
"# Darwin requires dlopen to be called with mode RTLD_GLOBAL instead",
"# of the default RTLD_LOCAL. Without this, you end up with",
"# libraries not being loadable, resulting in \"Symbol not found\"",
"# errors",
"if",
"s... | Given a path to a library, load it. | [
"Given",
"a",
"path",
"to",
"a",
"library",
"load",
"it",
"."
] | ba56196e32b6bf130ec5388bf52add7acb19c458 | https://github.com/wwwtyro/python-ovrsdk/blob/ba56196e32b6bf130ec5388bf52add7acb19c458/ovrsdk/linux/wrapper.py#L362-L374 |
50,723 | tarzanjw/python-mysql-binlog-to-blinker | setup.py | git_ls_files | def git_ls_files(*cmd_args):
"""Run ``git ls-files`` in the top-level project directory. Arguments go
directly to execution call.
:return: set of file names
:rtype: :class:`set`
"""
cmd = ['git', 'ls-files']
cmd.extend(cmd_args)
return set(subprocess.check_output(cmd).splitlines()) | python | def git_ls_files(*cmd_args):
"""Run ``git ls-files`` in the top-level project directory. Arguments go
directly to execution call.
:return: set of file names
:rtype: :class:`set`
"""
cmd = ['git', 'ls-files']
cmd.extend(cmd_args)
return set(subprocess.check_output(cmd).splitlines()) | [
"def",
"git_ls_files",
"(",
"*",
"cmd_args",
")",
":",
"cmd",
"=",
"[",
"'git'",
",",
"'ls-files'",
"]",
"cmd",
".",
"extend",
"(",
"cmd_args",
")",
"return",
"set",
"(",
"subprocess",
".",
"check_output",
"(",
"cmd",
")",
".",
"splitlines",
"(",
")",
... | Run ``git ls-files`` in the top-level project directory. Arguments go
directly to execution call.
:return: set of file names
:rtype: :class:`set` | [
"Run",
"git",
"ls",
"-",
"files",
"in",
"the",
"top",
"-",
"level",
"project",
"directory",
".",
"Arguments",
"go",
"directly",
"to",
"execution",
"call",
"."
] | d61ab5962345377e142a225b16f731ab4196fc26 | https://github.com/tarzanjw/python-mysql-binlog-to-blinker/blob/d61ab5962345377e142a225b16f731ab4196fc26/setup.py#L99-L108 |
50,724 | tarzanjw/python-mysql-binlog-to-blinker | setup.py | _lint | def _lint():
"""Run lint and return an exit code."""
# Flake8 doesn't have an easy way to run checks using a Python function, so
# just fork off another process to do it.
# Python 3 compat:
# - The result of subprocess call outputs are byte strings, meaning we need
# to pass a byte string to ... | python | def _lint():
"""Run lint and return an exit code."""
# Flake8 doesn't have an easy way to run checks using a Python function, so
# just fork off another process to do it.
# Python 3 compat:
# - The result of subprocess call outputs are byte strings, meaning we need
# to pass a byte string to ... | [
"def",
"_lint",
"(",
")",
":",
"# Flake8 doesn't have an easy way to run checks using a Python function, so",
"# just fork off another process to do it.",
"# Python 3 compat:",
"# - The result of subprocess call outputs are byte strings, meaning we need",
"# to pass a byte string to endswith.",
... | Run lint and return an exit code. | [
"Run",
"lint",
"and",
"return",
"an",
"exit",
"code",
"."
] | d61ab5962345377e142a225b16f731ab4196fc26 | https://github.com/tarzanjw/python-mysql-binlog-to-blinker/blob/d61ab5962345377e142a225b16f731ab4196fc26/setup.py#L150-L164 |
50,725 | lord63/v2ex_daily_mission | v2ex_daily_mission/v2ex.py | V2ex.login | def login(self):
"""Login v2ex, otherwise we can't complete the mission."""
response = self.session.get(self.signin_url, verify=False)
user_param, password_param = self._get_hashed_params(response.text)
login_data = {
user_param: self.config['username'],
password_... | python | def login(self):
"""Login v2ex, otherwise we can't complete the mission."""
response = self.session.get(self.signin_url, verify=False)
user_param, password_param = self._get_hashed_params(response.text)
login_data = {
user_param: self.config['username'],
password_... | [
"def",
"login",
"(",
"self",
")",
":",
"response",
"=",
"self",
".",
"session",
".",
"get",
"(",
"self",
".",
"signin_url",
",",
"verify",
"=",
"False",
")",
"user_param",
",",
"password_param",
"=",
"self",
".",
"_get_hashed_params",
"(",
"response",
".... | Login v2ex, otherwise we can't complete the mission. | [
"Login",
"v2ex",
"otherwise",
"we",
"can",
"t",
"complete",
"the",
"mission",
"."
] | 499901dd540dca68c3889d88c21c2594f25f27ec | https://github.com/lord63/v2ex_daily_mission/blob/499901dd540dca68c3889d88c21c2594f25f27ec/v2ex_daily_mission/v2ex.py#L36-L47 |
50,726 | lord63/v2ex_daily_mission | v2ex_daily_mission/v2ex.py | V2ex._get_once | def _get_once(self, page_text):
"""Get once which will be used when you login."""
soup = BeautifulSoup(page_text, 'html.parser')
once = soup.find('input', attrs={'name': 'once'})['value']
return once | python | def _get_once(self, page_text):
"""Get once which will be used when you login."""
soup = BeautifulSoup(page_text, 'html.parser')
once = soup.find('input', attrs={'name': 'once'})['value']
return once | [
"def",
"_get_once",
"(",
"self",
",",
"page_text",
")",
":",
"soup",
"=",
"BeautifulSoup",
"(",
"page_text",
",",
"'html.parser'",
")",
"once",
"=",
"soup",
".",
"find",
"(",
"'input'",
",",
"attrs",
"=",
"{",
"'name'",
":",
"'once'",
"}",
")",
"[",
... | Get once which will be used when you login. | [
"Get",
"once",
"which",
"will",
"be",
"used",
"when",
"you",
"login",
"."
] | 499901dd540dca68c3889d88c21c2594f25f27ec | https://github.com/lord63/v2ex_daily_mission/blob/499901dd540dca68c3889d88c21c2594f25f27ec/v2ex_daily_mission/v2ex.py#L54-L58 |
50,727 | lord63/v2ex_daily_mission | v2ex_daily_mission/v2ex.py | V2ex.get_money | def get_money(self):
"""Complete daily mission then get the money."""
response = self.session.get(self.mission_url, verify=False)
soup = BeautifulSoup(response.text, 'html.parser')
onclick = soup.find('input', class_='super normal button')['onclick']
url = onclick.split('=', 1)[1... | python | def get_money(self):
"""Complete daily mission then get the money."""
response = self.session.get(self.mission_url, verify=False)
soup = BeautifulSoup(response.text, 'html.parser')
onclick = soup.find('input', class_='super normal button')['onclick']
url = onclick.split('=', 1)[1... | [
"def",
"get_money",
"(",
"self",
")",
":",
"response",
"=",
"self",
".",
"session",
".",
"get",
"(",
"self",
".",
"mission_url",
",",
"verify",
"=",
"False",
")",
"soup",
"=",
"BeautifulSoup",
"(",
"response",
".",
"text",
",",
"'html.parser'",
")",
"o... | Complete daily mission then get the money. | [
"Complete",
"daily",
"mission",
"then",
"get",
"the",
"money",
"."
] | 499901dd540dca68c3889d88c21c2594f25f27ec | https://github.com/lord63/v2ex_daily_mission/blob/499901dd540dca68c3889d88c21c2594f25f27ec/v2ex_daily_mission/v2ex.py#L60-L75 |
50,728 | lord63/v2ex_daily_mission | v2ex_daily_mission/v2ex.py | V2ex._get_balance | def _get_balance(self):
"""Get to know how much you totally have and how much you get today."""
response = self.session.get(self.balance_url, verify=False)
soup = BeautifulSoup(response.text, 'html.parser')
first_line = soup.select(
"table.data tr:nth-of-type(2)")[0].text.str... | python | def _get_balance(self):
"""Get to know how much you totally have and how much you get today."""
response = self.session.get(self.balance_url, verify=False)
soup = BeautifulSoup(response.text, 'html.parser')
first_line = soup.select(
"table.data tr:nth-of-type(2)")[0].text.str... | [
"def",
"_get_balance",
"(",
"self",
")",
":",
"response",
"=",
"self",
".",
"session",
".",
"get",
"(",
"self",
".",
"balance_url",
",",
"verify",
"=",
"False",
")",
"soup",
"=",
"BeautifulSoup",
"(",
"response",
".",
"text",
",",
"'html.parser'",
")",
... | Get to know how much you totally have and how much you get today. | [
"Get",
"to",
"know",
"how",
"much",
"you",
"totally",
"have",
"and",
"how",
"much",
"you",
"get",
"today",
"."
] | 499901dd540dca68c3889d88c21c2594f25f27ec | https://github.com/lord63/v2ex_daily_mission/blob/499901dd540dca68c3889d88c21c2594f25f27ec/v2ex_daily_mission/v2ex.py#L77-L86 |
50,729 | lord63/v2ex_daily_mission | v2ex_daily_mission/v2ex.py | V2ex.get_last | def get_last(self):
"""Get to know how long you have kept signing in."""
response = self.session.get(self.mission_url, verify=False)
soup = BeautifulSoup(response.text, 'html.parser')
last = soup.select('#Main div')[-1].text
return last | python | def get_last(self):
"""Get to know how long you have kept signing in."""
response = self.session.get(self.mission_url, verify=False)
soup = BeautifulSoup(response.text, 'html.parser')
last = soup.select('#Main div')[-1].text
return last | [
"def",
"get_last",
"(",
"self",
")",
":",
"response",
"=",
"self",
".",
"session",
".",
"get",
"(",
"self",
".",
"mission_url",
",",
"verify",
"=",
"False",
")",
"soup",
"=",
"BeautifulSoup",
"(",
"response",
".",
"text",
",",
"'html.parser'",
")",
"la... | Get to know how long you have kept signing in. | [
"Get",
"to",
"know",
"how",
"long",
"you",
"have",
"kept",
"signing",
"in",
"."
] | 499901dd540dca68c3889d88c21c2594f25f27ec | https://github.com/lord63/v2ex_daily_mission/blob/499901dd540dca68c3889d88c21c2594f25f27ec/v2ex_daily_mission/v2ex.py#L88-L93 |
50,730 | tarzanjw/python-mysql-binlog-to-blinker | mysqlbinlog2blinker/binlog_pos_memory.py | FileBasedBinlogPosMemory._save_file_and_pos | def _save_file_and_pos(self):
""" Save current position into file
"""
if not self._pos_changed:
return
with open(self.pos_storage_filename, 'w+') as f:
_pos = '%s:%s' % (self._log_file, self._log_pos)
_logger.debug('Saving position %s to file %s'
... | python | def _save_file_and_pos(self):
""" Save current position into file
"""
if not self._pos_changed:
return
with open(self.pos_storage_filename, 'w+') as f:
_pos = '%s:%s' % (self._log_file, self._log_pos)
_logger.debug('Saving position %s to file %s'
... | [
"def",
"_save_file_and_pos",
"(",
"self",
")",
":",
"if",
"not",
"self",
".",
"_pos_changed",
":",
"return",
"with",
"open",
"(",
"self",
".",
"pos_storage_filename",
",",
"'w+'",
")",
"as",
"f",
":",
"_pos",
"=",
"'%s:%s'",
"%",
"(",
"self",
".",
"_lo... | Save current position into file | [
"Save",
"current",
"position",
"into",
"file"
] | d61ab5962345377e142a225b16f731ab4196fc26 | https://github.com/tarzanjw/python-mysql-binlog-to-blinker/blob/d61ab5962345377e142a225b16f731ab4196fc26/mysqlbinlog2blinker/binlog_pos_memory.py#L117-L127 |
50,731 | tarzanjw/python-mysql-binlog-to-blinker | mysqlbinlog2blinker/binlog_pos_memory.py | FileBasedBinlogPosMemory._read_file_and_pos | def _read_file_and_pos(self):
""" Read last position from file, store as current position
"""
try:
with open(self.pos_storage_filename, 'r+') as f:
_pos = f.read()
_logger.debug('Got position "%s" from file %s'
% (_pos, se... | python | def _read_file_and_pos(self):
""" Read last position from file, store as current position
"""
try:
with open(self.pos_storage_filename, 'r+') as f:
_pos = f.read()
_logger.debug('Got position "%s" from file %s'
% (_pos, se... | [
"def",
"_read_file_and_pos",
"(",
"self",
")",
":",
"try",
":",
"with",
"open",
"(",
"self",
".",
"pos_storage_filename",
",",
"'r+'",
")",
"as",
"f",
":",
"_pos",
"=",
"f",
".",
"read",
"(",
")",
"_logger",
".",
"debug",
"(",
"'Got position \"%s\" from ... | Read last position from file, store as current position | [
"Read",
"last",
"position",
"from",
"file",
"store",
"as",
"current",
"position"
] | d61ab5962345377e142a225b16f731ab4196fc26 | https://github.com/tarzanjw/python-mysql-binlog-to-blinker/blob/d61ab5962345377e142a225b16f731ab4196fc26/mysqlbinlog2blinker/binlog_pos_memory.py#L129-L149 |
50,732 | mlenzen/collections-extended | collections_extended/setlists.py | _basesetlist.index | def index(self, value, start=0, end=None):
"""Return the index of value between start and end.
By default, the entire setlist is searched.
This runs in O(1)
Args:
value: The value to find the index of
start (int): The index to start searching at (defaults to 0)
end (int): The index to stop searching... | python | def index(self, value, start=0, end=None):
"""Return the index of value between start and end.
By default, the entire setlist is searched.
This runs in O(1)
Args:
value: The value to find the index of
start (int): The index to start searching at (defaults to 0)
end (int): The index to stop searching... | [
"def",
"index",
"(",
"self",
",",
"value",
",",
"start",
"=",
"0",
",",
"end",
"=",
"None",
")",
":",
"try",
":",
"index",
"=",
"self",
".",
"_dict",
"[",
"value",
"]",
"except",
"KeyError",
":",
"raise",
"ValueError",
"else",
":",
"start",
"=",
... | Return the index of value between start and end.
By default, the entire setlist is searched.
This runs in O(1)
Args:
value: The value to find the index of
start (int): The index to start searching at (defaults to 0)
end (int): The index to stop searching at (defaults to the end of the list)
Returns:... | [
"Return",
"the",
"index",
"of",
"value",
"between",
"start",
"and",
"end",
"."
] | ee9e86f6bbef442dbebcb3a5970642c5c969e2cf | https://github.com/mlenzen/collections-extended/blob/ee9e86f6bbef442dbebcb3a5970642c5c969e2cf/collections_extended/setlists.py#L129-L156 |
50,733 | mlenzen/collections-extended | collections_extended/setlists.py | _basesetlist.sub_index | def sub_index(self, sub, start=0, end=None):
"""Return the index of a subsequence.
This runs in O(len(sub))
Args:
sub (Sequence): An Iterable to search for
Returns:
int: The index of the first element of sub
Raises:
ValueError: If sub isn't a subsequence
TypeError: If sub isn't iterable
Index... | python | def sub_index(self, sub, start=0, end=None):
"""Return the index of a subsequence.
This runs in O(len(sub))
Args:
sub (Sequence): An Iterable to search for
Returns:
int: The index of the first element of sub
Raises:
ValueError: If sub isn't a subsequence
TypeError: If sub isn't iterable
Index... | [
"def",
"sub_index",
"(",
"self",
",",
"sub",
",",
"start",
"=",
"0",
",",
"end",
"=",
"None",
")",
":",
"start_index",
"=",
"self",
".",
"index",
"(",
"sub",
"[",
"0",
"]",
",",
"start",
",",
"end",
")",
"end",
"=",
"self",
".",
"_fix_end_index",... | Return the index of a subsequence.
This runs in O(len(sub))
Args:
sub (Sequence): An Iterable to search for
Returns:
int: The index of the first element of sub
Raises:
ValueError: If sub isn't a subsequence
TypeError: If sub isn't iterable
IndexError: If start or end are out of range | [
"Return",
"the",
"index",
"of",
"a",
"subsequence",
"."
] | ee9e86f6bbef442dbebcb3a5970642c5c969e2cf | https://github.com/mlenzen/collections-extended/blob/ee9e86f6bbef442dbebcb3a5970642c5c969e2cf/collections_extended/setlists.py#L233-L254 |
50,734 | mlenzen/collections-extended | collections_extended/setlists.py | setlist.pop | def pop(self, index=-1):
"""Remove and return the item at index."""
value = self._list.pop(index)
del self._dict[value]
return value | python | def pop(self, index=-1):
"""Remove and return the item at index."""
value = self._list.pop(index)
del self._dict[value]
return value | [
"def",
"pop",
"(",
"self",
",",
"index",
"=",
"-",
"1",
")",
":",
"value",
"=",
"self",
".",
"_list",
".",
"pop",
"(",
"index",
")",
"del",
"self",
".",
"_dict",
"[",
"value",
"]",
"return",
"value"
] | Remove and return the item at index. | [
"Remove",
"and",
"return",
"the",
"item",
"at",
"index",
"."
] | ee9e86f6bbef442dbebcb3a5970642c5c969e2cf | https://github.com/mlenzen/collections-extended/blob/ee9e86f6bbef442dbebcb3a5970642c5c969e2cf/collections_extended/setlists.py#L300-L304 |
50,735 | mlenzen/collections-extended | collections_extended/setlists.py | setlist.insert | def insert(self, index, value):
"""Insert value at index.
Args:
index (int): Index to insert value at
value: Value to insert
Raises:
ValueError: If value already in self
IndexError: If start or end are out of range
"""
if value in self:
raise ValueError
index = self._fix_neg_index(index)
s... | python | def insert(self, index, value):
"""Insert value at index.
Args:
index (int): Index to insert value at
value: Value to insert
Raises:
ValueError: If value already in self
IndexError: If start or end are out of range
"""
if value in self:
raise ValueError
index = self._fix_neg_index(index)
s... | [
"def",
"insert",
"(",
"self",
",",
"index",
",",
"value",
")",
":",
"if",
"value",
"in",
"self",
":",
"raise",
"ValueError",
"index",
"=",
"self",
".",
"_fix_neg_index",
"(",
"index",
")",
"self",
".",
"_dict",
"[",
"value",
"]",
"=",
"index",
"for",... | Insert value at index.
Args:
index (int): Index to insert value at
value: Value to insert
Raises:
ValueError: If value already in self
IndexError: If start or end are out of range | [
"Insert",
"value",
"at",
"index",
"."
] | ee9e86f6bbef442dbebcb3a5970642c5c969e2cf | https://github.com/mlenzen/collections-extended/blob/ee9e86f6bbef442dbebcb3a5970642c5c969e2cf/collections_extended/setlists.py#L346-L362 |
50,736 | mlenzen/collections-extended | collections_extended/setlists.py | setlist.remove | def remove(self, value):
"""Remove value from self.
Args:
value: Element to remove from self
Raises:
ValueError: if element is already present
"""
try:
index = self._dict[value]
except KeyError:
raise ValueError('Value "%s" is not present.')
else:
del self[index] | python | def remove(self, value):
"""Remove value from self.
Args:
value: Element to remove from self
Raises:
ValueError: if element is already present
"""
try:
index = self._dict[value]
except KeyError:
raise ValueError('Value "%s" is not present.')
else:
del self[index] | [
"def",
"remove",
"(",
"self",
",",
"value",
")",
":",
"try",
":",
"index",
"=",
"self",
".",
"_dict",
"[",
"value",
"]",
"except",
"KeyError",
":",
"raise",
"ValueError",
"(",
"'Value \"%s\" is not present.'",
")",
"else",
":",
"del",
"self",
"[",
"index... | Remove value from self.
Args:
value: Element to remove from self
Raises:
ValueError: if element is already present | [
"Remove",
"value",
"from",
"self",
"."
] | ee9e86f6bbef442dbebcb3a5970642c5c969e2cf | https://github.com/mlenzen/collections-extended/blob/ee9e86f6bbef442dbebcb3a5970642c5c969e2cf/collections_extended/setlists.py#L402-L415 |
50,737 | mlenzen/collections-extended | collections_extended/setlists.py | setlist.difference_update | def difference_update(self, other):
"""Update self to include only the difference with other."""
other = set(other)
indices_to_delete = set()
for i, elem in enumerate(self):
if elem in other:
indices_to_delete.add(i)
if indices_to_delete:
self._delete_values_by_index(indices_to_delete) | python | def difference_update(self, other):
"""Update self to include only the difference with other."""
other = set(other)
indices_to_delete = set()
for i, elem in enumerate(self):
if elem in other:
indices_to_delete.add(i)
if indices_to_delete:
self._delete_values_by_index(indices_to_delete) | [
"def",
"difference_update",
"(",
"self",
",",
"other",
")",
":",
"other",
"=",
"set",
"(",
"other",
")",
"indices_to_delete",
"=",
"set",
"(",
")",
"for",
"i",
",",
"elem",
"in",
"enumerate",
"(",
"self",
")",
":",
"if",
"elem",
"in",
"other",
":",
... | Update self to include only the difference with other. | [
"Update",
"self",
"to",
"include",
"only",
"the",
"difference",
"with",
"other",
"."
] | ee9e86f6bbef442dbebcb3a5970642c5c969e2cf | https://github.com/mlenzen/collections-extended/blob/ee9e86f6bbef442dbebcb3a5970642c5c969e2cf/collections_extended/setlists.py#L486-L494 |
50,738 | mlenzen/collections-extended | collections_extended/setlists.py | setlist.symmetric_difference_update | def symmetric_difference_update(self, other):
"""Update self to include only the symmetric difference with other."""
other = setlist(other)
indices_to_delete = set()
for i, item in enumerate(self):
if item in other:
indices_to_delete.add(i)
for item in other:
self.add(item)
self._delete_values_by_... | python | def symmetric_difference_update(self, other):
"""Update self to include only the symmetric difference with other."""
other = setlist(other)
indices_to_delete = set()
for i, item in enumerate(self):
if item in other:
indices_to_delete.add(i)
for item in other:
self.add(item)
self._delete_values_by_... | [
"def",
"symmetric_difference_update",
"(",
"self",
",",
"other",
")",
":",
"other",
"=",
"setlist",
"(",
"other",
")",
"indices_to_delete",
"=",
"set",
"(",
")",
"for",
"i",
",",
"item",
"in",
"enumerate",
"(",
"self",
")",
":",
"if",
"item",
"in",
"ot... | Update self to include only the symmetric difference with other. | [
"Update",
"self",
"to",
"include",
"only",
"the",
"symmetric",
"difference",
"with",
"other",
"."
] | ee9e86f6bbef442dbebcb3a5970642c5c969e2cf | https://github.com/mlenzen/collections-extended/blob/ee9e86f6bbef442dbebcb3a5970642c5c969e2cf/collections_extended/setlists.py#L506-L515 |
50,739 | mlenzen/collections-extended | collections_extended/setlists.py | setlist.shuffle | def shuffle(self, random=None):
"""Shuffle all of the elements in self randomly."""
random_.shuffle(self._list, random=random)
for i, elem in enumerate(self._list):
self._dict[elem] = i | python | def shuffle(self, random=None):
"""Shuffle all of the elements in self randomly."""
random_.shuffle(self._list, random=random)
for i, elem in enumerate(self._list):
self._dict[elem] = i | [
"def",
"shuffle",
"(",
"self",
",",
"random",
"=",
"None",
")",
":",
"random_",
".",
"shuffle",
"(",
"self",
".",
"_list",
",",
"random",
"=",
"random",
")",
"for",
"i",
",",
"elem",
"in",
"enumerate",
"(",
"self",
".",
"_list",
")",
":",
"self",
... | Shuffle all of the elements in self randomly. | [
"Shuffle",
"all",
"of",
"the",
"elements",
"in",
"self",
"randomly",
"."
] | ee9e86f6bbef442dbebcb3a5970642c5c969e2cf | https://github.com/mlenzen/collections-extended/blob/ee9e86f6bbef442dbebcb3a5970642c5c969e2cf/collections_extended/setlists.py#L538-L542 |
50,740 | mlenzen/collections-extended | collections_extended/setlists.py | setlist.sort | def sort(self, *args, **kwargs):
"""Sort this setlist in place."""
self._list.sort(*args, **kwargs)
for index, value in enumerate(self._list):
self._dict[value] = index | python | def sort(self, *args, **kwargs):
"""Sort this setlist in place."""
self._list.sort(*args, **kwargs)
for index, value in enumerate(self._list):
self._dict[value] = index | [
"def",
"sort",
"(",
"self",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"self",
".",
"_list",
".",
"sort",
"(",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
"for",
"index",
",",
"value",
"in",
"enumerate",
"(",
"self",
".",
"_list",
")",... | Sort this setlist in place. | [
"Sort",
"this",
"setlist",
"in",
"place",
"."
] | ee9e86f6bbef442dbebcb3a5970642c5c969e2cf | https://github.com/mlenzen/collections-extended/blob/ee9e86f6bbef442dbebcb3a5970642c5c969e2cf/collections_extended/setlists.py#L544-L548 |
50,741 | mlenzen/collections-extended | collections_extended/setlists.py | setlist.swap | def swap(self, i, j):
"""Swap the values at indices i & j.
.. versionadded:: 1.1
"""
i = self._fix_neg_index(i)
j = self._fix_neg_index(j)
self._list[i], self._list[j] = self._list[j], self._list[i]
self._dict[self._list[i]] = i
self._dict[self._list[j]] = j | python | def swap(self, i, j):
"""Swap the values at indices i & j.
.. versionadded:: 1.1
"""
i = self._fix_neg_index(i)
j = self._fix_neg_index(j)
self._list[i], self._list[j] = self._list[j], self._list[i]
self._dict[self._list[i]] = i
self._dict[self._list[j]] = j | [
"def",
"swap",
"(",
"self",
",",
"i",
",",
"j",
")",
":",
"i",
"=",
"self",
".",
"_fix_neg_index",
"(",
"i",
")",
"j",
"=",
"self",
".",
"_fix_neg_index",
"(",
"j",
")",
"self",
".",
"_list",
"[",
"i",
"]",
",",
"self",
".",
"_list",
"[",
"j"... | Swap the values at indices i & j.
.. versionadded:: 1.1 | [
"Swap",
"the",
"values",
"at",
"indices",
"i",
"&",
"j",
"."
] | ee9e86f6bbef442dbebcb3a5970642c5c969e2cf | https://github.com/mlenzen/collections-extended/blob/ee9e86f6bbef442dbebcb3a5970642c5c969e2cf/collections_extended/setlists.py#L550-L559 |
50,742 | tarzanjw/python-mysql-binlog-to-blinker | mysqlbinlog2blinker/_subscribers.py | _get_updated_values | def _get_updated_values(before_values, after_values):
""" Get updated values from 2 dicts of values
Args:
before_values (dict): values before update
after_values (dict): values after update
Returns:
dict: a diff dict with key is field key, value is tuple of
(before_va... | python | def _get_updated_values(before_values, after_values):
""" Get updated values from 2 dicts of values
Args:
before_values (dict): values before update
after_values (dict): values after update
Returns:
dict: a diff dict with key is field key, value is tuple of
(before_va... | [
"def",
"_get_updated_values",
"(",
"before_values",
",",
"after_values",
")",
":",
"assert",
"before_values",
".",
"keys",
"(",
")",
"==",
"after_values",
".",
"keys",
"(",
")",
"return",
"dict",
"(",
"[",
"(",
"k",
",",
"[",
"before_values",
"[",
"k",
"... | Get updated values from 2 dicts of values
Args:
before_values (dict): values before update
after_values (dict): values after update
Returns:
dict: a diff dict with key is field key, value is tuple of
(before_value, after_value) | [
"Get",
"updated",
"values",
"from",
"2",
"dicts",
"of",
"values"
] | d61ab5962345377e142a225b16f731ab4196fc26 | https://github.com/tarzanjw/python-mysql-binlog-to-blinker/blob/d61ab5962345377e142a225b16f731ab4196fc26/mysqlbinlog2blinker/_subscribers.py#L12-L26 |
50,743 | tarzanjw/python-mysql-binlog-to-blinker | mysqlbinlog2blinker/_subscribers.py | _convert_update_row | def _convert_update_row(row):
""" Convert a row for update event
Args:
row (dict): event row data
"""
after_values = row['after_values'] # type: dict
before_values = row['before_values'] # type: dict
values = after_values
return {
'values': values,
'updated_values'... | python | def _convert_update_row(row):
""" Convert a row for update event
Args:
row (dict): event row data
"""
after_values = row['after_values'] # type: dict
before_values = row['before_values'] # type: dict
values = after_values
return {
'values': values,
'updated_values'... | [
"def",
"_convert_update_row",
"(",
"row",
")",
":",
"after_values",
"=",
"row",
"[",
"'after_values'",
"]",
"# type: dict",
"before_values",
"=",
"row",
"[",
"'before_values'",
"]",
"# type: dict",
"values",
"=",
"after_values",
"return",
"{",
"'values'",
":",
"... | Convert a row for update event
Args:
row (dict): event row data | [
"Convert",
"a",
"row",
"for",
"update",
"event"
] | d61ab5962345377e142a225b16f731ab4196fc26 | https://github.com/tarzanjw/python-mysql-binlog-to-blinker/blob/d61ab5962345377e142a225b16f731ab4196fc26/mysqlbinlog2blinker/_subscribers.py#L34-L46 |
50,744 | tarzanjw/python-mysql-binlog-to-blinker | mysqlbinlog2blinker/_subscribers.py | _rows_event_to_dict | def _rows_event_to_dict(e, stream):
""" Convert RowsEvent to a dict
Args:
e (pymysqlreplication.row_event.RowsEvent): the event
stream (pymysqlreplication.BinLogStreamReader):
the stream that yields event
Returns:
dict: event's data as a dict
"""
pk_cols = e.pri... | python | def _rows_event_to_dict(e, stream):
""" Convert RowsEvent to a dict
Args:
e (pymysqlreplication.row_event.RowsEvent): the event
stream (pymysqlreplication.BinLogStreamReader):
the stream that yields event
Returns:
dict: event's data as a dict
"""
pk_cols = e.pri... | [
"def",
"_rows_event_to_dict",
"(",
"e",
",",
"stream",
")",
":",
"pk_cols",
"=",
"e",
".",
"primary_key",
"if",
"isinstance",
"(",
"e",
".",
"primary_key",
",",
"(",
"list",
",",
"tuple",
")",
")",
"else",
"(",
"e",
".",
"primary_key",
",",
")",
"if"... | Convert RowsEvent to a dict
Args:
e (pymysqlreplication.row_event.RowsEvent): the event
stream (pymysqlreplication.BinLogStreamReader):
the stream that yields event
Returns:
dict: event's data as a dict | [
"Convert",
"RowsEvent",
"to",
"a",
"dict"
] | d61ab5962345377e142a225b16f731ab4196fc26 | https://github.com/tarzanjw/python-mysql-binlog-to-blinker/blob/d61ab5962345377e142a225b16f731ab4196fc26/mysqlbinlog2blinker/_subscribers.py#L49-L89 |
50,745 | tarzanjw/python-mysql-binlog-to-blinker | mysqlbinlog2blinker/_subscribers.py | on_binlog | def on_binlog(event, stream):
""" Process on a binlog event
1. Convert event instance into a dict
2. Send corresponding schema/table/signals
Args:
event (pymysqlreplication.row_event.RowsEvent): the event
"""
rows, meta = _rows_event_to_dict(event, stream)
table_name = '%s.%s' % (... | python | def on_binlog(event, stream):
""" Process on a binlog event
1. Convert event instance into a dict
2. Send corresponding schema/table/signals
Args:
event (pymysqlreplication.row_event.RowsEvent): the event
"""
rows, meta = _rows_event_to_dict(event, stream)
table_name = '%s.%s' % (... | [
"def",
"on_binlog",
"(",
"event",
",",
"stream",
")",
":",
"rows",
",",
"meta",
"=",
"_rows_event_to_dict",
"(",
"event",
",",
"stream",
")",
"table_name",
"=",
"'%s.%s'",
"%",
"(",
"meta",
"[",
"'schema'",
"]",
",",
"meta",
"[",
"'table'",
"]",
")",
... | Process on a binlog event
1. Convert event instance into a dict
2. Send corresponding schema/table/signals
Args:
event (pymysqlreplication.row_event.RowsEvent): the event | [
"Process",
"on",
"a",
"binlog",
"event"
] | d61ab5962345377e142a225b16f731ab4196fc26 | https://github.com/tarzanjw/python-mysql-binlog-to-blinker/blob/d61ab5962345377e142a225b16f731ab4196fc26/mysqlbinlog2blinker/_subscribers.py#L93-L115 |
50,746 | mlenzen/collections-extended | collections_extended/_util.py | deprecated | def deprecated(msg, dep_version):
"""Decorate a function, method or class to mark as deprecated.
Raise DeprecationWarning and add a deprecation notice to the docstring.
"""
def wrapper(func):
docstring = func.__doc__ or ''
docstring_msg = '.. deprecated:: {version} {msg}'.format(
version=dep_version,
msg... | python | def deprecated(msg, dep_version):
"""Decorate a function, method or class to mark as deprecated.
Raise DeprecationWarning and add a deprecation notice to the docstring.
"""
def wrapper(func):
docstring = func.__doc__ or ''
docstring_msg = '.. deprecated:: {version} {msg}'.format(
version=dep_version,
msg... | [
"def",
"deprecated",
"(",
"msg",
",",
"dep_version",
")",
":",
"def",
"wrapper",
"(",
"func",
")",
":",
"docstring",
"=",
"func",
".",
"__doc__",
"or",
"''",
"docstring_msg",
"=",
"'.. deprecated:: {version} {msg}'",
".",
"format",
"(",
"version",
"=",
"dep_... | Decorate a function, method or class to mark as deprecated.
Raise DeprecationWarning and add a deprecation notice to the docstring. | [
"Decorate",
"a",
"function",
"method",
"or",
"class",
"to",
"mark",
"as",
"deprecated",
"."
] | ee9e86f6bbef442dbebcb3a5970642c5c969e2cf | https://github.com/mlenzen/collections-extended/blob/ee9e86f6bbef442dbebcb3a5970642c5c969e2cf/collections_extended/_util.py#L63-L97 |
50,747 | mlenzen/collections-extended | collections_extended/range_map.py | RangeMap.ranges | def ranges(self, start=None, stop=None):
"""Generate MappedRanges for all mapped ranges.
Yields:
MappedRange
"""
_check_start_stop(start, stop)
start_loc = self._bisect_right(start)
if stop is None:
stop_loc = len(self._keys)
else:
stop_loc = self._bisect_left(stop)
start_val = self._values[st... | python | def ranges(self, start=None, stop=None):
"""Generate MappedRanges for all mapped ranges.
Yields:
MappedRange
"""
_check_start_stop(start, stop)
start_loc = self._bisect_right(start)
if stop is None:
stop_loc = len(self._keys)
else:
stop_loc = self._bisect_left(stop)
start_val = self._values[st... | [
"def",
"ranges",
"(",
"self",
",",
"start",
"=",
"None",
",",
"stop",
"=",
"None",
")",
":",
"_check_start_stop",
"(",
"start",
",",
"stop",
")",
"start_loc",
"=",
"self",
".",
"_bisect_right",
"(",
"start",
")",
"if",
"stop",
"is",
"None",
":",
"sto... | Generate MappedRanges for all mapped ranges.
Yields:
MappedRange | [
"Generate",
"MappedRanges",
"for",
"all",
"mapped",
"ranges",
"."
] | ee9e86f6bbef442dbebcb3a5970642c5c969e2cf | https://github.com/mlenzen/collections-extended/blob/ee9e86f6bbef442dbebcb3a5970642c5c969e2cf/collections_extended/range_map.py#L235-L254 |
50,748 | mlenzen/collections-extended | collections_extended/range_map.py | RangeMap.get_range | def get_range(self, start=None, stop=None):
"""Return a RangeMap for the range start to stop.
Returns:
A RangeMap
"""
return self.from_iterable(self.ranges(start, stop)) | python | def get_range(self, start=None, stop=None):
"""Return a RangeMap for the range start to stop.
Returns:
A RangeMap
"""
return self.from_iterable(self.ranges(start, stop)) | [
"def",
"get_range",
"(",
"self",
",",
"start",
"=",
"None",
",",
"stop",
"=",
"None",
")",
":",
"return",
"self",
".",
"from_iterable",
"(",
"self",
".",
"ranges",
"(",
"start",
",",
"stop",
")",
")"
] | Return a RangeMap for the range start to stop.
Returns:
A RangeMap | [
"Return",
"a",
"RangeMap",
"for",
"the",
"range",
"start",
"to",
"stop",
"."
] | ee9e86f6bbef442dbebcb3a5970642c5c969e2cf | https://github.com/mlenzen/collections-extended/blob/ee9e86f6bbef442dbebcb3a5970642c5c969e2cf/collections_extended/range_map.py#L293-L299 |
50,749 | mlenzen/collections-extended | collections_extended/range_map.py | RangeMap.set | def set(self, value, start=None, stop=None):
"""Set the range from start to stop to value."""
_check_start_stop(start, stop)
# start_index, stop_index will denote the sections we are replacing
start_index = self._bisect_left(start)
if start is not None: # start_index == 0
prev_value = self._values[start_i... | python | def set(self, value, start=None, stop=None):
"""Set the range from start to stop to value."""
_check_start_stop(start, stop)
# start_index, stop_index will denote the sections we are replacing
start_index = self._bisect_left(start)
if start is not None: # start_index == 0
prev_value = self._values[start_i... | [
"def",
"set",
"(",
"self",
",",
"value",
",",
"start",
"=",
"None",
",",
"stop",
"=",
"None",
")",
":",
"_check_start_stop",
"(",
"start",
",",
"stop",
")",
"# start_index, stop_index will denote the sections we are replacing",
"start_index",
"=",
"self",
".",
"... | Set the range from start to stop to value. | [
"Set",
"the",
"range",
"from",
"start",
"to",
"stop",
"to",
"value",
"."
] | ee9e86f6bbef442dbebcb3a5970642c5c969e2cf | https://github.com/mlenzen/collections-extended/blob/ee9e86f6bbef442dbebcb3a5970642c5c969e2cf/collections_extended/range_map.py#L301-L328 |
50,750 | mlenzen/collections-extended | collections_extended/range_map.py | RangeMap.delete | def delete(self, start=None, stop=None):
"""Delete the range from start to stop from self.
Raises:
KeyError: If part of the passed range isn't mapped.
"""
_check_start_stop(start, stop)
start_loc = self._bisect_right(start) - 1
if stop is None:
stop_loc = len(self._keys)
else:
stop_loc = self._b... | python | def delete(self, start=None, stop=None):
"""Delete the range from start to stop from self.
Raises:
KeyError: If part of the passed range isn't mapped.
"""
_check_start_stop(start, stop)
start_loc = self._bisect_right(start) - 1
if stop is None:
stop_loc = len(self._keys)
else:
stop_loc = self._b... | [
"def",
"delete",
"(",
"self",
",",
"start",
"=",
"None",
",",
"stop",
"=",
"None",
")",
":",
"_check_start_stop",
"(",
"start",
",",
"stop",
")",
"start_loc",
"=",
"self",
".",
"_bisect_right",
"(",
"start",
")",
"-",
"1",
"if",
"stop",
"is",
"None",... | Delete the range from start to stop from self.
Raises:
KeyError: If part of the passed range isn't mapped. | [
"Delete",
"the",
"range",
"from",
"start",
"to",
"stop",
"from",
"self",
"."
] | ee9e86f6bbef442dbebcb3a5970642c5c969e2cf | https://github.com/mlenzen/collections-extended/blob/ee9e86f6bbef442dbebcb3a5970642c5c969e2cf/collections_extended/range_map.py#L330-L346 |
50,751 | mlenzen/collections-extended | collections_extended/range_map.py | RangeMap.empty | def empty(self, start=None, stop=None):
"""Empty the range from start to stop.
Like delete, but no Error is raised if the entire range isn't mapped.
"""
self.set(NOT_SET, start=start, stop=stop) | python | def empty(self, start=None, stop=None):
"""Empty the range from start to stop.
Like delete, but no Error is raised if the entire range isn't mapped.
"""
self.set(NOT_SET, start=start, stop=stop) | [
"def",
"empty",
"(",
"self",
",",
"start",
"=",
"None",
",",
"stop",
"=",
"None",
")",
":",
"self",
".",
"set",
"(",
"NOT_SET",
",",
"start",
"=",
"start",
",",
"stop",
"=",
"stop",
")"
] | Empty the range from start to stop.
Like delete, but no Error is raised if the entire range isn't mapped. | [
"Empty",
"the",
"range",
"from",
"start",
"to",
"stop",
"."
] | ee9e86f6bbef442dbebcb3a5970642c5c969e2cf | https://github.com/mlenzen/collections-extended/blob/ee9e86f6bbef442dbebcb3a5970642c5c969e2cf/collections_extended/range_map.py#L348-L353 |
50,752 | mlenzen/collections-extended | collections_extended/range_map.py | RangeMap.start | def start(self):
"""Get the start key of the first range.
None if RangeMap is empty or unbounded to the left.
"""
if self._values[0] is NOT_SET:
try:
return self._keys[1]
except IndexError:
# This is empty or everything is mapped to a single value
return None
else:
# This is unbounded to... | python | def start(self):
"""Get the start key of the first range.
None if RangeMap is empty or unbounded to the left.
"""
if self._values[0] is NOT_SET:
try:
return self._keys[1]
except IndexError:
# This is empty or everything is mapped to a single value
return None
else:
# This is unbounded to... | [
"def",
"start",
"(",
"self",
")",
":",
"if",
"self",
".",
"_values",
"[",
"0",
"]",
"is",
"NOT_SET",
":",
"try",
":",
"return",
"self",
".",
"_keys",
"[",
"1",
"]",
"except",
"IndexError",
":",
"# This is empty or everything is mapped to a single value",
"re... | Get the start key of the first range.
None if RangeMap is empty or unbounded to the left. | [
"Get",
"the",
"start",
"key",
"of",
"the",
"first",
"range",
"."
] | ee9e86f6bbef442dbebcb3a5970642c5c969e2cf | https://github.com/mlenzen/collections-extended/blob/ee9e86f6bbef442dbebcb3a5970642c5c969e2cf/collections_extended/range_map.py#L361-L374 |
50,753 | justinabrahms/imhotep | imhotep/app.py | get_tools | def get_tools(whitelist, known_plugins):
"""
Filter all known plugins by a whitelist specified. If the whitelist is
empty, default to all plugins.
"""
def getpath(c):
return "%s:%s" % (c.__module__, c.__class__.__name__)
tools = [x for x in known_plugins if getpath(x) in whitelist]
... | python | def get_tools(whitelist, known_plugins):
"""
Filter all known plugins by a whitelist specified. If the whitelist is
empty, default to all plugins.
"""
def getpath(c):
return "%s:%s" % (c.__module__, c.__class__.__name__)
tools = [x for x in known_plugins if getpath(x) in whitelist]
... | [
"def",
"get_tools",
"(",
"whitelist",
",",
"known_plugins",
")",
":",
"def",
"getpath",
"(",
"c",
")",
":",
"return",
"\"%s:%s\"",
"%",
"(",
"c",
".",
"__module__",
",",
"c",
".",
"__class__",
".",
"__name__",
")",
"tools",
"=",
"[",
"x",
"for",
"x",... | Filter all known plugins by a whitelist specified. If the whitelist is
empty, default to all plugins. | [
"Filter",
"all",
"known",
"plugins",
"by",
"a",
"whitelist",
"specified",
".",
"If",
"the",
"whitelist",
"is",
"empty",
"default",
"to",
"all",
"plugins",
"."
] | c6dc365ef34505d7b6837187900e59b00e5fab08 | https://github.com/justinabrahms/imhotep/blob/c6dc365ef34505d7b6837187900e59b00e5fab08/imhotep/app.py#L193-L207 |
50,754 | lord63/v2ex_daily_mission | v2ex_daily_mission/cli.py | init | def init(directory):
"""Init the config fle."""
username = click.prompt("Input your username")
password = click.prompt("Input your password", hide_input=True,
confirmation_prompt=True)
log_directory = click.prompt("Input your log directory")
if not path.exists(log_direct... | python | def init(directory):
"""Init the config fle."""
username = click.prompt("Input your username")
password = click.prompt("Input your password", hide_input=True,
confirmation_prompt=True)
log_directory = click.prompt("Input your log directory")
if not path.exists(log_direct... | [
"def",
"init",
"(",
"directory",
")",
":",
"username",
"=",
"click",
".",
"prompt",
"(",
"\"Input your username\"",
")",
"password",
"=",
"click",
".",
"prompt",
"(",
"\"Input your password\"",
",",
"hide_input",
"=",
"True",
",",
"confirmation_prompt",
"=",
"... | Init the config fle. | [
"Init",
"the",
"config",
"fle",
"."
] | 499901dd540dca68c3889d88c21c2594f25f27ec | https://github.com/lord63/v2ex_daily_mission/blob/499901dd540dca68c3889d88c21c2594f25f27ec/v2ex_daily_mission/cli.py#L62-L80 |
50,755 | lord63/v2ex_daily_mission | v2ex_daily_mission/cli.py | sign | def sign(conf):
"""Sign in and get money."""
try:
v2ex = V2ex(conf.config)
v2ex.login()
balance = v2ex.get_money()
click.echo(balance)
except KeyError:
click.echo('Keyerror, please check your config file.')
except IndexError:
click.echo('Please check your ... | python | def sign(conf):
"""Sign in and get money."""
try:
v2ex = V2ex(conf.config)
v2ex.login()
balance = v2ex.get_money()
click.echo(balance)
except KeyError:
click.echo('Keyerror, please check your config file.')
except IndexError:
click.echo('Please check your ... | [
"def",
"sign",
"(",
"conf",
")",
":",
"try",
":",
"v2ex",
"=",
"V2ex",
"(",
"conf",
".",
"config",
")",
"v2ex",
".",
"login",
"(",
")",
"balance",
"=",
"v2ex",
".",
"get_money",
"(",
")",
"click",
".",
"echo",
"(",
"balance",
")",
"except",
"KeyE... | Sign in and get money. | [
"Sign",
"in",
"and",
"get",
"money",
"."
] | 499901dd540dca68c3889d88c21c2594f25f27ec | https://github.com/lord63/v2ex_daily_mission/blob/499901dd540dca68c3889d88c21c2594f25f27ec/v2ex_daily_mission/cli.py#L85-L95 |
50,756 | lord63/v2ex_daily_mission | v2ex_daily_mission/cli.py | read | def read(conf, count):
"""Read log file."""
file_path = os.path.join(path.abspath(conf.config['log_directory']),
'v2ex.log')
for line in deque(open(file_path, encoding='utf-8'), int(count)):
click.echo(line, nl=False) | python | def read(conf, count):
"""Read log file."""
file_path = os.path.join(path.abspath(conf.config['log_directory']),
'v2ex.log')
for line in deque(open(file_path, encoding='utf-8'), int(count)):
click.echo(line, nl=False) | [
"def",
"read",
"(",
"conf",
",",
"count",
")",
":",
"file_path",
"=",
"os",
".",
"path",
".",
"join",
"(",
"path",
".",
"abspath",
"(",
"conf",
".",
"config",
"[",
"'log_directory'",
"]",
")",
",",
"'v2ex.log'",
")",
"for",
"line",
"in",
"deque",
"... | Read log file. | [
"Read",
"log",
"file",
"."
] | 499901dd540dca68c3889d88c21c2594f25f27ec | https://github.com/lord63/v2ex_daily_mission/blob/499901dd540dca68c3889d88c21c2594f25f27ec/v2ex_daily_mission/cli.py#L101-L106 |
50,757 | lord63/v2ex_daily_mission | v2ex_daily_mission/cli.py | last | def last(conf):
"""How long you have kept signing in."""
try:
v2ex = V2ex(conf.config)
v2ex.login()
last_date = v2ex.get_last()
click.echo(last_date)
except KeyError:
click.echo('Keyerror, please check your config file.')
except IndexError:
click.echo('Ple... | python | def last(conf):
"""How long you have kept signing in."""
try:
v2ex = V2ex(conf.config)
v2ex.login()
last_date = v2ex.get_last()
click.echo(last_date)
except KeyError:
click.echo('Keyerror, please check your config file.')
except IndexError:
click.echo('Ple... | [
"def",
"last",
"(",
"conf",
")",
":",
"try",
":",
"v2ex",
"=",
"V2ex",
"(",
"conf",
".",
"config",
")",
"v2ex",
".",
"login",
"(",
")",
"last_date",
"=",
"v2ex",
".",
"get_last",
"(",
")",
"click",
".",
"echo",
"(",
"last_date",
")",
"except",
"K... | How long you have kept signing in. | [
"How",
"long",
"you",
"have",
"kept",
"signing",
"in",
"."
] | 499901dd540dca68c3889d88c21c2594f25f27ec | https://github.com/lord63/v2ex_daily_mission/blob/499901dd540dca68c3889d88c21c2594f25f27ec/v2ex_daily_mission/cli.py#L111-L121 |
50,758 | carljm/django-adminfiles | adminfiles/parse.py | get_uploads | def get_uploads(text):
"""
Return a generator yielding uploads referenced in the given text.
"""
uploads = []
for match in UPLOAD_RE.finditer(text):
try:
upload = FileUpload.objects.get(slug=match.group(1))
except FileUpload.DoesNotExist:
continue
yie... | python | def get_uploads(text):
"""
Return a generator yielding uploads referenced in the given text.
"""
uploads = []
for match in UPLOAD_RE.finditer(text):
try:
upload = FileUpload.objects.get(slug=match.group(1))
except FileUpload.DoesNotExist:
continue
yie... | [
"def",
"get_uploads",
"(",
"text",
")",
":",
"uploads",
"=",
"[",
"]",
"for",
"match",
"in",
"UPLOAD_RE",
".",
"finditer",
"(",
"text",
")",
":",
"try",
":",
"upload",
"=",
"FileUpload",
".",
"objects",
".",
"get",
"(",
"slug",
"=",
"match",
".",
"... | Return a generator yielding uploads referenced in the given text. | [
"Return",
"a",
"generator",
"yielding",
"uploads",
"referenced",
"in",
"the",
"given",
"text",
"."
] | b01dc7be266305d575c11d5ff9a37ccac04a78c2 | https://github.com/carljm/django-adminfiles/blob/b01dc7be266305d575c11d5ff9a37ccac04a78c2/adminfiles/parse.py#L15-L26 |
50,759 | carljm/django-adminfiles | adminfiles/parse.py | parse_match | def parse_match(match):
"""
Accept an re match object resulting from an ``UPLOAD_RE`` match
and return a two-tuple where the first element is the
corresponding ``FileUpload`` and the second is a dictionary of the
key=value options.
If there is no ``FileUpload`` object corresponding to the match... | python | def parse_match(match):
"""
Accept an re match object resulting from an ``UPLOAD_RE`` match
and return a two-tuple where the first element is the
corresponding ``FileUpload`` and the second is a dictionary of the
key=value options.
If there is no ``FileUpload`` object corresponding to the match... | [
"def",
"parse_match",
"(",
"match",
")",
":",
"try",
":",
"upload",
"=",
"FileUpload",
".",
"objects",
".",
"get",
"(",
"slug",
"=",
"match",
".",
"group",
"(",
"1",
")",
")",
"except",
"FileUpload",
".",
"DoesNotExist",
":",
"upload",
"=",
"None",
"... | Accept an re match object resulting from an ``UPLOAD_RE`` match
and return a two-tuple where the first element is the
corresponding ``FileUpload`` and the second is a dictionary of the
key=value options.
If there is no ``FileUpload`` object corresponding to the match,
the first element of the retur... | [
"Accept",
"an",
"re",
"match",
"object",
"resulting",
"from",
"an",
"UPLOAD_RE",
"match",
"and",
"return",
"a",
"two",
"-",
"tuple",
"where",
"the",
"first",
"element",
"is",
"the",
"corresponding",
"FileUpload",
"and",
"the",
"second",
"is",
"a",
"dictionar... | b01dc7be266305d575c11d5ff9a37ccac04a78c2 | https://github.com/carljm/django-adminfiles/blob/b01dc7be266305d575c11d5ff9a37ccac04a78c2/adminfiles/parse.py#L37-L53 |
50,760 | Trebek/pydealer | pydealer/deck.py | Deck.build | def build(self, jokers=False, num_jokers=0):
"""
Builds a standard 52 card French deck of Card instances.
:arg bool jokers:
Whether or not to include jokers in the deck.
:arg int num_jokers:
The number of jokers to include.
"""
jokers = jokers or... | python | def build(self, jokers=False, num_jokers=0):
"""
Builds a standard 52 card French deck of Card instances.
:arg bool jokers:
Whether or not to include jokers in the deck.
:arg int num_jokers:
The number of jokers to include.
"""
jokers = jokers or... | [
"def",
"build",
"(",
"self",
",",
"jokers",
"=",
"False",
",",
"num_jokers",
"=",
"0",
")",
":",
"jokers",
"=",
"jokers",
"or",
"self",
".",
"jokers",
"num_jokers",
"=",
"num_jokers",
"or",
"self",
".",
"num_jokers",
"self",
".",
"decks_used",
"+=",
"1... | Builds a standard 52 card French deck of Card instances.
:arg bool jokers:
Whether or not to include jokers in the deck.
:arg int num_jokers:
The number of jokers to include. | [
"Builds",
"a",
"standard",
"52",
"card",
"French",
"deck",
"of",
"Card",
"instances",
"."
] | 2ac583dd8c55715658c740b614387775f4dda333 | https://github.com/Trebek/pydealer/blob/2ac583dd8c55715658c740b614387775f4dda333/pydealer/deck.py#L120-L135 |
50,761 | Trebek/pydealer | pydealer/deck.py | Deck.deal | def deal(self, num=1, rebuild=False, shuffle=False, end=TOP):
"""
Returns a list of cards, which are removed from the deck.
:arg int num:
The number of cards to deal.
:arg bool rebuild:
Whether or not to rebuild the deck when cards run out.
:arg bool shuf... | python | def deal(self, num=1, rebuild=False, shuffle=False, end=TOP):
"""
Returns a list of cards, which are removed from the deck.
:arg int num:
The number of cards to deal.
:arg bool rebuild:
Whether or not to rebuild the deck when cards run out.
:arg bool shuf... | [
"def",
"deal",
"(",
"self",
",",
"num",
"=",
"1",
",",
"rebuild",
"=",
"False",
",",
"shuffle",
"=",
"False",
",",
"end",
"=",
"TOP",
")",
":",
"_num",
"=",
"num",
"rebuild",
"=",
"rebuild",
"or",
"self",
".",
"rebuild",
"re_shuffle",
"=",
"shuffle... | Returns a list of cards, which are removed from the deck.
:arg int num:
The number of cards to deal.
:arg bool rebuild:
Whether or not to rebuild the deck when cards run out.
:arg bool shuffle:
Whether or not to shuffle on rebuild.
:arg str end:
... | [
"Returns",
"a",
"list",
"of",
"cards",
"which",
"are",
"removed",
"from",
"the",
"deck",
"."
] | 2ac583dd8c55715658c740b614387775f4dda333 | https://github.com/Trebek/pydealer/blob/2ac583dd8c55715658c740b614387775f4dda333/pydealer/deck.py#L137-L183 |
50,762 | borntyping/python-riemann-client | riemann_client/transport.py | socket_recvall | def socket_recvall(socket, length, bufsize=4096):
"""A helper method to read of bytes from a socket to a maximum length"""
data = b""
while len(data) < length:
data += socket.recv(bufsize)
return data | python | def socket_recvall(socket, length, bufsize=4096):
"""A helper method to read of bytes from a socket to a maximum length"""
data = b""
while len(data) < length:
data += socket.recv(bufsize)
return data | [
"def",
"socket_recvall",
"(",
"socket",
",",
"length",
",",
"bufsize",
"=",
"4096",
")",
":",
"data",
"=",
"b\"\"",
"while",
"len",
"(",
"data",
")",
"<",
"length",
":",
"data",
"+=",
"socket",
".",
"recv",
"(",
"bufsize",
")",
"return",
"data"
] | A helper method to read of bytes from a socket to a maximum length | [
"A",
"helper",
"method",
"to",
"read",
"of",
"bytes",
"from",
"a",
"socket",
"to",
"a",
"maximum",
"length"
] | 3e181d90bdf685afd21c1ec5ee20e6840b011ea5 | https://github.com/borntyping/python-riemann-client/blob/3e181d90bdf685afd21c1ec5ee20e6840b011ea5/riemann_client/transport.py#L21-L26 |
50,763 | borntyping/python-riemann-client | riemann_client/transport.py | UDPTransport.send | def send(self, message):
"""Sends a message, but does not return a response
:returns: None - can't receive a response over UDP
"""
self.socket.sendto(message.SerializeToString(), self.address)
return None | python | def send(self, message):
"""Sends a message, but does not return a response
:returns: None - can't receive a response over UDP
"""
self.socket.sendto(message.SerializeToString(), self.address)
return None | [
"def",
"send",
"(",
"self",
",",
"message",
")",
":",
"self",
".",
"socket",
".",
"sendto",
"(",
"message",
".",
"SerializeToString",
"(",
")",
",",
"self",
".",
"address",
")",
"return",
"None"
] | Sends a message, but does not return a response
:returns: None - can't receive a response over UDP | [
"Sends",
"a",
"message",
"but",
"does",
"not",
"return",
"a",
"response"
] | 3e181d90bdf685afd21c1ec5ee20e6840b011ea5 | https://github.com/borntyping/python-riemann-client/blob/3e181d90bdf685afd21c1ec5ee20e6840b011ea5/riemann_client/transport.py#L102-L108 |
50,764 | borntyping/python-riemann-client | riemann_client/transport.py | TCPTransport.connect | def connect(self):
"""Connects to the given host"""
self.socket = socket.create_connection(self.address, self.timeout) | python | def connect(self):
"""Connects to the given host"""
self.socket = socket.create_connection(self.address, self.timeout) | [
"def",
"connect",
"(",
"self",
")",
":",
"self",
".",
"socket",
"=",
"socket",
".",
"create_connection",
"(",
"self",
".",
"address",
",",
"self",
".",
"timeout",
")"
] | Connects to the given host | [
"Connects",
"to",
"the",
"given",
"host"
] | 3e181d90bdf685afd21c1ec5ee20e6840b011ea5 | https://github.com/borntyping/python-riemann-client/blob/3e181d90bdf685afd21c1ec5ee20e6840b011ea5/riemann_client/transport.py#L122-L124 |
50,765 | borntyping/python-riemann-client | riemann_client/transport.py | TCPTransport.send | def send(self, message):
"""Sends a message to a Riemann server and returns it's response
:param message: The message to send to the Riemann server
:returns: The response message from Riemann
:raises RiemannError: if the server returns an error
"""
message = message.Seri... | python | def send(self, message):
"""Sends a message to a Riemann server and returns it's response
:param message: The message to send to the Riemann server
:returns: The response message from Riemann
:raises RiemannError: if the server returns an error
"""
message = message.Seri... | [
"def",
"send",
"(",
"self",
",",
"message",
")",
":",
"message",
"=",
"message",
".",
"SerializeToString",
"(",
")",
"self",
".",
"socket",
".",
"sendall",
"(",
"struct",
".",
"pack",
"(",
"'!I'",
",",
"len",
"(",
"message",
")",
")",
"+",
"message",... | Sends a message to a Riemann server and returns it's response
:param message: The message to send to the Riemann server
:returns: The response message from Riemann
:raises RiemannError: if the server returns an error | [
"Sends",
"a",
"message",
"to",
"a",
"Riemann",
"server",
"and",
"returns",
"it",
"s",
"response"
] | 3e181d90bdf685afd21c1ec5ee20e6840b011ea5 | https://github.com/borntyping/python-riemann-client/blob/3e181d90bdf685afd21c1ec5ee20e6840b011ea5/riemann_client/transport.py#L130-L147 |
50,766 | borntyping/python-riemann-client | riemann_client/transport.py | BlankTransport.send | def send(self, message):
"""Adds a message to the list, returning a fake 'ok' response
:returns: A response message with ``ok = True``
"""
for event in message.events:
self.events.append(event)
reply = riemann_client.riemann_pb2.Msg()
reply.ok = True
... | python | def send(self, message):
"""Adds a message to the list, returning a fake 'ok' response
:returns: A response message with ``ok = True``
"""
for event in message.events:
self.events.append(event)
reply = riemann_client.riemann_pb2.Msg()
reply.ok = True
... | [
"def",
"send",
"(",
"self",
",",
"message",
")",
":",
"for",
"event",
"in",
"message",
".",
"events",
":",
"self",
".",
"events",
".",
"append",
"(",
"event",
")",
"reply",
"=",
"riemann_client",
".",
"riemann_pb2",
".",
"Msg",
"(",
")",
"reply",
"."... | Adds a message to the list, returning a fake 'ok' response
:returns: A response message with ``ok = True`` | [
"Adds",
"a",
"message",
"to",
"the",
"list",
"returning",
"a",
"fake",
"ok",
"response"
] | 3e181d90bdf685afd21c1ec5ee20e6840b011ea5 | https://github.com/borntyping/python-riemann-client/blob/3e181d90bdf685afd21c1ec5ee20e6840b011ea5/riemann_client/transport.py#L186-L195 |
50,767 | staggerpkg/stagger | stagger/frames.py | Frame._in_version | def _in_version(self, *versions):
"Returns true if this frame is in any of the specified versions of ID3."
for version in versions:
if (self._version == version
or (isinstance(self._version, collections.Container)
and version in self._version)):
... | python | def _in_version(self, *versions):
"Returns true if this frame is in any of the specified versions of ID3."
for version in versions:
if (self._version == version
or (isinstance(self._version, collections.Container)
and version in self._version)):
... | [
"def",
"_in_version",
"(",
"self",
",",
"*",
"versions",
")",
":",
"for",
"version",
"in",
"versions",
":",
"if",
"(",
"self",
".",
"_version",
"==",
"version",
"or",
"(",
"isinstance",
"(",
"self",
".",
"_version",
",",
"collections",
".",
"Container",
... | Returns true if this frame is in any of the specified versions of ID3. | [
"Returns",
"true",
"if",
"this",
"frame",
"is",
"in",
"any",
"of",
"the",
"specified",
"versions",
"of",
"ID3",
"."
] | 6530db14afc5d7d8a4599b7f3b26158fb367d786 | https://github.com/staggerpkg/stagger/blob/6530db14afc5d7d8a4599b7f3b26158fb367d786/stagger/frames.py#L113-L120 |
50,768 | staggerpkg/stagger | stagger/frames.py | Frame._spec | def _spec(self, name):
"Return the named spec."
for s in self._framespec:
if s.name == name:
return s
raise ValueError("Unknown spec: " + name) | python | def _spec(self, name):
"Return the named spec."
for s in self._framespec:
if s.name == name:
return s
raise ValueError("Unknown spec: " + name) | [
"def",
"_spec",
"(",
"self",
",",
"name",
")",
":",
"for",
"s",
"in",
"self",
".",
"_framespec",
":",
"if",
"s",
".",
"name",
"==",
"name",
":",
"return",
"s",
"raise",
"ValueError",
"(",
"\"Unknown spec: \"",
"+",
"name",
")"
] | Return the named spec. | [
"Return",
"the",
"named",
"spec",
"."
] | 6530db14afc5d7d8a4599b7f3b26158fb367d786 | https://github.com/staggerpkg/stagger/blob/6530db14afc5d7d8a4599b7f3b26158fb367d786/stagger/frames.py#L192-L197 |
50,769 | yyuu/botornado | botornado/s3/key.py | AsyncKey.exists | def exists(self, callback=None):
"""
Returns True if the key exists
:rtype: bool
:return: Whether the key exists on S3
"""
def existence_tested(response):
if callable(callback):
callback(bool(response))
self.bucket.lookup(self.name, ca... | python | def exists(self, callback=None):
"""
Returns True if the key exists
:rtype: bool
:return: Whether the key exists on S3
"""
def existence_tested(response):
if callable(callback):
callback(bool(response))
self.bucket.lookup(self.name, ca... | [
"def",
"exists",
"(",
"self",
",",
"callback",
"=",
"None",
")",
":",
"def",
"existence_tested",
"(",
"response",
")",
":",
"if",
"callable",
"(",
"callback",
")",
":",
"callback",
"(",
"bool",
"(",
"response",
")",
")",
"self",
".",
"bucket",
".",
"... | Returns True if the key exists
:rtype: bool
:return: Whether the key exists on S3 | [
"Returns",
"True",
"if",
"the",
"key",
"exists"
] | fffb056f5ff2324d1d5c1304014cfb1d899f602e | https://github.com/yyuu/botornado/blob/fffb056f5ff2324d1d5c1304014cfb1d899f602e/botornado/s3/key.py#L153-L163 |
50,770 | yyuu/botornado | botornado/s3/key.py | AsyncKey.get_contents_to_filename | def get_contents_to_filename(self, filename, headers=None,
cb=None, num_cb=10,
torrent=False,
version_id=None,
res_download_handler=None,
response_headers=... | python | def get_contents_to_filename(self, filename, headers=None,
cb=None, num_cb=10,
torrent=False,
version_id=None,
res_download_handler=None,
response_headers=... | [
"def",
"get_contents_to_filename",
"(",
"self",
",",
"filename",
",",
"headers",
"=",
"None",
",",
"cb",
"=",
"None",
",",
"num_cb",
"=",
"10",
",",
"torrent",
"=",
"False",
",",
"version_id",
"=",
"None",
",",
"res_download_handler",
"=",
"None",
",",
"... | Retrieve an object from S3 using the name of the Key object as the
key in S3. Store contents of the object to a file named by 'filename'.
See get_contents_to_file method for details about the
parameters.
:type filename: string
:param filename: The filename of where to put the f... | [
"Retrieve",
"an",
"object",
"from",
"S3",
"using",
"the",
"name",
"of",
"the",
"Key",
"object",
"as",
"the",
"key",
"in",
"S3",
".",
"Store",
"contents",
"of",
"the",
"object",
"to",
"a",
"file",
"named",
"by",
"filename",
".",
"See",
"get_contents_to_fi... | fffb056f5ff2324d1d5c1304014cfb1d899f602e | https://github.com/yyuu/botornado/blob/fffb056f5ff2324d1d5c1304014cfb1d899f602e/botornado/s3/key.py#L785-L847 |
50,771 | staggerpkg/stagger | stagger/util.py | check_tag_data | def check_tag_data(data):
"Raise a ValueError if DATA doesn't seem to be a well-formed ID3 tag."
if len(data) < 10:
raise ValueError("Tag too short")
if data[0:3] != b"ID3":
raise ValueError("Missing ID3 identifier")
if data[3] >= 5 or data[4] != 0:
raise ValueError("Unknown ID3 ... | python | def check_tag_data(data):
"Raise a ValueError if DATA doesn't seem to be a well-formed ID3 tag."
if len(data) < 10:
raise ValueError("Tag too short")
if data[0:3] != b"ID3":
raise ValueError("Missing ID3 identifier")
if data[3] >= 5 or data[4] != 0:
raise ValueError("Unknown ID3 ... | [
"def",
"check_tag_data",
"(",
"data",
")",
":",
"if",
"len",
"(",
"data",
")",
"<",
"10",
":",
"raise",
"ValueError",
"(",
"\"Tag too short\"",
")",
"if",
"data",
"[",
"0",
":",
"3",
"]",
"!=",
"b\"ID3\"",
":",
"raise",
"ValueError",
"(",
"\"Missing ID... | Raise a ValueError if DATA doesn't seem to be a well-formed ID3 tag. | [
"Raise",
"a",
"ValueError",
"if",
"DATA",
"doesn",
"t",
"seem",
"to",
"be",
"a",
"well",
"-",
"formed",
"ID3",
"tag",
"."
] | 6530db14afc5d7d8a4599b7f3b26158fb367d786 | https://github.com/staggerpkg/stagger/blob/6530db14afc5d7d8a4599b7f3b26158fb367d786/stagger/util.py#L52-L62 |
50,772 | staggerpkg/stagger | stagger/util.py | get_raw_tag_data | def get_raw_tag_data(filename):
"Return the ID3 tag in FILENAME as a raw byte string."
with open(filename, "rb") as file:
try:
(cls, offset, length) = stagger.tags.detect_tag(file)
except stagger.NoTagError:
return bytes()
file.seek(offset)
return file.rea... | python | def get_raw_tag_data(filename):
"Return the ID3 tag in FILENAME as a raw byte string."
with open(filename, "rb") as file:
try:
(cls, offset, length) = stagger.tags.detect_tag(file)
except stagger.NoTagError:
return bytes()
file.seek(offset)
return file.rea... | [
"def",
"get_raw_tag_data",
"(",
"filename",
")",
":",
"with",
"open",
"(",
"filename",
",",
"\"rb\"",
")",
"as",
"file",
":",
"try",
":",
"(",
"cls",
",",
"offset",
",",
"length",
")",
"=",
"stagger",
".",
"tags",
".",
"detect_tag",
"(",
"file",
")",... | Return the ID3 tag in FILENAME as a raw byte string. | [
"Return",
"the",
"ID3",
"tag",
"in",
"FILENAME",
"as",
"a",
"raw",
"byte",
"string",
"."
] | 6530db14afc5d7d8a4599b7f3b26158fb367d786 | https://github.com/staggerpkg/stagger/blob/6530db14afc5d7d8a4599b7f3b26158fb367d786/stagger/util.py#L64-L72 |
50,773 | staggerpkg/stagger | stagger/util.py | set_raw_tag_data | def set_raw_tag_data(filename, data, act=True, verbose=False):
"Replace the ID3 tag in FILENAME with DATA."
check_tag_data(data)
with open(filename, "rb+") as file:
try:
(cls, offset, length) = stagger.tags.detect_tag(file)
except stagger.NoTagError:
(offset, length) ... | python | def set_raw_tag_data(filename, data, act=True, verbose=False):
"Replace the ID3 tag in FILENAME with DATA."
check_tag_data(data)
with open(filename, "rb+") as file:
try:
(cls, offset, length) = stagger.tags.detect_tag(file)
except stagger.NoTagError:
(offset, length) ... | [
"def",
"set_raw_tag_data",
"(",
"filename",
",",
"data",
",",
"act",
"=",
"True",
",",
"verbose",
"=",
"False",
")",
":",
"check_tag_data",
"(",
"data",
")",
"with",
"open",
"(",
"filename",
",",
"\"rb+\"",
")",
"as",
"file",
":",
"try",
":",
"(",
"c... | Replace the ID3 tag in FILENAME with DATA. | [
"Replace",
"the",
"ID3",
"tag",
"in",
"FILENAME",
"with",
"DATA",
"."
] | 6530db14afc5d7d8a4599b7f3b26158fb367d786 | https://github.com/staggerpkg/stagger/blob/6530db14afc5d7d8a4599b7f3b26158fb367d786/stagger/util.py#L74-L89 |
50,774 | yyuu/botornado | boto/sqs/connection.py | SQSConnection.delete_message | def delete_message(self, queue, message):
"""
Delete a message from a queue.
:type queue: A :class:`boto.sqs.queue.Queue` object
:param queue: The Queue from which messages are read.
:type message: A :class:`boto.sqs.message.Message` object
:param message: The M... | python | def delete_message(self, queue, message):
"""
Delete a message from a queue.
:type queue: A :class:`boto.sqs.queue.Queue` object
:param queue: The Queue from which messages are read.
:type message: A :class:`boto.sqs.message.Message` object
:param message: The M... | [
"def",
"delete_message",
"(",
"self",
",",
"queue",
",",
"message",
")",
":",
"params",
"=",
"{",
"'ReceiptHandle'",
":",
"message",
".",
"receipt_handle",
"}",
"return",
"self",
".",
"get_status",
"(",
"'DeleteMessage'",
",",
"params",
",",
"queue",
".",
... | Delete a message from a queue.
:type queue: A :class:`boto.sqs.queue.Queue` object
:param queue: The Queue from which messages are read.
:type message: A :class:`boto.sqs.message.Message` object
:param message: The Message to be deleted
:rtype: bool
:re... | [
"Delete",
"a",
"message",
"from",
"a",
"queue",
"."
] | fffb056f5ff2324d1d5c1304014cfb1d899f602e | https://github.com/yyuu/botornado/blob/fffb056f5ff2324d1d5c1304014cfb1d899f602e/boto/sqs/connection.py#L183-L197 |
50,775 | yyuu/botornado | boto/sqs/connection.py | SQSConnection.delete_message_from_handle | def delete_message_from_handle(self, queue, receipt_handle):
"""
Delete a message from a queue, given a receipt handle.
:type queue: A :class:`boto.sqs.queue.Queue` object
:param queue: The Queue from which messages are read.
:type receipt_handle: str
:param rec... | python | def delete_message_from_handle(self, queue, receipt_handle):
"""
Delete a message from a queue, given a receipt handle.
:type queue: A :class:`boto.sqs.queue.Queue` object
:param queue: The Queue from which messages are read.
:type receipt_handle: str
:param rec... | [
"def",
"delete_message_from_handle",
"(",
"self",
",",
"queue",
",",
"receipt_handle",
")",
":",
"params",
"=",
"{",
"'ReceiptHandle'",
":",
"receipt_handle",
"}",
"return",
"self",
".",
"get_status",
"(",
"'DeleteMessage'",
",",
"params",
",",
"queue",
".",
"... | Delete a message from a queue, given a receipt handle.
:type queue: A :class:`boto.sqs.queue.Queue` object
:param queue: The Queue from which messages are read.
:type receipt_handle: str
:param receipt_handle: The receipt handle for the message
:rtype: bool
... | [
"Delete",
"a",
"message",
"from",
"a",
"queue",
"given",
"a",
"receipt",
"handle",
"."
] | fffb056f5ff2324d1d5c1304014cfb1d899f602e | https://github.com/yyuu/botornado/blob/fffb056f5ff2324d1d5c1304014cfb1d899f602e/boto/sqs/connection.py#L199-L213 |
50,776 | yyuu/botornado | boto/sqs/connection.py | SQSConnection.send_message_batch | def send_message_batch(self, queue, messages):
"""
Delivers up to 10 messages to a queue in a single request.
:type queue: A :class:`boto.sqs.queue.Queue` object.
:param queue: The Queue to which the messages will be written.
:type messages: List of lists.
:param messag... | python | def send_message_batch(self, queue, messages):
"""
Delivers up to 10 messages to a queue in a single request.
:type queue: A :class:`boto.sqs.queue.Queue` object.
:param queue: The Queue to which the messages will be written.
:type messages: List of lists.
:param messag... | [
"def",
"send_message_batch",
"(",
"self",
",",
"queue",
",",
"messages",
")",
":",
"params",
"=",
"{",
"}",
"for",
"i",
",",
"msg",
"in",
"enumerate",
"(",
"messages",
")",
":",
"p_name",
"=",
"'SendMessageBatchRequestEntry.%i.Id'",
"%",
"(",
"i",
"+",
"... | Delivers up to 10 messages to a queue in a single request.
:type queue: A :class:`boto.sqs.queue.Queue` object.
:param queue: The Queue to which the messages will be written.
:type messages: List of lists.
:param messages: A list of lists or tuples. Each inner
tuple repres... | [
"Delivers",
"up",
"to",
"10",
"messages",
"to",
"a",
"queue",
"in",
"a",
"single",
"request",
"."
] | fffb056f5ff2324d1d5c1304014cfb1d899f602e | https://github.com/yyuu/botornado/blob/fffb056f5ff2324d1d5c1304014cfb1d899f602e/boto/sqs/connection.py#L222-L248 |
50,777 | yyuu/botornado | boto/sqs/connection.py | SQSConnection.get_all_queues | def get_all_queues(self, prefix=''):
"""
Retrieves all queues.
:keyword str prefix: Optionally, only return queues that start with
this value.
:rtype: list
:returns: A list of :py:class:`boto.sqs.queue.Queue` instances.
"""
params = {}
if pref... | python | def get_all_queues(self, prefix=''):
"""
Retrieves all queues.
:keyword str prefix: Optionally, only return queues that start with
this value.
:rtype: list
:returns: A list of :py:class:`boto.sqs.queue.Queue` instances.
"""
params = {}
if pref... | [
"def",
"get_all_queues",
"(",
"self",
",",
"prefix",
"=",
"''",
")",
":",
"params",
"=",
"{",
"}",
"if",
"prefix",
":",
"params",
"[",
"'QueueNamePrefix'",
"]",
"=",
"prefix",
"return",
"self",
".",
"get_list",
"(",
"'ListQueues'",
",",
"params",
",",
... | Retrieves all queues.
:keyword str prefix: Optionally, only return queues that start with
this value.
:rtype: list
:returns: A list of :py:class:`boto.sqs.queue.Queue` instances. | [
"Retrieves",
"all",
"queues",
"."
] | fffb056f5ff2324d1d5c1304014cfb1d899f602e | https://github.com/yyuu/botornado/blob/fffb056f5ff2324d1d5c1304014cfb1d899f602e/boto/sqs/connection.py#L271-L283 |
50,778 | yyuu/botornado | boto/sqs/connection.py | SQSConnection.get_queue | def get_queue(self, queue_name):
"""
Retrieves the queue with the given name, or ``None`` if no match
was found.
:param str queue_name: The name of the queue to retrieve.
:rtype: :py:class:`boto.sqs.queue.Queue` or ``None``
:returns: The requested queue, or ``None`` if n... | python | def get_queue(self, queue_name):
"""
Retrieves the queue with the given name, or ``None`` if no match
was found.
:param str queue_name: The name of the queue to retrieve.
:rtype: :py:class:`boto.sqs.queue.Queue` or ``None``
:returns: The requested queue, or ``None`` if n... | [
"def",
"get_queue",
"(",
"self",
",",
"queue_name",
")",
":",
"rs",
"=",
"self",
".",
"get_all_queues",
"(",
"queue_name",
")",
"for",
"q",
"in",
"rs",
":",
"if",
"q",
".",
"url",
".",
"endswith",
"(",
"queue_name",
")",
":",
"return",
"q",
"return",... | Retrieves the queue with the given name, or ``None`` if no match
was found.
:param str queue_name: The name of the queue to retrieve.
:rtype: :py:class:`boto.sqs.queue.Queue` or ``None``
:returns: The requested queue, or ``None`` if no match was found. | [
"Retrieves",
"the",
"queue",
"with",
"the",
"given",
"name",
"or",
"None",
"if",
"no",
"match",
"was",
"found",
"."
] | fffb056f5ff2324d1d5c1304014cfb1d899f602e | https://github.com/yyuu/botornado/blob/fffb056f5ff2324d1d5c1304014cfb1d899f602e/boto/sqs/connection.py#L285-L298 |
50,779 | llazzaro/analyzerstrategies | analyzerstrategies/periodStrategy.py | PeriodStrategy.increase_and_check_counter | def increase_and_check_counter(self):
''' increase counter by one and check whether a period is end '''
self.counter += 1
self.counter %= self.period
if not self.counter:
return True
else:
return False | python | def increase_and_check_counter(self):
''' increase counter by one and check whether a period is end '''
self.counter += 1
self.counter %= self.period
if not self.counter:
return True
else:
return False | [
"def",
"increase_and_check_counter",
"(",
"self",
")",
":",
"self",
".",
"counter",
"+=",
"1",
"self",
".",
"counter",
"%=",
"self",
".",
"period",
"if",
"not",
"self",
".",
"counter",
":",
"return",
"True",
"else",
":",
"return",
"False"
] | increase counter by one and check whether a period is end | [
"increase",
"counter",
"by",
"one",
"and",
"check",
"whether",
"a",
"period",
"is",
"end"
] | 3c647802f582bf2f06c6793f282bee0d26514cd6 | https://github.com/llazzaro/analyzerstrategies/blob/3c647802f582bf2f06c6793f282bee0d26514cd6/analyzerstrategies/periodStrategy.py#L27-L34 |
50,780 | gmichaeljaison/cv-utils | cv_utils/template_matching.py | match_one | def match_one(template, image, options=None):
"""
Match template and find exactly one match in the Image using specified features.
:param template: Template Image
:param image: Search Image
:param options: Options include
- features: List of options for each feature
:return: (Box, Score... | python | def match_one(template, image, options=None):
"""
Match template and find exactly one match in the Image using specified features.
:param template: Template Image
:param image: Search Image
:param options: Options include
- features: List of options for each feature
:return: (Box, Score... | [
"def",
"match_one",
"(",
"template",
",",
"image",
",",
"options",
"=",
"None",
")",
":",
"heatmap",
",",
"scale",
"=",
"multi_feat_match",
"(",
"template",
",",
"image",
",",
"options",
")",
"min_val",
",",
"_",
",",
"min_loc",
",",
"_",
"=",
"cv",
... | Match template and find exactly one match in the Image using specified features.
:param template: Template Image
:param image: Search Image
:param options: Options include
- features: List of options for each feature
:return: (Box, Score) Bounding box of the matched object, Heatmap value | [
"Match",
"template",
"and",
"find",
"exactly",
"one",
"match",
"in",
"the",
"Image",
"using",
"specified",
"features",
"."
] | a8251c870165a7428d8c468a6436aa41d0cf7c09 | https://github.com/gmichaeljaison/cv-utils/blob/a8251c870165a7428d8c468a6436aa41d0cf7c09/cv_utils/template_matching.py#L16-L33 |
50,781 | gmichaeljaison/cv-utils | cv_utils/template_matching.py | feature_match | def feature_match(template, image, options=None):
"""
Match template and image by extracting specified feature
:param template: Template image
:param image: Search image
:param options: Options include
- feature: Feature extractor to use. Default is 'rgb'. Available options are:
... | python | def feature_match(template, image, options=None):
"""
Match template and image by extracting specified feature
:param template: Template image
:param image: Search image
:param options: Options include
- feature: Feature extractor to use. Default is 'rgb'. Available options are:
... | [
"def",
"feature_match",
"(",
"template",
",",
"image",
",",
"options",
"=",
"None",
")",
":",
"op",
"=",
"_DEF_TM_OPT",
".",
"copy",
"(",
")",
"if",
"options",
"is",
"not",
"None",
":",
"op",
".",
"update",
"(",
"options",
")",
"feat",
"=",
"fe",
"... | Match template and image by extracting specified feature
:param template: Template image
:param image: Search image
:param options: Options include
- feature: Feature extractor to use. Default is 'rgb'. Available options are:
'hog', 'lab', 'rgb', 'gray'
:return: Heatmap | [
"Match",
"template",
"and",
"image",
"by",
"extracting",
"specified",
"feature"
] | a8251c870165a7428d8c468a6436aa41d0cf7c09 | https://github.com/gmichaeljaison/cv-utils/blob/a8251c870165a7428d8c468a6436aa41d0cf7c09/cv_utils/template_matching.py#L59-L80 |
50,782 | gmichaeljaison/cv-utils | cv_utils/template_matching.py | match_template | def match_template(template, image, options=None):
"""
Multi channel template matching using simple correlation distance
:param template: Template image
:param image: Search image
:param options: Other options:
- distance: Distance measure to use. Default: 'correlation'
- normalize:... | python | def match_template(template, image, options=None):
"""
Multi channel template matching using simple correlation distance
:param template: Template image
:param image: Search image
:param options: Other options:
- distance: Distance measure to use. Default: 'correlation'
- normalize:... | [
"def",
"match_template",
"(",
"template",
",",
"image",
",",
"options",
"=",
"None",
")",
":",
"# If the input has max of 3 channels, use the faster OpenCV matching",
"if",
"len",
"(",
"image",
".",
"shape",
")",
"<=",
"3",
"and",
"image",
".",
"shape",
"[",
"2"... | Multi channel template matching using simple correlation distance
:param template: Template image
:param image: Search image
:param options: Other options:
- distance: Distance measure to use. Default: 'correlation'
- normalize: Heatmap values will be in the range of 0 to 1. Default: True
... | [
"Multi",
"channel",
"template",
"matching",
"using",
"simple",
"correlation",
"distance"
] | a8251c870165a7428d8c468a6436aa41d0cf7c09 | https://github.com/gmichaeljaison/cv-utils/blob/a8251c870165a7428d8c468a6436aa41d0cf7c09/cv_utils/template_matching.py#L83-L133 |
50,783 | gmichaeljaison/cv-utils | cv_utils/template_matching.py | match_template_opencv | def match_template_opencv(template, image, options):
"""
Match template using OpenCV template matching implementation.
Limited by number of channels as maximum of 3.
Suitable for direct RGB or Gray-scale matching
:param options: Other options:
- distance: Distance measure to use. (e... | python | def match_template_opencv(template, image, options):
"""
Match template using OpenCV template matching implementation.
Limited by number of channels as maximum of 3.
Suitable for direct RGB or Gray-scale matching
:param options: Other options:
- distance: Distance measure to use. (e... | [
"def",
"match_template_opencv",
"(",
"template",
",",
"image",
",",
"options",
")",
":",
"# if image has more than 3 channels, use own implementation",
"if",
"len",
"(",
"image",
".",
"shape",
")",
">",
"3",
":",
"return",
"match_template",
"(",
"template",
",",
"... | Match template using OpenCV template matching implementation.
Limited by number of channels as maximum of 3.
Suitable for direct RGB or Gray-scale matching
:param options: Other options:
- distance: Distance measure to use. (euclidean | correlation | ccoeff).
Default: 'correlati... | [
"Match",
"template",
"using",
"OpenCV",
"template",
"matching",
"implementation",
".",
"Limited",
"by",
"number",
"of",
"channels",
"as",
"maximum",
"of",
"3",
".",
"Suitable",
"for",
"direct",
"RGB",
"or",
"Gray",
"-",
"scale",
"matching"
] | a8251c870165a7428d8c468a6436aa41d0cf7c09 | https://github.com/gmichaeljaison/cv-utils/blob/a8251c870165a7428d8c468a6436aa41d0cf7c09/cv_utils/template_matching.py#L136-L185 |
50,784 | guyskk/flask-restaction | flask_restaction/res.py | resp_json | def resp_json(resp):
"""
Get JSON from response if success, raise requests.HTTPError otherwise.
Args:
resp: requests.Response or flask.Response
Retuens:
JSON value
"""
if isinstance(resp, flask.Response):
if 400 <= resp.status_code < 600:
msg = resp.status
... | python | def resp_json(resp):
"""
Get JSON from response if success, raise requests.HTTPError otherwise.
Args:
resp: requests.Response or flask.Response
Retuens:
JSON value
"""
if isinstance(resp, flask.Response):
if 400 <= resp.status_code < 600:
msg = resp.status
... | [
"def",
"resp_json",
"(",
"resp",
")",
":",
"if",
"isinstance",
"(",
"resp",
",",
"flask",
".",
"Response",
")",
":",
"if",
"400",
"<=",
"resp",
".",
"status_code",
"<",
"600",
":",
"msg",
"=",
"resp",
".",
"status",
"try",
":",
"result",
"=",
"load... | Get JSON from response if success, raise requests.HTTPError otherwise.
Args:
resp: requests.Response or flask.Response
Retuens:
JSON value | [
"Get",
"JSON",
"from",
"response",
"if",
"success",
"raise",
"requests",
".",
"HTTPError",
"otherwise",
"."
] | 17db010b0cbba16bbc2408081975955b03553eb7 | https://github.com/guyskk/flask-restaction/blob/17db010b0cbba16bbc2408081975955b03553eb7/flask_restaction/res.py#L7-L43 |
50,785 | borntyping/python-riemann-client | riemann_client/client.py | Client.create_event | def create_event(data):
"""Translates a dictionary of event attributes to an Event object
:param dict data: The attributes to be set on the event
:returns: A protocol buffer ``Event`` object
"""
event = riemann_client.riemann_pb2.Event()
event.host = socket.gethostname()... | python | def create_event(data):
"""Translates a dictionary of event attributes to an Event object
:param dict data: The attributes to be set on the event
:returns: A protocol buffer ``Event`` object
"""
event = riemann_client.riemann_pb2.Event()
event.host = socket.gethostname()... | [
"def",
"create_event",
"(",
"data",
")",
":",
"event",
"=",
"riemann_client",
".",
"riemann_pb2",
".",
"Event",
"(",
")",
"event",
".",
"host",
"=",
"socket",
".",
"gethostname",
"(",
")",
"event",
".",
"tags",
".",
"extend",
"(",
"data",
".",
"pop",
... | Translates a dictionary of event attributes to an Event object
:param dict data: The attributes to be set on the event
:returns: A protocol buffer ``Event`` object | [
"Translates",
"a",
"dictionary",
"of",
"event",
"attributes",
"to",
"an",
"Event",
"object"
] | 3e181d90bdf685afd21c1ec5ee20e6840b011ea5 | https://github.com/borntyping/python-riemann-client/blob/3e181d90bdf685afd21c1ec5ee20e6840b011ea5/riemann_client/client.py#L78-L95 |
50,786 | borntyping/python-riemann-client | riemann_client/client.py | Client.send_events | def send_events(self, events):
"""Sends multiple events to Riemann in a single message
:param events: A list or iterable of ``Event`` objects
:returns: The response message from Riemann
"""
message = riemann_client.riemann_pb2.Msg()
for event in events:
messa... | python | def send_events(self, events):
"""Sends multiple events to Riemann in a single message
:param events: A list or iterable of ``Event`` objects
:returns: The response message from Riemann
"""
message = riemann_client.riemann_pb2.Msg()
for event in events:
messa... | [
"def",
"send_events",
"(",
"self",
",",
"events",
")",
":",
"message",
"=",
"riemann_client",
".",
"riemann_pb2",
".",
"Msg",
"(",
")",
"for",
"event",
"in",
"events",
":",
"message",
".",
"events",
".",
"add",
"(",
")",
".",
"MergeFrom",
"(",
"event",... | Sends multiple events to Riemann in a single message
:param events: A list or iterable of ``Event`` objects
:returns: The response message from Riemann | [
"Sends",
"multiple",
"events",
"to",
"Riemann",
"in",
"a",
"single",
"message"
] | 3e181d90bdf685afd21c1ec5ee20e6840b011ea5 | https://github.com/borntyping/python-riemann-client/blob/3e181d90bdf685afd21c1ec5ee20e6840b011ea5/riemann_client/client.py#L97-L106 |
50,787 | borntyping/python-riemann-client | riemann_client/client.py | Client.events | def events(self, *events):
"""Sends multiple events in a single message
>>> client.events({'service': 'riemann-client', 'state': 'awesome'})
:param \*events: event dictionaries for :py:func:`create_event`
:returns: The response message from Riemann
"""
return self.sen... | python | def events(self, *events):
"""Sends multiple events in a single message
>>> client.events({'service': 'riemann-client', 'state': 'awesome'})
:param \*events: event dictionaries for :py:func:`create_event`
:returns: The response message from Riemann
"""
return self.sen... | [
"def",
"events",
"(",
"self",
",",
"*",
"events",
")",
":",
"return",
"self",
".",
"send_events",
"(",
"self",
".",
"create_event",
"(",
"e",
")",
"for",
"e",
"in",
"events",
")"
] | Sends multiple events in a single message
>>> client.events({'service': 'riemann-client', 'state': 'awesome'})
:param \*events: event dictionaries for :py:func:`create_event`
:returns: The response message from Riemann | [
"Sends",
"multiple",
"events",
"in",
"a",
"single",
"message"
] | 3e181d90bdf685afd21c1ec5ee20e6840b011ea5 | https://github.com/borntyping/python-riemann-client/blob/3e181d90bdf685afd21c1ec5ee20e6840b011ea5/riemann_client/client.py#L116-L124 |
50,788 | borntyping/python-riemann-client | riemann_client/client.py | Client.create_dict | def create_dict(event):
"""Translates an Event object to a dictionary of event attributes
All attributes are included, so ``create_dict(create_event(input))``
may return more attributes than were present in the input.
:param event: A protocol buffer ``Event`` object
:returns: A... | python | def create_dict(event):
"""Translates an Event object to a dictionary of event attributes
All attributes are included, so ``create_dict(create_event(input))``
may return more attributes than were present in the input.
:param event: A protocol buffer ``Event`` object
:returns: A... | [
"def",
"create_dict",
"(",
"event",
")",
":",
"data",
"=",
"dict",
"(",
")",
"for",
"descriptor",
",",
"value",
"in",
"event",
".",
"ListFields",
"(",
")",
":",
"if",
"descriptor",
".",
"name",
"==",
"'tags'",
":",
"value",
"=",
"list",
"(",
"value",... | Translates an Event object to a dictionary of event attributes
All attributes are included, so ``create_dict(create_event(input))``
may return more attributes than were present in the input.
:param event: A protocol buffer ``Event`` object
:returns: A dictionary of event attributes | [
"Translates",
"an",
"Event",
"object",
"to",
"a",
"dictionary",
"of",
"event",
"attributes"
] | 3e181d90bdf685afd21c1ec5ee20e6840b011ea5 | https://github.com/borntyping/python-riemann-client/blob/3e181d90bdf685afd21c1ec5ee20e6840b011ea5/riemann_client/client.py#L137-L156 |
50,789 | borntyping/python-riemann-client | riemann_client/client.py | QueuedClient.send_events | def send_events(self, events):
"""Adds multiple events to the queued message
:returns: None - nothing has been sent to the Riemann server yet
"""
for event in events:
self.queue.events.add().MergeFrom(event)
return None | python | def send_events(self, events):
"""Adds multiple events to the queued message
:returns: None - nothing has been sent to the Riemann server yet
"""
for event in events:
self.queue.events.add().MergeFrom(event)
return None | [
"def",
"send_events",
"(",
"self",
",",
"events",
")",
":",
"for",
"event",
"in",
"events",
":",
"self",
".",
"queue",
".",
"events",
".",
"add",
"(",
")",
".",
"MergeFrom",
"(",
"event",
")",
"return",
"None"
] | Adds multiple events to the queued message
:returns: None - nothing has been sent to the Riemann server yet | [
"Adds",
"multiple",
"events",
"to",
"the",
"queued",
"message"
] | 3e181d90bdf685afd21c1ec5ee20e6840b011ea5 | https://github.com/borntyping/python-riemann-client/blob/3e181d90bdf685afd21c1ec5ee20e6840b011ea5/riemann_client/client.py#L210-L217 |
50,790 | yyuu/botornado | boto/https_connection.py | GetValidHostsForCert | def GetValidHostsForCert(cert):
"""Returns a list of valid host globs for an SSL certificate.
Args:
cert: A dictionary representing an SSL certificate.
Returns:
list: A list of valid host globs.
"""
if 'subjectAltName' in cert:
return [x[1] for x in cert['subjectAltName'] if x[0].lower() == 'dns'... | python | def GetValidHostsForCert(cert):
"""Returns a list of valid host globs for an SSL certificate.
Args:
cert: A dictionary representing an SSL certificate.
Returns:
list: A list of valid host globs.
"""
if 'subjectAltName' in cert:
return [x[1] for x in cert['subjectAltName'] if x[0].lower() == 'dns'... | [
"def",
"GetValidHostsForCert",
"(",
"cert",
")",
":",
"if",
"'subjectAltName'",
"in",
"cert",
":",
"return",
"[",
"x",
"[",
"1",
"]",
"for",
"x",
"in",
"cert",
"[",
"'subjectAltName'",
"]",
"if",
"x",
"[",
"0",
"]",
".",
"lower",
"(",
")",
"==",
"'... | Returns a list of valid host globs for an SSL certificate.
Args:
cert: A dictionary representing an SSL certificate.
Returns:
list: A list of valid host globs. | [
"Returns",
"a",
"list",
"of",
"valid",
"host",
"globs",
"for",
"an",
"SSL",
"certificate",
"."
] | fffb056f5ff2324d1d5c1304014cfb1d899f602e | https://github.com/yyuu/botornado/blob/fffb056f5ff2324d1d5c1304014cfb1d899f602e/boto/https_connection.py#L48-L60 |
50,791 | yyuu/botornado | boto/https_connection.py | ValidateCertificateHostname | def ValidateCertificateHostname(cert, hostname):
"""Validates that a given hostname is valid for an SSL certificate.
Args:
cert: A dictionary representing an SSL certificate.
hostname: The hostname to test.
Returns:
bool: Whether or not the hostname is valid for this certificate.
"""
hosts = GetV... | python | def ValidateCertificateHostname(cert, hostname):
"""Validates that a given hostname is valid for an SSL certificate.
Args:
cert: A dictionary representing an SSL certificate.
hostname: The hostname to test.
Returns:
bool: Whether or not the hostname is valid for this certificate.
"""
hosts = GetV... | [
"def",
"ValidateCertificateHostname",
"(",
"cert",
",",
"hostname",
")",
":",
"hosts",
"=",
"GetValidHostsForCert",
"(",
"cert",
")",
"boto",
".",
"log",
".",
"debug",
"(",
"\"validating server certificate: hostname=%s, certificate hosts=%s\"",
",",
"hostname",
",",
"... | Validates that a given hostname is valid for an SSL certificate.
Args:
cert: A dictionary representing an SSL certificate.
hostname: The hostname to test.
Returns:
bool: Whether or not the hostname is valid for this certificate. | [
"Validates",
"that",
"a",
"given",
"hostname",
"is",
"valid",
"for",
"an",
"SSL",
"certificate",
"."
] | fffb056f5ff2324d1d5c1304014cfb1d899f602e | https://github.com/yyuu/botornado/blob/fffb056f5ff2324d1d5c1304014cfb1d899f602e/boto/https_connection.py#L62-L79 |
50,792 | Trebek/pydealer | pydealer/stack.py | Stack.add | def add(self, cards, end=TOP):
"""
Adds the given list of ``Card`` instances to the top of the stack.
:arg cards:
The cards to add to the ``Stack``. Can be a single ``Card``
instance, or a ``list`` of cards.
:arg str end:
The end of the ``Stack`` to a... | python | def add(self, cards, end=TOP):
"""
Adds the given list of ``Card`` instances to the top of the stack.
:arg cards:
The cards to add to the ``Stack``. Can be a single ``Card``
instance, or a ``list`` of cards.
:arg str end:
The end of the ``Stack`` to a... | [
"def",
"add",
"(",
"self",
",",
"cards",
",",
"end",
"=",
"TOP",
")",
":",
"if",
"end",
"is",
"TOP",
":",
"try",
":",
"self",
".",
"cards",
"+=",
"cards",
"except",
":",
"self",
".",
"cards",
"+=",
"[",
"cards",
"]",
"elif",
"end",
"is",
"BOTTO... | Adds the given list of ``Card`` instances to the top of the stack.
:arg cards:
The cards to add to the ``Stack``. Can be a single ``Card``
instance, or a ``list`` of cards.
:arg str end:
The end of the ``Stack`` to add the cards to. Can be ``TOP`` ("top")
... | [
"Adds",
"the",
"given",
"list",
"of",
"Card",
"instances",
"to",
"the",
"top",
"of",
"the",
"stack",
"."
] | 2ac583dd8c55715658c740b614387775f4dda333 | https://github.com/Trebek/pydealer/blob/2ac583dd8c55715658c740b614387775f4dda333/pydealer/stack.py#L244-L265 |
50,793 | Trebek/pydealer | pydealer/stack.py | Stack.deal | def deal(self, num=1, end=TOP):
"""
Returns a list of cards, which are removed from the Stack.
:arg int num:
The number of cards to deal.
:arg str end:
Which end to deal from. Can be ``0`` (top) or ``1`` (bottom).
:returns:
The given number o... | python | def deal(self, num=1, end=TOP):
"""
Returns a list of cards, which are removed from the Stack.
:arg int num:
The number of cards to deal.
:arg str end:
Which end to deal from. Can be ``0`` (top) or ``1`` (bottom).
:returns:
The given number o... | [
"def",
"deal",
"(",
"self",
",",
"num",
"=",
"1",
",",
"end",
"=",
"TOP",
")",
":",
"ends",
"=",
"{",
"TOP",
":",
"self",
".",
"cards",
".",
"pop",
",",
"BOTTOM",
":",
"self",
".",
"cards",
".",
"popleft",
"}",
"self_size",
"=",
"self",
".",
... | Returns a list of cards, which are removed from the Stack.
:arg int num:
The number of cards to deal.
:arg str end:
Which end to deal from. Can be ``0`` (top) or ``1`` (bottom).
:returns:
The given number of cards from the stack. | [
"Returns",
"a",
"list",
"of",
"cards",
"which",
"are",
"removed",
"from",
"the",
"Stack",
"."
] | 2ac583dd8c55715658c740b614387775f4dda333 | https://github.com/Trebek/pydealer/blob/2ac583dd8c55715658c740b614387775f4dda333/pydealer/stack.py#L291-L324 |
50,794 | Trebek/pydealer | pydealer/stack.py | Stack.empty | def empty(self, return_cards=False):
"""
Empties the stack, removing all cards from it, and returns them.
:arg bool return_cards:
Whether or not to return the cards.
:returns:
If ``return_cards=True``, a list containing the cards removed
from the Sta... | python | def empty(self, return_cards=False):
"""
Empties the stack, removing all cards from it, and returns them.
:arg bool return_cards:
Whether or not to return the cards.
:returns:
If ``return_cards=True``, a list containing the cards removed
from the Sta... | [
"def",
"empty",
"(",
"self",
",",
"return_cards",
"=",
"False",
")",
":",
"cards",
"=",
"list",
"(",
"self",
".",
"cards",
")",
"self",
".",
"cards",
"=",
"[",
"]",
"if",
"return_cards",
":",
"return",
"cards"
] | Empties the stack, removing all cards from it, and returns them.
:arg bool return_cards:
Whether or not to return the cards.
:returns:
If ``return_cards=True``, a list containing the cards removed
from the Stack. | [
"Empties",
"the",
"stack",
"removing",
"all",
"cards",
"from",
"it",
"and",
"returns",
"them",
"."
] | 2ac583dd8c55715658c740b614387775f4dda333 | https://github.com/Trebek/pydealer/blob/2ac583dd8c55715658c740b614387775f4dda333/pydealer/stack.py#L326-L342 |
50,795 | Trebek/pydealer | pydealer/stack.py | Stack.find | def find(self, term, limit=0, sort=False, ranks=None):
"""
Searches the stack for cards with a value, suit, name, or
abbreviation matching the given argument, 'term'.
:arg str term:
The search term. Can be a card full name, value, suit,
or abbreviation.
:... | python | def find(self, term, limit=0, sort=False, ranks=None):
"""
Searches the stack for cards with a value, suit, name, or
abbreviation matching the given argument, 'term'.
:arg str term:
The search term. Can be a card full name, value, suit,
or abbreviation.
:... | [
"def",
"find",
"(",
"self",
",",
"term",
",",
"limit",
"=",
"0",
",",
"sort",
"=",
"False",
",",
"ranks",
"=",
"None",
")",
":",
"ranks",
"=",
"ranks",
"or",
"self",
".",
"ranks",
"found_indices",
"=",
"[",
"]",
"count",
"=",
"0",
"if",
"not",
... | Searches the stack for cards with a value, suit, name, or
abbreviation matching the given argument, 'term'.
:arg str term:
The search term. Can be a card full name, value, suit,
or abbreviation.
:arg int limit:
The number of items to retrieve for each term. `... | [
"Searches",
"the",
"stack",
"for",
"cards",
"with",
"a",
"value",
"suit",
"name",
"or",
"abbreviation",
"matching",
"the",
"given",
"argument",
"term",
"."
] | 2ac583dd8c55715658c740b614387775f4dda333 | https://github.com/Trebek/pydealer/blob/2ac583dd8c55715658c740b614387775f4dda333/pydealer/stack.py#L344-L386 |
50,796 | Trebek/pydealer | pydealer/stack.py | Stack.get_list | def get_list(self, terms, limit=0, sort=False, ranks=None):
"""
Get the specified cards from the stack.
:arg term:
The search term. Can be a card full name, value, suit,
abbreviation, or stack indice.
:arg int limit:
The number of items to retrieve fo... | python | def get_list(self, terms, limit=0, sort=False, ranks=None):
"""
Get the specified cards from the stack.
:arg term:
The search term. Can be a card full name, value, suit,
abbreviation, or stack indice.
:arg int limit:
The number of items to retrieve fo... | [
"def",
"get_list",
"(",
"self",
",",
"terms",
",",
"limit",
"=",
"0",
",",
"sort",
"=",
"False",
",",
"ranks",
"=",
"None",
")",
":",
"ranks",
"=",
"ranks",
"or",
"self",
".",
"ranks",
"got_cards",
"=",
"[",
"]",
"try",
":",
"indices",
"=",
"self... | Get the specified cards from the stack.
:arg term:
The search term. Can be a card full name, value, suit,
abbreviation, or stack indice.
:arg int limit:
The number of items to retrieve for each term.
:arg bool sort:
Whether or not to sort the resu... | [
"Get",
"the",
"specified",
"cards",
"from",
"the",
"stack",
"."
] | 2ac583dd8c55715658c740b614387775f4dda333 | https://github.com/Trebek/pydealer/blob/2ac583dd8c55715658c740b614387775f4dda333/pydealer/stack.py#L470-L516 |
50,797 | Trebek/pydealer | pydealer/stack.py | Stack.insert | def insert(self, card, indice=-1):
"""
Insert a given card into the stack at a given indice.
:arg Card card:
The card to insert into the stack.
:arg int indice:
Where to insert the given card.
"""
self_size = len(self.cards)
if indice in... | python | def insert(self, card, indice=-1):
"""
Insert a given card into the stack at a given indice.
:arg Card card:
The card to insert into the stack.
:arg int indice:
Where to insert the given card.
"""
self_size = len(self.cards)
if indice in... | [
"def",
"insert",
"(",
"self",
",",
"card",
",",
"indice",
"=",
"-",
"1",
")",
":",
"self_size",
"=",
"len",
"(",
"self",
".",
"cards",
")",
"if",
"indice",
"in",
"[",
"0",
",",
"-",
"1",
"]",
":",
"if",
"indice",
"==",
"-",
"1",
":",
"self",
... | Insert a given card into the stack at a given indice.
:arg Card card:
The card to insert into the stack.
:arg int indice:
Where to insert the given card. | [
"Insert",
"a",
"given",
"card",
"into",
"the",
"stack",
"at",
"a",
"given",
"indice",
"."
] | 2ac583dd8c55715658c740b614387775f4dda333 | https://github.com/Trebek/pydealer/blob/2ac583dd8c55715658c740b614387775f4dda333/pydealer/stack.py#L518-L537 |
50,798 | Trebek/pydealer | pydealer/stack.py | Stack.insert_list | def insert_list(self, cards, indice=-1):
"""
Insert a list of given cards into the stack at a given indice.
:arg list cards:
The list of cards to insert into the stack.
:arg int indice:
Where to insert the given cards.
"""
self_size = len(self.ca... | python | def insert_list(self, cards, indice=-1):
"""
Insert a list of given cards into the stack at a given indice.
:arg list cards:
The list of cards to insert into the stack.
:arg int indice:
Where to insert the given cards.
"""
self_size = len(self.ca... | [
"def",
"insert_list",
"(",
"self",
",",
"cards",
",",
"indice",
"=",
"-",
"1",
")",
":",
"self_size",
"=",
"len",
"(",
"self",
".",
"cards",
")",
"if",
"indice",
"in",
"[",
"0",
",",
"-",
"1",
"]",
":",
"if",
"indice",
"==",
"-",
"1",
":",
"s... | Insert a list of given cards into the stack at a given indice.
:arg list cards:
The list of cards to insert into the stack.
:arg int indice:
Where to insert the given cards. | [
"Insert",
"a",
"list",
"of",
"given",
"cards",
"into",
"the",
"stack",
"at",
"a",
"given",
"indice",
"."
] | 2ac583dd8c55715658c740b614387775f4dda333 | https://github.com/Trebek/pydealer/blob/2ac583dd8c55715658c740b614387775f4dda333/pydealer/stack.py#L540-L559 |
50,799 | Trebek/pydealer | pydealer/stack.py | Stack.is_sorted | def is_sorted(self, ranks=None):
"""
Checks whether the stack is sorted.
:arg dict ranks:
The rank dict to reference for checking. If ``None``, it will
default to ``DEFAULT_RANKS``.
:returns:
Whether or not the cards are sorted.
"""
... | python | def is_sorted(self, ranks=None):
"""
Checks whether the stack is sorted.
:arg dict ranks:
The rank dict to reference for checking. If ``None``, it will
default to ``DEFAULT_RANKS``.
:returns:
Whether or not the cards are sorted.
"""
... | [
"def",
"is_sorted",
"(",
"self",
",",
"ranks",
"=",
"None",
")",
":",
"ranks",
"=",
"ranks",
"or",
"self",
".",
"ranks",
"return",
"check_sorted",
"(",
"self",
",",
"ranks",
")"
] | Checks whether the stack is sorted.
:arg dict ranks:
The rank dict to reference for checking. If ``None``, it will
default to ``DEFAULT_RANKS``.
:returns:
Whether or not the cards are sorted. | [
"Checks",
"whether",
"the",
"stack",
"is",
"sorted",
"."
] | 2ac583dd8c55715658c740b614387775f4dda333 | https://github.com/Trebek/pydealer/blob/2ac583dd8c55715658c740b614387775f4dda333/pydealer/stack.py#L562-L576 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.