nwo stringlengths 5 106 | sha stringlengths 40 40 | path stringlengths 4 174 | language stringclasses 1
value | identifier stringlengths 1 140 | parameters stringlengths 0 87.7k | argument_list stringclasses 1
value | return_statement stringlengths 0 426k | docstring stringlengths 0 64.3k | docstring_summary stringlengths 0 26.3k | docstring_tokens list | function stringlengths 18 4.83M | function_tokens list | url stringlengths 83 304 |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
holzschu/Carnets | 44effb10ddfc6aa5c8b0687582a724ba82c6b547 | Library/lib/python3.7/site-packages/sympy/printing/pretty/stringpict.py | python | stringPict.__init__ | (self, s, baseline=0) | Initialize from string.
Multiline strings are centered. | Initialize from string.
Multiline strings are centered. | [
"Initialize",
"from",
"string",
".",
"Multiline",
"strings",
"are",
"centered",
"."
] | def __init__(self, s, baseline=0):
"""Initialize from string.
Multiline strings are centered.
"""
self.s = s
#picture is a string that just can be printed
self.picture = stringPict.equalLengths(s.splitlines())
#baseline is the line number of the "base line"
... | [
"def",
"__init__",
"(",
"self",
",",
"s",
",",
"baseline",
"=",
"0",
")",
":",
"self",
".",
"s",
"=",
"s",
"#picture is a string that just can be printed",
"self",
".",
"picture",
"=",
"stringPict",
".",
"equalLengths",
"(",
"s",
".",
"splitlines",
"(",
")... | https://github.com/holzschu/Carnets/blob/44effb10ddfc6aa5c8b0687582a724ba82c6b547/Library/lib/python3.7/site-packages/sympy/printing/pretty/stringpict.py#L27-L36 | ||
sagemath/sage | f9b2db94f675ff16963ccdefba4f1a3393b3fe0d | src/sage/misc/classgraph.py | python | class_graph | (top, depth=5, name_filter=None, classes=None, as_graph=True) | Return the class inheritance graph of a module, class, or object
INPUT:
- ``top`` -- the module, class, or object to start with (e.g. ``sage``, ``Integer``, ``3``)
- ``depth`` -- maximal recursion depth within submodules (default: 5)
- ``name_filter`` -- e.g. 'sage.rings' to only consider classes i... | Return the class inheritance graph of a module, class, or object | [
"Return",
"the",
"class",
"inheritance",
"graph",
"of",
"a",
"module",
"class",
"or",
"object"
] | def class_graph(top, depth=5, name_filter=None, classes=None, as_graph=True):
"""
Return the class inheritance graph of a module, class, or object
INPUT:
- ``top`` -- the module, class, or object to start with (e.g. ``sage``, ``Integer``, ``3``)
- ``depth`` -- maximal recursion depth within subm... | [
"def",
"class_graph",
"(",
"top",
",",
"depth",
"=",
"5",
",",
"name_filter",
"=",
"None",
",",
"classes",
"=",
"None",
",",
"as_graph",
"=",
"True",
")",
":",
"# This function descends recursively down the submodules of the",
"# top module (if ``top`` is a module) and ... | https://github.com/sagemath/sage/blob/f9b2db94f675ff16963ccdefba4f1a3393b3fe0d/src/sage/misc/classgraph.py#L15-L127 | ||
selfteaching/selfteaching-python-camp | 9982ee964b984595e7d664b07c389cddaf158f1e | exercises/1901100065/d09/mymodule/stats_word.py | python | stats_text_en | (text, count) | return Counter(text_list).most_common(count) | 输入一个英文字符串,统计字符串种每个英文但此出现的次数,最后返回一个按词频降序排列的数组。 | 输入一个英文字符串,统计字符串种每个英文但此出现的次数,最后返回一个按词频降序排列的数组。 | [
"输入一个英文字符串,统计字符串种每个英文但此出现的次数,最后返回一个按词频降序排列的数组。"
] | def stats_text_en(text, count):
"""输入一个英文字符串,统计字符串种每个英文但此出现的次数,最后返回一个按词频降序排列的数组。
"""
if not isinstance(text, str):
raise ValueError('返回参数必须是 str 类型,输入类型 %s ' % type(text))
# 将输入的字符串分词并整理成小写单词的列表
text1 = text.split()
text_list = []
symbols = '!,.-!*\''
for word in text1:
... | [
"def",
"stats_text_en",
"(",
"text",
",",
"count",
")",
":",
"if",
"not",
"isinstance",
"(",
"text",
",",
"str",
")",
":",
"raise",
"ValueError",
"(",
"'返回参数必须是 str 类型,输入类型 %s ' % type(text))",
"",
"",
"",
"",
"",
"",
"# 将输入的字符串分词并整理成小写单词的列表",
"text1",
"=",
... | https://github.com/selfteaching/selfteaching-python-camp/blob/9982ee964b984595e7d664b07c389cddaf158f1e/exercises/1901100065/d09/mymodule/stats_word.py#L7-L24 | |
zulip/python-zulip-api | 70b86614bd15347e28ec2cab4c87c01122faae16 | zulip_bots/zulip_bots/bots/merels/libraries/game_data.py | python | GameData.get_x_piece_possessed_not_on_grid | (self) | return 9 - self.x_taken - mechanics.get_piece("X", self.grid()) | Gets the amount of X pieces that the player X still have, but not
put yet on the grid
:return: Amount of pieces that X has, but not on grid | Gets the amount of X pieces that the player X still have, but not
put yet on the grid | [
"Gets",
"the",
"amount",
"of",
"X",
"pieces",
"that",
"the",
"player",
"X",
"still",
"have",
"but",
"not",
"put",
"yet",
"on",
"the",
"grid"
] | def get_x_piece_possessed_not_on_grid(self):
"""Gets the amount of X pieces that the player X still have, but not
put yet on the grid
:return: Amount of pieces that X has, but not on grid
"""
return 9 - self.x_taken - mechanics.get_piece("X", self.grid()) | [
"def",
"get_x_piece_possessed_not_on_grid",
"(",
"self",
")",
":",
"return",
"9",
"-",
"self",
".",
"x_taken",
"-",
"mechanics",
".",
"get_piece",
"(",
"\"X\"",
",",
"self",
".",
"grid",
"(",
")",
")"
] | https://github.com/zulip/python-zulip-api/blob/70b86614bd15347e28ec2cab4c87c01122faae16/zulip_bots/zulip_bots/bots/merels/libraries/game_data.py#L49-L55 | |
entropy1337/infernal-twin | 10995cd03312e39a48ade0f114ebb0ae3a711bb8 | Modules/build/pip/pip/_vendor/ipaddress.py | python | _BaseV6._explode_shorthand_ip_string | (self) | return ':'.join(parts) | Expand a shortened IPv6 address.
Args:
ip_str: A string, the IPv6 address.
Returns:
A string, the expanded IPv6 address. | Expand a shortened IPv6 address. | [
"Expand",
"a",
"shortened",
"IPv6",
"address",
"."
] | def _explode_shorthand_ip_string(self):
"""Expand a shortened IPv6 address.
Args:
ip_str: A string, the IPv6 address.
Returns:
A string, the expanded IPv6 address.
"""
if isinstance(self, IPv6Network):
ip_str = _compat_str(self.network_addre... | [
"def",
"_explode_shorthand_ip_string",
"(",
"self",
")",
":",
"if",
"isinstance",
"(",
"self",
",",
"IPv6Network",
")",
":",
"ip_str",
"=",
"_compat_str",
"(",
"self",
".",
"network_address",
")",
"elif",
"isinstance",
"(",
"self",
",",
"IPv6Interface",
")",
... | https://github.com/entropy1337/infernal-twin/blob/10995cd03312e39a48ade0f114ebb0ae3a711bb8/Modules/build/pip/pip/_vendor/ipaddress.py#L1947-L1969 | |
pyca/cryptography | cb63359d3fc874b565a19ff0026af52b52d87ee3 | src/cryptography/hazmat/primitives/asymmetric/dsa.py | python | DSAParameters.generate_private_key | (self) | Generates and returns a DSAPrivateKey. | Generates and returns a DSAPrivateKey. | [
"Generates",
"and",
"returns",
"a",
"DSAPrivateKey",
"."
] | def generate_private_key(self) -> "DSAPrivateKey":
"""
Generates and returns a DSAPrivateKey.
""" | [
"def",
"generate_private_key",
"(",
"self",
")",
"->",
"\"DSAPrivateKey\"",
":"
] | https://github.com/pyca/cryptography/blob/cb63359d3fc874b565a19ff0026af52b52d87ee3/src/cryptography/hazmat/primitives/asymmetric/dsa.py#L17-L20 | ||
entropy1337/infernal-twin | 10995cd03312e39a48ade0f114ebb0ae3a711bb8 | Modules/build/pip/pip/baseparser.py | python | CustomOptionParser.option_list_all | (self) | return res | Get a list of all options, including those in option groups. | Get a list of all options, including those in option groups. | [
"Get",
"a",
"list",
"of",
"all",
"options",
"including",
"those",
"in",
"option",
"groups",
"."
] | def option_list_all(self):
"""Get a list of all options, including those in option groups."""
res = self.option_list[:]
for i in self.option_groups:
res.extend(i.option_list)
return res | [
"def",
"option_list_all",
"(",
"self",
")",
":",
"res",
"=",
"self",
".",
"option_list",
"[",
":",
"]",
"for",
"i",
"in",
"self",
".",
"option_groups",
":",
"res",
".",
"extend",
"(",
"i",
".",
"option_list",
")",
"return",
"res"
] | https://github.com/entropy1337/infernal-twin/blob/10995cd03312e39a48ade0f114ebb0ae3a711bb8/Modules/build/pip/pip/baseparser.py#L126-L132 | |
tensorflow/lingvo | ce10019243d954c3c3ebe739f7589b5eebfdf907 | lingvo/jax/layers/ngrammer.py | python | VQNgrammer.__init__ | (self, params: InstantiableParams) | Constructs a VQ layer and an N-grammer layer. | Constructs a VQ layer and an N-grammer layer. | [
"Constructs",
"a",
"VQ",
"layer",
"and",
"an",
"N",
"-",
"grammer",
"layer",
"."
] | def __init__(self, params: InstantiableParams) -> None:
"""Constructs a VQ layer and an N-grammer layer."""
super().__init__(params)
p = self.params
if p.concat_ngrams:
# The ngram_emb_dim must be smaller than dim_per_head.
assert p.ngram_emb_dim <= p.dim_per_head
else:
# If not c... | [
"def",
"__init__",
"(",
"self",
",",
"params",
":",
"InstantiableParams",
")",
"->",
"None",
":",
"super",
"(",
")",
".",
"__init__",
"(",
"params",
")",
"p",
"=",
"self",
".",
"params",
"if",
"p",
".",
"concat_ngrams",
":",
"# The ngram_emb_dim must be sm... | https://github.com/tensorflow/lingvo/blob/ce10019243d954c3c3ebe739f7589b5eebfdf907/lingvo/jax/layers/ngrammer.py#L406-L438 | ||
GalSim-developers/GalSim | a05d4ec3b8d8574f99d3b0606ad882cbba53f345 | galsim/knots.py | python | RandomKnots._verify | (self) | type and range checking on the inputs | type and range checking on the inputs | [
"type",
"and",
"range",
"checking",
"on",
"the",
"inputs"
] | def _verify(self):
"""
type and range checking on the inputs
"""
from .random import BaseDeviate
try:
self._npoints = int(self._npoints)
except ValueError as err:
raise GalSimValueError("npoints should be a number: %s", str(err))
if self.... | [
"def",
"_verify",
"(",
"self",
")",
":",
"from",
".",
"random",
"import",
"BaseDeviate",
"try",
":",
"self",
".",
"_npoints",
"=",
"int",
"(",
"self",
".",
"_npoints",
")",
"except",
"ValueError",
"as",
"err",
":",
"raise",
"GalSimValueError",
"(",
"\"np... | https://github.com/GalSim-developers/GalSim/blob/a05d4ec3b8d8574f99d3b0606ad882cbba53f345/galsim/knots.py#L186-L218 | ||
Qirky/FoxDot | 76318f9630bede48ff3994146ed644affa27bfa4 | FoxDot/lib/Players.py | python | Player.kill | (self) | return | Removes this object from the Clock and resets itself | Removes this object from the Clock and resets itself | [
"Removes",
"this",
"object",
"from",
"the",
"Clock",
"and",
"resets",
"itself"
] | def kill(self):
""" Removes this object from the Clock and resets itself"""
self.isplaying = False
self.stopping = True
self.reset()
if self in self.metro.playing:
self.metro.playing.remove(self)
return | [
"def",
"kill",
"(",
"self",
")",
":",
"self",
".",
"isplaying",
"=",
"False",
"self",
".",
"stopping",
"=",
"True",
"self",
".",
"reset",
"(",
")",
"if",
"self",
"in",
"self",
".",
"metro",
".",
"playing",
":",
"self",
".",
"metro",
".",
"playing",... | https://github.com/Qirky/FoxDot/blob/76318f9630bede48ff3994146ed644affa27bfa4/FoxDot/lib/Players.py#L1799-L1811 | |
Azure/aztk | 8f8e7b268bdbf82c3ae4ecdcd907077bd6fe69b6 | aztk/client/base/base_operations.py | python | BaseOperations.get_cluster_data | (self, id: str) | return cluster_data.ClusterData(self.blob_client, id) | Gets the ClusterData object to manage data related to the given cluster
Args:
id (:obj:`str`): the id of the cluster to get
Returns:
:obj:`aztk.models.ClusterData`: Object used to manage the data and storage functions for a cluster | Gets the ClusterData object to manage data related to the given cluster | [
"Gets",
"the",
"ClusterData",
"object",
"to",
"manage",
"data",
"related",
"to",
"the",
"given",
"cluster"
] | def get_cluster_data(self, id: str) -> cluster_data.ClusterData:
"""Gets the ClusterData object to manage data related to the given cluster
Args:
id (:obj:`str`): the id of the cluster to get
Returns:
:obj:`aztk.models.ClusterData`: Object used to manage the data and st... | [
"def",
"get_cluster_data",
"(",
"self",
",",
"id",
":",
"str",
")",
"->",
"cluster_data",
".",
"ClusterData",
":",
"return",
"cluster_data",
".",
"ClusterData",
"(",
"self",
".",
"blob_client",
",",
"id",
")"
] | https://github.com/Azure/aztk/blob/8f8e7b268bdbf82c3ae4ecdcd907077bd6fe69b6/aztk/client/base/base_operations.py#L47-L56 | |
yourtion/DataminingGuideBook-Codes | ff8f41b3b5faa3b584475f92f60ed3f7613869b8 | chapter-2/filteringdataPearson.py | python | computeNearestNeighbor | (username, users) | return distances | creates a sorted list of users based on their distance to username | creates a sorted list of users based on their distance to username | [
"creates",
"a",
"sorted",
"list",
"of",
"users",
"based",
"on",
"their",
"distance",
"to",
"username"
] | def computeNearestNeighbor(username, users):
"""creates a sorted list of users based on their distance to username"""
distances = []
for user in users:
if user != username:
distance = manhattan(users[user], users[username])
distances.append((distance, user))
# sort based ... | [
"def",
"computeNearestNeighbor",
"(",
"username",
",",
"users",
")",
":",
"distances",
"=",
"[",
"]",
"for",
"user",
"in",
"users",
":",
"if",
"user",
"!=",
"username",
":",
"distance",
"=",
"manhattan",
"(",
"users",
"[",
"user",
"]",
",",
"users",
"[... | https://github.com/yourtion/DataminingGuideBook-Codes/blob/ff8f41b3b5faa3b584475f92f60ed3f7613869b8/chapter-2/filteringdataPearson.py#L64-L73 | |
mgalley/DSTC7-End-to-End-Conversation-Modeling | 76a347e1835b6ca245a2786208abbe81f48674f5 | data_extraction/src/create_official_data.py | python | insert_escaped_tags | (tags, label=None) | return found | For each tag in "tags", insert contextual tags (e.g., <p> </p>) as escaped text
so that these tags are still there when html markup is stripped out. | For each tag in "tags", insert contextual tags (e.g., <p> </p>) as escaped text
so that these tags are still there when html markup is stripped out. | [
"For",
"each",
"tag",
"in",
"tags",
"insert",
"contextual",
"tags",
"(",
"e",
".",
"g",
".",
"<p",
">",
"<",
"/",
"p",
">",
")",
"as",
"escaped",
"text",
"so",
"that",
"these",
"tags",
"are",
"still",
"there",
"when",
"html",
"markup",
"is",
"strip... | def insert_escaped_tags(tags, label=None):
"""For each tag in "tags", insert contextual tags (e.g., <p> </p>) as escaped text
so that these tags are still there when html markup is stripped out."""
found = False
for tag in tags:
strs = list(tag.strings)
if len(strs) > 0:
i... | [
"def",
"insert_escaped_tags",
"(",
"tags",
",",
"label",
"=",
"None",
")",
":",
"found",
"=",
"False",
"for",
"tag",
"in",
"tags",
":",
"strs",
"=",
"list",
"(",
"tag",
".",
"strings",
")",
"if",
"len",
"(",
"strs",
")",
">",
"0",
":",
"if",
"lab... | https://github.com/mgalley/DSTC7-End-to-End-Conversation-Modeling/blob/76a347e1835b6ca245a2786208abbe81f48674f5/data_extraction/src/create_official_data.py#L299-L313 | |
IdentityPython/pysaml2 | 6badb32d212257bd83ffcc816f9b625f68281b47 | src/saml2/xmldsig/__init__.py | python | signature_value_from_string | (xml_string) | return saml2.create_class_from_xml_string(SignatureValue, xml_string) | [] | def signature_value_from_string(xml_string):
return saml2.create_class_from_xml_string(SignatureValue, xml_string) | [
"def",
"signature_value_from_string",
"(",
"xml_string",
")",
":",
"return",
"saml2",
".",
"create_class_from_xml_string",
"(",
"SignatureValue",
",",
"xml_string",
")"
] | https://github.com/IdentityPython/pysaml2/blob/6badb32d212257bd83ffcc816f9b625f68281b47/src/saml2/xmldsig/__init__.py#L780-L781 | |||
clinton-hall/nzbToMedia | 27669389216902d1085660167e7bda0bd8527ecf | libs/common/musicbrainzngs/musicbrainz.py | python | browse_recordings | (artist=None, release=None, includes=[],
limit=None, offset=None) | return _browse_impl("recording", includes, limit, offset, params) | Get all recordings linked to an artist or a release.
You need to give one MusicBrainz ID.
*Available includes*: {includes} | Get all recordings linked to an artist or a release.
You need to give one MusicBrainz ID. | [
"Get",
"all",
"recordings",
"linked",
"to",
"an",
"artist",
"or",
"a",
"release",
".",
"You",
"need",
"to",
"give",
"one",
"MusicBrainz",
"ID",
"."
] | def browse_recordings(artist=None, release=None, includes=[],
limit=None, offset=None):
"""Get all recordings linked to an artist or a release.
You need to give one MusicBrainz ID.
*Available includes*: {includes}"""
params = {"artist": artist,
"release": release}
... | [
"def",
"browse_recordings",
"(",
"artist",
"=",
"None",
",",
"release",
"=",
"None",
",",
"includes",
"=",
"[",
"]",
",",
"limit",
"=",
"None",
",",
"offset",
"=",
"None",
")",
":",
"params",
"=",
"{",
"\"artist\"",
":",
"artist",
",",
"\"release\"",
... | https://github.com/clinton-hall/nzbToMedia/blob/27669389216902d1085660167e7bda0bd8527ecf/libs/common/musicbrainzngs/musicbrainz.py#L1131-L1139 | |
rthalley/dnspython | 280588bc99c88783a71b87c34054260a7febfe3e | dns/zone.py | python | Zone.find_rrset | (self, name, rdtype, covers=dns.rdatatype.NONE) | return rrset | Look for an rdataset with the specified name and type in the zone,
and return an RRset encapsulating it.
This method is less efficient than the similar
``find_rdataset()`` because it creates an RRset instead of
returning the matching rdataset. It may be more convenient
for some... | Look for an rdataset with the specified name and type in the zone,
and return an RRset encapsulating it. | [
"Look",
"for",
"an",
"rdataset",
"with",
"the",
"specified",
"name",
"and",
"type",
"in",
"the",
"zone",
"and",
"return",
"an",
"RRset",
"encapsulating",
"it",
"."
] | def find_rrset(self, name, rdtype, covers=dns.rdatatype.NONE):
"""Look for an rdataset with the specified name and type in the zone,
and return an RRset encapsulating it.
This method is less efficient than the similar
``find_rdataset()`` because it creates an RRset instead of
re... | [
"def",
"find_rrset",
"(",
"self",
",",
"name",
",",
"rdtype",
",",
"covers",
"=",
"dns",
".",
"rdatatype",
".",
"NONE",
")",
":",
"name",
"=",
"self",
".",
"_validate_name",
"(",
"name",
")",
"rdtype",
"=",
"dns",
".",
"rdatatype",
".",
"RdataType",
... | https://github.com/rthalley/dnspython/blob/280588bc99c88783a71b87c34054260a7febfe3e/dns/zone.py#L436-L482 | |
albertz/music-player | d23586f5bf657cbaea8147223be7814d117ae73d | mac/pyobjc-framework-Cocoa/Examples/AppKit/Todo/ToDoItem.py | python | ToDoItem.status | (self) | return self._status | [] | def status(self):
return self._status | [
"def",
"status",
"(",
"self",
")",
":",
"return",
"self",
".",
"_status"
] | https://github.com/albertz/music-player/blob/d23586f5bf657cbaea8147223be7814d117ae73d/mac/pyobjc-framework-Cocoa/Examples/AppKit/Todo/ToDoItem.py#L154-L155 | |||
SteveDoyle2/pyNastran | eda651ac2d4883d95a34951f8a002ff94f642a1a | pyNastran/gui/utils/qt/qelement_edit.py | python | QNodeEdit.__init__ | (self, win_parent, name, parent=None, pick_style='area', tab_to_next=False,
max_length=32767, cleanup=True, *args, **kwargs) | A node picker
Parameters
----------
win_parent : QDialog
set this to self
name : str
the name of the model
parent : the gui
this is the gui, it could be win_parent.parent, win_parent.parent.gui, etc.
pick_style : str; default='area'
... | A node picker | [
"A",
"node",
"picker"
] | def __init__(self, win_parent, name, parent=None, pick_style='area', tab_to_next=False,
max_length=32767, cleanup=True, *args, **kwargs):
"""
A node picker
Parameters
----------
win_parent : QDialog
set this to self
name : str
the... | [
"def",
"__init__",
"(",
"self",
",",
"win_parent",
",",
"name",
",",
"parent",
"=",
"None",
",",
"pick_style",
"=",
"'area'",
",",
"tab_to_next",
"=",
"False",
",",
"max_length",
"=",
"32767",
",",
"cleanup",
"=",
"True",
",",
"*",
"args",
",",
"*",
... | https://github.com/SteveDoyle2/pyNastran/blob/eda651ac2d4883d95a34951f8a002ff94f642a1a/pyNastran/gui/utils/qt/qelement_edit.py#L154-L177 | ||
vstinner/hachoir | 8fb142ed4ab8e3603e5b613a75714f79b372b3fe | hachoir/parser/container/riff.py | python | formatSerialNumber | (field) | return "%04X-%04X" % (sn >> 16, sn & 0xFFFF) | Format an disc serial number.
Eg. 0x00085C48 => "0008-5C48" | Format an disc serial number.
Eg. 0x00085C48 => "0008-5C48" | [
"Format",
"an",
"disc",
"serial",
"number",
".",
"Eg",
".",
"0x00085C48",
"=",
">",
"0008",
"-",
"5C48"
] | def formatSerialNumber(field):
"""
Format an disc serial number.
Eg. 0x00085C48 => "0008-5C48"
"""
sn = field.value
return "%04X-%04X" % (sn >> 16, sn & 0xFFFF) | [
"def",
"formatSerialNumber",
"(",
"field",
")",
":",
"sn",
"=",
"field",
".",
"value",
"return",
"\"%04X-%04X\"",
"%",
"(",
"sn",
">>",
"16",
",",
"sn",
"&",
"0xFFFF",
")"
] | https://github.com/vstinner/hachoir/blob/8fb142ed4ab8e3603e5b613a75714f79b372b3fe/hachoir/parser/container/riff.py#L138-L144 | |
HymanLiuTS/flaskTs | 286648286976e85d9b9a5873632331efcafe0b21 | flasky/lib/python2.7/site-packages/pkg_resources/__init__.py | python | compatible_platforms | (provided, required) | return False | Can code for the `provided` platform run on the `required` platform?
Returns true if either platform is ``None``, or the platforms are equal.
XXX Needs compatibility checks for Linux and other unixy OSes. | Can code for the `provided` platform run on the `required` platform? | [
"Can",
"code",
"for",
"the",
"provided",
"platform",
"run",
"on",
"the",
"required",
"platform?"
] | def compatible_platforms(provided, required):
"""Can code for the `provided` platform run on the `required` platform?
Returns true if either platform is ``None``, or the platforms are equal.
XXX Needs compatibility checks for Linux and other unixy OSes.
"""
if provided is None or required is None ... | [
"def",
"compatible_platforms",
"(",
"provided",
",",
"required",
")",
":",
"if",
"provided",
"is",
"None",
"or",
"required",
"is",
"None",
"or",
"provided",
"==",
"required",
":",
"# easy case",
"return",
"True",
"# Mac OS X special cases",
"reqMac",
"=",
"macos... | https://github.com/HymanLiuTS/flaskTs/blob/286648286976e85d9b9a5873632331efcafe0b21/flasky/lib/python2.7/site-packages/pkg_resources/__init__.py#L495-L538 | |
klen/graphite-beacon | c1f071e9f557693bc90f6acbc314994985dc3b77 | graphite_beacon/handlers/telegram.py | python | TelegramHandler.init_handler | (self) | [] | def init_handler(self):
token = self.options.get('token')
assert token, 'Telegram bot API token is not defined.'
self.client = CustomClient(token)
self.bot_ident = self.options.get('bot_ident')
assert self.bot_ident, 'Telegram bot ident token is not defined.'
chatfile... | [
"def",
"init_handler",
"(",
"self",
")",
":",
"token",
"=",
"self",
".",
"options",
".",
"get",
"(",
"'token'",
")",
"assert",
"token",
",",
"'Telegram bot API token is not defined.'",
"self",
".",
"client",
"=",
"CustomClient",
"(",
"token",
")",
"self",
".... | https://github.com/klen/graphite-beacon/blob/c1f071e9f557693bc90f6acbc314994985dc3b77/graphite_beacon/handlers/telegram.py#L48-L67 | ||||
coffeehb/Some-PoC-oR-ExP | eb757a6255c37cf7a2269482aa3d750a9a80ded1 | 验证Joomla是否存在反序列化漏洞的脚本/批量/hackUtils-master/bs4/element.py | python | PageElement.find_all_next | (self, name=None, attrs={}, text=None, limit=None,
**kwargs) | return self._find_all(name, attrs, text, limit, self.next_elements,
**kwargs) | Returns all items that match the given criteria and appear
after this Tag in the document. | Returns all items that match the given criteria and appear
after this Tag in the document. | [
"Returns",
"all",
"items",
"that",
"match",
"the",
"given",
"criteria",
"and",
"appear",
"after",
"this",
"Tag",
"in",
"the",
"document",
"."
] | def find_all_next(self, name=None, attrs={}, text=None, limit=None,
**kwargs):
"""Returns all items that match the given criteria and appear
after this Tag in the document."""
return self._find_all(name, attrs, text, limit, self.next_elements,
**k... | [
"def",
"find_all_next",
"(",
"self",
",",
"name",
"=",
"None",
",",
"attrs",
"=",
"{",
"}",
",",
"text",
"=",
"None",
",",
"limit",
"=",
"None",
",",
"*",
"*",
"kwargs",
")",
":",
"return",
"self",
".",
"_find_all",
"(",
"name",
",",
"attrs",
","... | https://github.com/coffeehb/Some-PoC-oR-ExP/blob/eb757a6255c37cf7a2269482aa3d750a9a80ded1/验证Joomla是否存在反序列化漏洞的脚本/批量/hackUtils-master/bs4/element.py#L384-L389 | |
kozec/sc-controller | ce92c773b8b26f6404882e9209aff212c4053170 | scc/gui/action_editor.py | python | ActionEditor.hide_action_buttons | (self) | Hides action buttons, effectivelly disallowing user to change action type | Hides action buttons, effectivelly disallowing user to change action type | [
"Hides",
"action",
"buttons",
"effectivelly",
"disallowing",
"user",
"to",
"change",
"action",
"type"
] | def hide_action_buttons(self):
""" Hides action buttons, effectivelly disallowing user to change action type """
for x in ("lblActionType", "vbActionButtons"):
self.builder.get_object(x).set_visible(False)
self.hide_modeshift()
self.hide_macro()
self.hide_ring() | [
"def",
"hide_action_buttons",
"(",
"self",
")",
":",
"for",
"x",
"in",
"(",
"\"lblActionType\"",
",",
"\"vbActionButtons\"",
")",
":",
"self",
".",
"builder",
".",
"get_object",
"(",
"x",
")",
".",
"set_visible",
"(",
"False",
")",
"self",
".",
"hide_modes... | https://github.com/kozec/sc-controller/blob/ce92c773b8b26f6404882e9209aff212c4053170/scc/gui/action_editor.py#L404-L410 | ||
aws/aws-sam-cli | 2aa7bf01b2e0b0864ef63b1898a8b30577443acc | samcli/commands/delete/delete_context.py | python | DeleteContext.s3_prompts | (self) | Guided prompts asking user to delete s3 artifacts | Guided prompts asking user to delete s3 artifacts | [
"Guided",
"prompts",
"asking",
"user",
"to",
"delete",
"s3",
"artifacts"
] | def s3_prompts(self):
"""
Guided prompts asking user to delete s3 artifacts
"""
# Note: s3_bucket and s3_prefix information is only
# available if a local toml file is present or if
# this information is obtained from the template resources and so if this
# inform... | [
"def",
"s3_prompts",
"(",
"self",
")",
":",
"# Note: s3_bucket and s3_prefix information is only",
"# available if a local toml file is present or if",
"# this information is obtained from the template resources and so if this",
"# information is not found, warn the user that S3 artifacts",
"# w... | https://github.com/aws/aws-sam-cli/blob/2aa7bf01b2e0b0864ef63b1898a8b30577443acc/samcli/commands/delete/delete_context.py#L140-L172 | ||
Chaffelson/nipyapi | d3b186fd701ce308c2812746d98af9120955e810 | nipyapi/nifi/models/jvm_flow_diagnostics_snapshot_dto.py | python | JVMFlowDiagnosticsSnapshotDTO.__repr__ | (self) | return self.to_str() | For `print` and `pprint` | For `print` and `pprint` | [
"For",
"print",
"and",
"pprint"
] | def __repr__(self):
"""
For `print` and `pprint`
"""
return self.to_str() | [
"def",
"__repr__",
"(",
"self",
")",
":",
"return",
"self",
".",
"to_str",
"(",
")"
] | https://github.com/Chaffelson/nipyapi/blob/d3b186fd701ce308c2812746d98af9120955e810/nipyapi/nifi/models/jvm_flow_diagnostics_snapshot_dto.py#L218-L222 | |
kensho-technologies/graphql-compiler | 4318443b7b2512a059f3616112bfc40bbf8eec06 | graphql_compiler/schema/schema_info.py | python | create_match_schema_info | (
schema: GraphQLSchema, type_equivalence_hints: Optional[Dict[str, str]] = None
) | return MatchSchemaInfo(generic_schema_info=generic_schema_info) | Create a SchemaInfo object for a database using MATCH. | Create a SchemaInfo object for a database using MATCH. | [
"Create",
"a",
"SchemaInfo",
"object",
"for",
"a",
"database",
"using",
"MATCH",
"."
] | def create_match_schema_info(
schema: GraphQLSchema, type_equivalence_hints: Optional[Dict[str, str]] = None
) -> MatchSchemaInfo:
"""Create a SchemaInfo object for a database using MATCH."""
generic_schema_info = GenericSchemaInfo(
schema=schema, type_equivalence_hints=type_equivalence_hints
)
... | [
"def",
"create_match_schema_info",
"(",
"schema",
":",
"GraphQLSchema",
",",
"type_equivalence_hints",
":",
"Optional",
"[",
"Dict",
"[",
"str",
",",
"str",
"]",
"]",
"=",
"None",
")",
"->",
"MatchSchemaInfo",
":",
"generic_schema_info",
"=",
"GenericSchemaInfo",
... | https://github.com/kensho-technologies/graphql-compiler/blob/4318443b7b2512a059f3616112bfc40bbf8eec06/graphql_compiler/schema/schema_info.py#L115-L122 | |
spacetx/starfish | 0e879d995d5c49b6f5a842e201e3be04c91afc7e | starfish/core/imagestack/parser/_tiledata.py | python | TileCollectionData.tile_shape | (self) | Returns the shape of a tile. | Returns the shape of a tile. | [
"Returns",
"the",
"shape",
"of",
"a",
"tile",
"."
] | def tile_shape(self) -> Mapping[Axes, int]:
"""Returns the shape of a tile."""
raise NotImplementedError() | [
"def",
"tile_shape",
"(",
"self",
")",
"->",
"Mapping",
"[",
"Axes",
",",
"int",
"]",
":",
"raise",
"NotImplementedError",
"(",
")"
] | https://github.com/spacetx/starfish/blob/0e879d995d5c49b6f5a842e201e3be04c91afc7e/starfish/core/imagestack/parser/_tiledata.py#L51-L53 | ||
TheAlgorithms/Python | 9af2eef9b3761bf51580dedfb6fa7136ca0c5c2c | data_structures/stacks/next_greater_element.py | python | next_greatest_element_slow | (arr: list[float]) | return result | Get the Next Greatest Element (NGE) for all elements in a list.
Maximum element present after the current one which is also greater than the
current one.
>>> next_greatest_element_slow(arr) == expect
True | Get the Next Greatest Element (NGE) for all elements in a list.
Maximum element present after the current one which is also greater than the
current one.
>>> next_greatest_element_slow(arr) == expect
True | [
"Get",
"the",
"Next",
"Greatest",
"Element",
"(",
"NGE",
")",
"for",
"all",
"elements",
"in",
"a",
"list",
".",
"Maximum",
"element",
"present",
"after",
"the",
"current",
"one",
"which",
"is",
"also",
"greater",
"than",
"the",
"current",
"one",
".",
">>... | def next_greatest_element_slow(arr: list[float]) -> list[float]:
"""
Get the Next Greatest Element (NGE) for all elements in a list.
Maximum element present after the current one which is also greater than the
current one.
>>> next_greatest_element_slow(arr) == expect
True
"""
result = ... | [
"def",
"next_greatest_element_slow",
"(",
"arr",
":",
"list",
"[",
"float",
"]",
")",
"->",
"list",
"[",
"float",
"]",
":",
"result",
"=",
"[",
"]",
"arr_size",
"=",
"len",
"(",
"arr",
")",
"for",
"i",
"in",
"range",
"(",
"arr_size",
")",
":",
"nex... | https://github.com/TheAlgorithms/Python/blob/9af2eef9b3761bf51580dedfb6fa7136ca0c5c2c/data_structures/stacks/next_greater_element.py#L7-L26 | |
holzschu/Carnets | 44effb10ddfc6aa5c8b0687582a724ba82c6b547 | Library/lib/python3.7/site-packages/bokeh-1.4.0-py3.7.egg/bokeh/core/property/descriptors.py | python | BasicPropertyDescriptor._real_set | (self, obj, old, value, hint=None, setter=None) | Internal implementation helper to set property values.
This function handles bookkeeping around noting whether values have
been explicitly set, etc.
Args:
obj (HasProps)
The object the property is being set on.
old (obj) :
The previous v... | Internal implementation helper to set property values. | [
"Internal",
"implementation",
"helper",
"to",
"set",
"property",
"values",
"."
] | def _real_set(self, obj, old, value, hint=None, setter=None):
''' Internal implementation helper to set property values.
This function handles bookkeeping around noting whether values have
been explicitly set, etc.
Args:
obj (HasProps)
The object the propert... | [
"def",
"_real_set",
"(",
"self",
",",
"obj",
",",
"old",
",",
"value",
",",
"hint",
"=",
"None",
",",
"setter",
"=",
"None",
")",
":",
"# Normally we want a \"no-op\" if the new value and old value are identical",
"# but some hinted events are in-place. This check will allo... | https://github.com/holzschu/Carnets/blob/44effb10ddfc6aa5c8b0687582a724ba82c6b547/Library/lib/python3.7/site-packages/bokeh-1.4.0-py3.7.egg/bokeh/core/property/descriptors.py#L771-L838 | ||
openhatch/oh-mainline | ce29352a034e1223141dcc2f317030bbc3359a51 | vendor/packages/gdata/src/gdata/analytics/__init__.py | python | AnalyticsDataFeedFromString | (xml_string) | return feed | Converts an XML string into an AccountListFeed object.
Args:
xml_string: string The XML describing an AccountList feed.
Returns:
An AccountListFeed object corresponding to the given XML.
Each metric and dimension is also referenced directly from
the entry for easier access. (e.g. entry.keyword.value) | Converts an XML string into an AccountListFeed object. | [
"Converts",
"an",
"XML",
"string",
"into",
"an",
"AccountListFeed",
"object",
"."
] | def AnalyticsDataFeedFromString(xml_string):
"""Converts an XML string into an AccountListFeed object.
Args:
xml_string: string The XML describing an AccountList feed.
Returns:
An AccountListFeed object corresponding to the given XML.
Each metric and dimension is also referenced directly from
the entry ... | [
"def",
"AnalyticsDataFeedFromString",
"(",
"xml_string",
")",
":",
"feed",
"=",
"atom",
".",
"CreateClassFromXMLString",
"(",
"AnalyticsDataFeed",
",",
"xml_string",
")",
"if",
"feed",
".",
"entry",
":",
"for",
"entry",
"in",
"feed",
".",
"entry",
":",
"for",
... | https://github.com/openhatch/oh-mainline/blob/ce29352a034e1223141dcc2f317030bbc3359a51/vendor/packages/gdata/src/gdata/analytics/__init__.py#L203-L223 | |
vyos/vyos-1x | 6e8a8934a7d4e1b21d7c828e372303683b499b56 | src/op_mode/show_users.py | python | is_locked | (user_name: str) | Check if a given user has password in shadow db | Check if a given user has password in shadow db | [
"Check",
"if",
"a",
"given",
"user",
"has",
"password",
"in",
"shadow",
"db"
] | def is_locked(user_name: str) -> bool:
"""Check if a given user has password in shadow db"""
try:
encrypted_password = spwd.getspnam(user_name)[1]
return encrypted_password == '*' or encrypted_password.startswith('!')
except (KeyError, PermissionError):
print('Cannot access shadow d... | [
"def",
"is_locked",
"(",
"user_name",
":",
"str",
")",
"->",
"bool",
":",
"try",
":",
"encrypted_password",
"=",
"spwd",
".",
"getspnam",
"(",
"user_name",
")",
"[",
"1",
"]",
"return",
"encrypted_password",
"==",
"'*'",
"or",
"encrypted_password",
".",
"s... | https://github.com/vyos/vyos-1x/blob/6e8a8934a7d4e1b21d7c828e372303683b499b56/src/op_mode/show_users.py#L47-L55 | ||
cornellius-gp/gpytorch | 61f643eb8b487aef332c818f661fbcdb1df576ca | gpytorch/models/exact_prediction_strategies.py | python | DefaultPredictionStrategy.get_fantasy_strategy | (self, inputs, targets, full_inputs, full_targets, full_output, **kwargs) | return fant_strat | Returns a new PredictionStrategy that incorporates the specified inputs and targets as new training data.
This method is primary responsible for updating the mean and covariance caches. To add fantasy data to a
GP model, use the :meth:`~gpytorch.models.ExactGP.get_fantasy_model` method.
Args:
... | Returns a new PredictionStrategy that incorporates the specified inputs and targets as new training data. | [
"Returns",
"a",
"new",
"PredictionStrategy",
"that",
"incorporates",
"the",
"specified",
"inputs",
"and",
"targets",
"as",
"new",
"training",
"data",
"."
] | def get_fantasy_strategy(self, inputs, targets, full_inputs, full_targets, full_output, **kwargs):
"""
Returns a new PredictionStrategy that incorporates the specified inputs and targets as new training data.
This method is primary responsible for updating the mean and covariance caches. To add... | [
"def",
"get_fantasy_strategy",
"(",
"self",
",",
"inputs",
",",
"targets",
",",
"full_inputs",
",",
"full_targets",
",",
"full_output",
",",
"*",
"*",
"kwargs",
")",
":",
"full_mean",
",",
"full_covar",
"=",
"full_output",
".",
"mean",
",",
"full_output",
".... | https://github.com/cornellius-gp/gpytorch/blob/61f643eb8b487aef332c818f661fbcdb1df576ca/gpytorch/models/exact_prediction_strategies.py#L105-L213 | |
quodlibet/quodlibet | e3099c89f7aa6524380795d325cc14630031886c | quodlibet/errorreport/sentrywrapper.py | python | CapturedException.send | (self, timeout) | Submit the error including the user feedback. Blocking.
Args:
timeout (float): timeout for each request made
Returns:
str: The sentry event id
Raises:
SentryError | Submit the error including the user feedback. Blocking. | [
"Submit",
"the",
"error",
"including",
"the",
"user",
"feedback",
".",
"Blocking",
"."
] | def send(self, timeout):
"""Submit the error including the user feedback. Blocking.
Args:
timeout (float): timeout for each request made
Returns:
str: The sentry event id
Raises:
SentryError
"""
from raven import Client
from r... | [
"def",
"send",
"(",
"self",
",",
"timeout",
")",
":",
"from",
"raven",
"import",
"Client",
"from",
"raven",
".",
"transport",
"import",
"http",
"from",
"raven",
".",
"transport",
".",
"http",
"import",
"HTTPTransport",
"http",
".",
"urlopen",
"=",
"urlopen... | https://github.com/quodlibet/quodlibet/blob/e3099c89f7aa6524380795d325cc14630031886c/quodlibet/errorreport/sentrywrapper.py#L124-L171 | ||
Antergos/Cnchi | 13ac2209da9432d453e0097cf48a107640b563a9 | src/pages/summary.py | python | Summary.get_install_screen | (self) | return install_screen | Returns installation screen page | Returns installation screen page | [
"Returns",
"installation",
"screen",
"page"
] | def get_install_screen(self):
""" Returns installation screen page """
page = "installation_" + self.settings.get('partition_mode')
install_screen = None
try:
install_screen = self.main_window.pages[page]
except (AttributeError, KeyError) as page_error:
ms... | [
"def",
"get_install_screen",
"(",
"self",
")",
":",
"page",
"=",
"\"installation_\"",
"+",
"self",
".",
"settings",
".",
"get",
"(",
"'partition_mode'",
")",
"install_screen",
"=",
"None",
"try",
":",
"install_screen",
"=",
"self",
".",
"main_window",
".",
"... | https://github.com/Antergos/Cnchi/blob/13ac2209da9432d453e0097cf48a107640b563a9/src/pages/summary.py#L161-L172 | |
CouchPotato/CouchPotatoServer | 7260c12f72447ddb6f062367c6dfbda03ecd4e9c | libs/requests/models.py | python | RequestEncodingMixin._encode_files | (files, data) | return body, content_type | Build the body for a multipart/form-data request.
Will successfully encode files when passed as a dict or a list of
2-tuples. Order is retained if data is a list of 2-tuples but arbitrary
if parameters are supplied as a dict. | Build the body for a multipart/form-data request. | [
"Build",
"the",
"body",
"for",
"a",
"multipart",
"/",
"form",
"-",
"data",
"request",
"."
] | def _encode_files(files, data):
"""Build the body for a multipart/form-data request.
Will successfully encode files when passed as a dict or a list of
2-tuples. Order is retained if data is a list of 2-tuples but arbitrary
if parameters are supplied as a dict.
"""
if (n... | [
"def",
"_encode_files",
"(",
"files",
",",
"data",
")",
":",
"if",
"(",
"not",
"files",
")",
":",
"raise",
"ValueError",
"(",
"\"Files must be provided.\"",
")",
"elif",
"isinstance",
"(",
"data",
",",
"basestring",
")",
":",
"raise",
"ValueError",
"(",
"\... | https://github.com/CouchPotato/CouchPotatoServer/blob/7260c12f72447ddb6f062367c6dfbda03ecd4e9c/libs/requests/models.py#L102-L158 | |
saltstack/salt | fae5bc757ad0f1716483ce7ae180b451545c2058 | salt/states/svn.py | python | dirty | (
name, target, user=None, username=None, password=None, ignore_unversioned=False
) | return _fail(ret, "This function is not implemented yet.") | Determine if the working directory has been changed. | Determine if the working directory has been changed. | [
"Determine",
"if",
"the",
"working",
"directory",
"has",
"been",
"changed",
"."
] | def dirty(
name, target, user=None, username=None, password=None, ignore_unversioned=False
):
"""
Determine if the working directory has been changed.
"""
ret = {"name": name, "result": True, "comment": "", "changes": {}}
return _fail(ret, "This function is not implemented yet.") | [
"def",
"dirty",
"(",
"name",
",",
"target",
",",
"user",
"=",
"None",
",",
"username",
"=",
"None",
",",
"password",
"=",
"None",
",",
"ignore_unversioned",
"=",
"False",
")",
":",
"ret",
"=",
"{",
"\"name\"",
":",
"name",
",",
"\"result\"",
":",
"Tr... | https://github.com/saltstack/salt/blob/fae5bc757ad0f1716483ce7ae180b451545c2058/salt/states/svn.py#L297-L304 | |
khanhnamle1994/natural-language-processing | 01d450d5ac002b0156ef4cf93a07cb508c1bcdc5 | assignment1/.env/lib/python2.7/site-packages/pip/vcs/__init__.py | python | VersionControl.check_version | (self, dest, rev_options) | Return True if the version is identical to what exists and
doesn't need to be updated. | Return True if the version is identical to what exists and
doesn't need to be updated. | [
"Return",
"True",
"if",
"the",
"version",
"is",
"identical",
"to",
"what",
"exists",
"and",
"doesn",
"t",
"need",
"to",
"be",
"updated",
"."
] | def check_version(self, dest, rev_options):
"""
Return True if the version is identical to what exists and
doesn't need to be updated.
"""
raise NotImplementedError | [
"def",
"check_version",
"(",
"self",
",",
"dest",
",",
"rev_options",
")",
":",
"raise",
"NotImplementedError"
] | https://github.com/khanhnamle1994/natural-language-processing/blob/01d450d5ac002b0156ef4cf93a07cb508c1bcdc5/assignment1/.env/lib/python2.7/site-packages/pip/vcs/__init__.py#L187-L192 | ||
nodesign/weio | 1d67d705a5c36a2e825ad13feab910b0aca9a2e8 | things/input/environmental/digitemp/device/termometer.py | python | DS18B20.get_resolution | (self) | return (iord(scratchpad, 4) >> 5) & 0b11 | [] | def get_resolution(self):
self._reset()
scratchpad = self._read_scratchpad()
return (iord(scratchpad, 4) >> 5) & 0b11 | [
"def",
"get_resolution",
"(",
"self",
")",
":",
"self",
".",
"_reset",
"(",
")",
"scratchpad",
"=",
"self",
".",
"_read_scratchpad",
"(",
")",
"return",
"(",
"iord",
"(",
"scratchpad",
",",
"4",
")",
">>",
"5",
")",
"&",
"0b11"
] | https://github.com/nodesign/weio/blob/1d67d705a5c36a2e825ad13feab910b0aca9a2e8/things/input/environmental/digitemp/device/termometer.py#L296-L299 | |||
deepjyoti30/ytmdl | 0227541f303739a01e27a6d74499229d9bf44f84 | ytmdl/metadata.py | python | get_from_lastfm | (SONG_NAME) | Get metadata from Last FM | Get metadata from Last FM | [
"Get",
"metadata",
"from",
"Last",
"FM"
] | def get_from_lastfm(SONG_NAME):
"""Get metadata from Last FM"""
try:
songs = lastfm.searchSong(SONG_NAME)
return songs
except Exception as e:
_logger_provider_error(e, 'LastFM') | [
"def",
"get_from_lastfm",
"(",
"SONG_NAME",
")",
":",
"try",
":",
"songs",
"=",
"lastfm",
".",
"searchSong",
"(",
"SONG_NAME",
")",
"return",
"songs",
"except",
"Exception",
"as",
"e",
":",
"_logger_provider_error",
"(",
"e",
",",
"'LastFM'",
")"
] | https://github.com/deepjyoti30/ytmdl/blob/0227541f303739a01e27a6d74499229d9bf44f84/ytmdl/metadata.py#L61-L67 | ||
OctoPrint/OctoPrint | 4b12b0e6f06c3abfb31b1840a0605e2de8e911d2 | src/octoprint/access/groups.py | python | Group.remove_subgroups_from_group | (self, subgroups) | return dirty | Removes a list of subgroups from a group | Removes a list of subgroups from a group | [
"Removes",
"a",
"list",
"of",
"subgroups",
"from",
"a",
"group"
] | def remove_subgroups_from_group(self, subgroups):
"""Removes a list of subgroups from a group"""
if not self.is_changeable():
raise GroupCantBeChanged(self.key)
# Make sure the subgroups variable is of type list
if not isinstance(subgroups, list):
subgroups = [su... | [
"def",
"remove_subgroups_from_group",
"(",
"self",
",",
"subgroups",
")",
":",
"if",
"not",
"self",
".",
"is_changeable",
"(",
")",
":",
"raise",
"GroupCantBeChanged",
"(",
"self",
".",
"key",
")",
"# Make sure the subgroups variable is of type list",
"if",
"not",
... | https://github.com/OctoPrint/OctoPrint/blob/4b12b0e6f06c3abfb31b1840a0605e2de8e911d2/src/octoprint/access/groups.py#L675-L692 | |
Ultimaker/Cura | a1622c77ea7259ecb956acd6de07b7d34b7ac52b | cura/Settings/MachineManager.py | python | MachineManager.correctExtruderSettings | (self) | Update extruder number to a valid value when the number of extruders are changed, or when an extruder is changed | Update extruder number to a valid value when the number of extruders are changed, or when an extruder is changed | [
"Update",
"extruder",
"number",
"to",
"a",
"valid",
"value",
"when",
"the",
"number",
"of",
"extruders",
"are",
"changed",
"or",
"when",
"an",
"extruder",
"is",
"changed"
] | def correctExtruderSettings(self) -> None:
"""Update extruder number to a valid value when the number of extruders are changed, or when an extruder is changed"""
if self._global_container_stack is None:
return
for setting_key in self.getIncompatibleSettingsOnEnabledExtruders(self._g... | [
"def",
"correctExtruderSettings",
"(",
"self",
")",
"->",
"None",
":",
"if",
"self",
".",
"_global_container_stack",
"is",
"None",
":",
"return",
"for",
"setting_key",
"in",
"self",
".",
"getIncompatibleSettingsOnEnabledExtruders",
"(",
"self",
".",
"_global_contain... | https://github.com/Ultimaker/Cura/blob/a1622c77ea7259ecb956acd6de07b7d34b7ac52b/cura/Settings/MachineManager.py#L843-L859 | ||
edfungus/Crouton | ada98b3930192938a48909072b45cb84b945f875 | clients/esp8266_clients/venv/lib/python2.7/site-packages/pip/_vendor/requests/models.py | python | Response.iter_content | (self, chunk_size=1, decode_unicode=False) | return chunks | Iterates over the response data. When stream=True is set on the
request, this avoids reading the content at once into memory for
large responses. The chunk size is the number of bytes it should
read into memory. This is not necessarily the length of each item
returned as decoding can ... | Iterates over the response data. When stream=True is set on the
request, this avoids reading the content at once into memory for
large responses. The chunk size is the number of bytes it should
read into memory. This is not necessarily the length of each item
returned as decoding can ... | [
"Iterates",
"over",
"the",
"response",
"data",
".",
"When",
"stream",
"=",
"True",
"is",
"set",
"on",
"the",
"request",
"this",
"avoids",
"reading",
"the",
"content",
"at",
"once",
"into",
"memory",
"for",
"large",
"responses",
".",
"The",
"chunk",
"size",... | def iter_content(self, chunk_size=1, decode_unicode=False):
"""Iterates over the response data. When stream=True is set on the
request, this avoids reading the content at once into memory for
large responses. The chunk size is the number of bytes it should
read into memory. This is no... | [
"def",
"iter_content",
"(",
"self",
",",
"chunk_size",
"=",
"1",
",",
"decode_unicode",
"=",
"False",
")",
":",
"def",
"generate",
"(",
")",
":",
"try",
":",
"# Special case for urllib3.",
"try",
":",
"for",
"chunk",
"in",
"self",
".",
"raw",
".",
"strea... | https://github.com/edfungus/Crouton/blob/ada98b3930192938a48909072b45cb84b945f875/clients/esp8266_clients/venv/lib/python2.7/site-packages/pip/_vendor/requests/models.py#L659-L703 | |
Source-Python-Dev-Team/Source.Python | d0ffd8ccbd1e9923c9bc44936f20613c1c76b7fb | addons/source-python/packages/source-python/auth/manager.py | python | PermissionBase.__init__ | (self, name) | Initialize the object. | Initialize the object. | [
"Initialize",
"the",
"object",
"."
] | def __init__(self, name):
"""Initialize the object."""
super().__init__()
self.parents = set()
self.name = name
if self.name != GUEST_PARENT_NAME:
# Don't update the backend, because it's a hidden group
self.add_parent(GUEST_PARENT_NAME, update_backend=Fal... | [
"def",
"__init__",
"(",
"self",
",",
"name",
")",
":",
"super",
"(",
")",
".",
"__init__",
"(",
")",
"self",
".",
"parents",
"=",
"set",
"(",
")",
"self",
".",
"name",
"=",
"name",
"if",
"self",
".",
"name",
"!=",
"GUEST_PARENT_NAME",
":",
"# Don't... | https://github.com/Source-Python-Dev-Team/Source.Python/blob/d0ffd8ccbd1e9923c9bc44936f20613c1c76b7fb/addons/source-python/packages/source-python/auth/manager.py#L54-L61 | ||
wbond/asn1crypto | 9ae350f212532dfee7f185f6b3eda24753249cf3 | asn1crypto/core.py | python | Sequence.__getitem__ | (self, key) | Allows accessing fields by name or index
:param key:
A unicode string of the field name, or an integer of the field index
:raises:
KeyError - when a field name or index is invalid
:return:
The Asn1Value object of the field specified | Allows accessing fields by name or index | [
"Allows",
"accessing",
"fields",
"by",
"name",
"or",
"index"
] | def __getitem__(self, key):
"""
Allows accessing fields by name or index
:param key:
A unicode string of the field name, or an integer of the field index
:raises:
KeyError - when a field name or index is invalid
:return:
The Asn1Value object... | [
"def",
"__getitem__",
"(",
"self",
",",
"key",
")",
":",
"# We inline this check to prevent method invocation each time",
"if",
"self",
".",
"children",
"is",
"None",
":",
"self",
".",
"_parse_children",
"(",
")",
"if",
"not",
"isinstance",
"(",
"key",
",",
"int... | https://github.com/wbond/asn1crypto/blob/9ae350f212532dfee7f185f6b3eda24753249cf3/asn1crypto/core.py#L3492-L3536 | ||
haiwen/seafile-docker | 2d2461d4c8cab3458ec9832611c419d47506c300 | cluster/scripts/utils/__init__.py | python | sudo | (*a, **kw) | [] | def sudo(*a, **kw):
call('sudo ' + a[0], *a[1:], **kw) | [
"def",
"sudo",
"(",
"*",
"a",
",",
"*",
"*",
"kw",
")",
":",
"call",
"(",
"'sudo '",
"+",
"a",
"[",
"0",
"]",
",",
"*",
"a",
"[",
"1",
":",
"]",
",",
"*",
"*",
"kw",
")"
] | https://github.com/haiwen/seafile-docker/blob/2d2461d4c8cab3458ec9832611c419d47506c300/cluster/scripts/utils/__init__.py#L37-L38 | ||||
ni/nidaqmx-python | 62fc6b48cbbb330fe1bcc9aedadc86610a1269b6 | nidaqmx/_task_modules/timing.py | python | Timing.ai_conv_rate | (self, val) | [] | def ai_conv_rate(self, val):
cfunc = lib_importer.windll.DAQmxSetAIConvRate
if cfunc.argtypes is None:
with cfunc.arglock:
if cfunc.argtypes is None:
cfunc.argtypes = [
lib_importer.task_handle, ctypes.c_double]
error_code ... | [
"def",
"ai_conv_rate",
"(",
"self",
",",
"val",
")",
":",
"cfunc",
"=",
"lib_importer",
".",
"windll",
".",
"DAQmxSetAIConvRate",
"if",
"cfunc",
".",
"argtypes",
"is",
"None",
":",
"with",
"cfunc",
".",
"arglock",
":",
"if",
"cfunc",
".",
"argtypes",
"is... | https://github.com/ni/nidaqmx-python/blob/62fc6b48cbbb330fe1bcc9aedadc86610a1269b6/nidaqmx/_task_modules/timing.py#L372-L382 | ||||
Fantomas42/django-blog-zinnia | 881101a9d1d455b2fc581d6f4ae0947cdd8126c6 | zinnia/views/archives.py | python | EntryWeek.get_dated_items | (self) | return self.date_list, self.object_list, extra_context | Override get_dated_items to add a useful 'week_end_day'
variable in the extra context of the view. | Override get_dated_items to add a useful 'week_end_day'
variable in the extra context of the view. | [
"Override",
"get_dated_items",
"to",
"add",
"a",
"useful",
"week_end_day",
"variable",
"in",
"the",
"extra",
"context",
"of",
"the",
"view",
"."
] | def get_dated_items(self):
"""
Override get_dated_items to add a useful 'week_end_day'
variable in the extra context of the view.
"""
self.date_list, self.object_list, extra_context = super(
EntryWeek, self).get_dated_items()
self.date_list = self.get_date_lis... | [
"def",
"get_dated_items",
"(",
"self",
")",
":",
"self",
".",
"date_list",
",",
"self",
".",
"object_list",
",",
"extra_context",
"=",
"super",
"(",
"EntryWeek",
",",
"self",
")",
".",
"get_dated_items",
"(",
")",
"self",
".",
"date_list",
"=",
"self",
"... | https://github.com/Fantomas42/django-blog-zinnia/blob/881101a9d1d455b2fc581d6f4ae0947cdd8126c6/zinnia/views/archives.py#L71-L81 | |
aws/sagemaker-python-sdk | 9d259b316f7f43838c16f35c10e98a110b56735b | src/sagemaker/processing.py | python | ProcessingJob.prepare_app_specification | (container_arguments, container_entrypoint, image_uri) | return config | Prepares a dict that represents a ProcessingJob's AppSpecification.
Args:
container_arguments (list[str]): The arguments for a container
used to run a processing job.
container_entrypoint (list[str]): The entrypoint for a container
used to run a processin... | Prepares a dict that represents a ProcessingJob's AppSpecification. | [
"Prepares",
"a",
"dict",
"that",
"represents",
"a",
"ProcessingJob",
"s",
"AppSpecification",
"."
] | def prepare_app_specification(container_arguments, container_entrypoint, image_uri):
"""Prepares a dict that represents a ProcessingJob's AppSpecification.
Args:
container_arguments (list[str]): The arguments for a container
used to run a processing job.
containe... | [
"def",
"prepare_app_specification",
"(",
"container_arguments",
",",
"container_entrypoint",
",",
"image_uri",
")",
":",
"config",
"=",
"{",
"\"ImageUri\"",
":",
"image_uri",
"}",
"if",
"container_arguments",
"is",
"not",
"None",
":",
"config",
"[",
"\"ContainerArgu... | https://github.com/aws/sagemaker-python-sdk/blob/9d259b316f7f43838c16f35c10e98a110b56735b/src/sagemaker/processing.py#L975-L994 | |
collinsctk/PyQYT | 7af3673955f94ff1b2df2f94220cd2dab2e252af | ExtentionPackages/pysnmp/smi/rfc1902.py | python | ObjectType.addMibSource | (self, *mibSources) | return self | Adds path to repository to search PySNMP MIB files.
Parameters
----------
*mibSources :
one or more paths to search or Python package names to import
and search for PySNMP MIB modules.
Returns
-------
: :py:class:`~pysnmp.smi.rfc1902.ObjectType`
... | Adds path to repository to search PySNMP MIB files. | [
"Adds",
"path",
"to",
"repository",
"to",
"search",
"PySNMP",
"MIB",
"files",
"."
] | def addMibSource(self, *mibSources):
"""Adds path to repository to search PySNMP MIB files.
Parameters
----------
*mibSources :
one or more paths to search or Python package names to import
and search for PySNMP MIB modules.
Returns
-------
... | [
"def",
"addMibSource",
"(",
"self",
",",
"*",
"mibSources",
")",
":",
"self",
".",
"__args",
"[",
"0",
"]",
".",
"addMibSource",
"(",
"*",
"mibSources",
")",
"return",
"self"
] | https://github.com/collinsctk/PyQYT/blob/7af3673955f94ff1b2df2f94220cd2dab2e252af/ExtentionPackages/pysnmp/smi/rfc1902.py#L745-L775 | |
openstack/nova | b49b7663e1c3073917d5844b81d38db8e86d05c4 | nova/compute/monitors/base.py | python | MonitorBase.populate_metrics | (self, metric_list) | Monitors are responsible for populating this metric_list object
with nova.objects.MonitorMetric objects with values collected via
the respective compute drivers.
Note that if the monitor class is responsible for tracking a *related*
set of metrics -- e.g. a set of percentages of CPU tim... | Monitors are responsible for populating this metric_list object
with nova.objects.MonitorMetric objects with values collected via
the respective compute drivers. | [
"Monitors",
"are",
"responsible",
"for",
"populating",
"this",
"metric_list",
"object",
"with",
"nova",
".",
"objects",
".",
"MonitorMetric",
"objects",
"with",
"values",
"collected",
"via",
"the",
"respective",
"compute",
"drivers",
"."
] | def populate_metrics(self, metric_list):
"""Monitors are responsible for populating this metric_list object
with nova.objects.MonitorMetric objects with values collected via
the respective compute drivers.
Note that if the monitor class is responsible for tracking a *related*
se... | [
"def",
"populate_metrics",
"(",
"self",
",",
"metric_list",
")",
":",
"raise",
"NotImplementedError",
"(",
"'populate_metrics'",
")"
] | https://github.com/openstack/nova/blob/b49b7663e1c3073917d5844b81d38db8e86d05c4/nova/compute/monitors/base.py#L43-L56 | ||
AppScale/gts | 46f909cf5dc5ba81faf9d81dc9af598dcf8a82a9 | AppServer/lib/django-1.5/django/db/backends/__init__.py | python | BaseDatabaseIntrospection.table_names | (self, cursor=None) | return sorted(self.get_table_list(cursor)) | Returns a list of names of all tables that exist in the database.
The returned table list is sorted by Python's default sorting. We
do NOT use database's ORDER BY here to avoid subtle differences
in sorting order between databases. | Returns a list of names of all tables that exist in the database.
The returned table list is sorted by Python's default sorting. We
do NOT use database's ORDER BY here to avoid subtle differences
in sorting order between databases. | [
"Returns",
"a",
"list",
"of",
"names",
"of",
"all",
"tables",
"that",
"exist",
"in",
"the",
"database",
".",
"The",
"returned",
"table",
"list",
"is",
"sorted",
"by",
"Python",
"s",
"default",
"sorting",
".",
"We",
"do",
"NOT",
"use",
"database",
"s",
... | def table_names(self, cursor=None):
"""
Returns a list of names of all tables that exist in the database.
The returned table list is sorted by Python's default sorting. We
do NOT use database's ORDER BY here to avoid subtle differences
in sorting order between databases.
... | [
"def",
"table_names",
"(",
"self",
",",
"cursor",
"=",
"None",
")",
":",
"if",
"cursor",
"is",
"None",
":",
"cursor",
"=",
"self",
".",
"connection",
".",
"cursor",
"(",
")",
"return",
"sorted",
"(",
"self",
".",
"get_table_list",
"(",
"cursor",
")",
... | https://github.com/AppScale/gts/blob/46f909cf5dc5ba81faf9d81dc9af598dcf8a82a9/AppServer/lib/django-1.5/django/db/backends/__init__.py#L957-L966 | |
apache/tvm | 6eb4ed813ebcdcd9558f0906a1870db8302ff1e0 | python/tvm/relay/analysis/analysis.py | python | get_calibration_data | (mod, data) | return calib_data | Get the calibration data of a given relay graph
This pass uses the graph executor to get the calibration data of a module, which
includes the input and output values of each function. The returned data uses
the GlobalVar of each function as a key. Users can further access the inputs and
outputs by usin... | Get the calibration data of a given relay graph | [
"Get",
"the",
"calibration",
"data",
"of",
"a",
"given",
"relay",
"graph"
] | def get_calibration_data(mod, data):
"""Get the calibration data of a given relay graph
This pass uses the graph executor to get the calibration data of a module, which
includes the input and output values of each function. The returned data uses
the GlobalVar of each function as a key. Users can furth... | [
"def",
"get_calibration_data",
"(",
"mod",
",",
"data",
")",
":",
"output_map",
"=",
"_ffi_api",
".",
"get_calibrate_output_map",
"(",
"mod",
")",
"mod",
"=",
"_ffi_api",
".",
"get_calibrate_module",
"(",
"mod",
")",
"mod",
"=",
"transform",
".",
"Inline",
"... | https://github.com/apache/tvm/blob/6eb4ed813ebcdcd9558f0906a1870db8302ff1e0/python/tvm/relay/analysis/analysis.py#L373-L417 | |
pysmt/pysmt | ade4dc2a825727615033a96d31c71e9f53ce4764 | pysmt/smtlib/printers.py | python | SmtPrinter.walk_bv_tonatural | (self, formula) | return self.walk_nary(formula, "bv2nat") | [] | def walk_bv_tonatural(self, formula): return self.walk_nary(formula, "bv2nat") | [
"def",
"walk_bv_tonatural",
"(",
"self",
",",
"formula",
")",
":",
"return",
"self",
".",
"walk_nary",
"(",
"formula",
",",
"\"bv2nat\"",
")"
] | https://github.com/pysmt/pysmt/blob/ade4dc2a825727615033a96d31c71e9f53ce4764/pysmt/smtlib/printers.py#L85-L85 | |||
TobyPDE/FRRN | 20041107a4625106d6acef1dcc903d4352220d3e | dltools/hybrid_training.py | python | get_split_outputs | (nnet, **kwargs) | return predictions, split_outputs, split_shapes | Returns the predictions output and the outputs at the split layers.
Args:
nnet: The nnet instance that carries the network definition.
**kwargs: Arguments for `lasagne.layers.get_output`. | Returns the predictions output and the outputs at the split layers. | [
"Returns",
"the",
"predictions",
"output",
"and",
"the",
"outputs",
"at",
"the",
"split",
"layers",
"."
] | def get_split_outputs(nnet, **kwargs):
"""Returns the predictions output and the outputs at the split layers.
Args:
nnet: The nnet instance that carries the network definition.
**kwargs: Arguments for `lasagne.layers.get_output`.
"""
all_outputs = lasagne.layers.get_output(
nnet... | [
"def",
"get_split_outputs",
"(",
"nnet",
",",
"*",
"*",
"kwargs",
")",
":",
"all_outputs",
"=",
"lasagne",
".",
"layers",
".",
"get_output",
"(",
"nnet",
".",
"output_layers",
"+",
"sum",
"(",
"nnet",
".",
"splits",
",",
"[",
"]",
")",
",",
"*",
"*",... | https://github.com/TobyPDE/FRRN/blob/20041107a4625106d6acef1dcc903d4352220d3e/dltools/hybrid_training.py#L16-L38 | |
golismero/golismero | 7d605b937e241f51c1ca4f47b20f755eeefb9d76 | thirdparty_libs/django/utils/itercompat.py | python | is_iterator | (x) | return isinstance(x, collections.Iterator) and hasattr(x, '__iter__') | An implementation independent way of checking for iterators
Python 2.6 has a different implementation of collections.Iterator which
accepts anything with a `next` method. 2.7+ requires and `__iter__` method
as well. | An implementation independent way of checking for iterators | [
"An",
"implementation",
"independent",
"way",
"of",
"checking",
"for",
"iterators"
] | def is_iterator(x):
"""An implementation independent way of checking for iterators
Python 2.6 has a different implementation of collections.Iterator which
accepts anything with a `next` method. 2.7+ requires and `__iter__` method
as well.
"""
if sys.version_info >= (2, 7):
return isinst... | [
"def",
"is_iterator",
"(",
"x",
")",
":",
"if",
"sys",
".",
"version_info",
">=",
"(",
"2",
",",
"7",
")",
":",
"return",
"isinstance",
"(",
"x",
",",
"collections",
".",
"Iterator",
")",
"return",
"isinstance",
"(",
"x",
",",
"collections",
".",
"It... | https://github.com/golismero/golismero/blob/7d605b937e241f51c1ca4f47b20f755eeefb9d76/thirdparty_libs/django/utils/itercompat.py#L22-L31 | |
PaddlePaddle/Research | 2da0bd6c72d60e9df403aff23a7802779561c4a1 | ST_DM/KDD2021-HGAMN/src/dataset/pointwise_dataset.py | python | parse_poi | (poi) | return pid, city_id, name, addr, poi_geo | parse poi | parse poi | [
"parse",
"poi"
] | def parse_poi(poi):
"""parse poi"""
poi = poi.split('\x02')
pid, city_id = poi[0].split('_')
city_id = int(city_id)
name = poi[1]
addr = poi[2] if len(poi) >= 4 else ""
poi_geo = geohash.get_loc_gh(poi[3])
return pid, city_id, name, addr, poi_geo | [
"def",
"parse_poi",
"(",
"poi",
")",
":",
"poi",
"=",
"poi",
".",
"split",
"(",
"'\\x02'",
")",
"pid",
",",
"city_id",
"=",
"poi",
"[",
"0",
"]",
".",
"split",
"(",
"'_'",
")",
"city_id",
"=",
"int",
"(",
"city_id",
")",
"name",
"=",
"poi",
"["... | https://github.com/PaddlePaddle/Research/blob/2da0bd6c72d60e9df403aff23a7802779561c4a1/ST_DM/KDD2021-HGAMN/src/dataset/pointwise_dataset.py#L40-L49 | |
censys/censys-python | 9528f6b600215e59e1762bbe65216437c859f877 | censys/search/v2/certs.py | python | CensysCerts.get_hosts_by_cert | (
self, sha256fp: str, cursor: Optional[str] = None
) | return result["hosts"], result["links"] | Returns a list of hosts which contain services presenting this certificate.
Args:
sha256fp (str): The SHA-256 fingerprint of the requested certificate.
cursor (str): Cursor token from the API response, which fetches the next page of hosts when added to the endpoint URL.
Returns... | Returns a list of hosts which contain services presenting this certificate. | [
"Returns",
"a",
"list",
"of",
"hosts",
"which",
"contain",
"services",
"presenting",
"this",
"certificate",
"."
] | def get_hosts_by_cert(
self, sha256fp: str, cursor: Optional[str] = None
) -> Tuple[List[str], dict]:
"""Returns a list of hosts which contain services presenting this certificate.
Args:
sha256fp (str): The SHA-256 fingerprint of the requested certificate.
cursor (st... | [
"def",
"get_hosts_by_cert",
"(",
"self",
",",
"sha256fp",
":",
"str",
",",
"cursor",
":",
"Optional",
"[",
"str",
"]",
"=",
"None",
")",
"->",
"Tuple",
"[",
"List",
"[",
"str",
"]",
",",
"dict",
"]",
":",
"args",
"=",
"{",
"\"cursor\"",
":",
"curso... | https://github.com/censys/censys-python/blob/9528f6b600215e59e1762bbe65216437c859f877/censys/search/v2/certs.py#L51-L65 | |
zihangdai/xlnet | bbaa3a6fa0b3a2ee694e8cf66167434f9eca9660 | modeling.py | python | embedding_lookup | (x, n_token, d_embed, initializer, use_tpu=True,
scope='embedding', reuse=None, dtype=tf.float32) | TPU and GPU embedding_lookup function. | TPU and GPU embedding_lookup function. | [
"TPU",
"and",
"GPU",
"embedding_lookup",
"function",
"."
] | def embedding_lookup(x, n_token, d_embed, initializer, use_tpu=True,
scope='embedding', reuse=None, dtype=tf.float32):
"""TPU and GPU embedding_lookup function."""
with tf.variable_scope(scope, reuse=reuse):
lookup_table = tf.get_variable('lookup_table', [n_token, d_embed],
... | [
"def",
"embedding_lookup",
"(",
"x",
",",
"n_token",
",",
"d_embed",
",",
"initializer",
",",
"use_tpu",
"=",
"True",
",",
"scope",
"=",
"'embedding'",
",",
"reuse",
"=",
"None",
",",
"dtype",
"=",
"tf",
".",
"float32",
")",
":",
"with",
"tf",
".",
"... | https://github.com/zihangdai/xlnet/blob/bbaa3a6fa0b3a2ee694e8cf66167434f9eca9660/modeling.py#L25-L38 | ||
HendrikStrobelt/Seq2Seq-Vis | 7e3096ccd5c411d72e09759bc8219bfaea15eddb | index/faiss/faiss.py | python | kmin | (array, k) | return D, I | return k smallest values (and their indices) of the lines of a
float32 array | return k smallest values (and their indices) of the lines of a
float32 array | [
"return",
"k",
"smallest",
"values",
"(",
"and",
"their",
"indices",
")",
"of",
"the",
"lines",
"of",
"a",
"float32",
"array"
] | def kmin(array, k):
"""return k smallest values (and their indices) of the lines of a
float32 array"""
m, n = array.shape
I = np.zeros((m, k), dtype='int64')
D = np.zeros((m, k), dtype='float32')
ha = float_maxheap_array_t()
ha.ids = swig_ptr(I)
ha.val = swig_ptr(D)
ha.nh = m
ha.... | [
"def",
"kmin",
"(",
"array",
",",
"k",
")",
":",
"m",
",",
"n",
"=",
"array",
".",
"shape",
"I",
"=",
"np",
".",
"zeros",
"(",
"(",
"m",
",",
"k",
")",
",",
"dtype",
"=",
"'int64'",
")",
"D",
"=",
"np",
".",
"zeros",
"(",
"(",
"m",
",",
... | https://github.com/HendrikStrobelt/Seq2Seq-Vis/blob/7e3096ccd5c411d72e09759bc8219bfaea15eddb/index/faiss/faiss.py#L355-L369 | |
googleads/google-ads-python | 2a1d6062221f6aad1992a6bcca0e7e4a93d2db86 | examples/remarketing/add_real_estate_feed.py | python | main | (client, customer_id) | The main method that creates all necessary entities for the example.
Args:
client: an initialized GoogleAdsClient instance.
customer_id: a client customer ID. | The main method that creates all necessary entities for the example. | [
"The",
"main",
"method",
"that",
"creates",
"all",
"necessary",
"entities",
"for",
"the",
"example",
"."
] | def main(client, customer_id):
"""The main method that creates all necessary entities for the example.
Args:
client: an initialized GoogleAdsClient instance.
customer_id: a client customer ID.
"""
# Creates a new feed, but you can fetch and re-use an existing feed by
# skipping the ... | [
"def",
"main",
"(",
"client",
",",
"customer_id",
")",
":",
"# Creates a new feed, but you can fetch and re-use an existing feed by",
"# skipping the _create_feed method and inserting the feed resource name of",
"# the existing feed.",
"feed_resource_name",
"=",
"_create_feed",
"(",
"c... | https://github.com/googleads/google-ads-python/blob/2a1d6062221f6aad1992a6bcca0e7e4a93d2db86/examples/remarketing/add_real_estate_feed.py#L29-L73 | ||
robotlearn/pyrobolearn | 9cd7c060723fda7d2779fa255ac998c2c82b8436 | pyrobolearn/physics/link_physics_randomizer.py | python | LinkPhysicsRandomizer.mass_bounds | (self, bounds) | Set the mass bound for each link. | Set the mass bound for each link. | [
"Set",
"the",
"mass",
"bound",
"for",
"each",
"link",
"."
] | def mass_bounds(self, bounds):
"""Set the mass bound for each link."""
self._check_bounds('masses', bounds)
self._mass_bounds = bounds | [
"def",
"mass_bounds",
"(",
"self",
",",
"bounds",
")",
":",
"self",
".",
"_check_bounds",
"(",
"'masses'",
",",
"bounds",
")",
"self",
".",
"_mass_bounds",
"=",
"bounds"
] | https://github.com/robotlearn/pyrobolearn/blob/9cd7c060723fda7d2779fa255ac998c2c82b8436/pyrobolearn/physics/link_physics_randomizer.py#L133-L136 | ||
bbc/brave | 88d4454412ee5acfa5ecf2ac5bc8cf75766c7be5 | brave/inputoutputoverlay.py | python | InputOutputOverlay.state | (self, new_state) | Allows the state to be set. Can be either a string (e.g. 'READY') or the Gst constant. | Allows the state to be set. Can be either a string (e.g. 'READY') or the Gst constant. | [
"Allows",
"the",
"state",
"to",
"be",
"set",
".",
"Can",
"be",
"either",
"a",
"string",
"(",
"e",
".",
"g",
".",
"READY",
")",
"or",
"the",
"Gst",
"constant",
"."
] | def state(self, new_state):
'''
Allows the state to be set. Can be either a string (e.g. 'READY') or the Gst constant.
'''
if new_state is None:
self._desired_state = None
return
if new_state not in [Gst.State.PLAYING, Gst.State.PAUSED, Gst.State.READY, G... | [
"def",
"state",
"(",
"self",
",",
"new_state",
")",
":",
"if",
"new_state",
"is",
"None",
":",
"self",
".",
"_desired_state",
"=",
"None",
"return",
"if",
"new_state",
"not",
"in",
"[",
"Gst",
".",
"State",
".",
"PLAYING",
",",
"Gst",
".",
"State",
"... | https://github.com/bbc/brave/blob/88d4454412ee5acfa5ecf2ac5bc8cf75766c7be5/brave/inputoutputoverlay.py#L352-L370 | ||
cloudmatrix/esky | 6fde3201f0335064931a6c7f7847fc5ad39001b4 | esky/util.py | python | deep_extract_zipfile | (source,target,name_filter=None) | return extract_zipfile(source,target,new_name_filter) | Extract the deep contents of a zipfile into a target directory.
This is just like extract_zipfile() except that any common prefix dirs
are removed. For example, if everything in the zipfile is under the
directory "example.app" then that prefix will be removed during unzipping.
This is useful to allow... | Extract the deep contents of a zipfile into a target directory. | [
"Extract",
"the",
"deep",
"contents",
"of",
"a",
"zipfile",
"into",
"a",
"target",
"directory",
"."
] | def deep_extract_zipfile(source,target,name_filter=None):
"""Extract the deep contents of a zipfile into a target directory.
This is just like extract_zipfile() except that any common prefix dirs
are removed. For example, if everything in the zipfile is under the
directory "example.app" then that pref... | [
"def",
"deep_extract_zipfile",
"(",
"source",
",",
"target",
",",
"name_filter",
"=",
"None",
")",
":",
"prefix",
"=",
"zipfile_common_prefix_dir",
"(",
"source",
")",
"if",
"prefix",
":",
"def",
"new_name_filter",
"(",
"nm",
")",
":",
"if",
"not",
"nm",
"... | https://github.com/cloudmatrix/esky/blob/6fde3201f0335064931a6c7f7847fc5ad39001b4/esky/util.py#L330-L350 | |
neurokernel/neurokernel | e21e4aece1e8551dfa206d96e8ffd113beb10a85 | neurokernel/pattern.py | python | Pattern.from_df | (cls, df_int, df_pat) | return pat | Create a Pattern from properly formatted DataFrames.
Parameters
----------
df_int : pandas.DataFrame
DataFrame with a MultiIndex and data columns 'interface',
'io', and 'type' (additional columns may also be present) that
describes the pattern's interfaces. T... | Create a Pattern from properly formatted DataFrames. | [
"Create",
"a",
"Pattern",
"from",
"properly",
"formatted",
"DataFrames",
"."
] | def from_df(cls, df_int, df_pat):
"""
Create a Pattern from properly formatted DataFrames.
Parameters
----------
df_int : pandas.DataFrame
DataFrame with a MultiIndex and data columns 'interface',
'io', and 'type' (additional columns may also be present) ... | [
"def",
"from_df",
"(",
"cls",
",",
"df_int",
",",
"df_pat",
")",
":",
"# Create pattern with phony selectors:",
"pat",
"=",
"cls",
"(",
"'/foo[0]'",
",",
"'/bar[0]'",
")",
"# Check that the 'interface' column of the interface DataFrame is set:",
"if",
"any",
"(",
"df_in... | https://github.com/neurokernel/neurokernel/blob/e21e4aece1e8551dfa206d96e8ffd113beb10a85/neurokernel/pattern.py#L1245-L1293 | |
gramps-project/gramps | 04d4651a43eb210192f40a9f8c2bad8ee8fa3753 | gramps/gui/widgets/validatedmaskedentry.py | python | ValidatableMaskedEntry.validate | (self, force=False) | Checks if the data is valid.
Validates data-type and custom validation.
:param force: if True, force validation
:returns: validated data or ValueUnset if it failed | Checks if the data is valid.
Validates data-type and custom validation. | [
"Checks",
"if",
"the",
"data",
"is",
"valid",
".",
"Validates",
"data",
"-",
"type",
"and",
"custom",
"validation",
"."
] | def validate(self, force=False):
"""
Checks if the data is valid.
Validates data-type and custom validation.
:param force: if True, force validation
:returns: validated data or ValueUnset if it failed
"""
# If we're not visible or sensitive return a blank value,... | [
"def",
"validate",
"(",
"self",
",",
"force",
"=",
"False",
")",
":",
"# If we're not visible or sensitive return a blank value, except",
"# when forcing the validation",
"if",
"not",
"force",
"and",
"(",
"not",
"self",
".",
"get_property",
"(",
"'visible'",
")",
"or"... | https://github.com/gramps-project/gramps/blob/04d4651a43eb210192f40a9f8c2bad8ee8fa3753/gramps/gui/widgets/validatedmaskedentry.py#L1067-L1112 | ||
khanhnamle1994/natural-language-processing | 01d450d5ac002b0156ef4cf93a07cb508c1bcdc5 | assignment1/.env/lib/python2.7/site-packages/IPython/html/services/notebooks/handlers.py | python | NotebookHandler.patch | (self, path='', name=None) | PATCH renames a notebook without re-uploading content. | PATCH renames a notebook without re-uploading content. | [
"PATCH",
"renames",
"a",
"notebook",
"without",
"re",
"-",
"uploading",
"content",
"."
] | def patch(self, path='', name=None):
"""PATCH renames a notebook without re-uploading content."""
nbm = self.notebook_manager
if name is None:
raise web.HTTPError(400, u'Notebook name missing')
model = self.get_json_body()
if model is None:
raise web.HTTPE... | [
"def",
"patch",
"(",
"self",
",",
"path",
"=",
"''",
",",
"name",
"=",
"None",
")",
":",
"nbm",
"=",
"self",
".",
"notebook_manager",
"if",
"name",
"is",
"None",
":",
"raise",
"web",
".",
"HTTPError",
"(",
"400",
",",
"u'Notebook name missing'",
")",
... | https://github.com/khanhnamle1994/natural-language-processing/blob/01d450d5ac002b0156ef4cf93a07cb508c1bcdc5/assignment1/.env/lib/python2.7/site-packages/IPython/html/services/notebooks/handlers.py#L92-L101 | ||
pwnieexpress/pwn_plug_sources | 1a23324f5dc2c3de20f9c810269b6a29b2758cad | src/metagoofil/pdfminer/pdfparser.py | python | PDFDocument.set_parser | (self, parser) | return | Set the document to use a given PDFParser object. | Set the document to use a given PDFParser object. | [
"Set",
"the",
"document",
"to",
"use",
"a",
"given",
"PDFParser",
"object",
"."
] | def set_parser(self, parser):
"Set the document to use a given PDFParser object."
if self._parser: return
self._parser = parser
# Retrieve the information of each header that was appended
# (maybe multiple times) at the end of the document.
self.xrefs = parser.read_xref()... | [
"def",
"set_parser",
"(",
"self",
",",
"parser",
")",
":",
"if",
"self",
".",
"_parser",
":",
"return",
"self",
".",
"_parser",
"=",
"parser",
"# Retrieve the information of each header that was appended",
"# (maybe multiple times) at the end of the document.",
"self",
".... | https://github.com/pwnieexpress/pwn_plug_sources/blob/1a23324f5dc2c3de20f9c810269b6a29b2758cad/src/metagoofil/pdfminer/pdfparser.py#L311-L337 | |
edisonlz/fastor | 342078a18363ac41d3c6b1ab29dbdd44fdb0b7b3 | base/site-packages/gdata/apps/service.py | python | AppsService.RetrieveAllNicknames | (self) | return self.AddAllElementsFromAllPages(
ret, gdata.apps.NicknameFeedFromString) | Retrieve all nicknames in the domain | Retrieve all nicknames in the domain | [
"Retrieve",
"all",
"nicknames",
"in",
"the",
"domain"
] | def RetrieveAllNicknames(self):
"""Retrieve all nicknames in the domain"""
ret = self.RetrievePageOfNicknames()
# pagination
return self.AddAllElementsFromAllPages(
ret, gdata.apps.NicknameFeedFromString) | [
"def",
"RetrieveAllNicknames",
"(",
"self",
")",
":",
"ret",
"=",
"self",
".",
"RetrievePageOfNicknames",
"(",
")",
"# pagination",
"return",
"self",
".",
"AddAllElementsFromAllPages",
"(",
"ret",
",",
"gdata",
".",
"apps",
".",
"NicknameFeedFromString",
")"
] | https://github.com/edisonlz/fastor/blob/342078a18363ac41d3c6b1ab29dbdd44fdb0b7b3/base/site-packages/gdata/apps/service.py#L255-L261 | |
MozillaSecurity/grizzly | 1c41478e32f323189a2c322ec041c3e0902a158a | grizzly/args.py | python | SortingHelpFormatter.add_usage | (self, usage, actions, groups, prefix=None) | [] | def add_usage(self, usage, actions, groups, prefix=None):
actions = sorted(actions, key=self.__sort_key)
super().add_usage(usage, actions, groups, prefix) | [
"def",
"add_usage",
"(",
"self",
",",
"usage",
",",
"actions",
",",
"groups",
",",
"prefix",
"=",
"None",
")",
":",
"actions",
"=",
"sorted",
"(",
"actions",
",",
"key",
"=",
"self",
".",
"__sort_key",
")",
"super",
"(",
")",
".",
"add_usage",
"(",
... | https://github.com/MozillaSecurity/grizzly/blob/1c41478e32f323189a2c322ec041c3e0902a158a/grizzly/args.py#L24-L26 | ||||
buke/GreenOdoo | 3d8c55d426fb41fdb3f2f5a1533cfe05983ba1df | runtime/python/lib/python2.7/site-packages/_xmlplus/dom/pulldom.py | python | DOMEventStream._emit | (self) | return rc | Fallback replacement for getEvent() that emits
the events that _slurp() read previously. | Fallback replacement for getEvent() that emits
the events that _slurp() read previously. | [
"Fallback",
"replacement",
"for",
"getEvent",
"()",
"that",
"emits",
"the",
"events",
"that",
"_slurp",
"()",
"read",
"previously",
"."
] | def _emit(self):
""" Fallback replacement for getEvent() that emits
the events that _slurp() read previously.
"""
rc = self.pulldom.firstEvent[1][0]
self.pulldom.firstEvent[1] = self.pulldom.firstEvent[1][1]
return rc | [
"def",
"_emit",
"(",
"self",
")",
":",
"rc",
"=",
"self",
".",
"pulldom",
".",
"firstEvent",
"[",
"1",
"]",
"[",
"0",
"]",
"self",
".",
"pulldom",
".",
"firstEvent",
"[",
"1",
"]",
"=",
"self",
".",
"pulldom",
".",
"firstEvent",
"[",
"1",
"]",
... | https://github.com/buke/GreenOdoo/blob/3d8c55d426fb41fdb3f2f5a1533cfe05983ba1df/runtime/python/lib/python2.7/site-packages/_xmlplus/dom/pulldom.py#L280-L286 | |
incuna/django-pgcrypto-fields | 5b4b8eed3f9636ba3331f26e41a639fe4bee9247 | pgcrypto/mixins.py | python | PGPMixin.cached_col | (self) | return DecryptedCol(
self.model._meta.db_table,
self
) | Get cached version of decryption for col. | Get cached version of decryption for col. | [
"Get",
"cached",
"version",
"of",
"decryption",
"for",
"col",
"."
] | def cached_col(self):
"""Get cached version of decryption for col."""
return DecryptedCol(
self.model._meta.db_table,
self
) | [
"def",
"cached_col",
"(",
"self",
")",
":",
"return",
"DecryptedCol",
"(",
"self",
".",
"model",
".",
"_meta",
".",
"db_table",
",",
"self",
")"
] | https://github.com/incuna/django-pgcrypto-fields/blob/5b4b8eed3f9636ba3331f26e41a639fe4bee9247/pgcrypto/mixins.py#L120-L125 | |
biolab/orange3 | 41685e1c7b1d1babe680113685a2d44bcc9fec0b | Orange/widgets/data/utils/pythoneditor/indenter.py | python | Indenter.text | (self) | Get indent text as \t or string of spaces | Get indent text as \t or string of spaces | [
"Get",
"indent",
"text",
"as",
"\\",
"t",
"or",
"string",
"of",
"spaces"
] | def text(self):
"""Get indent text as \t or string of spaces
"""
if self.useTabs:
return '\t'
else:
return ' ' * self.width | [
"def",
"text",
"(",
"self",
")",
":",
"if",
"self",
".",
"useTabs",
":",
"return",
"'\\t'",
"else",
":",
"return",
"' '",
"*",
"self",
".",
"width"
] | https://github.com/biolab/orange3/blob/41685e1c7b1d1babe680113685a2d44bcc9fec0b/Orange/widgets/data/utils/pythoneditor/indenter.py#L35-L41 | ||
basnijholt/miflora | c231bfd3f9aa624195dd39ce610ad175229b5712 | demo.py | python | _get_backend | (args) | return backend | Extract the backend class from the command line arguments. | Extract the backend class from the command line arguments. | [
"Extract",
"the",
"backend",
"class",
"from",
"the",
"command",
"line",
"arguments",
"."
] | def _get_backend(args):
"""Extract the backend class from the command line arguments."""
if args.backend == "gatttool":
backend = GatttoolBackend
elif args.backend == "bluepy":
backend = BluepyBackend
elif args.backend == "pygatt":
backend = PygattBackend
else:
raise ... | [
"def",
"_get_backend",
"(",
"args",
")",
":",
"if",
"args",
".",
"backend",
"==",
"\"gatttool\"",
":",
"backend",
"=",
"GatttoolBackend",
"elif",
"args",
".",
"backend",
"==",
"\"bluepy\"",
":",
"backend",
"=",
"BluepyBackend",
"elif",
"args",
".",
"backend"... | https://github.com/basnijholt/miflora/blob/c231bfd3f9aa624195dd39ce610ad175229b5712/demo.py#L57-L67 | |
robotlearn/pyrobolearn | 9cd7c060723fda7d2779fa255ac998c2c82b8436 | pyrobolearn/models/gaussian.py | python | Gaussian.normalization_constant | (self) | normalization constant | normalization constant | [
"normalization",
"constant"
] | def normalization_constant(self):
"""normalization constant"""
if self.cov is not None:
return self.compute_normalization_constant(self.cov) | [
"def",
"normalization_constant",
"(",
"self",
")",
":",
"if",
"self",
".",
"cov",
"is",
"not",
"None",
":",
"return",
"self",
".",
"compute_normalization_constant",
"(",
"self",
".",
"cov",
")"
] | https://github.com/robotlearn/pyrobolearn/blob/9cd7c060723fda7d2779fa255ac998c2c82b8436/pyrobolearn/models/gaussian.py#L221-L224 | ||
eirannejad/pyRevit | 49c0b7eb54eb343458ce1365425e6552d0c47d44 | site-packages/bson/network.py | python | sendobj | (self, obj) | Atomically send a BSON message. | Atomically send a BSON message. | [
"Atomically",
"send",
"a",
"BSON",
"message",
"."
] | def sendobj(self, obj):
"""
Atomically send a BSON message.
"""
data = dumps(obj)
self.sendall(data) | [
"def",
"sendobj",
"(",
"self",
",",
"obj",
")",
":",
"data",
"=",
"dumps",
"(",
"obj",
")",
"self",
".",
"sendall",
"(",
"data",
")"
] | https://github.com/eirannejad/pyRevit/blob/49c0b7eb54eb343458ce1365425e6552d0c47d44/site-packages/bson/network.py#L13-L18 | ||
pychess/pychess | e3f9b12947e429993edcc2b9288f79bc181e6500 | lib/pychess/ic/managers/FingerManager.py | python | FingerObject.getStatus | (self) | return self.__status | Returns the current user-status as a STATUS constant | Returns the current user-status as a STATUS constant | [
"Returns",
"the",
"current",
"user",
"-",
"status",
"as",
"a",
"STATUS",
"constant"
] | def getStatus(self):
""" Returns the current user-status as a STATUS constant """
return self.__status | [
"def",
"getStatus",
"(",
"self",
")",
":",
"return",
"self",
".",
"__status"
] | https://github.com/pychess/pychess/blob/e3f9b12947e429993edcc2b9288f79bc181e6500/lib/pychess/ic/managers/FingerManager.py#L56-L58 | |
pypa/setuptools | 9f37366aab9cd8f6baa23e6a77cfdb8daf97757e | pkg_resources/_vendor/pyparsing.py | python | Forward.streamline | ( self ) | return self | [] | def streamline( self ):
if not self.streamlined:
self.streamlined = True
if self.expr is not None:
self.expr.streamline()
return self | [
"def",
"streamline",
"(",
"self",
")",
":",
"if",
"not",
"self",
".",
"streamlined",
":",
"self",
".",
"streamlined",
"=",
"True",
"if",
"self",
".",
"expr",
"is",
"not",
"None",
":",
"self",
".",
"expr",
".",
"streamline",
"(",
")",
"return",
"self"... | https://github.com/pypa/setuptools/blob/9f37366aab9cd8f6baa23e6a77cfdb8daf97757e/pkg_resources/_vendor/pyparsing.py#L4183-L4188 | |||
wxWidgets/Phoenix | b2199e299a6ca6d866aa6f3d0888499136ead9d6 | wx/lib/agw/peakmeter.py | python | PeakMeterCtrl.SetFalloffDelay | (self, speed) | Set peak value speed before falling off.
:param `speed`: the speed at which the falloff happens. | Set peak value speed before falling off. | [
"Set",
"peak",
"value",
"speed",
"before",
"falling",
"off",
"."
] | def SetFalloffDelay(self, speed):
"""
Set peak value speed before falling off.
:param `speed`: the speed at which the falloff happens.
"""
self._speed = speed | [
"def",
"SetFalloffDelay",
"(",
"self",
",",
"speed",
")",
":",
"self",
".",
"_speed",
"=",
"speed"
] | https://github.com/wxWidgets/Phoenix/blob/b2199e299a6ca6d866aa6f3d0888499136ead9d6/wx/lib/agw/peakmeter.py#L485-L492 | ||
Cartus/AGGCN | 395c63ca0cb4952c711fbf9cf5e05376df2c3743 | semeval/data/loader.py | python | sort_all | (batch, lens) | return sorted_all[2:], sorted_all[1] | Sort all fields by descending order of lens, and return the original indices. | Sort all fields by descending order of lens, and return the original indices. | [
"Sort",
"all",
"fields",
"by",
"descending",
"order",
"of",
"lens",
"and",
"return",
"the",
"original",
"indices",
"."
] | def sort_all(batch, lens):
""" Sort all fields by descending order of lens, and return the original indices. """
unsorted_all = [lens] + [range(len(lens))] + list(batch)
sorted_all = [list(t) for t in zip(*sorted(zip(*unsorted_all), reverse=True))]
return sorted_all[2:], sorted_all[1] | [
"def",
"sort_all",
"(",
"batch",
",",
"lens",
")",
":",
"unsorted_all",
"=",
"[",
"lens",
"]",
"+",
"[",
"range",
"(",
"len",
"(",
"lens",
")",
")",
"]",
"+",
"list",
"(",
"batch",
")",
"sorted_all",
"=",
"[",
"list",
"(",
"t",
")",
"for",
"t",... | https://github.com/Cartus/AGGCN/blob/395c63ca0cb4952c711fbf9cf5e05376df2c3743/semeval/data/loader.py#L128-L132 | |
AstusRush/AMaDiA | e2ad87318d9dd30bc24428e05c29cb32a29c83aa | External_Libraries/python_control_master/control/iosys.py | python | InputOutputSystem.set_inputs | (self, inputs, prefix='u') | Set the number/names of the system inputs.
Parameters
----------
inputs : int, list of str, or None
Description of the system inputs. This can be given as an integer
count or as a list of strings that name the individual signals.
If an integer count is speci... | Set the number/names of the system inputs. | [
"Set",
"the",
"number",
"/",
"names",
"of",
"the",
"system",
"inputs",
"."
] | def set_inputs(self, inputs, prefix='u'):
"""Set the number/names of the system inputs.
Parameters
----------
inputs : int, list of str, or None
Description of the system inputs. This can be given as an integer
count or as a list of strings that name the individ... | [
"def",
"set_inputs",
"(",
"self",
",",
"inputs",
",",
"prefix",
"=",
"'u'",
")",
":",
"self",
".",
"ninputs",
",",
"self",
".",
"input_index",
"=",
"self",
".",
"_process_signal_list",
"(",
"inputs",
",",
"prefix",
"=",
"prefix",
")"
] | https://github.com/AstusRush/AMaDiA/blob/e2ad87318d9dd30bc24428e05c29cb32a29c83aa/External_Libraries/python_control_master/control/iosys.py#L418-L436 | ||
home-assistant/core | 265ebd17a3f17ed8dc1e9bdede03ac8e323f1ab1 | homeassistant/components/smartthings/sensor.py | python | SmartThingsPowerConsumptionSensor.unique_id | (self) | return f"{self._device.device_id}.{self.report_name}_meter" | Return a unique ID. | Return a unique ID. | [
"Return",
"a",
"unique",
"ID",
"."
] | def unique_id(self) -> str:
"""Return a unique ID."""
return f"{self._device.device_id}.{self.report_name}_meter" | [
"def",
"unique_id",
"(",
"self",
")",
"->",
"str",
":",
"return",
"f\"{self._device.device_id}.{self.report_name}_meter\""
] | https://github.com/home-assistant/core/blob/265ebd17a3f17ed8dc1e9bdede03ac8e323f1ab1/homeassistant/components/smartthings/sensor.py#L723-L725 | |
cloudera/impyla | 0c736af4cad2bade9b8e313badc08ec50e81c948 | impala/_thrift_gen/hive_metastore/ThriftHiveMetastore.py | python | update_master_key_args.__repr__ | (self) | return '%s(%s)' % (self.__class__.__name__, ', '.join(L)) | [] | def __repr__(self):
L = ['%s=%r' % (key, value)
for key, value in self.__dict__.items()]
return '%s(%s)' % (self.__class__.__name__, ', '.join(L)) | [
"def",
"__repr__",
"(",
"self",
")",
":",
"L",
"=",
"[",
"'%s=%r'",
"%",
"(",
"key",
",",
"value",
")",
"for",
"key",
",",
"value",
"in",
"self",
".",
"__dict__",
".",
"items",
"(",
")",
"]",
"return",
"'%s(%s)'",
"%",
"(",
"self",
".",
"__class_... | https://github.com/cloudera/impyla/blob/0c736af4cad2bade9b8e313badc08ec50e81c948/impala/_thrift_gen/hive_metastore/ThriftHiveMetastore.py#L31564-L31567 | |||
triaquae/triaquae | bbabf736b3ba56a0c6498e7f04e16c13b8b8f2b9 | TriAquae/models/Centos_6.4/pyasn1/codec/ber/encoder.py | python | ObjectIdentifierEncoder.encodeValue | (self, encodeFun, value, defMode, maxChunkSize) | return ints2octs(octets), 0 | [] | def encodeValue(self, encodeFun, value, defMode, maxChunkSize):
oid = value.asTuple()
if oid[:5] in self.precomputedValues:
octets = self.precomputedValues[oid[:5]]
index = 5
else:
if len(oid) < 2:
raise error.PyAsn1Error('Short OID %s' % (... | [
"def",
"encodeValue",
"(",
"self",
",",
"encodeFun",
",",
"value",
",",
"defMode",
",",
"maxChunkSize",
")",
":",
"oid",
"=",
"value",
".",
"asTuple",
"(",
")",
"if",
"oid",
"[",
":",
"5",
"]",
"in",
"self",
".",
"precomputedValues",
":",
"octets",
"... | https://github.com/triaquae/triaquae/blob/bbabf736b3ba56a0c6498e7f04e16c13b8b8f2b9/TriAquae/models/Centos_6.4/pyasn1/codec/ber/encoder.py#L160-L196 | |||
colour-science/colour | 38782ac059e8ddd91939f3432bf06811c16667f0 | colour/colorimetry/yellowness.py | python | yellowness_ASTMD1925 | (XYZ) | return from_range_100(YI) | Returns the *yellowness* index :math:`YI` of given sample *CIE XYZ*
tristimulus values using *ASTM D1925* method.
ASTM D1925 has been specifically developed for the definition of the
Yellowness of homogeneous, non-fluorescent, almost neutral-transparent,
white-scattering or opaque plastics as they will... | Returns the *yellowness* index :math:`YI` of given sample *CIE XYZ*
tristimulus values using *ASTM D1925* method. | [
"Returns",
"the",
"*",
"yellowness",
"*",
"index",
":",
"math",
":",
"YI",
"of",
"given",
"sample",
"*",
"CIE",
"XYZ",
"*",
"tristimulus",
"values",
"using",
"*",
"ASTM",
"D1925",
"*",
"method",
"."
] | def yellowness_ASTMD1925(XYZ):
"""
Returns the *yellowness* index :math:`YI` of given sample *CIE XYZ*
tristimulus values using *ASTM D1925* method.
ASTM D1925 has been specifically developed for the definition of the
Yellowness of homogeneous, non-fluorescent, almost neutral-transparent,
white... | [
"def",
"yellowness_ASTMD1925",
"(",
"XYZ",
")",
":",
"X",
",",
"Y",
",",
"Z",
"=",
"tsplit",
"(",
"to_domain_100",
"(",
"XYZ",
")",
")",
"YI",
"=",
"(",
"100",
"*",
"(",
"1.28",
"*",
"X",
"-",
"1.06",
"*",
"Z",
")",
")",
"/",
"Y",
"return",
"... | https://github.com/colour-science/colour/blob/38782ac059e8ddd91939f3432bf06811c16667f0/colour/colorimetry/yellowness.py#L60-L114 | |
oracle/graalpython | 577e02da9755d916056184ec441c26e00b70145c | graalpython/lib-python/3/turtledemo/sorting_animate.py | python | Block.glow | (self) | [] | def glow(self):
self.fillcolor("red") | [
"def",
"glow",
"(",
"self",
")",
":",
"self",
".",
"fillcolor",
"(",
"\"red\"",
")"
] | https://github.com/oracle/graalpython/blob/577e02da9755d916056184ec441c26e00b70145c/graalpython/lib-python/3/turtledemo/sorting_animate.py#L32-L33 | ||||
zhanghe06/news_spider | 9e29525a8bcb2310fca3bb4f9ca4b99b39ecfc9c | tools/duplicate.py | python | is_dup_detail | (detail_url, spider_name, channel_id=0) | return redis_client.sismember(detail_dup_key, detail_url_finger) | 检查详细页是否重复
:param detail_url:
:param spider_name:
:param channel_id:
:return: | 检查详细页是否重复
:param detail_url:
:param spider_name:
:param channel_id:
:return: | [
"检查详细页是否重复",
":",
"param",
"detail_url",
":",
":",
"param",
"spider_name",
":",
":",
"param",
"channel_id",
":",
":",
"return",
":"
] | def is_dup_detail(detail_url, spider_name, channel_id=0):
"""
检查详细页是否重复
:param detail_url:
:param spider_name:
:param channel_id:
:return:
"""
detail_dup_key = 'scrapy:dup:%s:%s' % (spider_name, channel_id)
detail_url_finger = get_request_finger(detail_url)
return redis_client.si... | [
"def",
"is_dup_detail",
"(",
"detail_url",
",",
"spider_name",
",",
"channel_id",
"=",
"0",
")",
":",
"detail_dup_key",
"=",
"'scrapy:dup:%s:%s'",
"%",
"(",
"spider_name",
",",
"channel_id",
")",
"detail_url_finger",
"=",
"get_request_finger",
"(",
"detail_url",
"... | https://github.com/zhanghe06/news_spider/blob/9e29525a8bcb2310fca3bb4f9ca4b99b39ecfc9c/tools/duplicate.py#L18-L28 | |
autotest/autotest | 4614ae5f550cc888267b9a419e4b90deb54f8fae | frontend/afe/rpc_utils.py | python | create_job_common | (name, priority, control_type, control_file=None,
hosts=[], profiles=[], meta_hosts=[], meta_host_profiles=[],
one_time_hosts=[], atomic_group_name=None, synch_count=None,
is_template=False, timeout=None, max_runtime_hrs=None,
run_v... | return create_new_job(owner=owner,
options=options,
host_objects=host_objects,
profiles=profiles,
metahost_objects=metahost_objects,
metahost_profiles=meta_host_profiles,
... | Common code between creating "standard" jobs and creating parameterized jobs | Common code between creating "standard" jobs and creating parameterized jobs | [
"Common",
"code",
"between",
"creating",
"standard",
"jobs",
"and",
"creating",
"parameterized",
"jobs"
] | def create_job_common(name, priority, control_type, control_file=None,
hosts=[], profiles=[], meta_hosts=[], meta_host_profiles=[],
one_time_hosts=[], atomic_group_name=None, synch_count=None,
is_template=False, timeout=None, max_runtime_hrs=None,
... | [
"def",
"create_job_common",
"(",
"name",
",",
"priority",
",",
"control_type",
",",
"control_file",
"=",
"None",
",",
"hosts",
"=",
"[",
"]",
",",
"profiles",
"=",
"[",
"]",
",",
"meta_hosts",
"=",
"[",
"]",
",",
"meta_host_profiles",
"=",
"[",
"]",
",... | https://github.com/autotest/autotest/blob/4614ae5f550cc888267b9a419e4b90deb54f8fae/frontend/afe/rpc_utils.py#L667-L787 | |
NeuralEnsemble/PyNN | 96f5d80a5e814e3ccf05958b0c1fb39e98cc981b | pyNN/nest/projections.py | python | Projection._identify_common_synapse_properties | (self) | Use the connection between the sample indices to distinguish
between local and common synapse properties. | Use the connection between the sample indices to distinguish
between local and common synapse properties. | [
"Use",
"the",
"connection",
"between",
"the",
"sample",
"indices",
"to",
"distinguish",
"between",
"local",
"and",
"common",
"synapse",
"properties",
"."
] | def _identify_common_synapse_properties(self):
"""
Use the connection between the sample indices to distinguish
between local and common synapse properties.
"""
sample_connection = nest.GetConnections(
source=nest.NodeCollection([next(iter(self._sources))]), # take a... | [
"def",
"_identify_common_synapse_properties",
"(",
"self",
")",
":",
"sample_connection",
"=",
"nest",
".",
"GetConnections",
"(",
"source",
"=",
"nest",
".",
"NodeCollection",
"(",
"[",
"next",
"(",
"iter",
"(",
"self",
".",
"_sources",
")",
")",
"]",
")",
... | https://github.com/NeuralEnsemble/PyNN/blob/96f5d80a5e814e3ccf05958b0c1fb39e98cc981b/pyNN/nest/projections.py#L144-L157 | ||
python-pillow/Pillow | fd2b07c454b20e1e9af0cea64923b21250f8f8d6 | src/PIL/ImageShow.py | python | UnixViewer.show_file | (self, file, **options) | return 1 | Display given file | Display given file | [
"Display",
"given",
"file"
] | def show_file(self, file, **options):
"""Display given file"""
fd, path = tempfile.mkstemp()
with os.fdopen(fd, "w") as f:
f.write(file)
with open(path) as f:
command = self.get_command_ex(file, **options)[0]
subprocess.Popen(
["im=$(ca... | [
"def",
"show_file",
"(",
"self",
",",
"file",
",",
"*",
"*",
"options",
")",
":",
"fd",
",",
"path",
"=",
"tempfile",
".",
"mkstemp",
"(",
")",
"with",
"os",
".",
"fdopen",
"(",
"fd",
",",
"\"w\"",
")",
"as",
"f",
":",
"f",
".",
"write",
"(",
... | https://github.com/python-pillow/Pillow/blob/fd2b07c454b20e1e9af0cea64923b21250f8f8d6/src/PIL/ImageShow.py#L175-L186 | |
openhatch/oh-mainline | ce29352a034e1223141dcc2f317030bbc3359a51 | vendor/packages/twisted/twisted/protocols/loopback.py | python | loopbackAsync | (server, client, pumpPolicy=identityPumpPolicy) | return _loopbackAsyncBody(
server, serverToClient, client, clientToServer, pumpPolicy) | Establish a connection between C{server} and C{client} then transfer data
between them until the connection is closed. This is often useful for
testing a protocol.
@param server: The protocol instance representing the server-side of this
connection.
@param client: The protocol instance represe... | Establish a connection between C{server} and C{client} then transfer data
between them until the connection is closed. This is often useful for
testing a protocol. | [
"Establish",
"a",
"connection",
"between",
"C",
"{",
"server",
"}",
"and",
"C",
"{",
"client",
"}",
"then",
"transfer",
"data",
"between",
"them",
"until",
"the",
"connection",
"is",
"closed",
".",
"This",
"is",
"often",
"useful",
"for",
"testing",
"a",
... | def loopbackAsync(server, client, pumpPolicy=identityPumpPolicy):
"""
Establish a connection between C{server} and C{client} then transfer data
between them until the connection is closed. This is often useful for
testing a protocol.
@param server: The protocol instance representing the server-side... | [
"def",
"loopbackAsync",
"(",
"server",
",",
"client",
",",
"pumpPolicy",
"=",
"identityPumpPolicy",
")",
":",
"serverToClient",
"=",
"_LoopbackQueue",
"(",
")",
"clientToServer",
"=",
"_LoopbackQueue",
"(",
")",
"server",
".",
"makeConnection",
"(",
"_LoopbackTran... | https://github.com/openhatch/oh-mainline/blob/ce29352a034e1223141dcc2f317030bbc3359a51/vendor/packages/twisted/twisted/protocols/loopback.py#L133-L167 | |
demisto/content | 5c664a65b992ac8ca90ac3f11b1b2cdf11ee9b07 | Packs/SentinelOne/Integrations/SentinelOne-V2/SentinelOne-V2.py | python | disconnect_agent_from_network | (client: Client, args: dict) | return 'No agents were disconnected from the network.' | Sends a "disconnect from network" command to all agents matching the input filter. | Sends a "disconnect from network" command to all agents matching the input filter. | [
"Sends",
"a",
"disconnect",
"from",
"network",
"command",
"to",
"all",
"agents",
"matching",
"the",
"input",
"filter",
"."
] | def disconnect_agent_from_network(client: Client, args: dict) -> Union[CommandResults, str]:
"""
Sends a "disconnect from network" command to all agents matching the input filter.
"""
agent_ids = argToList(args.get('agent_id'))
# Make request and get raw response
raw_response = client.disconnec... | [
"def",
"disconnect_agent_from_network",
"(",
"client",
":",
"Client",
",",
"args",
":",
"dict",
")",
"->",
"Union",
"[",
"CommandResults",
",",
"str",
"]",
":",
"agent_ids",
"=",
"argToList",
"(",
"args",
".",
"get",
"(",
"'agent_id'",
")",
")",
"# Make re... | https://github.com/demisto/content/blob/5c664a65b992ac8ca90ac3f11b1b2cdf11ee9b07/Packs/SentinelOne/Integrations/SentinelOne-V2/SentinelOne-V2.py#L1055-L1079 | |
XX-net/XX-Net | a9898cfcf0084195fb7e69b6bc834e59aecdf14f | code/default/lib/noarch/dnslib/dns.py | python | RD.pack | (self,buffer) | Pack record into buffer | Pack record into buffer | [
"Pack",
"record",
"into",
"buffer"
] | def pack(self,buffer):
"""
Pack record into buffer
"""
buffer.append(self.data) | [
"def",
"pack",
"(",
"self",
",",
"buffer",
")",
":",
"buffer",
".",
"append",
"(",
"self",
".",
"data",
")"
] | https://github.com/XX-net/XX-Net/blob/a9898cfcf0084195fb7e69b6bc834e59aecdf14f/code/default/lib/noarch/dnslib/dns.py#L892-L896 | ||
IronLanguages/ironpython2 | 51fdedeeda15727717fb8268a805f71b06c0b9f1 | Src/StdLib/Lib/_pyio.py | python | IOBase.__enter__ | (self) | return self | Context management protocol. Returns self. | Context management protocol. Returns self. | [
"Context",
"management",
"protocol",
".",
"Returns",
"self",
"."
] | def __enter__(self):
"""Context management protocol. Returns self."""
self._checkClosed()
return self | [
"def",
"__enter__",
"(",
"self",
")",
":",
"self",
".",
"_checkClosed",
"(",
")",
"return",
"self"
] | https://github.com/IronLanguages/ironpython2/blob/51fdedeeda15727717fb8268a805f71b06c0b9f1/Src/StdLib/Lib/_pyio.py#L432-L435 | |
zhongbiaodev/py-mysql-elasticsearch-sync | a2a076e00a73c838e508ea6fa0b32ff505fb6a7a | src/__init__.py | python | ElasticSync._formatter | (self, data) | format every field from xml, according to parsed table structure | format every field from xml, according to parsed table structure | [
"format",
"every",
"field",
"from",
"xml",
"according",
"to",
"parsed",
"table",
"structure"
] | def _formatter(self, data):
"""
format every field from xml, according to parsed table structure
"""
for item in data:
for field, serializer in self.table_structure.items():
if item['doc'][field]:
try:
item['doc'][fi... | [
"def",
"_formatter",
"(",
"self",
",",
"data",
")",
":",
"for",
"item",
"in",
"data",
":",
"for",
"field",
",",
"serializer",
"in",
"self",
".",
"table_structure",
".",
"items",
"(",
")",
":",
"if",
"item",
"[",
"'doc'",
"]",
"[",
"field",
"]",
":"... | https://github.com/zhongbiaodev/py-mysql-elasticsearch-sync/blob/a2a076e00a73c838e508ea6fa0b32ff505fb6a7a/src/__init__.py#L207-L222 | ||
Textualize/rich | d39626143036188cb2c9e1619e836540f5b627f8 | rich/logging.py | python | RichHandler.render_message | (self, record: LogRecord, message: str) | return message_text | Render message text in to Text.
record (LogRecord): logging Record.
message (str): String containing log message.
Returns:
ConsoleRenderable: Renderable to display log message. | Render message text in to Text. | [
"Render",
"message",
"text",
"in",
"to",
"Text",
"."
] | def render_message(self, record: LogRecord, message: str) -> "ConsoleRenderable":
"""Render message text in to Text.
record (LogRecord): logging Record.
message (str): String containing log message.
Returns:
ConsoleRenderable: Renderable to display log message.
"""
... | [
"def",
"render_message",
"(",
"self",
",",
"record",
":",
"LogRecord",
",",
"message",
":",
"str",
")",
"->",
"\"ConsoleRenderable\"",
":",
"use_markup",
"=",
"getattr",
"(",
"record",
",",
"\"markup\"",
",",
"self",
".",
"markup",
")",
"message_text",
"=",
... | https://github.com/Textualize/rich/blob/d39626143036188cb2c9e1619e836540f5b627f8/rich/logging.py#L158-L176 | |
NoneGG/aredis | b46e67163692cd0796763e5c9e17394821d9280c | aredis/commands/lists.py | python | ListsCommandMixin.rpop | (self, name) | return await self.execute_command('RPOP', name) | Removes and return the last item of the list ``name`` | Removes and return the last item of the list ``name`` | [
"Removes",
"and",
"return",
"the",
"last",
"item",
"of",
"the",
"list",
"name"
] | async def rpop(self, name):
"""Removes and return the last item of the list ``name``"""
return await self.execute_command('RPOP', name) | [
"async",
"def",
"rpop",
"(",
"self",
",",
"name",
")",
":",
"return",
"await",
"self",
".",
"execute_command",
"(",
"'RPOP'",
",",
"name",
")"
] | https://github.com/NoneGG/aredis/blob/b46e67163692cd0796763e5c9e17394821d9280c/aredis/commands/lists.py#L151-L153 | |
elastic/rally | 7c58ef6f81f618fbc142dfa58b0ed00a5b05fbae | esrally/utils/opts.py | python | TargetHosts.all_hosts | (self) | return self.all_options | Return a dict with all parsed options | Return a dict with all parsed options | [
"Return",
"a",
"dict",
"with",
"all",
"parsed",
"options"
] | def all_hosts(self):
"""Return a dict with all parsed options"""
return self.all_options | [
"def",
"all_hosts",
"(",
"self",
")",
":",
"return",
"self",
".",
"all_options"
] | https://github.com/elastic/rally/blob/7c58ef6f81f618fbc142dfa58b0ed00a5b05fbae/esrally/utils/opts.py#L162-L164 | |
zhl2008/awd-platform | 0416b31abea29743387b10b3914581fbe8e7da5e | web_hxb2/lib/python3.5/site-packages/django/core/mail/backends/filebased.py | python | EmailBackend.open | (self) | return False | [] | def open(self):
if self.stream is None:
self.stream = open(self._get_filename(), 'ab')
return True
return False | [
"def",
"open",
"(",
"self",
")",
":",
"if",
"self",
".",
"stream",
"is",
"None",
":",
"self",
".",
"stream",
"=",
"open",
"(",
"self",
".",
"_get_filename",
"(",
")",
",",
"'ab'",
")",
"return",
"True",
"return",
"False"
] | https://github.com/zhl2008/awd-platform/blob/0416b31abea29743387b10b3914581fbe8e7da5e/web_hxb2/lib/python3.5/site-packages/django/core/mail/backends/filebased.py#L59-L63 | |||
Tencent/GAutomator | 0ac9f849d1ca2c59760a91c5c94d3db375a380cd | GAutomatorIos/build/lib/ga2/device/iOS/wda/__init__.py | python | Session.tap_hold | (self, x, y, duration=1.0) | return self.http.post('/wda/touchAndHold', data=data) | Tap and hold for a moment
Args:
- x, y(int): position
- duration(float): seconds of hold time
[[FBRoute POST:@"/wda/touchAndHold"] respondWithTarget:self action:@selector(handleTouchAndHoldCoordinate:)], | Tap and hold for a moment | [
"Tap",
"and",
"hold",
"for",
"a",
"moment"
] | def tap_hold(self, x, y, duration=1.0):
"""
Tap and hold for a moment
Args:
- x, y(int): position
- duration(float): seconds of hold time
[[FBRoute POST:@"/wda/touchAndHold"] respondWithTarget:self action:@selector(handleTouchAndHoldCoordinate:)],
"""
... | [
"def",
"tap_hold",
"(",
"self",
",",
"x",
",",
"y",
",",
"duration",
"=",
"1.0",
")",
":",
"self",
".",
"check_alert",
"(",
")",
"data",
"=",
"{",
"'x'",
":",
"x",
",",
"'y'",
":",
"y",
",",
"'duration'",
":",
"duration",
"}",
"return",
"self",
... | https://github.com/Tencent/GAutomator/blob/0ac9f849d1ca2c59760a91c5c94d3db375a380cd/GAutomatorIos/build/lib/ga2/device/iOS/wda/__init__.py#L405-L417 | |
firedrakeproject/firedrake | 06ab4975c14c0d4dcb79be55821f8b9e41554125 | firedrake/bcs.py | python | BCBase.zero | (self, r) | r"""Zero the boundary condition nodes on ``r``.
:arg r: a :class:`.Function` to which the
boundary condition should be applied. | r"""Zero the boundary condition nodes on ``r``. | [
"r",
"Zero",
"the",
"boundary",
"condition",
"nodes",
"on",
"r",
"."
] | def zero(self, r):
r"""Zero the boundary condition nodes on ``r``.
:arg r: a :class:`.Function` to which the
boundary condition should be applied.
"""
if isinstance(r, matrix.MatrixBase):
raise NotImplementedError("Zeroing bcs on a Matrix is not supported")
... | [
"def",
"zero",
"(",
"self",
",",
"r",
")",
":",
"if",
"isinstance",
"(",
"r",
",",
"matrix",
".",
"MatrixBase",
")",
":",
"raise",
"NotImplementedError",
"(",
"\"Zeroing bcs on a Matrix is not supported\"",
")",
"for",
"idx",
"in",
"self",
".",
"_indices",
"... | https://github.com/firedrakeproject/firedrake/blob/06ab4975c14c0d4dcb79be55821f8b9e41554125/firedrake/bcs.py#L174-L189 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.