repo stringlengths 7 55 | path stringlengths 4 223 | url stringlengths 87 315 | code stringlengths 75 104k | code_tokens list | docstring stringlengths 1 46.9k | docstring_tokens list | language stringclasses 1
value | partition stringclasses 3
values | avg_line_len float64 7.91 980 |
|---|---|---|---|---|---|---|---|---|---|
shoebot/shoebot | shoebot/diagnose.py | https://github.com/shoebot/shoebot/blob/d554c1765c1899fa25727c9fc6805d221585562b/shoebot/diagnose.py#L122-L150 | def shoebot_example(**shoebot_kwargs):
"""
Decorator to run some code in a bot instance.
"""
def decorator(f):
def run():
from shoebot import ShoebotInstallError # https://github.com/shoebot/shoebot/issues/206
print(" Shoebot - %s:" % f.__name__.replace("_", " "))
... | [
"def",
"shoebot_example",
"(",
"*",
"*",
"shoebot_kwargs",
")",
":",
"def",
"decorator",
"(",
"f",
")",
":",
"def",
"run",
"(",
")",
":",
"from",
"shoebot",
"import",
"ShoebotInstallError",
"# https://github.com/shoebot/shoebot/issues/206",
"print",
"(",
"\" Sh... | Decorator to run some code in a bot instance. | [
"Decorator",
"to",
"run",
"some",
"code",
"in",
"a",
"bot",
"instance",
"."
] | python | valid | 34.068966 |
jhuapl-boss/intern | intern/service/boss/v1/project.py | https://github.com/jhuapl-boss/intern/blob/d8fc6df011d8f212c87e6a1fd4cc21cfb5d103ed/intern/service/boss/v1/project.py#L150-L177 | def list_group_members(self, name, url_prefix, auth, session, send_opts):
"""Get the members of a group (does not include maintainers).
Args:
name (string): Name of group to query.
url_prefix (string): Protocol + host such as https://api.theboss.io
auth (string): Tok... | [
"def",
"list_group_members",
"(",
"self",
",",
"name",
",",
"url_prefix",
",",
"auth",
",",
"session",
",",
"send_opts",
")",
":",
"req",
"=",
"self",
".",
"get_group_members_request",
"(",
"'GET'",
",",
"'application/json'",
",",
"url_prefix",
",",
"auth",
... | Get the members of a group (does not include maintainers).
Args:
name (string): Name of group to query.
url_prefix (string): Protocol + host such as https://api.theboss.io
auth (string): Token to send in the request header.
session (requests.Session): HTTP sessio... | [
"Get",
"the",
"members",
"of",
"a",
"group",
"(",
"does",
"not",
"include",
"maintainers",
")",
"."
] | python | train | 40.571429 |
foremast/foremast | src/foremast/awslambda/awslambda.py | https://github.com/foremast/foremast/blob/fb70f29b8ce532f061685a17d120486e47b215ba/src/foremast/awslambda/awslambda.py#L106-L116 | def _vpc_config(self):
"""Get VPC config."""
if self.vpc_enabled:
subnets = get_subnets(env=self.env, region=self.region, purpose='internal')['subnet_ids'][self.region]
security_groups = self._get_sg_ids()
vpc_config = {'SubnetIds': subnets, 'SecurityGroupIds': secur... | [
"def",
"_vpc_config",
"(",
"self",
")",
":",
"if",
"self",
".",
"vpc_enabled",
":",
"subnets",
"=",
"get_subnets",
"(",
"env",
"=",
"self",
".",
"env",
",",
"region",
"=",
"self",
".",
"region",
",",
"purpose",
"=",
"'internal'",
")",
"[",
"'subnet_ids... | Get VPC config. | [
"Get",
"VPC",
"config",
"."
] | python | train | 44.454545 |
eddiejessup/spatious | spatious/geom.py | https://github.com/eddiejessup/spatious/blob/b7ae91bec029e85a45a7f303ee184076433723cd/spatious/geom.py#L242-L257 | def spheres_intersect(ar, aR, br, bR):
"""Return whether or not two spheres intersect each other.
Parameters
----------
ar, br: array-like, shape (n,) in n dimensions
Coordinates of the centres of the spheres `a` and `b`.
aR, bR: float
Radiuses of the spheres `a` and `b`.
Retur... | [
"def",
"spheres_intersect",
"(",
"ar",
",",
"aR",
",",
"br",
",",
"bR",
")",
":",
"return",
"vector",
".",
"vector_mag_sq",
"(",
"ar",
"-",
"br",
")",
"<",
"(",
"aR",
"+",
"bR",
")",
"**",
"2"
] | Return whether or not two spheres intersect each other.
Parameters
----------
ar, br: array-like, shape (n,) in n dimensions
Coordinates of the centres of the spheres `a` and `b`.
aR, bR: float
Radiuses of the spheres `a` and `b`.
Returns
-------
intersecting: boolean
... | [
"Return",
"whether",
"or",
"not",
"two",
"spheres",
"intersect",
"each",
"other",
"."
] | python | train | 28.125 |
GetmeUK/MongoFrames | mongoframes/frames.py | https://github.com/GetmeUK/MongoFrames/blob/7d2bd792235dfa77a9deecab5366f5f73480823d/mongoframes/frames.py#L566-L621 | def _dereference(cls, documents, references):
"""Dereference one or more documents"""
# Dereference each reference
for path, projection in references.items():
# Check there is a $ref in the projection, else skip it
if '$ref' not in projection:
continue
... | [
"def",
"_dereference",
"(",
"cls",
",",
"documents",
",",
"references",
")",
":",
"# Dereference each reference",
"for",
"path",
",",
"projection",
"in",
"references",
".",
"items",
"(",
")",
":",
"# Check there is a $ref in the projection, else skip it",
"if",
"'$ref... | Dereference one or more documents | [
"Dereference",
"one",
"or",
"more",
"documents"
] | python | train | 33.089286 |
saltstack/salt | salt/proxy/ssh_sample.py | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/proxy/ssh_sample.py#L193-L205 | def service_start(name):
'''
Start a "service" on the ssh server
.. versionadded:: 2015.8.2
'''
cmd = 'start ' + name
# Send the command to execute
out, err = DETAILS['server'].sendline(cmd)
# "scrape" the output and return the right fields as a dict
return parse(out) | [
"def",
"service_start",
"(",
"name",
")",
":",
"cmd",
"=",
"'start '",
"+",
"name",
"# Send the command to execute",
"out",
",",
"err",
"=",
"DETAILS",
"[",
"'server'",
"]",
".",
"sendline",
"(",
"cmd",
")",
"# \"scrape\" the output and return the right fields as a ... | Start a "service" on the ssh server
.. versionadded:: 2015.8.2 | [
"Start",
"a",
"service",
"on",
"the",
"ssh",
"server"
] | python | train | 22.692308 |
CalebBell/fluids | fluids/geometry.py | https://github.com/CalebBell/fluids/blob/57f556752e039f1d3e5a822f408c184783db2828/fluids/geometry.py#L1130-L1189 | def SA_torispheroidal(D, fd, fk):
r'''Calculates surface area of a torispherical head according to [1]_.
Somewhat involved. Equations are adapted to be used for a full head.
.. math::
SA = S_1 + S_2
.. math::
S_1 = 2\pi D^2 f_d \alpha
.. math::
S_2 = 2\pi D^2 f_k\left(\alp... | [
"def",
"SA_torispheroidal",
"(",
"D",
",",
"fd",
",",
"fk",
")",
":",
"alpha_1",
"=",
"fd",
"*",
"(",
"1",
"-",
"(",
"1",
"-",
"(",
"(",
"0.5",
"-",
"fk",
")",
"/",
"(",
"fd",
"-",
"fk",
")",
")",
"**",
"2",
")",
"**",
"0.5",
")",
"alpha_... | r'''Calculates surface area of a torispherical head according to [1]_.
Somewhat involved. Equations are adapted to be used for a full head.
.. math::
SA = S_1 + S_2
.. math::
S_1 = 2\pi D^2 f_d \alpha
.. math::
S_2 = 2\pi D^2 f_k\left(\alpha - \alpha_1 + (0.5 - f_k)\left(\sin^... | [
"r",
"Calculates",
"surface",
"area",
"of",
"a",
"torispherical",
"head",
"according",
"to",
"[",
"1",
"]",
"_",
".",
"Somewhat",
"involved",
".",
"Equations",
"are",
"adapted",
"to",
"be",
"used",
"for",
"a",
"full",
"head",
"."
] | python | train | 29.5 |
RudolfCardinal/pythonlib | cardinal_pythonlib/dbfunc.py | https://github.com/RudolfCardinal/pythonlib/blob/0b84cb35f38bd7d8723958dae51b480a829b7227/cardinal_pythonlib/dbfunc.py#L107-L122 | def dictfetchall(cursor: Cursor) -> List[Dict[str, Any]]:
"""
Return all rows from a cursor as a list of :class:`OrderedDict` objects.
Args:
cursor: the cursor
Returns:
a list (one item per row) of :class:`OrderedDict` objects whose key are
column names and whose values are the... | [
"def",
"dictfetchall",
"(",
"cursor",
":",
"Cursor",
")",
"->",
"List",
"[",
"Dict",
"[",
"str",
",",
"Any",
"]",
"]",
":",
"columns",
"=",
"get_fieldnames_from_cursor",
"(",
"cursor",
")",
"return",
"[",
"OrderedDict",
"(",
"zip",
"(",
"columns",
",",
... | Return all rows from a cursor as a list of :class:`OrderedDict` objects.
Args:
cursor: the cursor
Returns:
a list (one item per row) of :class:`OrderedDict` objects whose key are
column names and whose values are the row values | [
"Return",
"all",
"rows",
"from",
"a",
"cursor",
"as",
"a",
"list",
"of",
":",
"class",
":",
"OrderedDict",
"objects",
"."
] | python | train | 29.25 |
cloud9ers/gurumate | environment/lib/python2.7/site-packages/IPython/frontend/qt/console/console_widget.py | https://github.com/cloud9ers/gurumate/blob/075dc74d1ee62a8c6b7a8bf2b271364f01629d1e/environment/lib/python2.7/site-packages/IPython/frontend/qt/console/console_widget.py#L1522-L1537 | def _get_word_end_cursor(self, position):
""" Find the end of the word to the right the given position. If a
sequence of non-word characters precedes the first word, skip over
them. (This emulates the behavior of bash, emacs, etc.)
"""
document = self._control.document()
... | [
"def",
"_get_word_end_cursor",
"(",
"self",
",",
"position",
")",
":",
"document",
"=",
"self",
".",
"_control",
".",
"document",
"(",
")",
"end",
"=",
"self",
".",
"_get_end_cursor",
"(",
")",
".",
"position",
"(",
")",
"while",
"position",
"<",
"end",
... | Find the end of the word to the right the given position. If a
sequence of non-word characters precedes the first word, skip over
them. (This emulates the behavior of bash, emacs, etc.) | [
"Find",
"the",
"end",
"of",
"the",
"word",
"to",
"the",
"right",
"the",
"given",
"position",
".",
"If",
"a",
"sequence",
"of",
"non",
"-",
"word",
"characters",
"precedes",
"the",
"first",
"word",
"skip",
"over",
"them",
".",
"(",
"This",
"emulates",
"... | python | test | 45.1875 |
saltstack/salt | salt/proxy/esxcluster.py | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/proxy/esxcluster.py#L197-L257 | def init(opts):
'''
This function gets called when the proxy starts up. For
login
the protocol and port are cached.
'''
log.debug('Initting esxcluster proxy module in process %s', os.getpid())
log.debug('Validating esxcluster proxy input')
schema = EsxclusterProxySchema.serialize()
l... | [
"def",
"init",
"(",
"opts",
")",
":",
"log",
".",
"debug",
"(",
"'Initting esxcluster proxy module in process %s'",
",",
"os",
".",
"getpid",
"(",
")",
")",
"log",
".",
"debug",
"(",
"'Validating esxcluster proxy input'",
")",
"schema",
"=",
"EsxclusterProxySchema... | This function gets called when the proxy starts up. For
login
the protocol and port are cached. | [
"This",
"function",
"gets",
"called",
"when",
"the",
"proxy",
"starts",
"up",
".",
"For",
"login",
"the",
"protocol",
"and",
"port",
"are",
"cached",
"."
] | python | train | 39.721311 |
RudolfCardinal/pythonlib | cardinal_pythonlib/winservice.py | https://github.com/RudolfCardinal/pythonlib/blob/0b84cb35f38bd7d8723958dae51b480a829b7227/cardinal_pythonlib/winservice.py#L375-L383 | def fullname(self) -> str:
"""
Description of the process.
"""
fullname = "Process {}/{} ({})".format(self.procnum, self.nprocs,
self.details.name)
if self.running:
fullname += " (PID={})".format(self.process.pid)
... | [
"def",
"fullname",
"(",
"self",
")",
"->",
"str",
":",
"fullname",
"=",
"\"Process {}/{} ({})\"",
".",
"format",
"(",
"self",
".",
"procnum",
",",
"self",
".",
"nprocs",
",",
"self",
".",
"details",
".",
"name",
")",
"if",
"self",
".",
"running",
":",
... | Description of the process. | [
"Description",
"of",
"the",
"process",
"."
] | python | train | 36.444444 |
JoelBender/bacpypes | py25/bacpypes/appservice.py | https://github.com/JoelBender/bacpypes/blob/4111b8604a16fa2b7f80d8104a43b9f3e28dfc78/py25/bacpypes/appservice.py#L1194-L1302 | def confirmation(self, pdu):
"""Packets coming up the stack are APDU's."""
if _debug: StateMachineAccessPoint._debug("confirmation %r", pdu)
# check device communication control
if self.dccEnableDisable == 'enable':
if _debug: StateMachineAccessPoint._debug(" - communicat... | [
"def",
"confirmation",
"(",
"self",
",",
"pdu",
")",
":",
"if",
"_debug",
":",
"StateMachineAccessPoint",
".",
"_debug",
"(",
"\"confirmation %r\"",
",",
"pdu",
")",
"# check device communication control",
"if",
"self",
".",
"dccEnableDisable",
"==",
"'enable'",
"... | Packets coming up the stack are APDU's. | [
"Packets",
"coming",
"up",
"the",
"stack",
"are",
"APDU",
"s",
"."
] | python | train | 39.091743 |
ronhanson/python-tbx | tbx/text.py | https://github.com/ronhanson/python-tbx/blob/87f72ae0cadecafbcd144f1e930181fba77f6b83/tbx/text.py#L158-L169 | def seconds_to_hms_verbose(t):
"""
Converts seconds float to 'H hours 8 minutes, 30 seconds' format
"""
hours = int((t / 3600))
mins = int((t / 60) % 60)
secs = int(t % 60)
return ' '.join([
(hours + ' hour' + ('s' if hours > 1 else '')) if hours > 0 else '',
(mins + ' minute... | [
"def",
"seconds_to_hms_verbose",
"(",
"t",
")",
":",
"hours",
"=",
"int",
"(",
"(",
"t",
"/",
"3600",
")",
")",
"mins",
"=",
"int",
"(",
"(",
"t",
"/",
"60",
")",
"%",
"60",
")",
"secs",
"=",
"int",
"(",
"t",
"%",
"60",
")",
"return",
"' '",
... | Converts seconds float to 'H hours 8 minutes, 30 seconds' format | [
"Converts",
"seconds",
"float",
"to",
"H",
"hours",
"8",
"minutes",
"30",
"seconds",
"format"
] | python | train | 36.833333 |
epio/mantrid | mantrid/actions.py | https://github.com/epio/mantrid/blob/1c699f1a4b33888b533c19cb6d025173f2160576/mantrid/actions.py#L178-L189 | def handle(self, sock, read_data, path, headers):
"Just waits, and checks for other actions to replace us"
for i in range(self.timeout // self.check_interval):
# Sleep first
eventlet.sleep(self.check_interval)
# Check for another action
action = self.balan... | [
"def",
"handle",
"(",
"self",
",",
"sock",
",",
"read_data",
",",
"path",
",",
"headers",
")",
":",
"for",
"i",
"in",
"range",
"(",
"self",
".",
"timeout",
"//",
"self",
".",
"check_interval",
")",
":",
"# Sleep first",
"eventlet",
".",
"sleep",
"(",
... | Just waits, and checks for other actions to replace us | [
"Just",
"waits",
"and",
"checks",
"for",
"other",
"actions",
"to",
"replace",
"us"
] | python | train | 53.333333 |
apache/spark | python/pyspark/sql/functions.py | https://github.com/apache/spark/blob/618d6bff71073c8c93501ab7392c3cc579730f0b/python/pyspark/sql/functions.py#L565-L575 | def nanvl(col1, col2):
"""Returns col1 if it is not NaN, or col2 if col1 is NaN.
Both inputs should be floating point columns (:class:`DoubleType` or :class:`FloatType`).
>>> df = spark.createDataFrame([(1.0, float('nan')), (float('nan'), 2.0)], ("a", "b"))
>>> df.select(nanvl("a", "b").alias("r1"), n... | [
"def",
"nanvl",
"(",
"col1",
",",
"col2",
")",
":",
"sc",
"=",
"SparkContext",
".",
"_active_spark_context",
"return",
"Column",
"(",
"sc",
".",
"_jvm",
".",
"functions",
".",
"nanvl",
"(",
"_to_java_column",
"(",
"col1",
")",
",",
"_to_java_column",
"(",
... | Returns col1 if it is not NaN, or col2 if col1 is NaN.
Both inputs should be floating point columns (:class:`DoubleType` or :class:`FloatType`).
>>> df = spark.createDataFrame([(1.0, float('nan')), (float('nan'), 2.0)], ("a", "b"))
>>> df.select(nanvl("a", "b").alias("r1"), nanvl(df.a, df.b).alias("r2")).... | [
"Returns",
"col1",
"if",
"it",
"is",
"not",
"NaN",
"or",
"col2",
"if",
"col1",
"is",
"NaN",
"."
] | python | train | 48.818182 |
supercoderz/pyflightdata | pyflightdata/flightdata.py | https://github.com/supercoderz/pyflightdata/blob/2caf9f429288f9a171893d1b8377d0c6244541cc/pyflightdata/flightdata.py#L135-L160 | def get_info_by_tail_number(self, tail_number, page=1, limit=100):
"""Fetch the details of a particular aircraft by its tail number.
This method can be used to get the details of a particular aircraft by its tail number.
Details include the serial number, age etc along with links to the images ... | [
"def",
"get_info_by_tail_number",
"(",
"self",
",",
"tail_number",
",",
"page",
"=",
"1",
",",
"limit",
"=",
"100",
")",
":",
"url",
"=",
"REG_BASE",
".",
"format",
"(",
"tail_number",
",",
"str",
"(",
"self",
".",
"AUTH_TOKEN",
")",
",",
"page",
",",
... | Fetch the details of a particular aircraft by its tail number.
This method can be used to get the details of a particular aircraft by its tail number.
Details include the serial number, age etc along with links to the images of the aircraft.
It checks the user authentication and returns the dat... | [
"Fetch",
"the",
"details",
"of",
"a",
"particular",
"aircraft",
"by",
"its",
"tail",
"number",
"."
] | python | train | 46.423077 |
awslabs/sockeye | sockeye/inference.py | https://github.com/awslabs/sockeye/blob/5d64a1ee1ef3cbba17c6d1d94bc061020c43f6ab/sockeye/inference.py#L1210-L1225 | def _expand_nbest_translation(translation: Translation) -> List[Translation]:
"""
Expand nbest translations in a single Translation object to one Translation
object per nbest translation.
:param translation: A Translation object.
:return: A list of Translation objects.
"""
nbest_list = ... | [
"def",
"_expand_nbest_translation",
"(",
"translation",
":",
"Translation",
")",
"->",
"List",
"[",
"Translation",
"]",
":",
"nbest_list",
"=",
"[",
"]",
"# type = List[Translation]",
"for",
"target_ids",
",",
"attention_matrix",
",",
"score",
"in",
"zip",
"(",
... | Expand nbest translations in a single Translation object to one Translation
object per nbest translation.
:param translation: A Translation object.
:return: A list of Translation objects. | [
"Expand",
"nbest",
"translations",
"in",
"a",
"single",
"Translation",
"object",
"to",
"one",
"Translation",
"object",
"per",
"nbest",
"translation",
"."
] | python | train | 53.6875 |
tensorflow/cleverhans | cleverhans/utils.py | https://github.com/tensorflow/cleverhans/blob/97488e215760547b81afc53f5e5de8ba7da5bd98/cleverhans/utils.py#L247-L262 | def create_logger(name):
"""
Create a logger object with the given name.
If this is the first time that we call this method, then initialize the
formatter.
"""
base = logging.getLogger("cleverhans")
if len(base.handlers) == 0:
ch = logging.StreamHandler()
formatter = logging.Formatter('[%(levelna... | [
"def",
"create_logger",
"(",
"name",
")",
":",
"base",
"=",
"logging",
".",
"getLogger",
"(",
"\"cleverhans\"",
")",
"if",
"len",
"(",
"base",
".",
"handlers",
")",
"==",
"0",
":",
"ch",
"=",
"logging",
".",
"StreamHandler",
"(",
")",
"formatter",
"=",... | Create a logger object with the given name.
If this is the first time that we call this method, then initialize the
formatter. | [
"Create",
"a",
"logger",
"object",
"with",
"the",
"given",
"name",
"."
] | python | train | 28.375 |
senaite/senaite.core | bika/lims/browser/analyses/view.py | https://github.com/senaite/senaite.core/blob/7602ce2ea2f9e81eb34e20ce17b98a3e70713f85/bika/lims/browser/analyses/view.py#L923-L946 | def _folder_item_uncertainty(self, analysis_brain, item):
"""Fills the analysis' uncertainty to the item passed in.
:param analysis_brain: Brain that represents an analysis
:param item: analysis' dictionary counterpart that represents a row
"""
item["Uncertainty"] = ""
... | [
"def",
"_folder_item_uncertainty",
"(",
"self",
",",
"analysis_brain",
",",
"item",
")",
":",
"item",
"[",
"\"Uncertainty\"",
"]",
"=",
"\"\"",
"if",
"not",
"self",
".",
"has_permission",
"(",
"ViewResults",
",",
"analysis_brain",
")",
":",
"return",
"result",... | Fills the analysis' uncertainty to the item passed in.
:param analysis_brain: Brain that represents an analysis
:param item: analysis' dictionary counterpart that represents a row | [
"Fills",
"the",
"analysis",
"uncertainty",
"to",
"the",
"item",
"passed",
"in",
"."
] | python | train | 35.958333 |
IdentityPython/pysaml2 | src/saml2/mdstore.py | https://github.com/IdentityPython/pysaml2/blob/d3aa78eeb7d37c12688f783cb4db1c7263a14ad6/src/saml2/mdstore.py#L747-L758 | def load(self, *args, **kwargs):
""" Imports metadata by the use of HTTP GET.
If the fingerprint is known the file will be checked for
compliance before it is imported.
"""
response = self.http.send(self.url)
if response.status_code == 200:
_txt = response.con... | [
"def",
"load",
"(",
"self",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"response",
"=",
"self",
".",
"http",
".",
"send",
"(",
"self",
".",
"url",
")",
"if",
"response",
".",
"status_code",
"==",
"200",
":",
"_txt",
"=",
"response",
"."... | Imports metadata by the use of HTTP GET.
If the fingerprint is known the file will be checked for
compliance before it is imported. | [
"Imports",
"metadata",
"by",
"the",
"use",
"of",
"HTTP",
"GET",
".",
"If",
"the",
"fingerprint",
"is",
"known",
"the",
"file",
"will",
"be",
"checked",
"for",
"compliance",
"before",
"it",
"is",
"imported",
"."
] | python | train | 41.25 |
saltstack/salt | salt/utils/smb.py | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/smb.py#L150-L157 | def string(self, writesize=None):
'''
Looks like a file handle
'''
if not self.finished:
self.finished = True
return self.content
return '' | [
"def",
"string",
"(",
"self",
",",
"writesize",
"=",
"None",
")",
":",
"if",
"not",
"self",
".",
"finished",
":",
"self",
".",
"finished",
"=",
"True",
"return",
"self",
".",
"content",
"return",
"''"
] | Looks like a file handle | [
"Looks",
"like",
"a",
"file",
"handle"
] | python | train | 24.5 |
insightindustry/validator-collection | validator_collection/checkers.py | https://github.com/insightindustry/validator-collection/blob/8c8047a0fa36cc88a021771279898278c4cc98e3/validator_collection/checkers.py#L89-L148 | def are_equivalent(*args, **kwargs):
"""Indicate if arguments passed to this function are equivalent.
.. hint::
This checker operates recursively on the members contained within iterables
and :class:`dict <python:dict>` objects.
.. caution::
If you only pass one argument to this checke... | [
"def",
"are_equivalent",
"(",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"len",
"(",
"args",
")",
"==",
"1",
":",
"return",
"True",
"first_item",
"=",
"args",
"[",
"0",
"]",
"for",
"item",
"in",
"args",
"[",
"1",
":",
"]",
":",
"if",... | Indicate if arguments passed to this function are equivalent.
.. hint::
This checker operates recursively on the members contained within iterables
and :class:`dict <python:dict>` objects.
.. caution::
If you only pass one argument to this checker - even if it is an iterable -
the ch... | [
"Indicate",
"if",
"arguments",
"passed",
"to",
"this",
"function",
"are",
"equivalent",
"."
] | python | train | 31.45 |
ankitmathur3193/song-cli | song/commands/MusicWebsiteParser/MrJattParser.py | https://github.com/ankitmathur3193/song-cli/blob/ca8ccfe547e9d702313ff6d14e81ae4355989a67/song/commands/MusicWebsiteParser/MrJattParser.py#L47-L76 | def check_if_song_name(self,html):
'''
Returns true if user entered artist or movie name
'''
soup=BeautifulSoup(html)
a_list=soup.findAll('a','touch')
#print a_list
text=[str(x) for x in a_list]
text=''.join(text)
text=text.lower()
string1='download in 48 kbps'
string2='download in 128 kbps'
str... | [
"def",
"check_if_song_name",
"(",
"self",
",",
"html",
")",
":",
"soup",
"=",
"BeautifulSoup",
"(",
"html",
")",
"a_list",
"=",
"soup",
".",
"findAll",
"(",
"'a'",
",",
"'touch'",
")",
"#print a_list",
"text",
"=",
"[",
"str",
"(",
"x",
")",
"for",
"... | Returns true if user entered artist or movie name | [
"Returns",
"true",
"if",
"user",
"entered",
"artist",
"or",
"movie",
"name"
] | python | test | 22.166667 |
herrjemand/flask-fido-u2f | flask_fido_u2f.py | https://github.com/herrjemand/flask-fido-u2f/blob/23acac4cfe285a33411e8a6bf980b3c345b04feb/flask_fido_u2f.py#L247-L255 | def get_enroll(self):
"""Returns new enroll seed"""
devices = [DeviceRegistration.wrap(device) for device in self.__get_u2f_devices()]
enroll = start_register(self.__appid, devices)
enroll['status'] = 'ok'
session['_u2f_enroll_'] = enroll.json
return enroll | [
"def",
"get_enroll",
"(",
"self",
")",
":",
"devices",
"=",
"[",
"DeviceRegistration",
".",
"wrap",
"(",
"device",
")",
"for",
"device",
"in",
"self",
".",
"__get_u2f_devices",
"(",
")",
"]",
"enroll",
"=",
"start_register",
"(",
"self",
".",
"__appid",
... | Returns new enroll seed | [
"Returns",
"new",
"enroll",
"seed"
] | python | train | 33.333333 |
MacHu-GWU/uszipcode-project | uszipcode/pkg/sqlalchemy_mate/engine_creator.py | https://github.com/MacHu-GWU/uszipcode-project/blob/96282b779a3efb422802de83c48ca284598ba952/uszipcode/pkg/sqlalchemy_mate/engine_creator.py#L210-L217 | def create_mysql_oursql(username, password, host, port, database, **kwargs): # pragma: no cover
"""
create an engine connected to a mysql database using oursql.
"""
return create_engine(
_create_mysql_oursql(username, password, host, port, database),
**kwargs
) | [
"def",
"create_mysql_oursql",
"(",
"username",
",",
"password",
",",
"host",
",",
"port",
",",
"database",
",",
"*",
"*",
"kwargs",
")",
":",
"# pragma: no cover",
"return",
"create_engine",
"(",
"_create_mysql_oursql",
"(",
"username",
",",
"password",
",",
"... | create an engine connected to a mysql database using oursql. | [
"create",
"an",
"engine",
"connected",
"to",
"a",
"mysql",
"database",
"using",
"oursql",
"."
] | python | train | 36.375 |
samuelcolvin/pydantic | pydantic/schema.py | https://github.com/samuelcolvin/pydantic/blob/bff8a1789dfde2c38928cced6640887b53615aa3/pydantic/schema.py#L216-L268 | def field_schema(
field: Field,
*,
by_alias: bool = True,
model_name_map: Dict[Type['main.BaseModel'], str],
ref_prefix: Optional[str] = None,
) -> Tuple[Dict[str, Any], Dict[str, Any]]:
"""
Process a Pydantic field and return a tuple with a JSON Schema for it as the first item.
Also ret... | [
"def",
"field_schema",
"(",
"field",
":",
"Field",
",",
"*",
",",
"by_alias",
":",
"bool",
"=",
"True",
",",
"model_name_map",
":",
"Dict",
"[",
"Type",
"[",
"'main.BaseModel'",
"]",
",",
"str",
"]",
",",
"ref_prefix",
":",
"Optional",
"[",
"str",
"]",... | Process a Pydantic field and return a tuple with a JSON Schema for it as the first item.
Also return a dictionary of definitions with models as keys and their schemas as values. If the passed field
is a model and has sub-models, and those sub-models don't have overrides (as ``title``, ``default``, etc), they
... | [
"Process",
"a",
"Pydantic",
"field",
"and",
"return",
"a",
"tuple",
"with",
"a",
"JSON",
"Schema",
"for",
"it",
"as",
"the",
"first",
"item",
".",
"Also",
"return",
"a",
"dictionary",
"of",
"definitions",
"with",
"models",
"as",
"keys",
"and",
"their",
"... | python | train | 39.396226 |
Yelp/kafka-utils | kafka_utils/kafka_consumer_manager/commands/offset_save.py | https://github.com/Yelp/kafka-utils/blob/cdb4d64308f3079ee0873250bf7b34d0d94eca50/kafka_utils/kafka_consumer_manager/commands/offset_save.py#L142-L151 | def write_offsets_to_file(cls, json_file_name, consumer_offsets_data):
"""Save built consumer-offsets data to given json file."""
# Save consumer-offsets to file
with open(json_file_name, "w") as json_file:
try:
json.dump(consumer_offsets_data, json_file)
... | [
"def",
"write_offsets_to_file",
"(",
"cls",
",",
"json_file_name",
",",
"consumer_offsets_data",
")",
":",
"# Save consumer-offsets to file",
"with",
"open",
"(",
"json_file_name",
",",
"\"w\"",
")",
"as",
"json_file",
":",
"try",
":",
"json",
".",
"dump",
"(",
... | Save built consumer-offsets data to given json file. | [
"Save",
"built",
"consumer",
"-",
"offsets",
"data",
"to",
"given",
"json",
"file",
"."
] | python | train | 53.9 |
waqasbhatti/astrobase | astrobase/fakelcs/recovery.py | https://github.com/waqasbhatti/astrobase/blob/2922a14619d183fb28005fa7d02027ac436f2265/astrobase/fakelcs/recovery.py#L1454-L1574 | def run_periodfinding(simbasedir,
pfmethods=('gls','pdm','bls'),
pfkwargs=({},{},{'startp':1.0,'maxtransitduration':0.3}),
getblssnr=False,
sigclip=5.0,
nperiodworkers=10,
ncontrolworkers=... | [
"def",
"run_periodfinding",
"(",
"simbasedir",
",",
"pfmethods",
"=",
"(",
"'gls'",
",",
"'pdm'",
",",
"'bls'",
")",
",",
"pfkwargs",
"=",
"(",
"{",
"}",
",",
"{",
"}",
",",
"{",
"'startp'",
":",
"1.0",
",",
"'maxtransitduration'",
":",
"0.3",
"}",
"... | This runs periodfinding using several period-finders on a collection of
fake LCs.
As a rough benchmark, 25000 fake LCs with 10000--50000 points per LC take
about 26 days in total to run on an invocation of this function using
GLS+PDM+BLS and 10 periodworkers and 4 controlworkers (so all 40 'cores') on
... | [
"This",
"runs",
"periodfinding",
"using",
"several",
"period",
"-",
"finders",
"on",
"a",
"collection",
"of",
"fake",
"LCs",
"."
] | python | valid | 38.801653 |
yougov/pmxbot | pmxbot/commands.py | https://github.com/yougov/pmxbot/blob/5da84a3258a0fd73cb35b60e39769a5d7bfb2ba7/pmxbot/commands.py#L847-L852 | def version(rest):
"Get the version of pmxbot or one of its plugins"
pkg = rest.strip() or 'pmxbot'
if pkg.lower() == 'python':
return sys.version.split()[0]
return importlib_metadata.version(pkg) | [
"def",
"version",
"(",
"rest",
")",
":",
"pkg",
"=",
"rest",
".",
"strip",
"(",
")",
"or",
"'pmxbot'",
"if",
"pkg",
".",
"lower",
"(",
")",
"==",
"'python'",
":",
"return",
"sys",
".",
"version",
".",
"split",
"(",
")",
"[",
"0",
"]",
"return",
... | Get the version of pmxbot or one of its plugins | [
"Get",
"the",
"version",
"of",
"pmxbot",
"or",
"one",
"of",
"its",
"plugins"
] | python | train | 32.833333 |
letuananh/chirptext | chirptext/deko.py | https://github.com/letuananh/chirptext/blob/ce60b47257b272a587c8703ea1f86cd1a45553a7/chirptext/deko.py#L113-L120 | def pos3(self):
''' Use pos-sc1-sc2 as POS '''
parts = [self.pos]
if self.sc1 and self.sc1 != '*':
parts.append(self.sc1)
if self.sc2 and self.sc2 != '*':
parts.append(self.sc2)
return '-'.join(parts) | [
"def",
"pos3",
"(",
"self",
")",
":",
"parts",
"=",
"[",
"self",
".",
"pos",
"]",
"if",
"self",
".",
"sc1",
"and",
"self",
".",
"sc1",
"!=",
"'*'",
":",
"parts",
".",
"append",
"(",
"self",
".",
"sc1",
")",
"if",
"self",
".",
"sc2",
"and",
"s... | Use pos-sc1-sc2 as POS | [
"Use",
"pos",
"-",
"sc1",
"-",
"sc2",
"as",
"POS"
] | python | train | 33.125 |
open-homeautomation/pknx | knxip/gatewayscanner.py | https://github.com/open-homeautomation/pknx/blob/a8aed8271563923c447aa330ba7c1c2927286f7a/knxip/gatewayscanner.py#L69-L116 | def start_search(self):
"""
Start the Gateway Search Request and return the address information
:rtype: (string,int)
:return: a tuple(string(IP),int(Port) when found or None when
timeout occurs
"""
self._asyncio_loop = asyncio.get_event_loop()
# Cre... | [
"def",
"start_search",
"(",
"self",
")",
":",
"self",
".",
"_asyncio_loop",
"=",
"asyncio",
".",
"get_event_loop",
"(",
")",
"# Creating Broadcast Receiver",
"coroutine_listen",
"=",
"self",
".",
"_asyncio_loop",
".",
"create_datagram_endpoint",
"(",
"lambda",
":",
... | Start the Gateway Search Request and return the address information
:rtype: (string,int)
:return: a tuple(string(IP),int(Port) when found or None when
timeout occurs | [
"Start",
"the",
"Gateway",
"Search",
"Request",
"and",
"return",
"the",
"address",
"information"
] | python | train | 39.229167 |
sci-bots/svg-model | svg_model/__init__.py | https://github.com/sci-bots/svg-model/blob/2d119650f995e62b29ce0b3151a23f3b957cb072/svg_model/__init__.py#L260-L304 | def scale_points(df_points, scale=INKSCAPE_PPmm.magnitude, inplace=False):
'''
Translate points such that bounding box is anchored at (0, 0) and scale
``x`` and ``y`` columns of input frame by specified :data:`scale`.
Parameters
----------
df_points : pandas.DataFrame
Table of ``x``/``y... | [
"def",
"scale_points",
"(",
"df_points",
",",
"scale",
"=",
"INKSCAPE_PPmm",
".",
"magnitude",
",",
"inplace",
"=",
"False",
")",
":",
"if",
"not",
"inplace",
":",
"df_points",
"=",
"df_points",
".",
"copy",
"(",
")",
"# Offset device, such that all coordinates ... | Translate points such that bounding box is anchored at (0, 0) and scale
``x`` and ``y`` columns of input frame by specified :data:`scale`.
Parameters
----------
df_points : pandas.DataFrame
Table of ``x``/``y`` point positions.
Must have at least the following columns:
- ``x``... | [
"Translate",
"points",
"such",
"that",
"bounding",
"box",
"is",
"anchored",
"at",
"(",
"0",
"0",
")",
"and",
"scale",
"x",
"and",
"y",
"columns",
"of",
"input",
"frame",
"by",
"specified",
":",
"data",
":",
"scale",
"."
] | python | train | 29.777778 |
mar10/wsgidav | wsgidav/util.py | https://github.com/mar10/wsgidav/blob/cec0d84222fc24bea01be1cea91729001963f172/wsgidav/util.py#L1103-L1185 | def evaluate_http_conditionals(dav_res, last_modified, entitytag, environ):
"""Handle 'If-...:' headers (but not 'If:' header).
If-Match
@see: http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.24
Only perform the action if the client supplied entity matches the
same entity on... | [
"def",
"evaluate_http_conditionals",
"(",
"dav_res",
",",
"last_modified",
",",
"entitytag",
",",
"environ",
")",
":",
"if",
"not",
"dav_res",
":",
"return",
"# Conditions",
"# An HTTP/1.1 origin server, upon receiving a conditional request that includes both a",
"# Last-Modifi... | Handle 'If-...:' headers (but not 'If:' header).
If-Match
@see: http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.24
Only perform the action if the client supplied entity matches the
same entity on the server. This is mainly for methods like
PUT to only update a resource ... | [
"Handle",
"If",
"-",
"...",
":",
"headers",
"(",
"but",
"not",
"If",
":",
"header",
")",
"."
] | python | valid | 48.951807 |
SwissDataScienceCenter/renku-python | renku/api/datasets.py | https://github.com/SwissDataScienceCenter/renku-python/blob/691644d695b055a01e0ca22b2620e55bbd928c0d/renku/api/datasets.py#L443-L458 | def check_for_git_repo(url):
"""Check if a url points to a git repository."""
u = parse.urlparse(url)
is_git = False
if os.path.splitext(u.path)[1] == '.git':
is_git = True
elif u.scheme in ('', 'file'):
from git import InvalidGitRepositoryError, Repo
try:
Repo(... | [
"def",
"check_for_git_repo",
"(",
"url",
")",
":",
"u",
"=",
"parse",
".",
"urlparse",
"(",
"url",
")",
"is_git",
"=",
"False",
"if",
"os",
".",
"path",
".",
"splitext",
"(",
"u",
".",
"path",
")",
"[",
"1",
"]",
"==",
"'.git'",
":",
"is_git",
"=... | Check if a url points to a git repository. | [
"Check",
"if",
"a",
"url",
"points",
"to",
"a",
"git",
"repository",
"."
] | python | train | 28.5625 |
lingthio/Flask-User | flask_user/db_adapters/dynamo_db_adapter.py | https://github.com/lingthio/Flask-User/blob/a379fa0a281789618c484b459cb41236779b95b1/flask_user/db_adapters/dynamo_db_adapter.py#L52-L71 | def find_objects(self, ObjectClass, **kwargs):
""" Retrieve all objects of type ``ObjectClass``,
matching the filters specified in ``**kwargs`` -- case sensitive.
"""
print('dynamo.find_objects(%s, %s)' % (ObjectClass, str(kwargs)))
query = self.db.engine.query(ObjectClass)
... | [
"def",
"find_objects",
"(",
"self",
",",
"ObjectClass",
",",
"*",
"*",
"kwargs",
")",
":",
"print",
"(",
"'dynamo.find_objects(%s, %s)'",
"%",
"(",
"ObjectClass",
",",
"str",
"(",
"kwargs",
")",
")",
")",
"query",
"=",
"self",
".",
"db",
".",
"engine",
... | Retrieve all objects of type ``ObjectClass``,
matching the filters specified in ``**kwargs`` -- case sensitive. | [
"Retrieve",
"all",
"objects",
"of",
"type",
"ObjectClass",
"matching",
"the",
"filters",
"specified",
"in",
"**",
"kwargs",
"--",
"case",
"sensitive",
"."
] | python | train | 40.35 |
scivision/pymap3d | pymap3d/ecef.py | https://github.com/scivision/pymap3d/blob/c9cf676594611cdb52ff7e0eca6388c80ed4f63f/pymap3d/ecef.py#L351-L381 | def uvw2enu(u: float, v: float, w: float,
lat0: float, lon0: float, deg: bool = True) -> Tuple[float, float, float]:
"""
Parameters
----------
u : float or numpy.ndarray of float
v : float or numpy.ndarray of float
w : float or numpy.ndarray of float
Results
-------
E... | [
"def",
"uvw2enu",
"(",
"u",
":",
"float",
",",
"v",
":",
"float",
",",
"w",
":",
"float",
",",
"lat0",
":",
"float",
",",
"lon0",
":",
"float",
",",
"deg",
":",
"bool",
"=",
"True",
")",
"->",
"Tuple",
"[",
"float",
",",
"float",
",",
"float",
... | Parameters
----------
u : float or numpy.ndarray of float
v : float or numpy.ndarray of float
w : float or numpy.ndarray of float
Results
-------
East : float or numpy.ndarray of float
target east ENU coordinate (meters)
North : float or numpy.ndarray of float
target ... | [
"Parameters",
"----------"
] | python | train | 26.193548 |
mrcagney/gtfstk | gtfstk/validators.py | https://github.com/mrcagney/gtfstk/blob/c91494e6fefc02523889655a0dc92d1c0eee8d03/gtfstk/validators.py#L230-L282 | def check_table(
problems: List,
table: str,
df: DataFrame,
condition,
message: str,
type_: str = "error",
) -> List:
"""
Check the given GTFS table for the given problem condition.
Parameters
----------
problems : list
A four-tuple containing
1. A problem t... | [
"def",
"check_table",
"(",
"problems",
":",
"List",
",",
"table",
":",
"str",
",",
"df",
":",
"DataFrame",
",",
"condition",
",",
"message",
":",
"str",
",",
"type_",
":",
"str",
"=",
"\"error\"",
",",
")",
"->",
"List",
":",
"indices",
"=",
"df",
... | Check the given GTFS table for the given problem condition.
Parameters
----------
problems : list
A four-tuple containing
1. A problem type (string) equal to ``'error'`` or ``'warning'``;
``'error'`` means the GTFS is violated;
``'warning'`` means there is a problem b... | [
"Check",
"the",
"given",
"GTFS",
"table",
"for",
"the",
"given",
"problem",
"condition",
"."
] | python | train | 29.716981 |
mwouts/jupytext | jupytext/jupytext.py | https://github.com/mwouts/jupytext/blob/eb7d6aee889f80ad779cfc53441c648f0db9246d/jupytext/jupytext.py#L45-L90 | def reads(self, s, **_):
"""Read a notebook represented as text"""
if self.fmt.get('format_name') == 'pandoc':
return md_to_notebook(s)
lines = s.splitlines()
cells = []
metadata, jupyter_md, header_cell, pos = header_to_metadata_and_cell(lines,
... | [
"def",
"reads",
"(",
"self",
",",
"s",
",",
"*",
"*",
"_",
")",
":",
"if",
"self",
".",
"fmt",
".",
"get",
"(",
"'format_name'",
")",
"==",
"'pandoc'",
":",
"return",
"md_to_notebook",
"(",
"s",
")",
"lines",
"=",
"s",
".",
"splitlines",
"(",
")"... | Read a notebook represented as text | [
"Read",
"a",
"notebook",
"represented",
"as",
"text"
] | python | train | 43.521739 |
crytic/slither | slither/slither.py | https://github.com/crytic/slither/blob/04c147f7e50223c6af458ca430befae747ccd259/slither/slither.py#L138-L145 | def register_printer(self, printer_class):
"""
:param printer_class: Class inheriting from `AbstractPrinter`.
"""
self._check_common_things('printer', printer_class, AbstractPrinter, self._printers)
instance = printer_class(self, logger_printer)
self._printers.append(ins... | [
"def",
"register_printer",
"(",
"self",
",",
"printer_class",
")",
":",
"self",
".",
"_check_common_things",
"(",
"'printer'",
",",
"printer_class",
",",
"AbstractPrinter",
",",
"self",
".",
"_printers",
")",
"instance",
"=",
"printer_class",
"(",
"self",
",",
... | :param printer_class: Class inheriting from `AbstractPrinter`. | [
":",
"param",
"printer_class",
":",
"Class",
"inheriting",
"from",
"AbstractPrinter",
"."
] | python | train | 39.875 |
mosesschwartz/scrypture | scrypture/scrypture.py | https://github.com/mosesschwartz/scrypture/blob/d51eb0c9835a5122a655078268185ce8ab9ec86a/scrypture/scrypture.py#L350-L377 | def load_scripts():
'''Import all of the modules named in REGISTERED_SCRIPTS'''
# Add scrypture package package to the path before importing
# so everything can import everything else regardless of package
scrypture_dir = os.path.realpath(
os.path.abspath(
... | [
"def",
"load_scripts",
"(",
")",
":",
"# Add scrypture package package to the path before importing",
"# so everything can import everything else regardless of package",
"scrypture_dir",
"=",
"os",
".",
"path",
".",
"realpath",
"(",
"os",
".",
"path",
".",
"abspath",
"(",
"... | Import all of the modules named in REGISTERED_SCRIPTS | [
"Import",
"all",
"of",
"the",
"modules",
"named",
"in",
"REGISTERED_SCRIPTS"
] | python | train | 40.785714 |
bububa/pyTOP | pyTOP/simba.py | https://github.com/bububa/pyTOP/blob/1e48009bcfe886be392628244b370e6374e1f2b2/pyTOP/simba.py#L140-L149 | def update(self, campaign_id, schedule, nick=None):
'''xxxxx.xxxxx.campaign.schedule.update
===================================
更新一个推广计划的分时折扣设置'''
request = TOPRequest('xxxxx.xxxxx.campaign.schedule.update')
request['campaign_id'] = campaign_id
request['schedule'] = sched... | [
"def",
"update",
"(",
"self",
",",
"campaign_id",
",",
"schedule",
",",
"nick",
"=",
"None",
")",
":",
"request",
"=",
"TOPRequest",
"(",
"'xxxxx.xxxxx.campaign.schedule.update'",
")",
"request",
"[",
"'campaign_id'",
"]",
"=",
"campaign_id",
"request",
"[",
"... | xxxxx.xxxxx.campaign.schedule.update
===================================
更新一个推广计划的分时折扣设置 | [
"xxxxx",
".",
"xxxxx",
".",
"campaign",
".",
"schedule",
".",
"update",
"===================================",
"更新一个推广计划的分时折扣设置"
] | python | train | 53.6 |
brainiak/brainiak | brainiak/utils/utils.py | https://github.com/brainiak/brainiak/blob/408f12dec2ff56559a26873a848a09e4c8facfeb/brainiak/utils/utils.py#L72-L92 | def from_sym_2_tri(symm):
"""convert a 2D symmetric matrix to an upper
triangular matrix in 1D format
Parameters
----------
symm : 2D array
Symmetric matrix
Returns
-------
tri: 1D array
Contains elements of upper triangular matrix
"""
inds = np.triu_... | [
"def",
"from_sym_2_tri",
"(",
"symm",
")",
":",
"inds",
"=",
"np",
".",
"triu_indices_from",
"(",
"symm",
")",
"tri",
"=",
"symm",
"[",
"inds",
"]",
"return",
"tri"
] | convert a 2D symmetric matrix to an upper
triangular matrix in 1D format
Parameters
----------
symm : 2D array
Symmetric matrix
Returns
-------
tri: 1D array
Contains elements of upper triangular matrix | [
"convert",
"a",
"2D",
"symmetric",
"matrix",
"to",
"an",
"upper",
"triangular",
"matrix",
"in",
"1D",
"format"
] | python | train | 16.857143 |
horejsek/python-webdriverwrapper | webdriverwrapper/info.py | https://github.com/horejsek/python-webdriverwrapper/blob/a492f79ab60ed83d860dd817b6a0961500d7e3f5/webdriverwrapper/info.py#L27-L39 | def allowed_info_messages(*info_messages):
"""
Decorator ignoring defined info messages at the end of test method. As
param use what
:py:meth:`~.WebdriverWrapperInfoMixin.get_info_messages`
returns.
.. versionadded:: 2.0
"""
def wrapper(func):
setattr(func, ALLOWED_INFO_MESSAGES... | [
"def",
"allowed_info_messages",
"(",
"*",
"info_messages",
")",
":",
"def",
"wrapper",
"(",
"func",
")",
":",
"setattr",
"(",
"func",
",",
"ALLOWED_INFO_MESSAGES",
",",
"info_messages",
")",
"return",
"func",
"return",
"wrapper"
] | Decorator ignoring defined info messages at the end of test method. As
param use what
:py:meth:`~.WebdriverWrapperInfoMixin.get_info_messages`
returns.
.. versionadded:: 2.0 | [
"Decorator",
"ignoring",
"defined",
"info",
"messages",
"at",
"the",
"end",
"of",
"test",
"method",
".",
"As",
"param",
"use",
"what",
":",
"py",
":",
"meth",
":",
"~",
".",
"WebdriverWrapperInfoMixin",
".",
"get_info_messages",
"returns",
"."
] | python | train | 27.923077 |
StackStorm/pybind | pybind/nos/v7_2_0/rbridge_id/vrf/address_family/ipv6/unicast/__init__.py | https://github.com/StackStorm/pybind/blob/44c467e71b2b425be63867aba6e6fa28b2cfe7fb/pybind/nos/v7_2_0/rbridge_id/vrf/address_family/ipv6/unicast/__init__.py#L136-L157 | def _set_route_target(self, v, load=False):
"""
Setter method for route_target, mapped from YANG variable /rbridge_id/vrf/address_family/ipv6/unicast/route_target (list)
If this variable is read-only (config: false) in the
source YANG file, then _set_route_target is considered as a private
method. B... | [
"def",
"_set_route_target",
"(",
"self",
",",
"v",
",",
"load",
"=",
"False",
")",
":",
"if",
"hasattr",
"(",
"v",
",",
"\"_utype\"",
")",
":",
"v",
"=",
"v",
".",
"_utype",
"(",
"v",
")",
"try",
":",
"t",
"=",
"YANGDynClass",
"(",
"v",
",",
"b... | Setter method for route_target, mapped from YANG variable /rbridge_id/vrf/address_family/ipv6/unicast/route_target (list)
If this variable is read-only (config: false) in the
source YANG file, then _set_route_target is considered as a private
method. Backends looking to populate this variable should
do ... | [
"Setter",
"method",
"for",
"route_target",
"mapped",
"from",
"YANG",
"variable",
"/",
"rbridge_id",
"/",
"vrf",
"/",
"address_family",
"/",
"ipv6",
"/",
"unicast",
"/",
"route_target",
"(",
"list",
")",
"If",
"this",
"variable",
"is",
"read",
"-",
"only",
... | python | train | 123.090909 |
ArduPilot/MAVProxy | MAVProxy/modules/mavproxy_devop.py | https://github.com/ArduPilot/MAVProxy/blob/f50bdeff33064876f7dc8dc4683d278ff47f75d5/MAVProxy/modules/mavproxy_devop.py#L16-L35 | def cmd_devop(self, args):
'''device operations'''
usage = "Usage: devop <read|write> <spi|i2c> name bus address"
if len(args) < 5:
print(usage)
return
if args[1] == 'spi':
bustype = mavutil.mavlink.DEVICE_OP_BUSTYPE_SPI
elif args[1] == 'i2c':... | [
"def",
"cmd_devop",
"(",
"self",
",",
"args",
")",
":",
"usage",
"=",
"\"Usage: devop <read|write> <spi|i2c> name bus address\"",
"if",
"len",
"(",
"args",
")",
"<",
"5",
":",
"print",
"(",
"usage",
")",
"return",
"if",
"args",
"[",
"1",
"]",
"==",
"'spi'"... | device operations | [
"device",
"operations"
] | python | train | 29.9 |
Chilipp/psyplot | psyplot/data.py | https://github.com/Chilipp/psyplot/blob/75a0a15a9a1dd018e79d2df270d56c4bf5f311d5/psyplot/data.py#L3312-L3356 | def rename(self, arr, new_name=True):
"""
Rename an array to find a name that isn't already in the list
Parameters
----------
arr: InteractiveBase
A :class:`InteractiveArray` or :class:`InteractiveList` instance
whose name shall be checked
new_nam... | [
"def",
"rename",
"(",
"self",
",",
"arr",
",",
"new_name",
"=",
"True",
")",
":",
"name_in_me",
"=",
"arr",
".",
"psy",
".",
"arr_name",
"in",
"self",
".",
"arr_names",
"if",
"not",
"name_in_me",
":",
"return",
"arr",
",",
"False",
"elif",
"name_in_me"... | Rename an array to find a name that isn't already in the list
Parameters
----------
arr: InteractiveBase
A :class:`InteractiveArray` or :class:`InteractiveList` instance
whose name shall be checked
new_name: bool or str
If False, and the ``arr_name`` ... | [
"Rename",
"an",
"array",
"to",
"find",
"a",
"name",
"that",
"isn",
"t",
"already",
"in",
"the",
"list"
] | python | train | 42.066667 |
thecynic/pylutron | pylutron/__init__.py | https://github.com/thecynic/pylutron/blob/4d9222c96ef7ac7ac458031c058ad93ec31cebbf/pylutron/__init__.py#L640-L644 | def handle_update(self, action, params):
"""Handle the specified action on this component."""
_LOGGER.debug('Keypad: "%s" Handling "%s" Action: %s Params: %s"' % (
self._keypad.name, self.name, action, params))
return False | [
"def",
"handle_update",
"(",
"self",
",",
"action",
",",
"params",
")",
":",
"_LOGGER",
".",
"debug",
"(",
"'Keypad: \"%s\" Handling \"%s\" Action: %s Params: %s\"'",
"%",
"(",
"self",
".",
"_keypad",
".",
"name",
",",
"self",
".",
"name",
",",
"action",
",",
... | Handle the specified action on this component. | [
"Handle",
"the",
"specified",
"action",
"on",
"this",
"component",
"."
] | python | train | 49.8 |
Iotic-Labs/py-IoticAgent | src/IoticAgent/IOT/ResourceMeta.py | https://github.com/Iotic-Labs/py-IoticAgent/blob/893e8582ad1dacfe32dfc0ee89452bbd6f57d28d/src/IoticAgent/IOT/ResourceMeta.py#L148-L165 | def set_label(self, label, lang=None):
"""Sets the `label` metadata property on your Thing/Point. Only one label is allowed per language, so any
other labels in this language are removed before adding this one
Raises `ValueError` containing an error message if the parameters fail validation
... | [
"def",
"set_label",
"(",
"self",
",",
"label",
",",
"lang",
"=",
"None",
")",
":",
"label",
"=",
"Validation",
".",
"label_check_convert",
"(",
"label",
")",
"lang",
"=",
"Validation",
".",
"lang_check_convert",
"(",
"lang",
",",
"default",
"=",
"self",
... | Sets the `label` metadata property on your Thing/Point. Only one label is allowed per language, so any
other labels in this language are removed before adding this one
Raises `ValueError` containing an error message if the parameters fail validation
`label` (mandatory) (string) the new text o... | [
"Sets",
"the",
"label",
"metadata",
"property",
"on",
"your",
"Thing",
"/",
"Point",
".",
"Only",
"one",
"label",
"is",
"allowed",
"per",
"language",
"so",
"any",
"other",
"labels",
"in",
"this",
"language",
"are",
"removed",
"before",
"adding",
"this",
"o... | python | train | 53.333333 |
cloud-custodian/cloud-custodian | tools/ops/mugc.py | https://github.com/cloud-custodian/cloud-custodian/blob/52ef732eb3d7bc939d1579faf519314814695c08/tools/ops/mugc.py#L113-L129 | def resources_gc_prefix(options, policy_config, policy_collection):
"""Garbage collect old custodian policies based on prefix.
We attempt to introspect to find the event sources for a policy
but without the old configuration this is implicit.
"""
# Classify policies by region
policy_regions = ... | [
"def",
"resources_gc_prefix",
"(",
"options",
",",
"policy_config",
",",
"policy_collection",
")",
":",
"# Classify policies by region",
"policy_regions",
"=",
"{",
"}",
"for",
"p",
"in",
"policy_collection",
":",
"if",
"p",
".",
"execution_mode",
"==",
"'poll'",
... | Garbage collect old custodian policies based on prefix.
We attempt to introspect to find the event sources for a policy
but without the old configuration this is implicit. | [
"Garbage",
"collect",
"old",
"custodian",
"policies",
"based",
"on",
"prefix",
"."
] | python | train | 35.588235 |
saltstack/salt | salt/state.py | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/state.py#L3386-L3447 | def _merge_tops_same(self, tops):
'''
For each saltenv, only consider the top file from that saltenv. All
sections matching a given saltenv, which appear in a different
saltenv's top file, will be ignored.
'''
top = DefaultOrderedDict(OrderedDict)
for cenv, ctops ... | [
"def",
"_merge_tops_same",
"(",
"self",
",",
"tops",
")",
":",
"top",
"=",
"DefaultOrderedDict",
"(",
"OrderedDict",
")",
"for",
"cenv",
",",
"ctops",
"in",
"six",
".",
"iteritems",
"(",
"tops",
")",
":",
"if",
"all",
"(",
"[",
"x",
"==",
"{",
"}",
... | For each saltenv, only consider the top file from that saltenv. All
sections matching a given saltenv, which appear in a different
saltenv's top file, will be ignored. | [
"For",
"each",
"saltenv",
"only",
"consider",
"the",
"top",
"file",
"from",
"that",
"saltenv",
".",
"All",
"sections",
"matching",
"a",
"given",
"saltenv",
"which",
"appear",
"in",
"a",
"different",
"saltenv",
"s",
"top",
"file",
"will",
"be",
"ignored",
"... | python | train | 45.274194 |
mozilla-releng/signtool | signtool/util/archives.py | https://github.com/mozilla-releng/signtool/blob/0a778778a181cb9cab424b29fa104b70345f53c2/signtool/util/archives.py#L171-L183 | def packtar(tarfile, files, srcdir):
""" Pack the given files into a tar, setting cwd = srcdir"""
nullfd = open(os.devnull, "w")
tarfile = cygpath(os.path.abspath(tarfile))
log.debug("pack tar %s from folder %s with files ", tarfile, srcdir)
log.debug(files)
try:
check_call([TAR, '-czf'... | [
"def",
"packtar",
"(",
"tarfile",
",",
"files",
",",
"srcdir",
")",
":",
"nullfd",
"=",
"open",
"(",
"os",
".",
"devnull",
",",
"\"w\"",
")",
"tarfile",
"=",
"cygpath",
"(",
"os",
".",
"path",
".",
"abspath",
"(",
"tarfile",
")",
")",
"log",
".",
... | Pack the given files into a tar, setting cwd = srcdir | [
"Pack",
"the",
"given",
"files",
"into",
"a",
"tar",
"setting",
"cwd",
"=",
"srcdir"
] | python | train | 40.230769 |
bcbio/bcbio-nextgen | bcbio/rnaseq/qc.py | https://github.com/bcbio/bcbio-nextgen/blob/6a9348c0054ccd5baffd22f1bb7d0422f6978b20/bcbio/rnaseq/qc.py#L42-L64 | def estimate_library_complexity(df, algorithm="RNA-seq"):
"""
estimate library complexity from the number of reads vs.
number of unique start sites. returns "NA" if there are
not enough data points to fit the line
"""
DEFAULT_CUTOFFS = {"RNA-seq": (0.25, 0.40)}
cutoffs = DEFAULT_CUTOFFS[algo... | [
"def",
"estimate_library_complexity",
"(",
"df",
",",
"algorithm",
"=",
"\"RNA-seq\"",
")",
":",
"DEFAULT_CUTOFFS",
"=",
"{",
"\"RNA-seq\"",
":",
"(",
"0.25",
",",
"0.40",
")",
"}",
"cutoffs",
"=",
"DEFAULT_CUTOFFS",
"[",
"algorithm",
"]",
"if",
"len",
"(",
... | estimate library complexity from the number of reads vs.
number of unique start sites. returns "NA" if there are
not enough data points to fit the line | [
"estimate",
"library",
"complexity",
"from",
"the",
"number",
"of",
"reads",
"vs",
".",
"number",
"of",
"unique",
"start",
"sites",
".",
"returns",
"NA",
"if",
"there",
"are",
"not",
"enough",
"data",
"points",
"to",
"fit",
"the",
"line"
] | python | train | 33.73913 |
westurner/pyrpo | pyrpo/pyrpo.py | https://github.com/westurner/pyrpo/blob/2a910af055dc405b761571a52ef87842397ddadf/pyrpo/pyrpo.py#L1439-L1518 | def _parselog(self, r):
"""
Parse bazaar log file format
Args:
r (str): bzr revision identifier
Yields:
dict: dict of (attr, value) pairs
::
$ bzr log -l1
------------------------------------------------------------
... | [
"def",
"_parselog",
"(",
"self",
",",
"r",
")",
":",
"def",
"__parselog",
"(",
"entry",
")",
":",
"\"\"\"\n Parse bazaar log file format\n\n Args:\n entry (str): log message string\n\n Yields:\n tuple: (attrname, value)\n ... | Parse bazaar log file format
Args:
r (str): bzr revision identifier
Yields:
dict: dict of (attr, value) pairs
::
$ bzr log -l1
------------------------------------------------------------
revno: 1
committer: ubuntu <ubun... | [
"Parse",
"bazaar",
"log",
"file",
"format"
] | python | train | 30.3875 |
pyscaffold/configupdater | src/configupdater/configupdater.py | https://github.com/pyscaffold/configupdater/blob/6ebac0b1fa7b8222baacdd4991d18cfc61659f84/src/configupdater/configupdater.py#L121-L124 | def add_after(self):
"""Returns a builder inserting a new block after the current block"""
idx = self._container.structure.index(self)
return BlockBuilder(self._container, idx+1) | [
"def",
"add_after",
"(",
"self",
")",
":",
"idx",
"=",
"self",
".",
"_container",
".",
"structure",
".",
"index",
"(",
"self",
")",
"return",
"BlockBuilder",
"(",
"self",
".",
"_container",
",",
"idx",
"+",
"1",
")"
] | Returns a builder inserting a new block after the current block | [
"Returns",
"a",
"builder",
"inserting",
"a",
"new",
"block",
"after",
"the",
"current",
"block"
] | python | train | 49.75 |
RJT1990/pyflux | pyflux/gas/gasreg.py | https://github.com/RJT1990/pyflux/blob/297f2afc2095acd97c12e827dd500e8ea5da0c0f/pyflux/gas/gasreg.py#L443-L528 | def plot_predict(self, h=5, past_values=20, intervals=True, oos_data=None, **kwargs):
""" Makes forecast with the estimated model
Parameters
----------
h : int (default : 5)
How many steps ahead would you like to forecast?
past_values : int (default : 20)
... | [
"def",
"plot_predict",
"(",
"self",
",",
"h",
"=",
"5",
",",
"past_values",
"=",
"20",
",",
"intervals",
"=",
"True",
",",
"oos_data",
"=",
"None",
",",
"*",
"*",
"kwargs",
")",
":",
"import",
"matplotlib",
".",
"pyplot",
"as",
"plt",
"import",
"seab... | Makes forecast with the estimated model
Parameters
----------
h : int (default : 5)
How many steps ahead would you like to forecast?
past_values : int (default : 20)
How many past observations to show on the forecast graph?
intervals : Boolean
... | [
"Makes",
"forecast",
"with",
"the",
"estimated",
"model"
] | python | train | 45.255814 |
KelSolaar/Umbra | umbra/ui/models.py | https://github.com/KelSolaar/Umbra/blob/66f45f08d9d723787f1191989f8b0dda84b412ce/umbra/ui/models.py#L328-L363 | def setData(self, index, value, role=Qt.EditRole):
"""
Reimplements the :meth:`QAbstractItemModel.setData` method.
:param index: Index.
:type index: QModelIndex
:param value: Value.
:type value: QVariant
:param role: Role.
:type role: int
:return:... | [
"def",
"setData",
"(",
"self",
",",
"index",
",",
"value",
",",
"role",
"=",
"Qt",
".",
"EditRole",
")",
":",
"if",
"not",
"index",
".",
"isValid",
"(",
")",
":",
"return",
"False",
"node",
"=",
"self",
".",
"get_node",
"(",
"index",
")",
"if",
"... | Reimplements the :meth:`QAbstractItemModel.setData` method.
:param index: Index.
:type index: QModelIndex
:param value: Value.
:type value: QVariant
:param role: Role.
:type role: int
:return: Method success.
:rtype: bool | [
"Reimplements",
"the",
":",
"meth",
":",
"QAbstractItemModel",
".",
"setData",
"method",
"."
] | python | train | 30.972222 |
openstack/networking-cisco | networking_cisco/apps/saf/server/services/firewall/native/fabric_setup_base.py | https://github.com/openstack/networking-cisco/blob/aa58a30aec25b86f9aa5952b0863045975debfa9/networking_cisco/apps/saf/server/services/firewall/native/fabric_setup_base.py#L1702-L1793 | def correct_db_restart(self):
"""Ensure DB is consistent after unexpected restarts. """
LOG.info("Checking consistency of DB")
# Any Segments allocated that's not in Network or FW DB, release it
seg_netid_dict = self.service_segs.get_seg_netid_src(fw_const.FW_CONST)
vlan_netid_di... | [
"def",
"correct_db_restart",
"(",
"self",
")",
":",
"LOG",
".",
"info",
"(",
"\"Checking consistency of DB\"",
")",
"# Any Segments allocated that's not in Network or FW DB, release it",
"seg_netid_dict",
"=",
"self",
".",
"service_segs",
".",
"get_seg_netid_src",
"(",
"fw_... | Ensure DB is consistent after unexpected restarts. | [
"Ensure",
"DB",
"is",
"consistent",
"after",
"unexpected",
"restarts",
"."
] | python | train | 50.967391 |
xeroc/python-graphenelib | graphenestorage/masterpassword.py | https://github.com/xeroc/python-graphenelib/blob/8bb5396bc79998ee424cf3813af478304173f3a6/graphenestorage/masterpassword.py#L141-L153 | def _get_encrypted_masterpassword(self):
""" Obtain the encrypted masterkey
.. note:: The encrypted masterkey is checksummed, so that we can
figure out that a provided password is correct or not. The
checksum is only 4 bytes long!
"""
if not self.unlo... | [
"def",
"_get_encrypted_masterpassword",
"(",
"self",
")",
":",
"if",
"not",
"self",
".",
"unlocked",
"(",
")",
":",
"raise",
"WalletLocked",
"aes",
"=",
"AESCipher",
"(",
"self",
".",
"password",
")",
"return",
"\"{}${}\"",
".",
"format",
"(",
"self",
".",... | Obtain the encrypted masterkey
.. note:: The encrypted masterkey is checksummed, so that we can
figure out that a provided password is correct or not. The
checksum is only 4 bytes long! | [
"Obtain",
"the",
"encrypted",
"masterkey"
] | python | valid | 38.846154 |
spyder-ide/spyder | spyder/plugins/editor/widgets/editor.py | https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/plugins/editor/widgets/editor.py#L2122-L2143 | def refresh(self, index=None):
"""Refresh tabwidget"""
if index is None:
index = self.get_stack_index()
# Set current editor
if self.get_stack_count():
index = self.get_stack_index()
finfo = self.data[index]
editor = finfo.editor
... | [
"def",
"refresh",
"(",
"self",
",",
"index",
"=",
"None",
")",
":",
"if",
"index",
"is",
"None",
":",
"index",
"=",
"self",
".",
"get_stack_index",
"(",
")",
"# Set current editor\r",
"if",
"self",
".",
"get_stack_count",
"(",
")",
":",
"index",
"=",
"... | Refresh tabwidget | [
"Refresh",
"tabwidget"
] | python | train | 38.636364 |
mbj4668/pyang | pyang/plugins/sample-xml-skeleton.py | https://github.com/mbj4668/pyang/blob/f2a5cc3142162e5b9ee4e18d154568d939ff63dd/pyang/plugins/sample-xml-skeleton.py#L135-L140 | def process_children(self, node, elem, module, path, omit=[]):
"""Proceed with all children of `node`."""
for ch in node.i_children:
if ch not in omit and (ch.i_config or self.doctype == "data"):
self.node_handler.get(ch.keyword, self.ignore)(
ch, elem, mo... | [
"def",
"process_children",
"(",
"self",
",",
"node",
",",
"elem",
",",
"module",
",",
"path",
",",
"omit",
"=",
"[",
"]",
")",
":",
"for",
"ch",
"in",
"node",
".",
"i_children",
":",
"if",
"ch",
"not",
"in",
"omit",
"and",
"(",
"ch",
".",
"i_conf... | Proceed with all children of `node`. | [
"Proceed",
"with",
"all",
"children",
"of",
"node",
"."
] | python | train | 54.333333 |
indico/indico-plugins | piwik/indico_piwik/reports.py | https://github.com/indico/indico-plugins/blob/fe50085cc63be9b8161b09539e662e7b04e4b38e/piwik/indico_piwik/reports.py#L59-L74 | def get(cls, *args, **kwargs):
"""Create and return a serializable Report object, retrieved from cache if possible"""
from indico_piwik.plugin import PiwikPlugin
if not PiwikPlugin.settings.get('cache_enabled'):
return cls(*args, **kwargs).to_serializable()
cache = Generic... | [
"def",
"get",
"(",
"cls",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"from",
"indico_piwik",
".",
"plugin",
"import",
"PiwikPlugin",
"if",
"not",
"PiwikPlugin",
".",
"settings",
".",
"get",
"(",
"'cache_enabled'",
")",
":",
"return",
"cls",
"... | Create and return a serializable Report object, retrieved from cache if possible | [
"Create",
"and",
"return",
"a",
"serializable",
"Report",
"object",
"retrieved",
"from",
"cache",
"if",
"possible"
] | python | train | 37.4375 |
WZBSocialScienceCenter/tmtoolkit | tmtoolkit/topicmod/model_stats.py | https://github.com/WZBSocialScienceCenter/tmtoolkit/blob/ca8b9d072e37ccc82b533f47d48bd9755722305b/tmtoolkit/topicmod/model_stats.py#L65-L75 | def get_word_saliency(topic_word_distrib, doc_topic_distrib, doc_lengths):
"""
Calculate word saliency according to Chuang et al. 2012.
saliency(w) = p(w) * distinctiveness(w)
J. Chuang, C. Manning, J. Heer 2012: "Termite: Visualization Techniques for Assessing Textual Topic Models"
"""
p_t = g... | [
"def",
"get_word_saliency",
"(",
"topic_word_distrib",
",",
"doc_topic_distrib",
",",
"doc_lengths",
")",
":",
"p_t",
"=",
"get_marginal_topic_distrib",
"(",
"doc_topic_distrib",
",",
"doc_lengths",
")",
"p_w",
"=",
"get_marginal_word_distrib",
"(",
"topic_word_distrib",
... | Calculate word saliency according to Chuang et al. 2012.
saliency(w) = p(w) * distinctiveness(w)
J. Chuang, C. Manning, J. Heer 2012: "Termite: Visualization Techniques for Assessing Textual Topic Models" | [
"Calculate",
"word",
"saliency",
"according",
"to",
"Chuang",
"et",
"al",
".",
"2012",
".",
"saliency",
"(",
"w",
")",
"=",
"p",
"(",
"w",
")",
"*",
"distinctiveness",
"(",
"w",
")"
] | python | train | 45.090909 |
junzis/pyModeS | pyModeS/decoder/bds/bds44.py | https://github.com/junzis/pyModeS/blob/8cd5655a04b08171a9ad5f1ffd232b7e0178ea53/pyModeS/decoder/bds/bds44.py#L121-L138 | def p44(msg):
"""Static pressure.
Args:
msg (String): 28 bytes hexadecimal message string
Returns:
int: static pressure in hPa
"""
d = hex2bin(data(msg))
if d[34] == '0':
return None
p = bin2int(d[35:46]) # hPa
return p | [
"def",
"p44",
"(",
"msg",
")",
":",
"d",
"=",
"hex2bin",
"(",
"data",
"(",
"msg",
")",
")",
"if",
"d",
"[",
"34",
"]",
"==",
"'0'",
":",
"return",
"None",
"p",
"=",
"bin2int",
"(",
"d",
"[",
"35",
":",
"46",
"]",
")",
"# hPa",
"return",
"p"... | Static pressure.
Args:
msg (String): 28 bytes hexadecimal message string
Returns:
int: static pressure in hPa | [
"Static",
"pressure",
"."
] | python | train | 14.833333 |
YoSmudge/dnsyo | dnsyo/dnsyo.py | https://github.com/YoSmudge/dnsyo/blob/4734e36d712fefeb9a8ff22dfba678e382dde6cf/dnsyo/dnsyo.py#L352-L407 | def outputStandard(self, extended=False):
"""
Standard, multi-line output display
"""
successfulResponses = len(
[
True for rsp in self.results if rsp['success']
]
)
sys.stdout.write(""" - RESULTS
I asked {num_servers} servers fo... | [
"def",
"outputStandard",
"(",
"self",
",",
"extended",
"=",
"False",
")",
":",
"successfulResponses",
"=",
"len",
"(",
"[",
"True",
"for",
"rsp",
"in",
"self",
".",
"results",
"if",
"rsp",
"[",
"'success'",
"]",
"]",
")",
"sys",
".",
"stdout",
".",
"... | Standard, multi-line output display | [
"Standard",
"multi",
"-",
"line",
"output",
"display"
] | python | train | 28.678571 |
cvxgrp/qcqp | qcqp/qcqp.py | https://github.com/cvxgrp/qcqp/blob/6b7a9804ad7429b72094c9a8da3b29d807037fe9/qcqp/qcqp.py#L72-L97 | def solve_sdr(prob, *args, **kwargs):
"""Solve the SDP relaxation.
"""
# lifted variables and semidefinite constraint
X = cvx.Semidef(prob.n + 1)
W = prob.f0.homogeneous_form()
rel_obj = cvx.Minimize(cvx.sum_entries(cvx.mul_elemwise(W, X)))
rel_constr = [X[-1, -1] == 1]
for f in prob.... | [
"def",
"solve_sdr",
"(",
"prob",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"# lifted variables and semidefinite constraint",
"X",
"=",
"cvx",
".",
"Semidef",
"(",
"prob",
".",
"n",
"+",
"1",
")",
"W",
"=",
"prob",
".",
"f0",
".",
"homogeneou... | Solve the SDP relaxation. | [
"Solve",
"the",
"SDP",
"relaxation",
"."
] | python | train | 29.730769 |
pypa/bandersnatch | src/bandersnatch_filter_plugins/regex_name.py | https://github.com/pypa/bandersnatch/blob/8b702c3bc128c5a1cbdd18890adede2f7f17fad4/src/bandersnatch_filter_plugins/regex_name.py#L72-L86 | def check_match(self, name):
"""
Check if a release version matches any of the specificed patterns.
Parameters
==========
name: str
Release name
Returns
=======
bool:
True if it matches, False otherwise.
"""
return... | [
"def",
"check_match",
"(",
"self",
",",
"name",
")",
":",
"return",
"any",
"(",
"pattern",
".",
"match",
"(",
"name",
")",
"for",
"pattern",
"in",
"self",
".",
"patterns",
")"
] | Check if a release version matches any of the specificed patterns.
Parameters
==========
name: str
Release name
Returns
=======
bool:
True if it matches, False otherwise. | [
"Check",
"if",
"a",
"release",
"version",
"matches",
"any",
"of",
"the",
"specificed",
"patterns",
"."
] | python | train | 24 |
juanifioren/django-oidc-provider | oidc_provider/lib/utils/oauth2.py | https://github.com/juanifioren/django-oidc-provider/blob/f0daed07b2ac7608565b80d4c80ccf04d8c416a8/oidc_provider/lib/utils/oauth2.py#L56-L93 | def protected_resource_view(scopes=None):
"""
View decorator. The client accesses protected resources by presenting the
access token to the resource server.
https://tools.ietf.org/html/rfc6749#section-7
"""
if scopes is None:
scopes = []
def wrapper(view):
def view_wrapper(r... | [
"def",
"protected_resource_view",
"(",
"scopes",
"=",
"None",
")",
":",
"if",
"scopes",
"is",
"None",
":",
"scopes",
"=",
"[",
"]",
"def",
"wrapper",
"(",
"view",
")",
":",
"def",
"view_wrapper",
"(",
"request",
",",
"*",
"args",
",",
"*",
"*",
"kwar... | View decorator. The client accesses protected resources by presenting the
access token to the resource server.
https://tools.ietf.org/html/rfc6749#section-7 | [
"View",
"decorator",
".",
"The",
"client",
"accesses",
"protected",
"resources",
"by",
"presenting",
"the",
"access",
"token",
"to",
"the",
"resource",
"server",
".",
"https",
":",
"//",
"tools",
".",
"ietf",
".",
"org",
"/",
"html",
"/",
"rfc6749#section",
... | python | train | 38.526316 |
jgorset/django-respite | respite/formats.py | https://github.com/jgorset/django-respite/blob/719469d11baf91d05917bab1623bd82adc543546/respite/formats.py#L57-L67 | def find_by_name(name):
"""
Find and return a format by name.
:param name: A string describing the name of the format.
"""
for format in FORMATS:
if name == format.name:
return format
raise UnknownFormat('No format found with name "%s"' % name) | [
"def",
"find_by_name",
"(",
"name",
")",
":",
"for",
"format",
"in",
"FORMATS",
":",
"if",
"name",
"==",
"format",
".",
"name",
":",
"return",
"format",
"raise",
"UnknownFormat",
"(",
"'No format found with name \"%s\"'",
"%",
"name",
")"
] | Find and return a format by name.
:param name: A string describing the name of the format. | [
"Find",
"and",
"return",
"a",
"format",
"by",
"name",
"."
] | python | train | 25.454545 |
saltstack/salt | salt/modules/nova.py | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/nova.py#L659-L678 | def image_meta_set(image_id=None,
name=None,
profile=None,
**kwargs): # pylint: disable=C0103
'''
Sets a key=value pair in the metadata for an image (nova image-meta set)
CLI Examples:
.. code-block:: bash
salt '*' nova.image_meta_set ... | [
"def",
"image_meta_set",
"(",
"image_id",
"=",
"None",
",",
"name",
"=",
"None",
",",
"profile",
"=",
"None",
",",
"*",
"*",
"kwargs",
")",
":",
"# pylint: disable=C0103",
"conn",
"=",
"_auth",
"(",
"profile",
",",
"*",
"*",
"kwargs",
")",
"return",
"c... | Sets a key=value pair in the metadata for an image (nova image-meta set)
CLI Examples:
.. code-block:: bash
salt '*' nova.image_meta_set 6f52b2ff-0b31-4d84-8fd1-af45b84824f6 cheese=gruyere
salt '*' nova.image_meta_set name=myimage salad=pasta beans=baked | [
"Sets",
"a",
"key",
"=",
"value",
"pair",
"in",
"the",
"metadata",
"for",
"an",
"image",
"(",
"nova",
"image",
"-",
"meta",
"set",
")"
] | python | train | 27.85 |
IdentityPython/pysaml2 | src/saml2/sigver.py | https://github.com/IdentityPython/pysaml2/blob/d3aa78eeb7d37c12688f783cb4db1c7263a14ad6/src/saml2/sigver.py#L965-L987 | def validate_signature(self, signedtext, cert_file, cert_type, node_name, node_id, id_attr):
"""
Validate signature on XML document.
The parameters actually used in this CryptoBackend
implementation are :
:param signedtext: The signed XML data as string
:param cert_file... | [
"def",
"validate_signature",
"(",
"self",
",",
"signedtext",
",",
"cert_file",
",",
"cert_type",
",",
"node_name",
",",
"node_id",
",",
"id_attr",
")",
":",
"if",
"cert_type",
"!=",
"'pem'",
":",
"raise",
"Unsupported",
"(",
"'Only PEM certs supported here'",
")... | Validate signature on XML document.
The parameters actually used in this CryptoBackend
implementation are :
:param signedtext: The signed XML data as string
:param cert_file: xmlsec key_spec string(), filename,
'pkcs11://' URI or PEM data
:param cert_type: string, m... | [
"Validate",
"signature",
"on",
"XML",
"document",
"."
] | python | train | 34.565217 |
happyleavesaoc/python-limitlessled | limitlessled/bridge.py | https://github.com/happyleavesaoc/python-limitlessled/blob/70307c2bf8c91430a99579d2ad18b228ec7a8488/limitlessled/bridge.py#L175-L225 | def _consume(self):
""" Consume commands from the queue.
The command is repeated according to the configured value.
Wait after each command is sent.
The bridge socket is a shared resource. It must only
be used by one thread at a time. Note that this can and
will delay c... | [
"def",
"_consume",
"(",
"self",
")",
":",
"while",
"not",
"self",
".",
"is_closed",
":",
"# Get command from queue.",
"msg",
"=",
"self",
".",
"_command_queue",
".",
"get",
"(",
")",
"# Closed",
"if",
"msg",
"is",
"None",
":",
"return",
"# Use the lock so we... | Consume commands from the queue.
The command is repeated according to the configured value.
Wait after each command is sent.
The bridge socket is a shared resource. It must only
be used by one thread at a time. Note that this can and
will delay commands if multiple groups are a... | [
"Consume",
"commands",
"from",
"the",
"queue",
"."
] | python | train | 42.784314 |
quantmind/dynts | dynts/utils/numbers.py | https://github.com/quantmind/dynts/blob/21ac57c648bfec402fa6b1fe569496cf098fb5e8/dynts/utils/numbers.py#L10-L22 | def isnumeric(obj):
'''
Return true if obj is a numeric value
'''
from decimal import Decimal
if type(obj) == Decimal:
return True
else:
try:
float(obj)
except:
return False
return True | [
"def",
"isnumeric",
"(",
"obj",
")",
":",
"from",
"decimal",
"import",
"Decimal",
"if",
"type",
"(",
"obj",
")",
"==",
"Decimal",
":",
"return",
"True",
"else",
":",
"try",
":",
"float",
"(",
"obj",
")",
"except",
":",
"return",
"False",
"return",
"T... | Return true if obj is a numeric value | [
"Return",
"true",
"if",
"obj",
"is",
"a",
"numeric",
"value"
] | python | train | 20.384615 |
vladimarius/pyap | pyap/parser.py | https://github.com/vladimarius/pyap/blob/7896b5293982a30c1443e0c81c1ca32eeb8db15c/pyap/parser.py#L81-L103 | def _combine_results(self, match_as_dict):
'''Combine results from different parsed parts:
we look for non-empty results in values like
'postal_code_b' or 'postal_code_c' and store
them as main value.
So 'postal_code_b':'123456'
becomes:
... | [
"def",
"_combine_results",
"(",
"self",
",",
"match_as_dict",
")",
":",
"keys",
"=",
"[",
"]",
"vals",
"=",
"[",
"]",
"for",
"k",
",",
"v",
"in",
"six",
".",
"iteritems",
"(",
"match_as_dict",
")",
":",
"if",
"k",
"[",
"-",
"2",
":",
"]",
"in",
... | Combine results from different parsed parts:
we look for non-empty results in values like
'postal_code_b' or 'postal_code_c' and store
them as main value.
So 'postal_code_b':'123456'
becomes:
'postal_code' :'123456' | [
"Combine",
"results",
"from",
"different",
"parsed",
"parts",
":",
"we",
"look",
"for",
"non",
"-",
"empty",
"results",
"in",
"values",
"like",
"postal_code_b",
"or",
"postal_code_c",
"and",
"store",
"them",
"as",
"main",
"value",
"."
] | python | train | 37.217391 |
nicolargo/glances | glances/plugins/glances_help.py | https://github.com/nicolargo/glances/blob/5bd4d587a736e0d2b03170b56926841d2a3eb7ee/glances/plugins/glances_help.py#L55-L103 | def generate_view_data(self):
"""Generate the views."""
self.view_data['version'] = '{} {}'.format('Glances', __version__)
self.view_data['psutil_version'] = ' with psutil {}'.format(psutil_version)
try:
self.view_data['configuration_file'] = 'Configuration file: {}'.format(... | [
"def",
"generate_view_data",
"(",
"self",
")",
":",
"self",
".",
"view_data",
"[",
"'version'",
"]",
"=",
"'{} {}'",
".",
"format",
"(",
"'Glances'",
",",
"__version__",
")",
"self",
".",
"view_data",
"[",
"'psutil_version'",
"]",
"=",
"' with psutil {}'",
"... | Generate the views. | [
"Generate",
"the",
"views",
"."
] | python | train | 81.714286 |
genialis/resolwe-runtime-utils | resolwe_runtime_utils.py | https://github.com/genialis/resolwe-runtime-utils/blob/5657d7cf981972a5259b9b475eae220479401001/resolwe_runtime_utils.py#L325-L530 | def import_file(
src,
file_name,
imported_format=ImportedFormat.BOTH,
progress_from=0.0,
progress_to=None,
):
"""Import file to working directory.
:param src: Source file path or URL
:param file_name: Source file name
:param imported_format: Import file format (extracted, compressed... | [
"def",
"import_file",
"(",
"src",
",",
"file_name",
",",
"imported_format",
"=",
"ImportedFormat",
".",
"BOTH",
",",
"progress_from",
"=",
"0.0",
",",
"progress_to",
"=",
"None",
",",
")",
":",
"if",
"progress_to",
"is",
"not",
"None",
":",
"if",
"not",
... | Import file to working directory.
:param src: Source file path or URL
:param file_name: Source file name
:param imported_format: Import file format (extracted, compressed or both)
:param progress_from: Initial progress value
:param progress_to: Final progress value
:return: Destination file pat... | [
"Import",
"file",
"to",
"working",
"directory",
"."
] | python | train | 38.058252 |
wonambi-python/wonambi | wonambi/widgets/notes.py | https://github.com/wonambi-python/wonambi/blob/1d8e3d7e53df8017c199f703bcab582914676e76/wonambi/widgets/notes.py#L844-L876 | def go_to_marker(self, row, col, table_type):
"""Move to point in time marked by the marker.
Parameters
----------
row : QtCore.int
column : QtCore.int
table_type : str
'dataset' table or 'annot' table, it works on either
"""
if table_type =... | [
"def",
"go_to_marker",
"(",
"self",
",",
"row",
",",
"col",
",",
"table_type",
")",
":",
"if",
"table_type",
"==",
"'dataset'",
":",
"marker_time",
"=",
"self",
".",
"idx_marker",
".",
"property",
"(",
"'start'",
")",
"[",
"row",
"]",
"marker_end_time",
... | Move to point in time marked by the marker.
Parameters
----------
row : QtCore.int
column : QtCore.int
table_type : str
'dataset' table or 'annot' table, it works on either | [
"Move",
"to",
"point",
"in",
"time",
"marked",
"by",
"the",
"marker",
"."
] | python | train | 36.424242 |
PyCQA/astroid | astroid/node_classes.py | https://github.com/PyCQA/astroid/blob/e0a298df55b15abcb77c2a93253f5ab7be52d0fb/astroid/node_classes.py#L2294-L2306 | def postinit(self, left=None, ops=None):
"""Do some setup after initialisation.
:param left: The value at the left being applied to a comparison
operator.
:type left: NodeNG or None
:param ops: The remainder of the operators
and their relevant right hand value.
... | [
"def",
"postinit",
"(",
"self",
",",
"left",
"=",
"None",
",",
"ops",
"=",
"None",
")",
":",
"self",
".",
"left",
"=",
"left",
"self",
".",
"ops",
"=",
"ops"
] | Do some setup after initialisation.
:param left: The value at the left being applied to a comparison
operator.
:type left: NodeNG or None
:param ops: The remainder of the operators
and their relevant right hand value.
:type ops: list(tuple(str, NodeNG)) or None | [
"Do",
"some",
"setup",
"after",
"initialisation",
"."
] | python | train | 32.230769 |
internetarchive/brozzler | brozzler/model.py | https://github.com/internetarchive/brozzler/blob/411b3f266a38b9bb942021c0121ebd8e5ca66447/brozzler/model.py#L266-L316 | def accept_reject_or_neither(self, url, parent_page=None):
'''
Returns `True` (accepted), `False` (rejected), or `None` (no decision).
`None` usually means rejected, unless `max_hops_off` comes into play.
'''
if not isinstance(url, urlcanon.ParsedUrl):
url = urlcanon... | [
"def",
"accept_reject_or_neither",
"(",
"self",
",",
"url",
",",
"parent_page",
"=",
"None",
")",
":",
"if",
"not",
"isinstance",
"(",
"url",
",",
"urlcanon",
".",
"ParsedUrl",
")",
":",
"url",
"=",
"urlcanon",
".",
"semantic",
"(",
"url",
")",
"if",
"... | Returns `True` (accepted), `False` (rejected), or `None` (no decision).
`None` usually means rejected, unless `max_hops_off` comes into play. | [
"Returns",
"True",
"(",
"accepted",
")",
"False",
"(",
"rejected",
")",
"or",
"None",
"(",
"no",
"decision",
")",
"."
] | python | train | 35.941176 |
StyXman/ayrton | ayrton/parser/error.py | https://github.com/StyXman/ayrton/blob/e1eed5c7ef230e3c2340a1f0bf44c72bbdc0debb/ayrton/parser/error.py#L166-L241 | def normalize_exception(self, space):
"""Normalize the OperationError. In other words, fix w_type and/or
w_value to make sure that the __class__ of w_value is exactly w_type.
"""
#
# This method covers all ways in which the Python statement
# "raise X, Y" can produce a v... | [
"def",
"normalize_exception",
"(",
"self",
",",
"space",
")",
":",
"#",
"# This method covers all ways in which the Python statement",
"# \"raise X, Y\" can produce a valid exception type and instance.",
"#",
"# In the following table, 'Class' means a subclass of BaseException",
"# and 'in... | Normalize the OperationError. In other words, fix w_type and/or
w_value to make sure that the __class__ of w_value is exactly w_type. | [
"Normalize",
"the",
"OperationError",
".",
"In",
"other",
"words",
"fix",
"w_type",
"and",
"/",
"or",
"w_value",
"to",
"make",
"sure",
"that",
"the",
"__class__",
"of",
"w_value",
"is",
"exactly",
"w_type",
"."
] | python | train | 50.986842 |
coin-or/GiMPy | src/gimpy/graph.py | https://github.com/coin-or/GiMPy/blob/51853122a50eb6019d06bbdedbfc396a833b5a22/src/gimpy/graph.py#L1484-L1524 | def cycle_canceling(self, display):
'''
API:
cycle_canceling(self, display)
Description:
Solves minimum cost feasible flow problem using cycle canceling
algorithm. Returns True when an optimal solution is found, returns
False otherwise. 'flow' attr... | [
"def",
"cycle_canceling",
"(",
"self",
",",
"display",
")",
":",
"# find a feasible solution to flow problem",
"if",
"not",
"self",
".",
"find_feasible_flow",
"(",
")",
":",
"return",
"False",
"# create residual graph",
"residual_g",
"=",
"self",
".",
"create_residual... | API:
cycle_canceling(self, display)
Description:
Solves minimum cost feasible flow problem using cycle canceling
algorithm. Returns True when an optimal solution is found, returns
False otherwise. 'flow' attribute values of arcs should be
considered as... | [
"API",
":",
"cycle_canceling",
"(",
"self",
"display",
")",
"Description",
":",
"Solves",
"minimum",
"cost",
"feasible",
"flow",
"problem",
"using",
"cycle",
"canceling",
"algorithm",
".",
"Returns",
"True",
"when",
"an",
"optimal",
"solution",
"is",
"found",
... | python | train | 42.170732 |
bolt-project/bolt | bolt/spark/chunk.py | https://github.com/bolt-project/bolt/blob/9cd7104aa085498da3097b72696184b9d3651c51/bolt/spark/chunk.py#L146-L200 | def unchunk(self):
"""
Convert a chunked array back into a full array with (key,value) pairs
where key is a tuple of indices, and value is an ndarray.
"""
plan, padding, vshape, split = self.plan, self.padding, self.vshape, self.split
nchunks = self.getnumber(plan, vshape... | [
"def",
"unchunk",
"(",
"self",
")",
":",
"plan",
",",
"padding",
",",
"vshape",
",",
"split",
"=",
"self",
".",
"plan",
",",
"self",
".",
"padding",
",",
"self",
".",
"vshape",
",",
"self",
".",
"split",
"nchunks",
"=",
"self",
".",
"getnumber",
"(... | Convert a chunked array back into a full array with (key,value) pairs
where key is a tuple of indices, and value is an ndarray. | [
"Convert",
"a",
"chunked",
"array",
"back",
"into",
"a",
"full",
"array",
"with",
"(",
"key",
"value",
")",
"pairs",
"where",
"key",
"is",
"a",
"tuple",
"of",
"indices",
"and",
"value",
"is",
"an",
"ndarray",
"."
] | python | test | 41.2 |
mikedh/trimesh | trimesh/primitives.py | https://github.com/mikedh/trimesh/blob/25e059bf6d4caa74f62ffd58ce4f61a90ee4e518/trimesh/primitives.py#L448-L458 | def moment_inertia(self):
"""
The analytic inertia tensor of the sphere primitive.
Returns
----------
tensor: (3,3) float, 3D inertia tensor
"""
tensor = inertia.sphere_inertia(mass=self.volume,
radius=self.primitive.radius... | [
"def",
"moment_inertia",
"(",
"self",
")",
":",
"tensor",
"=",
"inertia",
".",
"sphere_inertia",
"(",
"mass",
"=",
"self",
".",
"volume",
",",
"radius",
"=",
"self",
".",
"primitive",
".",
"radius",
")",
"return",
"tensor"
] | The analytic inertia tensor of the sphere primitive.
Returns
----------
tensor: (3,3) float, 3D inertia tensor | [
"The",
"analytic",
"inertia",
"tensor",
"of",
"the",
"sphere",
"primitive",
"."
] | python | train | 30.272727 |
treycucco/pyebnf | pyebnf/primitive.py | https://github.com/treycucco/pyebnf/blob/3634ddabbe5d73508bcc20f4a591f86a46634e1d/pyebnf/primitive.py#L87-L97 | def add_ignored(self, ignored):
"""Add ignored text to the node. This will add the length of the ignored text to the node's
consumed property.
"""
if ignored:
if self.ignored:
self.ignored = ignored + self.ignored
else:
self.ignored = ignored
self.consumed += len(ignored... | [
"def",
"add_ignored",
"(",
"self",
",",
"ignored",
")",
":",
"if",
"ignored",
":",
"if",
"self",
".",
"ignored",
":",
"self",
".",
"ignored",
"=",
"ignored",
"+",
"self",
".",
"ignored",
"else",
":",
"self",
".",
"ignored",
"=",
"ignored",
"self",
".... | Add ignored text to the node. This will add the length of the ignored text to the node's
consumed property. | [
"Add",
"ignored",
"text",
"to",
"the",
"node",
".",
"This",
"will",
"add",
"the",
"length",
"of",
"the",
"ignored",
"text",
"to",
"the",
"node",
"s",
"consumed",
"property",
"."
] | python | test | 28.272727 |
Ex-Mente/auxi.0 | auxi/core/time.py | https://github.com/Ex-Mente/auxi.0/blob/2dcdae74154f136f8ca58289fe5b20772f215046/auxi/core/time.py#L79-L103 | def get_datetime_at_period_ix(self, ix):
"""
Get the datetime at a given period.
:param period: The index of the period.
:returns: The datetime.
"""
if self.timestep_period_duration == TimePeriod.millisecond:
return self.start_datetime + timedelta(milliseco... | [
"def",
"get_datetime_at_period_ix",
"(",
"self",
",",
"ix",
")",
":",
"if",
"self",
".",
"timestep_period_duration",
"==",
"TimePeriod",
".",
"millisecond",
":",
"return",
"self",
".",
"start_datetime",
"+",
"timedelta",
"(",
"milliseconds",
"=",
"ix",
")",
"e... | Get the datetime at a given period.
:param period: The index of the period.
:returns: The datetime. | [
"Get",
"the",
"datetime",
"at",
"a",
"given",
"period",
"."
] | python | valid | 47.84 |
mamrhein/specification | specification/_extd_ast_expr.py | https://github.com/mamrhein/specification/blob/a4c09a0d286cda7a04e8a189f12e23edd97f64ea/specification/_extd_ast_expr.py#L527-L530 | def visit_GeneratorExp(self, node: AST, dfltChaining: bool = True) -> str:
"""Return `node`s representation as generator expression."""
return f"({self.visit(node.elt)} " \
f"{' '.join(self.visit(gen) for gen in node.generators)})" | [
"def",
"visit_GeneratorExp",
"(",
"self",
",",
"node",
":",
"AST",
",",
"dfltChaining",
":",
"bool",
"=",
"True",
")",
"->",
"str",
":",
"return",
"f\"({self.visit(node.elt)} \"",
"f\"{' '.join(self.visit(gen) for gen in node.generators)})\""
] | Return `node`s representation as generator expression. | [
"Return",
"node",
"s",
"representation",
"as",
"generator",
"expression",
"."
] | python | train | 64.75 |
NaturalHistoryMuseum/pyzbar | pyzbar/wrapper.py | https://github.com/NaturalHistoryMuseum/pyzbar/blob/833b375c0e84077943b7100cc9dc22a7bd48754b/pyzbar/wrapper.py#L123-L136 | def zbar_function(fname, restype, *args):
"""Returns a foreign function exported by `zbar`.
Args:
fname (:obj:`str`): Name of the exported function as string.
restype (:obj:): Return type - one of the `ctypes` primitive C data
types.
*args: Arguments - a sequence of `ctypes` pri... | [
"def",
"zbar_function",
"(",
"fname",
",",
"restype",
",",
"*",
"args",
")",
":",
"prototype",
"=",
"CFUNCTYPE",
"(",
"restype",
",",
"*",
"args",
")",
"return",
"prototype",
"(",
"(",
"fname",
",",
"load_libzbar",
"(",
")",
")",
")"
] | Returns a foreign function exported by `zbar`.
Args:
fname (:obj:`str`): Name of the exported function as string.
restype (:obj:): Return type - one of the `ctypes` primitive C data
types.
*args: Arguments - a sequence of `ctypes` primitive C data types.
Returns:
cddl.C... | [
"Returns",
"a",
"foreign",
"function",
"exported",
"by",
"zbar",
"."
] | python | train | 35.428571 |
Erotemic/utool | utool/util_numpy.py | https://github.com/Erotemic/utool/blob/3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a/utool/util_numpy.py#L270-L294 | def deterministic_shuffle(list_, seed=0, rng=None):
r"""
Args:
list_ (list):
seed (int):
Returns:
list: list_
CommandLine:
python -m utool.util_numpy --test-deterministic_shuffle
Example:
>>> # ENABLE_DOCTEST
>>> from utool.util_numpy import * # NO... | [
"def",
"deterministic_shuffle",
"(",
"list_",
",",
"seed",
"=",
"0",
",",
"rng",
"=",
"None",
")",
":",
"rng",
"=",
"ensure_rng",
"(",
"seed",
"if",
"rng",
"is",
"None",
"else",
"rng",
")",
"rng",
".",
"shuffle",
"(",
"list_",
")",
"return",
"list_"
... | r"""
Args:
list_ (list):
seed (int):
Returns:
list: list_
CommandLine:
python -m utool.util_numpy --test-deterministic_shuffle
Example:
>>> # ENABLE_DOCTEST
>>> from utool.util_numpy import * # NOQA
>>> list_ = [1, 2, 3, 4, 5, 6]
>>> se... | [
"r",
"Args",
":",
"list_",
"(",
"list",
")",
":",
"seed",
"(",
"int",
")",
":"
] | python | train | 23.88 |
ojake/django-tracked-model | tracked_model/control.py | https://github.com/ojake/django-tracked-model/blob/19bc48874dd2e5fb5defedc6b8c5c3915cce1424/tracked_model/control.py#L7-L21 | def create_track_token(request):
"""Returns ``TrackToken``.
``TrackToken' contains request and user making changes.
It can be passed to ``TrackedModel.save`` instead of ``request``.
It is intended to be used when passing ``request`` is not possible
e.g. when ``TrackedModel.save`` will be called fro... | [
"def",
"create_track_token",
"(",
"request",
")",
":",
"from",
"tracked_model",
".",
"models",
"import",
"RequestInfo",
"request_pk",
"=",
"RequestInfo",
".",
"create_or_get_from_request",
"(",
"request",
")",
".",
"pk",
"user_pk",
"=",
"None",
"if",
"request",
... | Returns ``TrackToken``.
``TrackToken' contains request and user making changes.
It can be passed to ``TrackedModel.save`` instead of ``request``.
It is intended to be used when passing ``request`` is not possible
e.g. when ``TrackedModel.save`` will be called from celery task. | [
"Returns",
"TrackToken",
".",
"TrackToken",
"contains",
"request",
"and",
"user",
"making",
"changes",
"."
] | python | train | 40.066667 |
jamieleshaw/lurklib | lurklib/connection.py | https://github.com/jamieleshaw/lurklib/blob/a861f35d880140422103dd78ec3239814e85fd7e/lurklib/connection.py#L319-L330 | def quit(self, reason=''):
"""
Sends a QUIT message, closes the connection and -
ends Lurklib's main loop.
Optional arguments:
* reason='' - Reason for quitting.
"""
with self.lock:
self.keep_going = False
self._quit(reason)
... | [
"def",
"quit",
"(",
"self",
",",
"reason",
"=",
"''",
")",
":",
"with",
"self",
".",
"lock",
":",
"self",
".",
"keep_going",
"=",
"False",
"self",
".",
"_quit",
"(",
"reason",
")",
"self",
".",
"_socket",
".",
"shutdown",
"(",
"self",
".",
"_m_sock... | Sends a QUIT message, closes the connection and -
ends Lurklib's main loop.
Optional arguments:
* reason='' - Reason for quitting. | [
"Sends",
"a",
"QUIT",
"message",
"closes",
"the",
"connection",
"and",
"-",
"ends",
"Lurklib",
"s",
"main",
"loop",
".",
"Optional",
"arguments",
":",
"*",
"reason",
"=",
"-",
"Reason",
"for",
"quitting",
"."
] | python | train | 32.5 |
tomplus/kubernetes_asyncio | kubernetes_asyncio/client/api/core_v1_api.py | https://github.com/tomplus/kubernetes_asyncio/blob/f9ab15317ec921409714c7afef11aeb0f579985d/kubernetes_asyncio/client/api/core_v1_api.py#L6747-L6771 | def create_namespaced_resource_quota(self, namespace, body, **kwargs): # noqa: E501
"""create_namespaced_resource_quota # noqa: E501
create a ResourceQuota # noqa: E501
This method makes a synchronous HTTP request by default. To make an
asynchronous HTTP request, please pass async_re... | [
"def",
"create_namespaced_resource_quota",
"(",
"self",
",",
"namespace",
",",
"body",
",",
"*",
"*",
"kwargs",
")",
":",
"# noqa: E501",
"kwargs",
"[",
"'_return_http_data_only'",
"]",
"=",
"True",
"if",
"kwargs",
".",
"get",
"(",
"'async_req'",
")",
":",
"... | create_namespaced_resource_quota # noqa: E501
create a ResourceQuota # noqa: E501
This method makes a synchronous HTTP request by default. To make an
asynchronous HTTP request, please pass async_req=True
>>> thread = api.create_namespaced_resource_quota(namespace, body, async_req=True... | [
"create_namespaced_resource_quota",
"#",
"noqa",
":",
"E501"
] | python | train | 62.68 |
inonit/drf-haystack | drf_haystack/filters.py | https://github.com/inonit/drf-haystack/blob/ceabd0f6318f129758341ab08292a20205d6f4cd/drf_haystack/filters.py#L67-L73 | def get_query_builder(self, *args, **kwargs):
"""
Return the query builder class instance that should be used to
build the query which is passed to the search engine backend.
"""
query_builder = self.get_query_builder_class()
return query_builder(*args, **kwargs) | [
"def",
"get_query_builder",
"(",
"self",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"query_builder",
"=",
"self",
".",
"get_query_builder_class",
"(",
")",
"return",
"query_builder",
"(",
"*",
"args",
",",
"*",
"*",
"kwargs",
")"
] | Return the query builder class instance that should be used to
build the query which is passed to the search engine backend. | [
"Return",
"the",
"query",
"builder",
"class",
"instance",
"that",
"should",
"be",
"used",
"to",
"build",
"the",
"query",
"which",
"is",
"passed",
"to",
"the",
"search",
"engine",
"backend",
"."
] | python | train | 43.571429 |
saltstack/salt | salt/returners/splunk.py | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/returners/splunk.py#L70-L104 | def _send_splunk(event, index_override=None, sourcetype_override=None):
'''
Send the results to Splunk.
Requires the Splunk HTTP Event Collector running on port 8088.
This is available on Splunk Enterprise version 6.3 or higher.
'''
# Get Splunk Options
opts = _get_options()
log.info(st... | [
"def",
"_send_splunk",
"(",
"event",
",",
"index_override",
"=",
"None",
",",
"sourcetype_override",
"=",
"None",
")",
":",
"# Get Splunk Options",
"opts",
"=",
"_get_options",
"(",
")",
"log",
".",
"info",
"(",
"str",
"(",
"'Options: %s'",
")",
",",
"# futu... | Send the results to Splunk.
Requires the Splunk HTTP Event Collector running on port 8088.
This is available on Splunk Enterprise version 6.3 or higher. | [
"Send",
"the",
"results",
"to",
"Splunk",
".",
"Requires",
"the",
"Splunk",
"HTTP",
"Event",
"Collector",
"running",
"on",
"port",
"8088",
".",
"This",
"is",
"available",
"on",
"Splunk",
"Enterprise",
"version",
"6",
".",
"3",
"or",
"higher",
"."
] | python | train | 35.057143 |
Alignak-monitoring/alignak | alignak/objects/satellitelink.py | https://github.com/Alignak-monitoring/alignak/blob/f3c145207e83159b799d3714e4241399c7740a64/alignak/objects/satellitelink.py#L979-L991 | def get_actions(self, params):
"""Send a HTTP request to the satellite (GET /_checks)
Get actions from the scheduler.
Un-serialize data received.
:param params: the request parameters
:type params: str
:return: Actions list on success, [] on failure
:rtype: list
... | [
"def",
"get_actions",
"(",
"self",
",",
"params",
")",
":",
"res",
"=",
"self",
".",
"con",
".",
"get",
"(",
"'_checks'",
",",
"params",
",",
"wait",
"=",
"True",
")",
"logger",
".",
"debug",
"(",
"\"Got checks to execute from %s: %s\"",
",",
"self",
"."... | Send a HTTP request to the satellite (GET /_checks)
Get actions from the scheduler.
Un-serialize data received.
:param params: the request parameters
:type params: str
:return: Actions list on success, [] on failure
:rtype: list | [
"Send",
"a",
"HTTP",
"request",
"to",
"the",
"satellite",
"(",
"GET",
"/",
"_checks",
")",
"Get",
"actions",
"from",
"the",
"scheduler",
".",
"Un",
"-",
"serialize",
"data",
"received",
"."
] | python | train | 37.538462 |
emc-openstack/storops | storops/vnx/resource/system.py | https://github.com/emc-openstack/storops/blob/24b4b13bf065c0ef0538dd0b5ebb8f25d24176bd/storops/vnx/resource/system.py#L518-L531 | def get_rsc_list_2(self, rsc_clz_list=None):
"""get the list of resource list to collect based on clz list
:param rsc_clz_list: the list of classes to collect
:return: filtered list of resource list,
like [VNXLunList(), VNXDiskList()]
"""
rsc_list_2 = self._defa... | [
"def",
"get_rsc_list_2",
"(",
"self",
",",
"rsc_clz_list",
"=",
"None",
")",
":",
"rsc_list_2",
"=",
"self",
".",
"_default_rsc_list_with_perf_stats",
"(",
")",
"if",
"rsc_clz_list",
"is",
"None",
":",
"rsc_clz_list",
"=",
"ResourceList",
".",
"get_rsc_clz_list",
... | get the list of resource list to collect based on clz list
:param rsc_clz_list: the list of classes to collect
:return: filtered list of resource list,
like [VNXLunList(), VNXDiskList()] | [
"get",
"the",
"list",
"of",
"resource",
"list",
"to",
"collect",
"based",
"on",
"clz",
"list"
] | python | train | 41 |
RudolfCardinal/pythonlib | cardinal_pythonlib/hash.py | https://github.com/RudolfCardinal/pythonlib/blob/0b84cb35f38bd7d8723958dae51b480a829b7227/cardinal_pythonlib/hash.py#L188-L196 | def hash(self, raw: Any) -> str:
"""
Returns the hex digest of a HMAC-encoded version of the input.
"""
with MultiTimerContext(timer, TIMING_HASH):
raw_bytes = str(raw).encode('utf-8')
hmac_obj = hmac.new(key=self.key_bytes, msg=raw_bytes,
... | [
"def",
"hash",
"(",
"self",
",",
"raw",
":",
"Any",
")",
"->",
"str",
":",
"with",
"MultiTimerContext",
"(",
"timer",
",",
"TIMING_HASH",
")",
":",
"raw_bytes",
"=",
"str",
"(",
"raw",
")",
".",
"encode",
"(",
"'utf-8'",
")",
"hmac_obj",
"=",
"hmac",... | Returns the hex digest of a HMAC-encoded version of the input. | [
"Returns",
"the",
"hex",
"digest",
"of",
"a",
"HMAC",
"-",
"encoded",
"version",
"of",
"the",
"input",
"."
] | python | train | 42.777778 |
iotile/coretools | iotilecore/iotile/core/hw/auth/env_auth_provider.py | https://github.com/iotile/coretools/blob/2d794f5f1346b841b0dcd16c9d284e9bf2f3c6ec/iotilecore/iotile/core/hw/auth/env_auth_provider.py#L102-L145 | def verify_report(self, device_id, root, data, signature, **kwargs):
"""Verify a buffer of report data on behalf of a device.
Args:
device_id (int): The id of the device that we should encrypt for
root (int): The root key type that should be used to generate the report
... | [
"def",
"verify_report",
"(",
"self",
",",
"device_id",
",",
"root",
",",
"data",
",",
"signature",
",",
"*",
"*",
"kwargs",
")",
":",
"report_key",
"=",
"self",
".",
"_verify_derive_key",
"(",
"device_id",
",",
"root",
",",
"*",
"*",
"kwargs",
")",
"me... | Verify a buffer of report data on behalf of a device.
Args:
device_id (int): The id of the device that we should encrypt for
root (int): The root key type that should be used to generate the report
data (bytearray): The data that we should verify
signature (bytea... | [
"Verify",
"a",
"buffer",
"of",
"report",
"data",
"on",
"behalf",
"of",
"a",
"device",
"."
] | python | train | 45.613636 |
inasafe/inasafe | safe/plugin.py | https://github.com/inasafe/inasafe/blob/831d60abba919f6d481dc94a8d988cc205130724/safe/plugin.py#L428-L444 | def _create_add_petabencana_layer_action(self):
"""Create action for import OSM Dialog."""
icon = resources_path('img', 'icons', 'add-petabencana-layer.svg')
self.action_add_petabencana_layer = QAction(
QIcon(icon),
self.tr('Add PetaBencana Flood Layer'),
self... | [
"def",
"_create_add_petabencana_layer_action",
"(",
"self",
")",
":",
"icon",
"=",
"resources_path",
"(",
"'img'",
",",
"'icons'",
",",
"'add-petabencana-layer.svg'",
")",
"self",
".",
"action_add_petabencana_layer",
"=",
"QAction",
"(",
"QIcon",
"(",
"icon",
")",
... | Create action for import OSM Dialog. | [
"Create",
"action",
"for",
"import",
"OSM",
"Dialog",
"."
] | python | train | 49 |
mikeboers/MultiMap | multimap.py | https://github.com/mikeboers/MultiMap/blob/0251e5d5df693cc247b4ac5b95adfdd10e3bec04/multimap.py#L206-L216 | def iteritems(self):
"""Iterator across all the non-duplicate keys and their values.
Only yields the first key of duplicates.
"""
keys_yielded = set()
for k, v in self._pairs:
if k not in keys_yielded:
keys_yielded.add(k)
... | [
"def",
"iteritems",
"(",
"self",
")",
":",
"keys_yielded",
"=",
"set",
"(",
")",
"for",
"k",
",",
"v",
"in",
"self",
".",
"_pairs",
":",
"if",
"k",
"not",
"in",
"keys_yielded",
":",
"keys_yielded",
".",
"add",
"(",
"k",
")",
"yield",
"k",
",",
"v... | Iterator across all the non-duplicate keys and their values.
Only yields the first key of duplicates. | [
"Iterator",
"across",
"all",
"the",
"non",
"-",
"duplicate",
"keys",
"and",
"their",
"values",
".",
"Only",
"yields",
"the",
"first",
"key",
"of",
"duplicates",
"."
] | python | train | 29.454545 |
portantier/habu | habu/cli/cmd_shodan.py | https://github.com/portantier/habu/blob/87091e389dc6332fe1b82830c22b2eefc55816f2/habu/cli/cmd_shodan.py#L20-L66 | def cmd_shodan(ip, no_cache, verbose, output):
"""Simple shodan API client.
Prints the JSON result of a shodan query.
Example:
\b
$ habu.shodan 8.8.8.8
{
"hostnames": [
"google-public-dns-a.google.com"
],
"country_code": "US",
"org": "Google",
... | [
"def",
"cmd_shodan",
"(",
"ip",
",",
"no_cache",
",",
"verbose",
",",
"output",
")",
":",
"habucfg",
"=",
"loadcfg",
"(",
")",
"if",
"'SHODAN_APIKEY'",
"not",
"in",
"habucfg",
":",
"print",
"(",
"'You must provide a shodan apikey. Use the ~/.habu.json file (variable... | Simple shodan API client.
Prints the JSON result of a shodan query.
Example:
\b
$ habu.shodan 8.8.8.8
{
"hostnames": [
"google-public-dns-a.google.com"
],
"country_code": "US",
"org": "Google",
"data": [
{
"isp": "Goo... | [
"Simple",
"shodan",
"API",
"client",
"."
] | python | train | 25.297872 |
bitesofcode/projex | projex/enum.py | https://github.com/bitesofcode/projex/blob/d31743ec456a41428709968ab11a2cf6c6c76247/projex/enum.py#L115-L124 | def all(self):
"""
Returns all the values joined together.
:return <int>
"""
out = 0
for key, value in self.items():
out |= value
return out | [
"def",
"all",
"(",
"self",
")",
":",
"out",
"=",
"0",
"for",
"key",
",",
"value",
"in",
"self",
".",
"items",
"(",
")",
":",
"out",
"|=",
"value",
"return",
"out"
] | Returns all the values joined together.
:return <int> | [
"Returns",
"all",
"the",
"values",
"joined",
"together",
".",
":",
"return",
"<int",
">"
] | python | train | 21.2 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.