repo stringlengths 7 54 | path stringlengths 4 192 | url stringlengths 87 284 | code stringlengths 78 104k | code_tokens list | docstring stringlengths 1 46.9k | docstring_tokens list | language stringclasses 1
value | partition stringclasses 3
values |
|---|---|---|---|---|---|---|---|---|
mbj4668/pyang | pyang/yang_parser.py | https://github.com/mbj4668/pyang/blob/f2a5cc3142162e5b9ee4e18d154568d939ff63dd/pyang/yang_parser.py#L51-L78 | def skip(self):
"""Skip whitespace and count position"""
buflen = len(self.buf)
while True:
self.buf = self.buf.lstrip()
if self.buf == '':
self.readline()
buflen = len(self.buf)
else:
self.offset += (buflen - l... | [
"def",
"skip",
"(",
"self",
")",
":",
"buflen",
"=",
"len",
"(",
"self",
".",
"buf",
")",
"while",
"True",
":",
"self",
".",
"buf",
"=",
"self",
".",
"buf",
".",
"lstrip",
"(",
")",
"if",
"self",
".",
"buf",
"==",
"''",
":",
"self",
".",
"rea... | Skip whitespace and count position | [
"Skip",
"whitespace",
"and",
"count",
"position"
] | python | train |
Jajcus/pyxmpp2 | pyxmpp2/ext/vcard.py | https://github.com/Jajcus/pyxmpp2/blob/14a40a3950910a9cd008b55f0d8905aa0186ce18/pyxmpp2/ext/vcard.py#L1399-L1415 | def __make_fn(self):
"""Initialize the mandatory `self.fn` from `self.n`.
This is a workaround for buggy clients which set only one of them."""
s=[]
if self.n.prefix:
s.append(self.n.prefix)
if self.n.given:
s.append(self.n.given)
if self.n.middle... | [
"def",
"__make_fn",
"(",
"self",
")",
":",
"s",
"=",
"[",
"]",
"if",
"self",
".",
"n",
".",
"prefix",
":",
"s",
".",
"append",
"(",
"self",
".",
"n",
".",
"prefix",
")",
"if",
"self",
".",
"n",
".",
"given",
":",
"s",
".",
"append",
"(",
"s... | Initialize the mandatory `self.fn` from `self.n`.
This is a workaround for buggy clients which set only one of them. | [
"Initialize",
"the",
"mandatory",
"self",
".",
"fn",
"from",
"self",
".",
"n",
"."
] | python | valid |
3ll3d00d/vibe | backend/src/analyser/common/signal.py | https://github.com/3ll3d00d/vibe/blob/124b029f13ac746723e92cb47e9cb56edd2e54b5/backend/src/analyser/common/signal.py#L92-L120 | def spectrum(self, ref=None, segmentLengthMultiplier=1, mode=None, **kwargs):
"""
analyses the source to generate the linear spectrum.
:param ref: the reference value for dB purposes.
:param segmentLengthMultiplier: allow for increased resolution.
:param mode: cq or none.
... | [
"def",
"spectrum",
"(",
"self",
",",
"ref",
"=",
"None",
",",
"segmentLengthMultiplier",
"=",
"1",
",",
"mode",
"=",
"None",
",",
"*",
"*",
"kwargs",
")",
":",
"def",
"analysisFunc",
"(",
"x",
",",
"nperseg",
",",
"*",
"*",
"kwargs",
")",
":",
"f",... | analyses the source to generate the linear spectrum.
:param ref: the reference value for dB purposes.
:param segmentLengthMultiplier: allow for increased resolution.
:param mode: cq or none.
:return:
f : ndarray
Array of sample frequencies.
Pxx : ndarr... | [
"analyses",
"the",
"source",
"to",
"generate",
"the",
"linear",
"spectrum",
".",
":",
"param",
"ref",
":",
"the",
"reference",
"value",
"for",
"dB",
"purposes",
".",
":",
"param",
"segmentLengthMultiplier",
":",
"allow",
"for",
"increased",
"resolution",
".",
... | python | train |
crs4/pydoop | pydoop/hdfs/__init__.py | https://github.com/crs4/pydoop/blob/f375be2a06f9c67eaae3ce6f605195dbca143b2b/pydoop/hdfs/__init__.py#L340-L353 | def move(src, dest, user=None):
"""
Move or rename src to dest.
"""
src_host, src_port, src_path = path.split(src, user)
dest_host, dest_port, dest_path = path.split(dest, user)
src_fs = hdfs(src_host, src_port, user)
dest_fs = hdfs(dest_host, dest_port, user)
try:
retval = src_f... | [
"def",
"move",
"(",
"src",
",",
"dest",
",",
"user",
"=",
"None",
")",
":",
"src_host",
",",
"src_port",
",",
"src_path",
"=",
"path",
".",
"split",
"(",
"src",
",",
"user",
")",
"dest_host",
",",
"dest_port",
",",
"dest_path",
"=",
"path",
".",
"s... | Move or rename src to dest. | [
"Move",
"or",
"rename",
"src",
"to",
"dest",
"."
] | python | train |
saltstack/salt | salt/modules/rest_service.py | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/rest_service.py#L128-L169 | def status(name, sig=None):
'''
Return the status for a service via rest_sample.
If the name contains globbing, a dict mapping service name to True/False
values is returned.
.. versionadded:: 2015.8.0
.. versionchanged:: 2018.3.0
The service name can now be a glob (e.g. ``salt*``)
... | [
"def",
"status",
"(",
"name",
",",
"sig",
"=",
"None",
")",
":",
"proxy_fn",
"=",
"'rest_sample.service_status'",
"contains_globbing",
"=",
"bool",
"(",
"re",
".",
"search",
"(",
"r'\\*|\\?|\\[.+\\]'",
",",
"name",
")",
")",
"if",
"contains_globbing",
":",
"... | Return the status for a service via rest_sample.
If the name contains globbing, a dict mapping service name to True/False
values is returned.
.. versionadded:: 2015.8.0
.. versionchanged:: 2018.3.0
The service name can now be a glob (e.g. ``salt*``)
Args:
name (str): The name of t... | [
"Return",
"the",
"status",
"for",
"a",
"service",
"via",
"rest_sample",
".",
"If",
"the",
"name",
"contains",
"globbing",
"a",
"dict",
"mapping",
"service",
"name",
"to",
"True",
"/",
"False",
"values",
"is",
"returned",
"."
] | python | train |
PyGithub/PyGithub | github/Repository.py | https://github.com/PyGithub/PyGithub/blob/f716df86bbe7dc276c6596699fa9712b61ef974c/github/Repository.py#L2417-L2429 | def get_stats_participation(self):
"""
:calls: `GET /repos/:owner/:repo/stats/participation <http://developer.github.com/v3/repos/statistics/#get-the-weekly-commit-count-for-the-repo-owner-and-everyone-else>`_
:rtype: None or :class:`github.StatsParticipation.StatsParticipation`
"""
... | [
"def",
"get_stats_participation",
"(",
"self",
")",
":",
"headers",
",",
"data",
"=",
"self",
".",
"_requester",
".",
"requestJsonAndCheck",
"(",
"\"GET\"",
",",
"self",
".",
"url",
"+",
"\"/stats/participation\"",
")",
"if",
"not",
"data",
":",
"return",
"N... | :calls: `GET /repos/:owner/:repo/stats/participation <http://developer.github.com/v3/repos/statistics/#get-the-weekly-commit-count-for-the-repo-owner-and-everyone-else>`_
:rtype: None or :class:`github.StatsParticipation.StatsParticipation` | [
":",
"calls",
":",
"GET",
"/",
"repos",
"/",
":",
"owner",
"/",
":",
"repo",
"/",
"stats",
"/",
"participation",
"<http",
":",
"//",
"developer",
".",
"github",
".",
"com",
"/",
"v3",
"/",
"repos",
"/",
"statistics",
"/",
"#get",
"-",
"the",
"-",
... | python | train |
fossasia/knittingpattern | knittingpattern/Dumper/file.py | https://github.com/fossasia/knittingpattern/blob/8e608896b0ab82fea1ca9fbfa2b4ee023d8c8027/knittingpattern/Dumper/file.py#L142-L147 | def _temporary_file(self, delete):
""":return: a temporary file where the content is dumped to."""
file = NamedTemporaryFile("w+", delete=delete,
encoding=self.__encoding)
self._file(file)
return file | [
"def",
"_temporary_file",
"(",
"self",
",",
"delete",
")",
":",
"file",
"=",
"NamedTemporaryFile",
"(",
"\"w+\"",
",",
"delete",
"=",
"delete",
",",
"encoding",
"=",
"self",
".",
"__encoding",
")",
"self",
".",
"_file",
"(",
"file",
")",
"return",
"file"... | :return: a temporary file where the content is dumped to. | [
":",
"return",
":",
"a",
"temporary",
"file",
"where",
"the",
"content",
"is",
"dumped",
"to",
"."
] | python | valid |
projectshift/shift-schema | shiftschema/translator.py | https://github.com/projectshift/shift-schema/blob/07787b540d3369bb37217ffbfbe629118edaf0eb/shiftschema/translator.py#L51-L89 | def get_translations(self, locale):
"""
Get translation dictionary
Returns a dictionary for locale or raises an exception if such can't
be located. If a dictionary for locale was previously loaded returns
that, otherwise goes through registered locations and merges any
fo... | [
"def",
"get_translations",
"(",
"self",
",",
"locale",
")",
":",
"locale",
"=",
"self",
".",
"normalize_locale",
"(",
"locale",
")",
"if",
"locale",
"in",
"self",
".",
"translations",
":",
"return",
"self",
".",
"translations",
"[",
"locale",
"]",
"transla... | Get translation dictionary
Returns a dictionary for locale or raises an exception if such can't
be located. If a dictionary for locale was previously loaded returns
that, otherwise goes through registered locations and merges any
found custom dictionaries with defaults.
:param l... | [
"Get",
"translation",
"dictionary",
"Returns",
"a",
"dictionary",
"for",
"locale",
"or",
"raises",
"an",
"exception",
"if",
"such",
"can",
"t",
"be",
"located",
".",
"If",
"a",
"dictionary",
"for",
"locale",
"was",
"previously",
"loaded",
"returns",
"that",
... | python | train |
LogicalDash/LiSE | allegedb/allegedb/__init__.py | https://github.com/LogicalDash/LiSE/blob/fe6fd4f0a7c1780e065f4c9babb9bc443af6bb84/allegedb/allegedb/__init__.py#L227-L229 | def setnode(delta, graph, node, exists):
"""Change a delta to say that a node was created or deleted"""
delta.setdefault(graph, {}).setdefault('nodes', {})[node] = bool(exists) | [
"def",
"setnode",
"(",
"delta",
",",
"graph",
",",
"node",
",",
"exists",
")",
":",
"delta",
".",
"setdefault",
"(",
"graph",
",",
"{",
"}",
")",
".",
"setdefault",
"(",
"'nodes'",
",",
"{",
"}",
")",
"[",
"node",
"]",
"=",
"bool",
"(",
"exists",... | Change a delta to say that a node was created or deleted | [
"Change",
"a",
"delta",
"to",
"say",
"that",
"a",
"node",
"was",
"created",
"or",
"deleted"
] | python | train |
ssalentin/plip | plip/modules/detection.py | https://github.com/ssalentin/plip/blob/906c8d36463689779b403f6c2c9ed06174acaf9a/plip/modules/detection.py#L232-L260 | def halogen(acceptor, donor):
"""Detect all halogen bonds of the type Y-O...X-C"""
data = namedtuple('halogenbond', 'acc acc_orig_idx don don_orig_idx distance don_angle acc_angle restype '
'resnr reschain restype_l resnr_l reschain_l donortype acctype sidechain')
pairin... | [
"def",
"halogen",
"(",
"acceptor",
",",
"donor",
")",
":",
"data",
"=",
"namedtuple",
"(",
"'halogenbond'",
",",
"'acc acc_orig_idx don don_orig_idx distance don_angle acc_angle restype '",
"'resnr reschain restype_l resnr_l reschain_l donortype acctype sidechain'",
")",
"pairings"... | Detect all halogen bonds of the type Y-O...X-C | [
"Detect",
"all",
"halogen",
"bonds",
"of",
"the",
"type",
"Y",
"-",
"O",
"...",
"X",
"-",
"C"
] | python | train |
chaoss/grimoirelab-perceval-mozilla | perceval/backends/mozilla/crates.py | https://github.com/chaoss/grimoirelab-perceval-mozilla/blob/4514f8d3d609d3cb79d83c72d51fcc4b4a7daeb4/perceval/backends/mozilla/crates.py#L267-L273 | def summary(self):
"""Get Crates.io summary"""
path = urijoin(CRATES_API_URL, CATEGORY_SUMMARY)
raw_content = self.fetch(path)
return raw_content | [
"def",
"summary",
"(",
"self",
")",
":",
"path",
"=",
"urijoin",
"(",
"CRATES_API_URL",
",",
"CATEGORY_SUMMARY",
")",
"raw_content",
"=",
"self",
".",
"fetch",
"(",
"path",
")",
"return",
"raw_content"
] | Get Crates.io summary | [
"Get",
"Crates",
".",
"io",
"summary"
] | python | test |
mitsei/dlkit | dlkit/json_/learning/managers.py | https://github.com/mitsei/dlkit/blob/445f968a175d61c8d92c0f617a3c17dc1dc7c584/dlkit/json_/learning/managers.py#L1811-L1828 | def get_objective_requisite_session(self, proxy):
"""Gets the session for examining objective requisites.
arg: proxy (osid.proxy.Proxy): a proxy
return: (osid.learning.ObjectiveRequisiteSession) - an
``ObjectiveRequisiteSession``
raise: NullArgument - ``proxy`` is ``... | [
"def",
"get_objective_requisite_session",
"(",
"self",
",",
"proxy",
")",
":",
"if",
"not",
"self",
".",
"supports_objective_requisite",
"(",
")",
":",
"raise",
"errors",
".",
"Unimplemented",
"(",
")",
"# pylint: disable=no-member",
"return",
"sessions",
".",
"Ob... | Gets the session for examining objective requisites.
arg: proxy (osid.proxy.Proxy): a proxy
return: (osid.learning.ObjectiveRequisiteSession) - an
``ObjectiveRequisiteSession``
raise: NullArgument - ``proxy`` is ``null``
raise: OperationFailed - unable to complete r... | [
"Gets",
"the",
"session",
"for",
"examining",
"objective",
"requisites",
"."
] | python | train |
hawkular/hawkular-client-python | hawkular/metrics.py | https://github.com/hawkular/hawkular-client-python/blob/52371f9ebabbe310efee2a8ff8eb735ccc0654bb/hawkular/metrics.py#L223-L242 | def query_metric_definitions(self, metric_type=None, id_filter=None, **tags):
"""
Query available metric definitions.
:param metric_type: A MetricType to be queried. If left to None, matches all the MetricTypes
:param id_filter: Filter the id with regexp is tag filtering is used, otherw... | [
"def",
"query_metric_definitions",
"(",
"self",
",",
"metric_type",
"=",
"None",
",",
"id_filter",
"=",
"None",
",",
"*",
"*",
"tags",
")",
":",
"params",
"=",
"{",
"}",
"if",
"id_filter",
"is",
"not",
"None",
":",
"params",
"[",
"'id'",
"]",
"=",
"i... | Query available metric definitions.
:param metric_type: A MetricType to be queried. If left to None, matches all the MetricTypes
:param id_filter: Filter the id with regexp is tag filtering is used, otherwise a list of exact metric ids
:param tags: A dict of tag key/value pairs. Uses Hawkular-M... | [
"Query",
"available",
"metric",
"definitions",
"."
] | python | train |
cloud9ers/gurumate | environment/lib/python2.7/site-packages/IPython/parallel/controller/sqlitedb.py | https://github.com/cloud9ers/gurumate/blob/075dc74d1ee62a8c6b7a8bf2b271364f01629d1e/environment/lib/python2.7/site-packages/IPython/parallel/controller/sqlitedb.py#L181-L187 | def _defaults(self, keys=None):
"""create an empty record"""
d = {}
keys = self._keys if keys is None else keys
for key in keys:
d[key] = None
return d | [
"def",
"_defaults",
"(",
"self",
",",
"keys",
"=",
"None",
")",
":",
"d",
"=",
"{",
"}",
"keys",
"=",
"self",
".",
"_keys",
"if",
"keys",
"is",
"None",
"else",
"keys",
"for",
"key",
"in",
"keys",
":",
"d",
"[",
"key",
"]",
"=",
"None",
"return"... | create an empty record | [
"create",
"an",
"empty",
"record"
] | python | test |
MostAwesomeDude/blackjack | blackjack.py | https://github.com/MostAwesomeDude/blackjack/blob/1346642e353719ab68c0dc3573aa33b688431bf8/blackjack.py#L65-L73 | def flip(self):
"""
Flip colors of a node and its children.
"""
left = self.left._replace(red=not self.left.red)
right = self.right._replace(red=not self.right.red)
top = self._replace(left=left, right=right, red=not self.red)
return top | [
"def",
"flip",
"(",
"self",
")",
":",
"left",
"=",
"self",
".",
"left",
".",
"_replace",
"(",
"red",
"=",
"not",
"self",
".",
"left",
".",
"red",
")",
"right",
"=",
"self",
".",
"right",
".",
"_replace",
"(",
"red",
"=",
"not",
"self",
".",
"ri... | Flip colors of a node and its children. | [
"Flip",
"colors",
"of",
"a",
"node",
"and",
"its",
"children",
"."
] | python | train |
LudovicRousseau/pyscard | smartcard/ExclusiveTransmitCardConnection.py | https://github.com/LudovicRousseau/pyscard/blob/62e675028086c75656444cc21d563d9f08ebf8e7/smartcard/ExclusiveTransmitCardConnection.py#L63-L83 | def unlock(self):
'''Unlock card with SCardEndTransaction.'''
component = self.component
while True:
if isinstance(
component,
smartcard.pcsc.PCSCCardConnection.PCSCCardConnection):
hresult = SCardEndTransaction(component.hcard,... | [
"def",
"unlock",
"(",
"self",
")",
":",
"component",
"=",
"self",
".",
"component",
"while",
"True",
":",
"if",
"isinstance",
"(",
"component",
",",
"smartcard",
".",
"pcsc",
".",
"PCSCCardConnection",
".",
"PCSCCardConnection",
")",
":",
"hresult",
"=",
"... | Unlock card with SCardEndTransaction. | [
"Unlock",
"card",
"with",
"SCardEndTransaction",
"."
] | python | train |
stain/forgetSQL | lib/forgetSQL.py | https://github.com/stain/forgetSQL/blob/2e13f983020b121fd75a95fcafce3ea75573fb6b/lib/forgetSQL.py#L429-L437 | def save(self):
"""Save to database if anything has changed since last load"""
if ( self._new or
(self._validID() and self._changed) or
(self._updated and self._changed > self._updated) ):
# Don't save if we have not loaded existing data!
self._saveDB()
... | [
"def",
"save",
"(",
"self",
")",
":",
"if",
"(",
"self",
".",
"_new",
"or",
"(",
"self",
".",
"_validID",
"(",
")",
"and",
"self",
".",
"_changed",
")",
"or",
"(",
"self",
".",
"_updated",
"and",
"self",
".",
"_changed",
">",
"self",
".",
"_updat... | Save to database if anything has changed since last load | [
"Save",
"to",
"database",
"if",
"anything",
"has",
"changed",
"since",
"last",
"load"
] | python | train |
senaite/senaite.core | bika/lims/content/calculation.py | https://github.com/senaite/senaite.core/blob/7602ce2ea2f9e81eb34e20ce17b98a3e70713f85/bika/lims/content/calculation.py#L396-L411 | def _getModuleMember(self, dotted_name, member):
"""Get the member object of a module.
:param dotted_name: The dotted name of the module, e.g. 'scipy.special'
:type dotted_name: string
:param member: The name of the member function, e.g. 'gammaincinv'
:type member: string
... | [
"def",
"_getModuleMember",
"(",
"self",
",",
"dotted_name",
",",
"member",
")",
":",
"try",
":",
"mod",
"=",
"importlib",
".",
"import_module",
"(",
"dotted_name",
")",
"except",
"ImportError",
":",
"return",
"None",
"members",
"=",
"dict",
"(",
"inspect",
... | Get the member object of a module.
:param dotted_name: The dotted name of the module, e.g. 'scipy.special'
:type dotted_name: string
:param member: The name of the member function, e.g. 'gammaincinv'
:type member: string
:returns: member object or None | [
"Get",
"the",
"member",
"object",
"of",
"a",
"module",
"."
] | python | train |
PierreRust/apigpio | apigpio/apigpio.py | https://github.com/PierreRust/apigpio/blob/2b969f40e06219b43a43498d8baf87f5935ceab2/apigpio/apigpio.py#L301-L319 | def u2i(uint32):
"""
Converts a 32 bit unsigned number to signed.
uint32:= an unsigned 32 bit number
...
print(u2i(4294967272))
-24
print(u2i(37))
37
...
"""
mask = (2 ** 32) - 1
if uint32 & (1 << 31):
v = uint32 | ~mask
else:
v = uint32 & mask
r... | [
"def",
"u2i",
"(",
"uint32",
")",
":",
"mask",
"=",
"(",
"2",
"**",
"32",
")",
"-",
"1",
"if",
"uint32",
"&",
"(",
"1",
"<<",
"31",
")",
":",
"v",
"=",
"uint32",
"|",
"~",
"mask",
"else",
":",
"v",
"=",
"uint32",
"&",
"mask",
"return",
"v"
... | Converts a 32 bit unsigned number to signed.
uint32:= an unsigned 32 bit number
...
print(u2i(4294967272))
-24
print(u2i(37))
37
... | [
"Converts",
"a",
"32",
"bit",
"unsigned",
"number",
"to",
"signed",
"."
] | python | train |
HydraChain/hydrachain | hydrachain/examples/native/fungible/fungible_contract.py | https://github.com/HydraChain/hydrachain/blob/6c0919b0575dc8aa481f3a8c703e1a7f0575ecc3/hydrachain/examples/native/fungible/fungible_contract.py#L156-L163 | def issue_funds(ctx, amount='uint256', rtgs_hash='bytes32', returns=STATUS):
"In the IOU fungible the supply is set by Issuer, who issue funds."
# allocate new issue as result of a new cash entry
ctx.accounts[ctx.msg_sender] += amount
ctx.issued_amounts[ctx.msg_sender] += amount
... | [
"def",
"issue_funds",
"(",
"ctx",
",",
"amount",
"=",
"'uint256'",
",",
"rtgs_hash",
"=",
"'bytes32'",
",",
"returns",
"=",
"STATUS",
")",
":",
"# allocate new issue as result of a new cash entry",
"ctx",
".",
"accounts",
"[",
"ctx",
".",
"msg_sender",
"]",
"+="... | In the IOU fungible the supply is set by Issuer, who issue funds. | [
"In",
"the",
"IOU",
"fungible",
"the",
"supply",
"is",
"set",
"by",
"Issuer",
"who",
"issue",
"funds",
"."
] | python | test |
offu/WeRoBot | werobot/client.py | https://github.com/offu/WeRoBot/blob/fd42109105b03f9acf45ebd9dcabb9d5cff98f3c/werobot/client.py#L751-L772 | def send_image_message(self, user_id, media_id, kf_account=None):
"""
发送图片消息。
:param user_id: 用户 ID 。 就是你收到的 `Message` 的 source
:param media_id: 图片的媒体ID。 可以通过 :func:`upload_media` 上传。
:param kf_account: 发送消息的客服账户,默认值为 None,None 为不指定
:return: 返回的 JSON 数据包
"""
... | [
"def",
"send_image_message",
"(",
"self",
",",
"user_id",
",",
"media_id",
",",
"kf_account",
"=",
"None",
")",
":",
"data",
"=",
"{",
"\"touser\"",
":",
"user_id",
",",
"\"msgtype\"",
":",
"\"image\"",
",",
"\"image\"",
":",
"{",
"\"media_id\"",
":",
"med... | 发送图片消息。
:param user_id: 用户 ID 。 就是你收到的 `Message` 的 source
:param media_id: 图片的媒体ID。 可以通过 :func:`upload_media` 上传。
:param kf_account: 发送消息的客服账户,默认值为 None,None 为不指定
:return: 返回的 JSON 数据包 | [
"发送图片消息。"
] | python | train |
saltstack/salt | salt/states/environ.py | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/states/environ.py#L34-L184 | def setenv(name,
value,
false_unsets=False,
clear_all=False,
update_minion=False,
permanent=False):
'''
Set the salt process environment variables.
name
The environment key to set. Must be a string.
value
Either a string or dict. W... | [
"def",
"setenv",
"(",
"name",
",",
"value",
",",
"false_unsets",
"=",
"False",
",",
"clear_all",
"=",
"False",
",",
"update_minion",
"=",
"False",
",",
"permanent",
"=",
"False",
")",
":",
"ret",
"=",
"{",
"'name'",
":",
"name",
",",
"'changes'",
":",
... | Set the salt process environment variables.
name
The environment key to set. Must be a string.
value
Either a string or dict. When string, it will be the value
set for the environment key of 'name' above.
When a dict, each key/value pair represents an environment
variab... | [
"Set",
"the",
"salt",
"process",
"environment",
"variables",
"."
] | python | train |
gwpy/gwpy | gwpy/table/io/gwf.py | https://github.com/gwpy/gwpy/blob/7a92b917e7dd2d99b15895293a1fa1d66cdb210a/gwpy/table/io/gwf.py#L45-L63 | def _row_from_frevent(frevent, columns, selection):
"""Generate a table row from an FrEvent
Filtering (``selection``) is done here, rather than in the table reader,
to enable filtering on columns that aren't being returned.
"""
# read params
params = dict(frevent.GetParam())
params['time'] ... | [
"def",
"_row_from_frevent",
"(",
"frevent",
",",
"columns",
",",
"selection",
")",
":",
"# read params",
"params",
"=",
"dict",
"(",
"frevent",
".",
"GetParam",
"(",
")",
")",
"params",
"[",
"'time'",
"]",
"=",
"float",
"(",
"LIGOTimeGPS",
"(",
"*",
"fre... | Generate a table row from an FrEvent
Filtering (``selection``) is done here, rather than in the table reader,
to enable filtering on columns that aren't being returned. | [
"Generate",
"a",
"table",
"row",
"from",
"an",
"FrEvent"
] | python | train |
Capitains/MyCapytain | MyCapytain/resources/texts/remote/cts.py | https://github.com/Capitains/MyCapytain/blob/b11bbf6b6ae141fc02be70471e3fbf6907be6593/MyCapytain/resources/texts/remote/cts.py#L119-L132 | def getReffs(self, level=1, subreference=None):
""" Reference available at a given level
:param level: Depth required. If not set, should retrieve first encountered level (1 based)
:type level: Int
:param subreference: Subreference (optional)
:type subreference: CtsReference
... | [
"def",
"getReffs",
"(",
"self",
",",
"level",
"=",
"1",
",",
"subreference",
"=",
"None",
")",
":",
"if",
"self",
".",
"depth",
"is",
"not",
"None",
":",
"level",
"+=",
"self",
".",
"depth",
"return",
"self",
".",
"getValidReff",
"(",
"level",
",",
... | Reference available at a given level
:param level: Depth required. If not set, should retrieve first encountered level (1 based)
:type level: Int
:param subreference: Subreference (optional)
:type subreference: CtsReference
:rtype: [text_type]
:returns: List of levels | [
"Reference",
"available",
"at",
"a",
"given",
"level"
] | python | train |
secdev/scapy | scapy/utils.py | https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/utils.py#L1151-L1162 | def read_block_epb(self, block, size):
"""Enhanced Packet Block"""
intid, tshigh, tslow, caplen, wirelen = struct.unpack(
self.endian + "5I",
block[:20],
)
return (block[20:20 + caplen][:size],
RawPcapNgReader.PacketMetadata(linktype=self.interface... | [
"def",
"read_block_epb",
"(",
"self",
",",
"block",
",",
"size",
")",
":",
"intid",
",",
"tshigh",
",",
"tslow",
",",
"caplen",
",",
"wirelen",
"=",
"struct",
".",
"unpack",
"(",
"self",
".",
"endian",
"+",
"\"5I\"",
",",
"block",
"[",
":",
"20",
"... | Enhanced Packet Block | [
"Enhanced",
"Packet",
"Block"
] | python | train |
spyder-ide/spyder | spyder/preferences/appearance.py | https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/preferences/appearance.py#L379-L391 | def edit_scheme(self):
"""Edit current scheme."""
dlg = self.scheme_editor_dialog
dlg.set_scheme(self.current_scheme)
if dlg.exec_():
# Update temp scheme to reflect instant edits on the preview
temporal_color_scheme = dlg.get_edited_color_scheme()
fo... | [
"def",
"edit_scheme",
"(",
"self",
")",
":",
"dlg",
"=",
"self",
".",
"scheme_editor_dialog",
"dlg",
".",
"set_scheme",
"(",
"self",
".",
"current_scheme",
")",
"if",
"dlg",
".",
"exec_",
"(",
")",
":",
"# Update temp scheme to reflect instant edits on the preview... | Edit current scheme. | [
"Edit",
"current",
"scheme",
"."
] | python | train |
grycap/RADL | radl/radl.py | https://github.com/grycap/RADL/blob/03ccabb0313a48a5aa0e20c1f7983fddcb95e9cb/radl/radl.py#L1190-L1200 | def get(self, aspect):
"""Get a network, system or configure or contextualize with the same id as aspect passed."""
classification = [(network, self.networks), (system, self.systems),
(configure, self.configures)]
aspect_list = [l for t, l in classification if isinstan... | [
"def",
"get",
"(",
"self",
",",
"aspect",
")",
":",
"classification",
"=",
"[",
"(",
"network",
",",
"self",
".",
"networks",
")",
",",
"(",
"system",
",",
"self",
".",
"systems",
")",
",",
"(",
"configure",
",",
"self",
".",
"configures",
")",
"]"... | Get a network, system or configure or contextualize with the same id as aspect passed. | [
"Get",
"a",
"network",
"system",
"or",
"configure",
"or",
"contextualize",
"with",
"the",
"same",
"id",
"as",
"aspect",
"passed",
"."
] | python | train |
saulpw/visidata | visidata/vdtui.py | https://github.com/saulpw/visidata/blob/32771e0cea6c24fc7902683d14558391395c591f/visidata/vdtui.py#L801-L820 | def drawRightStatus(self, scr, vs):
'Draw right side of status bar. Return length displayed.'
rightx = self.windowWidth-1
ret = 0
for rstatcolor in self.callHook('rstatus', vs):
if rstatcolor:
try:
rstatus, coloropt = rstatcolor
... | [
"def",
"drawRightStatus",
"(",
"self",
",",
"scr",
",",
"vs",
")",
":",
"rightx",
"=",
"self",
".",
"windowWidth",
"-",
"1",
"ret",
"=",
"0",
"for",
"rstatcolor",
"in",
"self",
".",
"callHook",
"(",
"'rstatus'",
",",
"vs",
")",
":",
"if",
"rstatcolor... | Draw right side of status bar. Return length displayed. | [
"Draw",
"right",
"side",
"of",
"status",
"bar",
".",
"Return",
"length",
"displayed",
"."
] | python | train |
vaexio/vaex | packages/vaex-core/vaex/dataframe.py | https://github.com/vaexio/vaex/blob/a45b672f8287afca2ada8e36b74b604b9b28dd85/packages/vaex-core/vaex/dataframe.py#L3397-L3401 | def tail(self, n=10):
"""Return a shallow copy a DataFrame with the last n rows."""
N = len(self)
# self.cat(i1=max(0, N-n), i2=min(len(self), N))
return self[max(0, N - n):min(len(self), N)] | [
"def",
"tail",
"(",
"self",
",",
"n",
"=",
"10",
")",
":",
"N",
"=",
"len",
"(",
"self",
")",
"# self.cat(i1=max(0, N-n), i2=min(len(self), N))",
"return",
"self",
"[",
"max",
"(",
"0",
",",
"N",
"-",
"n",
")",
":",
"min",
"(",
"len",
"(",
"self",
... | Return a shallow copy a DataFrame with the last n rows. | [
"Return",
"a",
"shallow",
"copy",
"a",
"DataFrame",
"with",
"the",
"last",
"n",
"rows",
"."
] | python | test |
GeorgeArgyros/symautomata | symautomata/cfgpda.py | https://github.com/GeorgeArgyros/symautomata/blob/f5d66533573b27e155bec3f36b8c00b8e3937cb3/symautomata/cfgpda.py#L39-L78 | def _mpda(self, re_grammar, splitstring=0):
"""
Args:
re_grammar (list): A list of grammar rules
splitstring (bool): A boolean for enabling or disabling
the splitting of symbols using a space
Returns:
PDA: The generated PDA
... | [
"def",
"_mpda",
"(",
"self",
",",
"re_grammar",
",",
"splitstring",
"=",
"0",
")",
":",
"cnfgrammar",
"=",
"CNFGenerator",
"(",
"re_grammar",
")",
"if",
"not",
"self",
".",
"alphabet",
":",
"self",
".",
"_extract_alphabet",
"(",
"cnfgrammar",
")",
"cnftopd... | Args:
re_grammar (list): A list of grammar rules
splitstring (bool): A boolean for enabling or disabling
the splitting of symbols using a space
Returns:
PDA: The generated PDA | [
"Args",
":",
"re_grammar",
"(",
"list",
")",
":",
"A",
"list",
"of",
"grammar",
"rules",
"splitstring",
"(",
"bool",
")",
":",
"A",
"boolean",
"for",
"enabling",
"or",
"disabling",
"the",
"splitting",
"of",
"symbols",
"using",
"a",
"space",
"Returns",
":... | python | train |
apache/incubator-mxnet | example/rnn/large_word_lm/run_utils.py | https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/example/rnn/large_word_lm/run_utils.py#L66-L90 | def evaluate(mod, data_iter, epoch, log_interval):
""" Run evaluation on cpu. """
start = time.time()
total_L = 0.0
nbatch = 0
density = 0
mod.set_states(value=0)
for batch in data_iter:
mod.forward(batch, is_train=False)
outputs = mod.get_outputs(merge_multi_context=False)
... | [
"def",
"evaluate",
"(",
"mod",
",",
"data_iter",
",",
"epoch",
",",
"log_interval",
")",
":",
"start",
"=",
"time",
".",
"time",
"(",
")",
"total_L",
"=",
"0.0",
"nbatch",
"=",
"0",
"density",
"=",
"0",
"mod",
".",
"set_states",
"(",
"value",
"=",
... | Run evaluation on cpu. | [
"Run",
"evaluation",
"on",
"cpu",
"."
] | python | train |
awslabs/aws-sam-cli | samcli/lib/utils/colors.py | https://github.com/awslabs/aws-sam-cli/blob/c05af5e7378c6f05f7d82ad3f0bca17204177db6/samcli/lib/utils/colors.py#L61-L64 | def _color(self, msg, color):
"""Internal helper method to add colors to input"""
kwargs = {'fg': color}
return click.style(msg, **kwargs) if self.colorize else msg | [
"def",
"_color",
"(",
"self",
",",
"msg",
",",
"color",
")",
":",
"kwargs",
"=",
"{",
"'fg'",
":",
"color",
"}",
"return",
"click",
".",
"style",
"(",
"msg",
",",
"*",
"*",
"kwargs",
")",
"if",
"self",
".",
"colorize",
"else",
"msg"
] | Internal helper method to add colors to input | [
"Internal",
"helper",
"method",
"to",
"add",
"colors",
"to",
"input"
] | python | train |
GNS3/gns3-server | gns3server/config.py | https://github.com/GNS3/gns3-server/blob/a221678448fb5d24e977ef562f81d56aacc89ab1/gns3server/config.py#L157-L164 | def reload(self):
"""
Reload configuration
"""
self.read_config()
for section in self._override_config:
self.set_section_config(section, self._override_config[section]) | [
"def",
"reload",
"(",
"self",
")",
":",
"self",
".",
"read_config",
"(",
")",
"for",
"section",
"in",
"self",
".",
"_override_config",
":",
"self",
".",
"set_section_config",
"(",
"section",
",",
"self",
".",
"_override_config",
"[",
"section",
"]",
")"
] | Reload configuration | [
"Reload",
"configuration"
] | python | train |
jasonrbriggs/proton | python/proton/xmlutils.py | https://github.com/jasonrbriggs/proton/blob/e734734750797ef0caaa1680379e07b86d7a53e3/python/proton/xmlutils.py#L18-L26 | def index(elem):
'''
Return the index position of an element in the children of a parent.
'''
parent = elem.getparent()
for x in range(0, len(parent.getchildren())):
if parent.getchildren()[x] == elem:
return x
return -1 | [
"def",
"index",
"(",
"elem",
")",
":",
"parent",
"=",
"elem",
".",
"getparent",
"(",
")",
"for",
"x",
"in",
"range",
"(",
"0",
",",
"len",
"(",
"parent",
".",
"getchildren",
"(",
")",
")",
")",
":",
"if",
"parent",
".",
"getchildren",
"(",
")",
... | Return the index position of an element in the children of a parent. | [
"Return",
"the",
"index",
"position",
"of",
"an",
"element",
"in",
"the",
"children",
"of",
"a",
"parent",
"."
] | python | train |
johnwmillr/LyricsGenius | lyricsgenius/api.py | https://github.com/johnwmillr/LyricsGenius/blob/e36482f7c42235037f3b9b7013edcd54141124e3/lyricsgenius/api.py#L93-L102 | def search_genius_web(self, search_term, per_page=5):
"""Use the web-version of Genius search"""
endpoint = "search/multi?"
params = {'per_page': per_page, 'q': search_term}
# This endpoint is not part of the API, requires different formatting
url = "https://genius.com/api/" + e... | [
"def",
"search_genius_web",
"(",
"self",
",",
"search_term",
",",
"per_page",
"=",
"5",
")",
":",
"endpoint",
"=",
"\"search/multi?\"",
"params",
"=",
"{",
"'per_page'",
":",
"per_page",
",",
"'q'",
":",
"search_term",
"}",
"# This endpoint is not part of the API,... | Use the web-version of Genius search | [
"Use",
"the",
"web",
"-",
"version",
"of",
"Genius",
"search"
] | python | train |
PmagPy/PmagPy | dialogs/grid_frame3.py | https://github.com/PmagPy/PmagPy/blob/c7984f8809bf40fe112e53dcc311a33293b62d0b/dialogs/grid_frame3.py#L89-L291 | def InitUI(self):
"""
initialize window
"""
self.main_sizer = wx.BoxSizer(wx.VERTICAL)
if self.grid_type in self.contribution.tables:
dataframe = self.contribution.tables[self.grid_type]
else:
dataframe = None
self.grid_builder = GridBuild... | [
"def",
"InitUI",
"(",
"self",
")",
":",
"self",
".",
"main_sizer",
"=",
"wx",
".",
"BoxSizer",
"(",
"wx",
".",
"VERTICAL",
")",
"if",
"self",
".",
"grid_type",
"in",
"self",
".",
"contribution",
".",
"tables",
":",
"dataframe",
"=",
"self",
".",
"con... | initialize window | [
"initialize",
"window"
] | python | train |
astropy/photutils | photutils/detection/findstars.py | https://github.com/astropy/photutils/blob/cc9bb4534ab76bac98cb5f374a348a2573d10401/photutils/detection/findstars.py#L897-L991 | def find_stars(self, data, mask=None):
"""
Find stars in an astronomical image.
Parameters
----------
data : 2D array_like
The 2D image array.
mask : 2D bool array, optional
A boolean mask with the same shape as ``data``, where a
`Tru... | [
"def",
"find_stars",
"(",
"self",
",",
"data",
",",
"mask",
"=",
"None",
")",
":",
"star_cutouts",
"=",
"_find_stars",
"(",
"data",
",",
"self",
".",
"kernel",
",",
"self",
".",
"threshold_eff",
",",
"mask",
"=",
"mask",
",",
"exclude_border",
"=",
"se... | Find stars in an astronomical image.
Parameters
----------
data : 2D array_like
The 2D image array.
mask : 2D bool array, optional
A boolean mask with the same shape as ``data``, where a
`True` value indicates the corresponding element of ``data``
... | [
"Find",
"stars",
"in",
"an",
"astronomical",
"image",
"."
] | python | train |
CI-WATER/gsshapy | gsshapy/orm/msk.py | https://github.com/CI-WATER/gsshapy/blob/00fd4af0fd65f1614d75a52fe950a04fb0867f4c/gsshapy/orm/msk.py#L45-L143 | def generateFromWatershedShapefile(self,
shapefile_path,
cell_size,
out_raster_path=None,
load_raster_to_db=True):
"""
Generates a mask from a water... | [
"def",
"generateFromWatershedShapefile",
"(",
"self",
",",
"shapefile_path",
",",
"cell_size",
",",
"out_raster_path",
"=",
"None",
",",
"load_raster_to_db",
"=",
"True",
")",
":",
"if",
"not",
"self",
".",
"projectFile",
":",
"raise",
"ValueError",
"(",
"\"Must... | Generates a mask from a watershed_shapefile
Example::
from gsshapy.orm import ProjectFile, WatershedMaskFile
from gsshapy.lib import db_tools as dbt
gssha_directory = '/gsshapy/tests/grid_standard/gssha_project'
shapefile_path = 'watershed_boundary.shp'
... | [
"Generates",
"a",
"mask",
"from",
"a",
"watershed_shapefile"
] | python | train |
SpectoLabs/hoverpy | hoverpy/hp.py | https://github.com/SpectoLabs/hoverpy/blob/e153ec57f80634019d827d378f184c01fedc5a0e/hoverpy/hp.py#L135-L148 | def simulation(self, data=None):
"""
Gets / Sets the simulation data.
If no data is passed in, then this method acts as a getter.
if data is passed in, then this method acts as a setter.
Keyword arguments:
data -- the simulation data you wish to set (default None)
... | [
"def",
"simulation",
"(",
"self",
",",
"data",
"=",
"None",
")",
":",
"if",
"data",
":",
"return",
"self",
".",
"_session",
".",
"put",
"(",
"self",
".",
"__v2",
"(",
")",
"+",
"\"/simulation\"",
",",
"data",
"=",
"data",
")",
"else",
":",
"return"... | Gets / Sets the simulation data.
If no data is passed in, then this method acts as a getter.
if data is passed in, then this method acts as a setter.
Keyword arguments:
data -- the simulation data you wish to set (default None) | [
"Gets",
"/",
"Sets",
"the",
"simulation",
"data",
"."
] | python | train |
emory-libraries/eulfedora | eulfedora/syncutil.py | https://github.com/emory-libraries/eulfedora/blob/161826f3fdcdab4007f6fa7dfd9f1ecabc4bcbe4/eulfedora/syncutil.py#L315-L409 | def object_data(self):
'''Process the archival export and return a buffer with foxml
content for ingest into the destination repository.
:returns: :class:`io.BytesIO` for ingest, with references
to uploaded datastream content or content location urls
'''
self.foxml_b... | [
"def",
"object_data",
"(",
"self",
")",
":",
"self",
".",
"foxml_buffer",
"=",
"io",
".",
"BytesIO",
"(",
")",
"if",
"self",
".",
"progress_bar",
":",
"self",
".",
"progress_bar",
".",
"start",
"(",
")",
"previous_section",
"=",
"None",
"while",
"True",
... | Process the archival export and return a buffer with foxml
content for ingest into the destination repository.
:returns: :class:`io.BytesIO` for ingest, with references
to uploaded datastream content or content location urls | [
"Process",
"the",
"archival",
"export",
"and",
"return",
"a",
"buffer",
"with",
"foxml",
"content",
"for",
"ingest",
"into",
"the",
"destination",
"repository",
"."
] | python | train |
ellmetha/django-machina | machina/apps/forum_permission/handler.py | https://github.com/ellmetha/django-machina/blob/89ac083c1eaf1cfdeae6686ee094cc86362e8c69/machina/apps/forum_permission/handler.py#L125-L142 | def can_edit_post(self, post, user):
""" Given a forum post, checks whether the user can edit the latter. """
checker = self._get_checker(user)
# A user can edit a post if...
# they are a superuser
# they are the original poster of the forum post
# they belon... | [
"def",
"can_edit_post",
"(",
"self",
",",
"post",
",",
"user",
")",
":",
"checker",
"=",
"self",
".",
"_get_checker",
"(",
"user",
")",
"# A user can edit a post if...",
"# they are a superuser",
"# they are the original poster of the forum post",
"# they belong... | Given a forum post, checks whether the user can edit the latter. | [
"Given",
"a",
"forum",
"post",
"checks",
"whether",
"the",
"user",
"can",
"edit",
"the",
"latter",
"."
] | python | train |
fastmonkeys/pontus | pontus/_compat.py | https://github.com/fastmonkeys/pontus/blob/cf02fb22c4558b899e2dcbe437a1a525321c4f12/pontus/_compat.py#L25-L33 | def unicode_compatible(cls):
"""
A decorator that defines ``__str__`` and ``__unicode__`` methods
under Python 2.
"""
if not is_py3:
cls.__unicode__ = cls.__str__
cls.__str__ = lambda self: self.__unicode__().encode('utf-8')
return cls | [
"def",
"unicode_compatible",
"(",
"cls",
")",
":",
"if",
"not",
"is_py3",
":",
"cls",
".",
"__unicode__",
"=",
"cls",
".",
"__str__",
"cls",
".",
"__str__",
"=",
"lambda",
"self",
":",
"self",
".",
"__unicode__",
"(",
")",
".",
"encode",
"(",
"'utf-8'"... | A decorator that defines ``__str__`` and ``__unicode__`` methods
under Python 2. | [
"A",
"decorator",
"that",
"defines",
"__str__",
"and",
"__unicode__",
"methods",
"under",
"Python",
"2",
"."
] | python | train |
Tenchi2xh/Almonds | almonds/utils.py | https://github.com/Tenchi2xh/Almonds/blob/6b27024729f055f2cb5e14ae3ca3cb428ae054bc/almonds/utils.py#L59-L70 | def open_file(filename):
"""
Multi-platform way to make the OS open a file with its default application
"""
if sys.platform.startswith("darwin"):
subprocess.call(("open", filename))
elif sys.platform == "cygwin":
subprocess.call(("cygstart", filename))
elif os.name == "nt":
... | [
"def",
"open_file",
"(",
"filename",
")",
":",
"if",
"sys",
".",
"platform",
".",
"startswith",
"(",
"\"darwin\"",
")",
":",
"subprocess",
".",
"call",
"(",
"(",
"\"open\"",
",",
"filename",
")",
")",
"elif",
"sys",
".",
"platform",
"==",
"\"cygwin\"",
... | Multi-platform way to make the OS open a file with its default application | [
"Multi",
"-",
"platform",
"way",
"to",
"make",
"the",
"OS",
"open",
"a",
"file",
"with",
"its",
"default",
"application"
] | python | train |
padfoot27/merlin | venv/lib/python2.7/site-packages/setuptools/sandbox.py | https://github.com/padfoot27/merlin/blob/c317505c5eca0e774fcf8b8c7f08801479a5099a/venv/lib/python2.7/site-packages/setuptools/sandbox.py#L32-L46 | def _execfile(filename, globals, locals=None):
"""
Python 3 implementation of execfile.
"""
mode = 'rb'
# Python 2.6 compile requires LF for newlines, so use deprecated
# Universal newlines support.
if sys.version_info < (2, 7):
mode += 'U'
with open(filename, mode) as stream:
... | [
"def",
"_execfile",
"(",
"filename",
",",
"globals",
",",
"locals",
"=",
"None",
")",
":",
"mode",
"=",
"'rb'",
"# Python 2.6 compile requires LF for newlines, so use deprecated",
"# Universal newlines support.",
"if",
"sys",
".",
"version_info",
"<",
"(",
"2",
",",
... | Python 3 implementation of execfile. | [
"Python",
"3",
"implementation",
"of",
"execfile",
"."
] | python | train |
ToucanToco/toucan-data-sdk | toucan_data_sdk/utils/decorators.py | https://github.com/ToucanToco/toucan-data-sdk/blob/c3ca874e1b64f4bdcc2edda750a72d45d1561d8a/toucan_data_sdk/utils/decorators.py#L109-L120 | def log_message(logger, message=""):
"""
Decorator to log a message before executing a function
"""
def decorator(func):
@wraps(func)
def wrapper(*args, **kwargs):
_log_message(logger, func.__name__, message)
result = func(*args, **kwargs)
return resul... | [
"def",
"log_message",
"(",
"logger",
",",
"message",
"=",
"\"\"",
")",
":",
"def",
"decorator",
"(",
"func",
")",
":",
"@",
"wraps",
"(",
"func",
")",
"def",
"wrapper",
"(",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"_log_message",
"(",
"logg... | Decorator to log a message before executing a function | [
"Decorator",
"to",
"log",
"a",
"message",
"before",
"executing",
"a",
"function"
] | python | test |
apache/airflow | airflow/contrib/hooks/bigquery_hook.py | https://github.com/apache/airflow/blob/b69c686ad8a0c89b9136bb4b31767257eb7b2597/airflow/contrib/hooks/bigquery_hook.py#L1657-L1703 | def get_datasets_list(self, project_id=None):
"""
Method returns full list of BigQuery datasets in the current project
.. seealso::
For more information, see:
https://cloud.google.com/bigquery/docs/reference/rest/v2/datasets/list
:param project_id: Google Cloud ... | [
"def",
"get_datasets_list",
"(",
"self",
",",
"project_id",
"=",
"None",
")",
":",
"dataset_project_id",
"=",
"project_id",
"if",
"project_id",
"else",
"self",
".",
"project_id",
"try",
":",
"datasets_list",
"=",
"self",
".",
"service",
".",
"datasets",
"(",
... | Method returns full list of BigQuery datasets in the current project
.. seealso::
For more information, see:
https://cloud.google.com/bigquery/docs/reference/rest/v2/datasets/list
:param project_id: Google Cloud Project for which you
try to get all datasets
... | [
"Method",
"returns",
"full",
"list",
"of",
"BigQuery",
"datasets",
"in",
"the",
"current",
"project"
] | python | test |
dropbox/stone | stone/backends/obj_c.py | https://github.com/dropbox/stone/blob/2e95cbcd1c48e05cca68c919fd8d24adec6b0f58/stone/backends/obj_c.py#L129-L162 | def _get_imports_m(self, data_types, default_imports):
"""Emits all necessary implementation file imports for the given Stone data type."""
if not isinstance(data_types, list):
data_types = [data_types]
import_classes = default_imports
for data_type in data_types:
... | [
"def",
"_get_imports_m",
"(",
"self",
",",
"data_types",
",",
"default_imports",
")",
":",
"if",
"not",
"isinstance",
"(",
"data_types",
",",
"list",
")",
":",
"data_types",
"=",
"[",
"data_types",
"]",
"import_classes",
"=",
"default_imports",
"for",
"data_ty... | Emits all necessary implementation file imports for the given Stone data type. | [
"Emits",
"all",
"necessary",
"implementation",
"file",
"imports",
"for",
"the",
"given",
"Stone",
"data",
"type",
"."
] | python | train |
iotile/coretools | iotileemulate/iotile/emulate/reference/controller_features/sensor_graph.py | https://github.com/iotile/coretools/blob/2d794f5f1346b841b0dcd16c9d284e9bf2f3c6ec/iotileemulate/iotile/emulate/reference/controller_features/sensor_graph.py#L221-L270 | def _seek_streamer(self, index, value):
"""Complex logic for actually seeking a streamer to a reading_id.
This routine hides all of the gnarly logic of the various edge cases.
In particular, the behavior depends on whether the reading id is found,
and if it is found, whether it belongs ... | [
"def",
"_seek_streamer",
"(",
"self",
",",
"index",
",",
"value",
")",
":",
"highest_id",
"=",
"self",
".",
"_rsl",
".",
"highest_stored_id",
"(",
")",
"streamer",
"=",
"self",
".",
"graph",
".",
"streamers",
"[",
"index",
"]",
"if",
"not",
"streamer",
... | Complex logic for actually seeking a streamer to a reading_id.
This routine hides all of the gnarly logic of the various edge cases.
In particular, the behavior depends on whether the reading id is found,
and if it is found, whether it belongs to the indicated streamer or not.
If not, ... | [
"Complex",
"logic",
"for",
"actually",
"seeking",
"a",
"streamer",
"to",
"a",
"reading_id",
"."
] | python | train |
asmodehn/filefinder2 | filefinder2/_fileloader2.py | https://github.com/asmodehn/filefinder2/blob/3f0b211ce11a34562e2a2160e039ae5290b68d6b/filefinder2/_fileloader2.py#L154-L160 | def is_package(self, fullname):
"""Concrete implementation of InspectLoader.is_package by checking if
the path returned by get_filename has a filename of '__init__.py'."""
filename = os.path.split(self.get_filename(fullname))[1]
filename_base = filename.rsplit('.', 1)[0]
tail_nam... | [
"def",
"is_package",
"(",
"self",
",",
"fullname",
")",
":",
"filename",
"=",
"os",
".",
"path",
".",
"split",
"(",
"self",
".",
"get_filename",
"(",
"fullname",
")",
")",
"[",
"1",
"]",
"filename_base",
"=",
"filename",
".",
"rsplit",
"(",
"'.'",
",... | Concrete implementation of InspectLoader.is_package by checking if
the path returned by get_filename has a filename of '__init__.py'. | [
"Concrete",
"implementation",
"of",
"InspectLoader",
".",
"is_package",
"by",
"checking",
"if",
"the",
"path",
"returned",
"by",
"get_filename",
"has",
"a",
"filename",
"of",
"__init__",
".",
"py",
"."
] | python | train |
eqcorrscan/EQcorrscan | eqcorrscan/utils/despike.py | https://github.com/eqcorrscan/EQcorrscan/blob/3121b4aca801ee5d38f56ca297ce1c0f9515d9ff/eqcorrscan/utils/despike.py#L102-L139 | def _median_window(window, window_start, multiplier, starttime, sampling_rate,
debug=0):
"""
Internal function to aid parallel processing
:type window: numpy.ndarry
:param window: Data to look for peaks in.
:type window_start: int
:param window_start: Index of window start po... | [
"def",
"_median_window",
"(",
"window",
",",
"window_start",
",",
"multiplier",
",",
"starttime",
",",
"sampling_rate",
",",
"debug",
"=",
"0",
")",
":",
"MAD",
"=",
"np",
".",
"median",
"(",
"np",
".",
"abs",
"(",
"window",
")",
")",
"thresh",
"=",
... | Internal function to aid parallel processing
:type window: numpy.ndarry
:param window: Data to look for peaks in.
:type window_start: int
:param window_start: Index of window start point in larger array, used \
for peak indexing.
:type multiplier: float
:param multiplier: Multiple of MA... | [
"Internal",
"function",
"to",
"aid",
"parallel",
"processing"
] | python | train |
inasafe/inasafe | safe/gui/widgets/dock.py | https://github.com/inasafe/inasafe/blob/831d60abba919f6d481dc94a8d988cc205130724/safe/gui/widgets/dock.py#L487-L498 | def disconnect_layer_listener(self):
"""Destroy the signal/slot to listen for layers loaded in QGIS.
..seealso:: connect_layer_listener
"""
project = QgsProject.instance()
project.layersWillBeRemoved.disconnect(self.get_layers)
project.layersAdded.disconnect(self.get_lay... | [
"def",
"disconnect_layer_listener",
"(",
"self",
")",
":",
"project",
"=",
"QgsProject",
".",
"instance",
"(",
")",
"project",
".",
"layersWillBeRemoved",
".",
"disconnect",
"(",
"self",
".",
"get_layers",
")",
"project",
".",
"layersAdded",
".",
"disconnect",
... | Destroy the signal/slot to listen for layers loaded in QGIS.
..seealso:: connect_layer_listener | [
"Destroy",
"the",
"signal",
"/",
"slot",
"to",
"listen",
"for",
"layers",
"loaded",
"in",
"QGIS",
"."
] | python | train |
saltstack/salt | salt/states/mysql_query.py | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/states/mysql_query.py#L53-L222 | def run_file(name,
database,
query_file=None,
output=None,
grain=None,
key=None,
overwrite=True,
saltenv=None,
check_db_exists=True,
**connection_args):
'''
Execute an arbitrary query on the specified database
.. versionadded:: 2017.7.... | [
"def",
"run_file",
"(",
"name",
",",
"database",
",",
"query_file",
"=",
"None",
",",
"output",
"=",
"None",
",",
"grain",
"=",
"None",
",",
"key",
"=",
"None",
",",
"overwrite",
"=",
"True",
",",
"saltenv",
"=",
"None",
",",
"check_db_exists",
"=",
... | Execute an arbitrary query on the specified database
.. versionadded:: 2017.7.0
name
Used only as an ID
database
The name of the database to execute the query_file on
query_file
The file of mysql commands to run
output
grain: output in a grain
other: the ... | [
"Execute",
"an",
"arbitrary",
"query",
"on",
"the",
"specified",
"database"
] | python | train |
mpds-io/python-api-client | mpds_client/retrieve_MPDS.py | https://github.com/mpds-io/python-api-client/blob/edfdd79c6aac44d0a5f7f785e252a88acc95b6fe/mpds_client/retrieve_MPDS.py#L236-L316 | def get_data(self, search, phases=None, fields=default_fields):
"""
Retrieve data in JSON.
JSON is expected to be valid against the schema
at https://developer.mpds.io/mpds.schema.json
Args:
search: (dict) Search query like {"categ_A": "val_A", "categ_B": "val_B"},
... | [
"def",
"get_data",
"(",
"self",
",",
"search",
",",
"phases",
"=",
"None",
",",
"fields",
"=",
"default_fields",
")",
":",
"output",
"=",
"[",
"]",
"fields",
"=",
"{",
"key",
":",
"[",
"jmespath",
".",
"compile",
"(",
"item",
")",
"if",
"isinstance",... | Retrieve data in JSON.
JSON is expected to be valid against the schema
at https://developer.mpds.io/mpds.schema.json
Args:
search: (dict) Search query like {"categ_A": "val_A", "categ_B": "val_B"},
documented at https://developer.mpds.io/#Categories
phase... | [
"Retrieve",
"data",
"in",
"JSON",
".",
"JSON",
"is",
"expected",
"to",
"be",
"valid",
"against",
"the",
"schema",
"at",
"https",
":",
"//",
"developer",
".",
"mpds",
".",
"io",
"/",
"mpds",
".",
"schema",
".",
"json"
] | python | train |
materialsvirtuallab/monty | monty/pprint.py | https://github.com/materialsvirtuallab/monty/blob/d99d6f3c68372d83489d28ff515566c93cd569e2/monty/pprint.py#L10-L42 | def pprint_table(table, out=sys.stdout, rstrip=False):
"""
Prints out a table of data, padded for alignment
Each row must have the same number of columns.
Args:
table: The table to print. A list of lists.
out: Output stream (file-like object)
rstrip: if True, trailing withespace... | [
"def",
"pprint_table",
"(",
"table",
",",
"out",
"=",
"sys",
".",
"stdout",
",",
"rstrip",
"=",
"False",
")",
":",
"def",
"max_width_col",
"(",
"table",
",",
"col_idx",
")",
":",
"\"\"\"\n Get the maximum width of the given column index\n \"\"\"",
"ret... | Prints out a table of data, padded for alignment
Each row must have the same number of columns.
Args:
table: The table to print. A list of lists.
out: Output stream (file-like object)
rstrip: if True, trailing withespaces are removed from the entries. | [
"Prints",
"out",
"a",
"table",
"of",
"data",
"padded",
"for",
"alignment",
"Each",
"row",
"must",
"have",
"the",
"same",
"number",
"of",
"columns",
"."
] | python | train |
pypa/bandersnatch | src/bandersnatch_filter_plugins/whitelist_name.py | https://github.com/pypa/bandersnatch/blob/8b702c3bc128c5a1cbdd18890adede2f7f17fad4/src/bandersnatch_filter_plugins/whitelist_name.py#L28-L48 | def _determine_unfiltered_package_names(self):
"""
Return a list of package names to be filtered base on the configuration
file.
"""
# This plugin only processes packages, if the line in the packages
# configuration contains a PEP440 specifier it will be processed by the
... | [
"def",
"_determine_unfiltered_package_names",
"(",
"self",
")",
":",
"# This plugin only processes packages, if the line in the packages",
"# configuration contains a PEP440 specifier it will be processed by the",
"# blacklist release filter. So we need to remove any packages that",
"# are not ap... | Return a list of package names to be filtered base on the configuration
file. | [
"Return",
"a",
"list",
"of",
"package",
"names",
"to",
"be",
"filtered",
"base",
"on",
"the",
"configuration",
"file",
"."
] | python | train |
reingart/gui2py | gui/graphic.py | https://github.com/reingart/gui2py/blob/aca0a05f6fcde55c94ad7cc058671a06608b01a4/gui/graphic.py#L153-L190 | def _getbitmap_type( self, filename ) :
"""
Get the type of an image from the file's extension ( .jpg, etc. )
"""
# KEA 2001-07-27
# was
#name, ext = filename.split( '.' )
#ext = ext.upper()
if filename is None or filename == '':
retur... | [
"def",
"_getbitmap_type",
"(",
"self",
",",
"filename",
")",
":",
"# KEA 2001-07-27\r",
"# was\r",
"#name, ext = filename.split( '.' )\r",
"#ext = ext.upper()\r",
"if",
"filename",
"is",
"None",
"or",
"filename",
"==",
"''",
":",
"return",
"None",
"name",
",",
"ext"... | Get the type of an image from the file's extension ( .jpg, etc. ) | [
"Get",
"the",
"type",
"of",
"an",
"image",
"from",
"the",
"file",
"s",
"extension",
"(",
".",
"jpg",
"etc",
".",
")"
] | python | test |
saimn/sigal | sigal/image.py | https://github.com/saimn/sigal/blob/912ca39991355d358dc85fd55c7aeabdd7acc386/sigal/image.py#L140-L156 | def generate_thumbnail(source, outname, box, fit=True, options=None,
thumb_fit_centering=(0.5, 0.5)):
"""Create a thumbnail image."""
logger = logging.getLogger(__name__)
img = _read_image(source)
original_format = img.format
if fit:
img = ImageOps.fit(img, box, PILI... | [
"def",
"generate_thumbnail",
"(",
"source",
",",
"outname",
",",
"box",
",",
"fit",
"=",
"True",
",",
"options",
"=",
"None",
",",
"thumb_fit_centering",
"=",
"(",
"0.5",
",",
"0.5",
")",
")",
":",
"logger",
"=",
"logging",
".",
"getLogger",
"(",
"__na... | Create a thumbnail image. | [
"Create",
"a",
"thumbnail",
"image",
"."
] | python | valid |
senaite/senaite.core | bika/lims/content/abstractanalysis.py | https://github.com/senaite/senaite.core/blob/7602ce2ea2f9e81eb34e20ce17b98a3e70713f85/bika/lims/content/abstractanalysis.py#L699-L714 | def isMethodAllowed(self, method):
"""Checks if the analysis can follow the method specified, either if
the method was assigned directly (by using "Allows manual entry of
results") or indirectly via Instrument ("Allows instrument entry of
results") in Analysis Service Edit view.
... | [
"def",
"isMethodAllowed",
"(",
"self",
",",
"method",
")",
":",
"if",
"isinstance",
"(",
"method",
",",
"str",
")",
":",
"uid",
"=",
"method",
"else",
":",
"uid",
"=",
"method",
".",
"UID",
"(",
")",
"return",
"uid",
"in",
"self",
".",
"getAllowedMet... | Checks if the analysis can follow the method specified, either if
the method was assigned directly (by using "Allows manual entry of
results") or indirectly via Instrument ("Allows instrument entry of
results") in Analysis Service Edit view.
Param method can be either a uid or an object
... | [
"Checks",
"if",
"the",
"analysis",
"can",
"follow",
"the",
"method",
"specified",
"either",
"if",
"the",
"method",
"was",
"assigned",
"directly",
"(",
"by",
"using",
"Allows",
"manual",
"entry",
"of",
"results",
")",
"or",
"indirectly",
"via",
"Instrument",
... | python | train |
gitpython-developers/GitPython | git/remote.py | https://github.com/gitpython-developers/GitPython/blob/1f66e25c25cde2423917ee18c4704fff83b837d1/git/remote.py#L602-L613 | def create(cls, repo, name, url, **kwargs):
"""Create a new remote to the given repository
:param repo: Repository instance that is to receive the new remote
:param name: Desired name of the remote
:param url: URL which corresponds to the remote's name
:param kwargs: Additional a... | [
"def",
"create",
"(",
"cls",
",",
"repo",
",",
"name",
",",
"url",
",",
"*",
"*",
"kwargs",
")",
":",
"scmd",
"=",
"'add'",
"kwargs",
"[",
"'insert_kwargs_after'",
"]",
"=",
"scmd",
"repo",
".",
"git",
".",
"remote",
"(",
"scmd",
",",
"name",
",",
... | Create a new remote to the given repository
:param repo: Repository instance that is to receive the new remote
:param name: Desired name of the remote
:param url: URL which corresponds to the remote's name
:param kwargs: Additional arguments to be passed to the git-remote add command
... | [
"Create",
"a",
"new",
"remote",
"to",
"the",
"given",
"repository",
":",
"param",
"repo",
":",
"Repository",
"instance",
"that",
"is",
"to",
"receive",
"the",
"new",
"remote",
":",
"param",
"name",
":",
"Desired",
"name",
"of",
"the",
"remote",
":",
"par... | python | train |
bxlab/bx-python | lib/bx_extras/stats.py | https://github.com/bxlab/bx-python/blob/09cb725284803df90a468d910f2274628d8647de/lib/bx_extras/stats.py#L1403-L1421 | def lksprob(alam):
"""
Computes a Kolmolgorov-Smirnov t-test significance level. Adapted from
Numerical Recipies.
Usage: lksprob(alam)
"""
fac = 2.0
sum = 0.0
termbf = 0.0
a2 = -2.0*alam*alam
for j in range(1,201):
term = fac*math.exp(a2*j*j)
sum = sum + term
if math.... | [
"def",
"lksprob",
"(",
"alam",
")",
":",
"fac",
"=",
"2.0",
"sum",
"=",
"0.0",
"termbf",
"=",
"0.0",
"a2",
"=",
"-",
"2.0",
"*",
"alam",
"*",
"alam",
"for",
"j",
"in",
"range",
"(",
"1",
",",
"201",
")",
":",
"term",
"=",
"fac",
"*",
"math",
... | Computes a Kolmolgorov-Smirnov t-test significance level. Adapted from
Numerical Recipies.
Usage: lksprob(alam) | [
"Computes",
"a",
"Kolmolgorov",
"-",
"Smirnov",
"t",
"-",
"test",
"significance",
"level",
".",
"Adapted",
"from",
"Numerical",
"Recipies",
"."
] | python | train |
pycontribs/pyrax | pyrax/clouddatabases.py | https://github.com/pycontribs/pyrax/blob/9ddfd5064b3a292d7337906f3b2d5dce95b50b99/pyrax/clouddatabases.py#L552-L557 | def list_backups(self, limit=20, marker=0):
"""
Returns a paginated list of backups for this instance.
"""
return self.manager._list_backups_for_instance(self, limit=limit,
marker=marker) | [
"def",
"list_backups",
"(",
"self",
",",
"limit",
"=",
"20",
",",
"marker",
"=",
"0",
")",
":",
"return",
"self",
".",
"manager",
".",
"_list_backups_for_instance",
"(",
"self",
",",
"limit",
"=",
"limit",
",",
"marker",
"=",
"marker",
")"
] | Returns a paginated list of backups for this instance. | [
"Returns",
"a",
"paginated",
"list",
"of",
"backups",
"for",
"this",
"instance",
"."
] | python | train |
moonso/vcftoolbox | vcftoolbox/header_parser.py | https://github.com/moonso/vcftoolbox/blob/438fb1d85a83812c389774b94802eb5921c89e3a/vcftoolbox/header_parser.py#L249-L269 | def remove_header(self, name):
"""Remove a field from the header"""
if name in self.info_dict:
self.info_dict.pop(name)
logger.info("Removed '{0}' from INFO".format(name))
if name in self.filter_dict:
self.filter_dict.pop(name)
logger.info("Removed... | [
"def",
"remove_header",
"(",
"self",
",",
"name",
")",
":",
"if",
"name",
"in",
"self",
".",
"info_dict",
":",
"self",
".",
"info_dict",
".",
"pop",
"(",
"name",
")",
"logger",
".",
"info",
"(",
"\"Removed '{0}' from INFO\"",
".",
"format",
"(",
"name",
... | Remove a field from the header | [
"Remove",
"a",
"field",
"from",
"the",
"header"
] | python | train |
mozillazg/python-shanbay | shanbay/team.py | https://github.com/mozillazg/python-shanbay/blob/d505ba614dc13a36afce46969d13fc64e10dde0d/shanbay/team.py#L116-L121 | def members(self):
"""获取小组所有成员的信息列表"""
all_members = []
for page in range(1, self.max_page() + 1):
all_members.extend(self.single_page_members(page))
return all_members | [
"def",
"members",
"(",
"self",
")",
":",
"all_members",
"=",
"[",
"]",
"for",
"page",
"in",
"range",
"(",
"1",
",",
"self",
".",
"max_page",
"(",
")",
"+",
"1",
")",
":",
"all_members",
".",
"extend",
"(",
"self",
".",
"single_page_members",
"(",
"... | 获取小组所有成员的信息列表 | [
"获取小组所有成员的信息列表"
] | python | train |
DinoTools/python-overpy | overpy/__init__.py | https://github.com/DinoTools/python-overpy/blob/db8f80eeb1b4d1405816bd62c16ddb3364e0c46d/overpy/__init__.py#L1464-L1486 | def _handle_start_node(self, attrs):
"""
Handle opening node element
:param attrs: Attributes of the element
:type attrs: Dict
"""
self._curr = {
'attributes': dict(attrs),
'lat': None,
'lon': None,
'node_id': None,
... | [
"def",
"_handle_start_node",
"(",
"self",
",",
"attrs",
")",
":",
"self",
".",
"_curr",
"=",
"{",
"'attributes'",
":",
"dict",
"(",
"attrs",
")",
",",
"'lat'",
":",
"None",
",",
"'lon'",
":",
"None",
",",
"'node_id'",
":",
"None",
",",
"'tags'",
":",... | Handle opening node element
:param attrs: Attributes of the element
:type attrs: Dict | [
"Handle",
"opening",
"node",
"element"
] | python | train |
pywbem/pywbem | pywbem/_statistics.py | https://github.com/pywbem/pywbem/blob/e54ecb82c2211e289a268567443d60fdd489f1e4/pywbem/_statistics.py#L508-L543 | def formatted(self, include_server_time):
"""
Return a formatted one-line string with the statistics
values for the operation for which this statistics object
maintains data.
This is a low-level method that is called by
:meth:`pywbem.Statistics.formatted`.
"""
... | [
"def",
"formatted",
"(",
"self",
",",
"include_server_time",
")",
":",
"if",
"include_server_time",
":",
"# pylint: disable=no-else-return",
"return",
"(",
"'{0:5d} {1:5d} '",
"'{2:7.3f} {3:7.3f} {4:7.3f} '",
"'{5:7.3f} {6:7.3f} {7:7.3f} '",
"'{8:6.0f} {9:6.0f} {10:6.0f} '",
"'{1... | Return a formatted one-line string with the statistics
values for the operation for which this statistics object
maintains data.
This is a low-level method that is called by
:meth:`pywbem.Statistics.formatted`. | [
"Return",
"a",
"formatted",
"one",
"-",
"line",
"string",
"with",
"the",
"statistics",
"values",
"for",
"the",
"operation",
"for",
"which",
"this",
"statistics",
"object",
"maintains",
"data",
"."
] | python | train |
base4sistemas/pyescpos | escpos/conn/serial.py | https://github.com/base4sistemas/pyescpos/blob/621bd00f1499aff700f37d8d36d04e0d761708f1/escpos/conn/serial.py#L131-L139 | def get_parities():
"""
Returns supported parities in a Django-like choices tuples.
"""
parities = []
s = pyserial.Serial()
for name, value in s.getSupportedParities():
parities.append((value, name,))
return tuple(parities) | [
"def",
"get_parities",
"(",
")",
":",
"parities",
"=",
"[",
"]",
"s",
"=",
"pyserial",
".",
"Serial",
"(",
")",
"for",
"name",
",",
"value",
"in",
"s",
".",
"getSupportedParities",
"(",
")",
":",
"parities",
".",
"append",
"(",
"(",
"value",
",",
"... | Returns supported parities in a Django-like choices tuples. | [
"Returns",
"supported",
"parities",
"in",
"a",
"Django",
"-",
"like",
"choices",
"tuples",
"."
] | python | train |
numberoverzero/accordian | accordian.py | https://github.com/numberoverzero/accordian/blob/f1fe44dc9c646006418017bbf70f597b180c8b97/accordian.py#L118-L131 | def unregister(self, event):
"""
Remove all registered handlers for an event.
Silent return when event was not registered.
Usage:
dispatch.unregister("my_event")
dispatch.unregister("my_event") # no-op
"""
if self.running:
raise Run... | [
"def",
"unregister",
"(",
"self",
",",
"event",
")",
":",
"if",
"self",
".",
"running",
":",
"raise",
"RuntimeError",
"(",
"\"Can't unregister while running\"",
")",
"self",
".",
"_handlers",
".",
"pop",
"(",
"event",
",",
"None",
")"
] | Remove all registered handlers for an event.
Silent return when event was not registered.
Usage:
dispatch.unregister("my_event")
dispatch.unregister("my_event") # no-op | [
"Remove",
"all",
"registered",
"handlers",
"for",
"an",
"event",
".",
"Silent",
"return",
"when",
"event",
"was",
"not",
"registered",
"."
] | python | train |
SBRG/ssbio | ssbio/protein/sequence/utils/fasta.py | https://github.com/SBRG/ssbio/blob/e9449e64ffc1a1f5ad07e5849aa12a650095f8a2/ssbio/protein/sequence/utils/fasta.py#L131-L153 | def fasta_files_equal(seq_file1, seq_file2):
"""Check equality of a FASTA file to another FASTA file
Args:
seq_file1: Path to a FASTA file
seq_file2: Path to another FASTA file
Returns:
bool: If the sequences are the same
"""
# Load already set representative sequence
... | [
"def",
"fasta_files_equal",
"(",
"seq_file1",
",",
"seq_file2",
")",
":",
"# Load already set representative sequence",
"seq1",
"=",
"SeqIO",
".",
"read",
"(",
"open",
"(",
"seq_file1",
")",
",",
"'fasta'",
")",
"# Load kegg sequence",
"seq2",
"=",
"SeqIO",
".",
... | Check equality of a FASTA file to another FASTA file
Args:
seq_file1: Path to a FASTA file
seq_file2: Path to another FASTA file
Returns:
bool: If the sequences are the same | [
"Check",
"equality",
"of",
"a",
"FASTA",
"file",
"to",
"another",
"FASTA",
"file"
] | python | train |
pjuren/pyokit | src/pyokit/io/indexedFile.py | https://github.com/pjuren/pyokit/blob/fddae123b5d817daa39496183f19c000d9c3791f/src/pyokit/io/indexedFile.py#L284-L390 | def read_index(self, fh, indexed_fh, rec_iterator=None,
rec_hash_func=None, parse_hash=str, flush=True,
no_reindex=True, verbose=False):
"""
Populate this index from a file. Input format is just a tab-separated file,
one record per line. The last column is the file location... | [
"def",
"read_index",
"(",
"self",
",",
"fh",
",",
"indexed_fh",
",",
"rec_iterator",
"=",
"None",
",",
"rec_hash_func",
"=",
"None",
",",
"parse_hash",
"=",
"str",
",",
"flush",
"=",
"True",
",",
"no_reindex",
"=",
"True",
",",
"verbose",
"=",
"False",
... | Populate this index from a file. Input format is just a tab-separated file,
one record per line. The last column is the file location for the record
and all columns before that are collectively considered to be the hash key
for that record (which is probably only 1 column, but this allows us to
permit t... | [
"Populate",
"this",
"index",
"from",
"a",
"file",
".",
"Input",
"format",
"is",
"just",
"a",
"tab",
"-",
"separated",
"file",
"one",
"record",
"per",
"line",
".",
"The",
"last",
"column",
"is",
"the",
"file",
"location",
"for",
"the",
"record",
"and",
... | python | train |
cyrus-/cypy | cypy/np/plotting.py | https://github.com/cyrus-/cypy/blob/04bb59e91fa314e8cf987743189c77a9b6bc371d/cypy/np/plotting.py#L25-L39 | def raster(times, indices, max_time=None, max_index=None,
x_label="Timestep", y_label="Index", **kwargs):
"""Plots a raster plot given times and indices of events."""
# set default size to 1
if 's' not in kwargs:
kwargs['s'] = 1
scatter(times, indices, **kwargs)
if max_time ... | [
"def",
"raster",
"(",
"times",
",",
"indices",
",",
"max_time",
"=",
"None",
",",
"max_index",
"=",
"None",
",",
"x_label",
"=",
"\"Timestep\"",
",",
"y_label",
"=",
"\"Index\"",
",",
"*",
"*",
"kwargs",
")",
":",
"# set default size to 1",
"if",
"'s'",
... | Plots a raster plot given times and indices of events. | [
"Plots",
"a",
"raster",
"plot",
"given",
"times",
"and",
"indices",
"of",
"events",
"."
] | python | train |
leosartaj/tvstats | tvstats/graph.py | https://github.com/leosartaj/tvstats/blob/164fe736111d43869f8c9686e07a5ab1b9f22444/tvstats/graph.py#L7-L24 | def graphdata(data):
"""returns ratings and episode number
to be used for making graphs"""
data = jh.get_ratings(data)
num = 1
rating_final = []
episode_final = []
for k,v in data.iteritems():
rating=[]
epinum=[]
for r in v:
if r != None:
r... | [
"def",
"graphdata",
"(",
"data",
")",
":",
"data",
"=",
"jh",
".",
"get_ratings",
"(",
"data",
")",
"num",
"=",
"1",
"rating_final",
"=",
"[",
"]",
"episode_final",
"=",
"[",
"]",
"for",
"k",
",",
"v",
"in",
"data",
".",
"iteritems",
"(",
")",
":... | returns ratings and episode number
to be used for making graphs | [
"returns",
"ratings",
"and",
"episode",
"number",
"to",
"be",
"used",
"for",
"making",
"graphs"
] | python | train |
ihgazni2/elist | elist/elist.py | https://github.com/ihgazni2/elist/blob/8c07b5029bda34ead60ce10335ceb145f209263c/elist/elist.py#L6617-L6630 | def is_lop(ch,block_op_pairs_dict=get_block_op_pairs('{}[]()')):
'''
# is_lop('{',block_op_pairs_dict)
# is_lop('[',block_op_pairs_dict)
# is_lop('}',block_op_pairs_dict)
# is_lop(']',block_op_pairs_dict)
# is_lop('a',block_op_pairs_dict)
'''
for i in range(1,block_op_pairs_dict.__len__(... | [
"def",
"is_lop",
"(",
"ch",
",",
"block_op_pairs_dict",
"=",
"get_block_op_pairs",
"(",
"'{}[]()'",
")",
")",
":",
"for",
"i",
"in",
"range",
"(",
"1",
",",
"block_op_pairs_dict",
".",
"__len__",
"(",
")",
"+",
"1",
")",
":",
"if",
"(",
"ch",
"==",
"... | # is_lop('{',block_op_pairs_dict)
# is_lop('[',block_op_pairs_dict)
# is_lop('}',block_op_pairs_dict)
# is_lop(']',block_op_pairs_dict)
# is_lop('a',block_op_pairs_dict) | [
"#",
"is_lop",
"(",
"{",
"block_op_pairs_dict",
")",
"#",
"is_lop",
"(",
"[",
"block_op_pairs_dict",
")",
"#",
"is_lop",
"(",
"}",
"block_op_pairs_dict",
")",
"#",
"is_lop",
"(",
"]",
"block_op_pairs_dict",
")",
"#",
"is_lop",
"(",
"a",
"block_op_pairs_dict",
... | python | valid |
cqparts/cqparts | src/cqparts/display/__init__.py | https://github.com/cqparts/cqparts/blob/018e87e14c2c4d1d40b4bfe6a7e22bcf9baf0a53/src/cqparts/display/__init__.py#L66-L83 | def display(component, **kwargs):
"""
Display the given component based on the environment it's run from.
See :class:`DisplayEnvironment <cqparts.display.environment.DisplayEnvironment>`
documentation for more details.
:param component: component to display
:type component: :class:`Component <c... | [
"def",
"display",
"(",
"component",
",",
"*",
"*",
"kwargs",
")",
":",
"disp_env",
"=",
"get_display_environment",
"(",
")",
"if",
"disp_env",
"is",
"None",
":",
"raise",
"LookupError",
"(",
"'valid display environment could not be found'",
")",
"disp_env",
".",
... | Display the given component based on the environment it's run from.
See :class:`DisplayEnvironment <cqparts.display.environment.DisplayEnvironment>`
documentation for more details.
:param component: component to display
:type component: :class:`Component <cqparts.Component>`
Additional parameters ... | [
"Display",
"the",
"given",
"component",
"based",
"on",
"the",
"environment",
"it",
"s",
"run",
"from",
".",
"See",
":",
"class",
":",
"DisplayEnvironment",
"<cqparts",
".",
"display",
".",
"environment",
".",
"DisplayEnvironment",
">",
"documentation",
"for",
... | python | train |
spyder-ide/spyder | spyder/plugins/editor/plugin.py | https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/plugins/editor/plugin.py#L1930-L1938 | def open_last_closed(self):
""" Reopens the last closed tab."""
editorstack = self.get_current_editorstack()
last_closed_files = editorstack.get_last_closed_files()
if (len(last_closed_files) > 0):
file_to_open = last_closed_files[0]
last_closed_files.remove... | [
"def",
"open_last_closed",
"(",
"self",
")",
":",
"editorstack",
"=",
"self",
".",
"get_current_editorstack",
"(",
")",
"last_closed_files",
"=",
"editorstack",
".",
"get_last_closed_files",
"(",
")",
"if",
"(",
"len",
"(",
"last_closed_files",
")",
">",
"0",
... | Reopens the last closed tab. | [
"Reopens",
"the",
"last",
"closed",
"tab",
"."
] | python | train |
ianmiell/shutit | shutit_class.py | https://github.com/ianmiell/shutit/blob/19cd64cdfb23515b106b40213dccff4101617076/shutit_class.py#L1785-L1796 | def step_through(self, msg='', shutit_pexpect_child=None, level=1, print_input=True, value=True):
"""Implements a step-through function, using pause_point.
"""
shutit_global.shutit_global_object.yield_to_draw()
shutit_pexpect_child = shutit_pexpect_child or self.get_current_shutit_pexpect_session().pexpect_chil... | [
"def",
"step_through",
"(",
"self",
",",
"msg",
"=",
"''",
",",
"shutit_pexpect_child",
"=",
"None",
",",
"level",
"=",
"1",
",",
"print_input",
"=",
"True",
",",
"value",
"=",
"True",
")",
":",
"shutit_global",
".",
"shutit_global_object",
".",
"yield_to_... | Implements a step-through function, using pause_point. | [
"Implements",
"a",
"step",
"-",
"through",
"function",
"using",
"pause_point",
"."
] | python | train |
minus7/asif | asif/bot.py | https://github.com/minus7/asif/blob/0d8acc5306ba93386ec679f69d466b56f099b877/asif/bot.py#L680-L687 | def _populate(self, client):
"""
Populate module with the client when available
"""
self.client = client
for fn in self._buffered_calls:
self._log.debug("Executing buffered call {}".format(fn))
fn() | [
"def",
"_populate",
"(",
"self",
",",
"client",
")",
":",
"self",
".",
"client",
"=",
"client",
"for",
"fn",
"in",
"self",
".",
"_buffered_calls",
":",
"self",
".",
"_log",
".",
"debug",
"(",
"\"Executing buffered call {}\"",
".",
"format",
"(",
"fn",
")... | Populate module with the client when available | [
"Populate",
"module",
"with",
"the",
"client",
"when",
"available"
] | python | train |
StackStorm/pybind | pybind/slxos/v17r_2_00/interface/port_channel/__init__.py | https://github.com/StackStorm/pybind/blob/44c467e71b2b425be63867aba6e6fa28b2cfe7fb/pybind/slxos/v17r_2_00/interface/port_channel/__init__.py#L1151-L1181 | def _set_port_profile_port(self, v, load=False):
"""
Setter method for port_profile_port, mapped from YANG variable /interface/port_channel/port_profile_port (empty)
If this variable is read-only (config: false) in the
source YANG file, then _set_port_profile_port is considered as a private
method. ... | [
"def",
"_set_port_profile_port",
"(",
"self",
",",
"v",
",",
"load",
"=",
"False",
")",
":",
"if",
"hasattr",
"(",
"v",
",",
"\"_utype\"",
")",
":",
"v",
"=",
"v",
".",
"_utype",
"(",
"v",
")",
"try",
":",
"t",
"=",
"YANGDynClass",
"(",
"v",
",",... | Setter method for port_profile_port, mapped from YANG variable /interface/port_channel/port_profile_port (empty)
If this variable is read-only (config: false) in the
source YANG file, then _set_port_profile_port is considered as a private
method. Backends looking to populate this variable should
do so v... | [
"Setter",
"method",
"for",
"port_profile_port",
"mapped",
"from",
"YANG",
"variable",
"/",
"interface",
"/",
"port_channel",
"/",
"port_profile_port",
"(",
"empty",
")",
"If",
"this",
"variable",
"is",
"read",
"-",
"only",
"(",
"config",
":",
"false",
")",
"... | python | train |
greenbone/ospd | ospd/misc.py | https://github.com/greenbone/ospd/blob/cef773166b15a19c17764721d3fe404fa0e107bf/ospd/misc.py#L130-L140 | def get_hosts_unfinished(self, scan_id):
""" Get a list of finished hosts."""
unfinished_hosts = list()
for target in self.scans_table[scan_id]['finished_hosts']:
unfinished_hosts.extend(target_str_to_list(target))
for target in self.scans_table[scan_id]['finished_hosts']:
... | [
"def",
"get_hosts_unfinished",
"(",
"self",
",",
"scan_id",
")",
":",
"unfinished_hosts",
"=",
"list",
"(",
")",
"for",
"target",
"in",
"self",
".",
"scans_table",
"[",
"scan_id",
"]",
"[",
"'finished_hosts'",
"]",
":",
"unfinished_hosts",
".",
"extend",
"("... | Get a list of finished hosts. | [
"Get",
"a",
"list",
"of",
"finished",
"hosts",
"."
] | python | train |
googlefonts/fontbakery | Lib/fontbakery/profiles/googlefonts.py | https://github.com/googlefonts/fontbakery/blob/b355aea2e619a4477769e060d24c32448aa65399/Lib/fontbakery/profiles/googlefonts.py#L3127-L3167 | def com_google_fonts_check_name_typographicsubfamilyname(ttFont, style_with_spaces):
""" Check name table: TYPOGRAPHIC_SUBFAMILY_NAME entries. """
from fontbakery.utils import name_entry_id
failed = False
if style_with_spaces in ['Regular',
'Italic',
'Bold'... | [
"def",
"com_google_fonts_check_name_typographicsubfamilyname",
"(",
"ttFont",
",",
"style_with_spaces",
")",
":",
"from",
"fontbakery",
".",
"utils",
"import",
"name_entry_id",
"failed",
"=",
"False",
"if",
"style_with_spaces",
"in",
"[",
"'Regular'",
",",
"'Italic'",
... | Check name table: TYPOGRAPHIC_SUBFAMILY_NAME entries. | [
"Check",
"name",
"table",
":",
"TYPOGRAPHIC_SUBFAMILY_NAME",
"entries",
"."
] | python | train |
brocade/pynos | pynos/versions/ver_6/ver_6_0_1/yang/brocade_netconf_ext.py | https://github.com/brocade/pynos/blob/bd8a34e98f322de3fc06750827d8bbc3a0c00380/pynos/versions/ver_6/ver_6_0_1/yang/brocade_netconf_ext.py#L81-L93 | def get_netconf_client_capabilities_output_session_version(self, **kwargs):
"""Auto Generated Code
"""
config = ET.Element("config")
get_netconf_client_capabilities = ET.Element("get_netconf_client_capabilities")
config = get_netconf_client_capabilities
output = ET.SubEle... | [
"def",
"get_netconf_client_capabilities_output_session_version",
"(",
"self",
",",
"*",
"*",
"kwargs",
")",
":",
"config",
"=",
"ET",
".",
"Element",
"(",
"\"config\"",
")",
"get_netconf_client_capabilities",
"=",
"ET",
".",
"Element",
"(",
"\"get_netconf_client_capab... | Auto Generated Code | [
"Auto",
"Generated",
"Code"
] | python | train |
mattupstate/flask-security | flask_security/utils.py | https://github.com/mattupstate/flask-security/blob/a401fb47018fbbbe0b899ea55afadfd0e3cd847a/flask_security/utils.py#L114-L129 | def get_hmac(password):
"""Returns a Base64 encoded HMAC+SHA512 of the password signed with
the salt specified by ``SECURITY_PASSWORD_SALT``.
:param password: The password to sign
"""
salt = _security.password_salt
if salt is None:
raise RuntimeError(
'The configuration val... | [
"def",
"get_hmac",
"(",
"password",
")",
":",
"salt",
"=",
"_security",
".",
"password_salt",
"if",
"salt",
"is",
"None",
":",
"raise",
"RuntimeError",
"(",
"'The configuration value `SECURITY_PASSWORD_SALT` must '",
"'not be None when the value of `SECURITY_PASSWORD_HASH` is... | Returns a Base64 encoded HMAC+SHA512 of the password signed with
the salt specified by ``SECURITY_PASSWORD_SALT``.
:param password: The password to sign | [
"Returns",
"a",
"Base64",
"encoded",
"HMAC",
"+",
"SHA512",
"of",
"the",
"password",
"signed",
"with",
"the",
"salt",
"specified",
"by",
"SECURITY_PASSWORD_SALT",
"."
] | python | train |
sivakov512/python-static-api-generator | static_api_generator/loaders.py | https://github.com/sivakov512/python-static-api-generator/blob/0a7ec27324b9b2a3d1fa9894c4cba73af9ebcc01/static_api_generator/loaders.py#L26-L34 | def _validate_extension(self):
"""Validates that source file extension is supported.
:raises: UnsupportedExtensionError
"""
extension = self.fpath.split('.')[-1]
if extension not in self.supported_extensions:
raise UnsupportedExtensionError | [
"def",
"_validate_extension",
"(",
"self",
")",
":",
"extension",
"=",
"self",
".",
"fpath",
".",
"split",
"(",
"'.'",
")",
"[",
"-",
"1",
"]",
"if",
"extension",
"not",
"in",
"self",
".",
"supported_extensions",
":",
"raise",
"UnsupportedExtensionError"
] | Validates that source file extension is supported.
:raises: UnsupportedExtensionError | [
"Validates",
"that",
"source",
"file",
"extension",
"is",
"supported",
"."
] | python | train |
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#L1410-L1423 | def delete_dcnm_out_nwk(self, tenant_id, fw_dict, is_fw_virt=False):
"""Delete the DCNM OUT network and update the result. """
tenant_name = fw_dict.get('tenant_name')
ret = self._delete_service_nwk(tenant_id, tenant_name, 'out')
if ret:
res = fw_const.DCNM_OUT_NETWORK_DEL_SU... | [
"def",
"delete_dcnm_out_nwk",
"(",
"self",
",",
"tenant_id",
",",
"fw_dict",
",",
"is_fw_virt",
"=",
"False",
")",
":",
"tenant_name",
"=",
"fw_dict",
".",
"get",
"(",
"'tenant_name'",
")",
"ret",
"=",
"self",
".",
"_delete_service_nwk",
"(",
"tenant_id",
",... | Delete the DCNM OUT network and update the result. | [
"Delete",
"the",
"DCNM",
"OUT",
"network",
"and",
"update",
"the",
"result",
"."
] | python | train |
google/budou | budou/budou.py | https://github.com/google/budou/blob/101224e6523186851f38ee57a6b2e7bdbd826de2/budou/budou.py#L86-L104 | def authenticate(json_path=None):
"""Gets a Natural Language API parser by authenticating the API.
**This method is deprecated.** Please use :obj:`budou.get_parser` to obtain a
parser instead.
Args:
json_path (:obj:`str`, optional): The file path to the service account's
credentials.
Returns:
... | [
"def",
"authenticate",
"(",
"json_path",
"=",
"None",
")",
":",
"msg",
"=",
"(",
"'budou.authentication() is deprecated. '",
"'Please use budou.get_parser() to obtain a parser instead.'",
")",
"warnings",
".",
"warn",
"(",
"msg",
",",
"DeprecationWarning",
")",
"parser",
... | Gets a Natural Language API parser by authenticating the API.
**This method is deprecated.** Please use :obj:`budou.get_parser` to obtain a
parser instead.
Args:
json_path (:obj:`str`, optional): The file path to the service account's
credentials.
Returns:
Parser. (:obj:`budou.parser.NLAPIPar... | [
"Gets",
"a",
"Natural",
"Language",
"API",
"parser",
"by",
"authenticating",
"the",
"API",
"."
] | python | train |
log2timeline/dfvfs | dfvfs/file_io/sqlite_blob_file_io.py | https://github.com/log2timeline/dfvfs/blob/2b3ccd115f9901d89f383397d4a1376a873c83c4/dfvfs/file_io/sqlite_blob_file_io.py#L217-L242 | def seek(self, offset, whence=os.SEEK_SET):
"""Seeks to an offset within the file-like object.
Args:
offset (int): offset to seek to.
whence (Optional(int)): value that indicates whether offset is an absolute
or relative position within the file.
Raises:
IOError: if the seek fa... | [
"def",
"seek",
"(",
"self",
",",
"offset",
",",
"whence",
"=",
"os",
".",
"SEEK_SET",
")",
":",
"if",
"not",
"self",
".",
"_database_object",
":",
"raise",
"IOError",
"(",
"'Not opened.'",
")",
"if",
"whence",
"==",
"os",
".",
"SEEK_CUR",
":",
"offset"... | Seeks to an offset within the file-like object.
Args:
offset (int): offset to seek to.
whence (Optional(int)): value that indicates whether offset is an absolute
or relative position within the file.
Raises:
IOError: if the seek failed.
OSError: if the seek failed. | [
"Seeks",
"to",
"an",
"offset",
"within",
"the",
"file",
"-",
"like",
"object",
"."
] | python | train |
gbiggs/rtctree | rtctree/component.py | https://github.com/gbiggs/rtctree/blob/bd725a47ac87c259c8bce06156ccc9ab71111c26/rtctree/component.py#L532-L552 | def activate_in_ec(self, ec_index):
'''Activate this component in an execution context.
@param ec_index The index of the execution context to activate in.
This index is into the total array of contexts, that
is both owned and participating contexts. If th... | [
"def",
"activate_in_ec",
"(",
"self",
",",
"ec_index",
")",
":",
"with",
"self",
".",
"_mutex",
":",
"if",
"ec_index",
">=",
"len",
"(",
"self",
".",
"owned_ecs",
")",
":",
"ec_index",
"-=",
"len",
"(",
"self",
".",
"owned_ecs",
")",
"if",
"ec_index",
... | Activate this component in an execution context.
@param ec_index The index of the execution context to activate in.
This index is into the total array of contexts, that
is both owned and participating contexts. If the value
of ec_index is ... | [
"Activate",
"this",
"component",
"in",
"an",
"execution",
"context",
"."
] | python | train |
oseledets/ttpy | tt/core/vector.py | https://github.com/oseledets/ttpy/blob/b440f6299a6338de4aea67f3d839d613f4ef1374/tt/core/vector.py#L127-L145 | def erank(self):
""" Effective rank of the TT-vector """
r = self.r
n = self.n
d = self.d
if d <= 1:
er = 0e0
else:
sz = _np.dot(n * r[0:d], r[1:])
if sz == 0:
er = 0e0
else:
b = r[0] * n[0] +... | [
"def",
"erank",
"(",
"self",
")",
":",
"r",
"=",
"self",
".",
"r",
"n",
"=",
"self",
".",
"n",
"d",
"=",
"self",
".",
"d",
"if",
"d",
"<=",
"1",
":",
"er",
"=",
"0e0",
"else",
":",
"sz",
"=",
"_np",
".",
"dot",
"(",
"n",
"*",
"r",
"[",
... | Effective rank of the TT-vector | [
"Effective",
"rank",
"of",
"the",
"TT",
"-",
"vector"
] | python | train |
google/python-gflags | gflags/flagvalues.py | https://github.com/google/python-gflags/blob/4f06c3d0d6cbe9b1fb90ee9fb1c082b3bf9285f6/gflags/flagvalues.py#L714-L806 | def _ParseArgs(self, args, known_only):
"""Helper function to do the main argument parsing.
This function goes through args and does the bulk of the flag parsing.
It will find the corresponding flag in our flag dictionary, and call its
.parse() method on the flag value.
Args:
args: List of s... | [
"def",
"_ParseArgs",
"(",
"self",
",",
"args",
",",
"known_only",
")",
":",
"unknown_flags",
",",
"unparsed_args",
",",
"undefok",
"=",
"[",
"]",
",",
"[",
"]",
",",
"set",
"(",
")",
"flag_dict",
"=",
"self",
".",
"FlagDict",
"(",
")",
"args",
"=",
... | Helper function to do the main argument parsing.
This function goes through args and does the bulk of the flag parsing.
It will find the corresponding flag in our flag dictionary, and call its
.parse() method on the flag value.
Args:
args: List of strings with the arguments to parse.
known... | [
"Helper",
"function",
"to",
"do",
"the",
"main",
"argument",
"parsing",
"."
] | python | train |
ljcooke/see | see/output.py | https://github.com/ljcooke/see/blob/4cbc67a31c92367977ecb4bbb1f0736fa688a6ba/see/output.py#L92-L103 | def filter_ignoring_case(self, pattern):
"""
Like ``filter`` but case-insensitive.
Expects a regular expression string without the surrounding ``/``
characters.
>>> see().filter('^my', ignore_case=True)
MyClass()
"""
return self.filter(re.co... | [
"def",
"filter_ignoring_case",
"(",
"self",
",",
"pattern",
")",
":",
"return",
"self",
".",
"filter",
"(",
"re",
".",
"compile",
"(",
"pattern",
",",
"re",
".",
"I",
")",
")"
] | Like ``filter`` but case-insensitive.
Expects a regular expression string without the surrounding ``/``
characters.
>>> see().filter('^my', ignore_case=True)
MyClass() | [
"Like",
"filter",
"but",
"case",
"-",
"insensitive",
"."
] | python | train |
pypa/pipenv | pipenv/patched/notpip/_internal/index.py | https://github.com/pypa/pipenv/blob/cae8d76c210b9777e90aab76e9c4b0e53bb19cde/pipenv/patched/notpip/_internal/index.py#L124-L138 | def _ensure_html_response(url, session):
# type: (str, PipSession) -> None
"""Send a HEAD request to the URL, and ensure the response contains HTML.
Raises `_NotHTTP` if the URL is not available for a HEAD request, or
`_NotHTML` if the content type is not text/html.
"""
scheme, netloc, path, qu... | [
"def",
"_ensure_html_response",
"(",
"url",
",",
"session",
")",
":",
"# type: (str, PipSession) -> None",
"scheme",
",",
"netloc",
",",
"path",
",",
"query",
",",
"fragment",
"=",
"urllib_parse",
".",
"urlsplit",
"(",
"url",
")",
"if",
"scheme",
"not",
"in",
... | Send a HEAD request to the URL, and ensure the response contains HTML.
Raises `_NotHTTP` if the URL is not available for a HEAD request, or
`_NotHTML` if the content type is not text/html. | [
"Send",
"a",
"HEAD",
"request",
"to",
"the",
"URL",
"and",
"ensure",
"the",
"response",
"contains",
"HTML",
"."
] | python | train |
acutesoftware/virtual-AI-simulator | vais/build_internet.py | https://github.com/acutesoftware/virtual-AI-simulator/blob/57de679a5b1a58c38fefe6aea58af1f3a7e79c58/vais/build_internet.py#L12-L21 | def main():
"""
generates a virtual internet, sets pages and runs web_users on it
"""
e = mod_env.Internet('VAIS - Load testing', 'Simulation of several websites')
e.create(800)
print(e)
#Create some users to browse the web and load test website
print(npc.web_users.params) | [
"def",
"main",
"(",
")",
":",
"e",
"=",
"mod_env",
".",
"Internet",
"(",
"'VAIS - Load testing'",
",",
"'Simulation of several websites'",
")",
"e",
".",
"create",
"(",
"800",
")",
"print",
"(",
"e",
")",
"#Create some users to browse the web and load test website",... | generates a virtual internet, sets pages and runs web_users on it | [
"generates",
"a",
"virtual",
"internet",
"sets",
"pages",
"and",
"runs",
"web_users",
"on",
"it"
] | python | train |
openstack/networking-cisco | networking_cisco/apps/saf/server/services/firewall/native/fw_mgr.py | https://github.com/openstack/networking-cisco/blob/aa58a30aec25b86f9aa5952b0863045975debfa9/networking_cisco/apps/saf/server/services/firewall/native/fw_mgr.py#L717-L720 | def fw_policy_delete(self, data, fw_name=None):
"""Top level policy delete routine. """
LOG.debug("FW Policy Debug")
self._fw_policy_delete(fw_name, data) | [
"def",
"fw_policy_delete",
"(",
"self",
",",
"data",
",",
"fw_name",
"=",
"None",
")",
":",
"LOG",
".",
"debug",
"(",
"\"FW Policy Debug\"",
")",
"self",
".",
"_fw_policy_delete",
"(",
"fw_name",
",",
"data",
")"
] | Top level policy delete routine. | [
"Top",
"level",
"policy",
"delete",
"routine",
"."
] | python | train |
sebdah/dynamic-dynamodb | dynamic_dynamodb/statistics/gsi.py | https://github.com/sebdah/dynamic-dynamodb/blob/bfd0ca806b1c3301e724696de90ef0f973410493/dynamic_dynamodb/statistics/gsi.py#L14-L58 | def get_consumed_read_units_percent(
table_name, gsi_name, lookback_window_start=15, lookback_period=5):
""" Returns the number of consumed read units in percent
:type table_name: str
:param table_name: Name of the DynamoDB table
:type gsi_name: str
:param gsi_name: Name of the GSI
:typ... | [
"def",
"get_consumed_read_units_percent",
"(",
"table_name",
",",
"gsi_name",
",",
"lookback_window_start",
"=",
"15",
",",
"lookback_period",
"=",
"5",
")",
":",
"try",
":",
"metrics",
"=",
"__get_aws_metric",
"(",
"table_name",
",",
"gsi_name",
",",
"lookback_wi... | Returns the number of consumed read units in percent
:type table_name: str
:param table_name: Name of the DynamoDB table
:type gsi_name: str
:param gsi_name: Name of the GSI
:type lookback_window_start: int
:param lookback_window_start: Relative start time for the CloudWatch metric
:type lo... | [
"Returns",
"the",
"number",
"of",
"consumed",
"read",
"units",
"in",
"percent"
] | python | train |
PMEAL/porespy | porespy/tools/__funcs__.py | https://github.com/PMEAL/porespy/blob/1e13875b56787d8f5b7ffdabce8c4342c33ba9f8/porespy/tools/__funcs__.py#L709-L734 | def in_hull(points, hull):
"""
Test if a list of coordinates are inside a given convex hull
Parameters
----------
points : array_like (N x ndims)
The spatial coordinates of the points to check
hull : scipy.spatial.ConvexHull object **OR** array_like
Can be either a convex hull ... | [
"def",
"in_hull",
"(",
"points",
",",
"hull",
")",
":",
"from",
"scipy",
".",
"spatial",
"import",
"Delaunay",
",",
"ConvexHull",
"if",
"isinstance",
"(",
"hull",
",",
"ConvexHull",
")",
":",
"hull",
"=",
"hull",
".",
"points",
"hull",
"=",
"Delaunay",
... | Test if a list of coordinates are inside a given convex hull
Parameters
----------
points : array_like (N x ndims)
The spatial coordinates of the points to check
hull : scipy.spatial.ConvexHull object **OR** array_like
Can be either a convex hull object as returned by
``scipy.s... | [
"Test",
"if",
"a",
"list",
"of",
"coordinates",
"are",
"inside",
"a",
"given",
"convex",
"hull"
] | python | train |
tdryer/hangups | hangups/client.py | https://github.com/tdryer/hangups/blob/85c0bf0a57698d077461283895707260f9dbf931/hangups/client.py#L611-L616 | async def set_active_client(self, set_active_client_request):
"""Set the active client."""
response = hangouts_pb2.SetActiveClientResponse()
await self._pb_request('clients/setactiveclient',
set_active_client_request, response)
return response | [
"async",
"def",
"set_active_client",
"(",
"self",
",",
"set_active_client_request",
")",
":",
"response",
"=",
"hangouts_pb2",
".",
"SetActiveClientResponse",
"(",
")",
"await",
"self",
".",
"_pb_request",
"(",
"'clients/setactiveclient'",
",",
"set_active_client_reques... | Set the active client. | [
"Set",
"the",
"active",
"client",
"."
] | python | valid |
titusjan/argos | argos/repo/rtiplugins/pandasio.py | https://github.com/titusjan/argos/blob/20d0a3cae26c36ea789a5d219c02ca7df21279dd/argos/repo/rtiplugins/pandasio.py#L234-L243 | def _fetchAllChildren(self):
""" Fetches the index if the showIndex member is True
Descendants can override this function to add the subdevicions.
"""
assert self.isSliceable, "No underlying pandas object: self._ndFrame is None"
childItems = []
if self._standAlone:
... | [
"def",
"_fetchAllChildren",
"(",
"self",
")",
":",
"assert",
"self",
".",
"isSliceable",
",",
"\"No underlying pandas object: self._ndFrame is None\"",
"childItems",
"=",
"[",
"]",
"if",
"self",
".",
"_standAlone",
":",
"childItems",
".",
"append",
"(",
"self",
".... | Fetches the index if the showIndex member is True
Descendants can override this function to add the subdevicions. | [
"Fetches",
"the",
"index",
"if",
"the",
"showIndex",
"member",
"is",
"True"
] | python | train |
project-rig/rig | rig/routing_table/minimise.py | https://github.com/project-rig/rig/blob/3a3e053d3214899b6d68758685835de0afd5542b/rig/routing_table/minimise.py#L74-L132 | def minimise_table(table, target_length,
methods=(remove_default_entries, ordered_covering)):
"""Apply different minimisation algorithms to minimise a single routing
table.
Parameters
----------
table : [:py:class:`~rig.routing_table.RoutingTableEntry`, ...]
Routing table... | [
"def",
"minimise_table",
"(",
"table",
",",
"target_length",
",",
"methods",
"=",
"(",
"remove_default_entries",
",",
"ordered_covering",
")",
")",
":",
"# Add a final method which checks the size of the table and returns it if",
"# the size is correct. NOTE: This method will avoid... | Apply different minimisation algorithms to minimise a single routing
table.
Parameters
----------
table : [:py:class:`~rig.routing_table.RoutingTableEntry`, ...]
Routing table to minimise. NOTE: This is the data structure as
returned by :py:meth:`~rig.routing_table.routing_tree_to_tabl... | [
"Apply",
"different",
"minimisation",
"algorithms",
"to",
"minimise",
"a",
"single",
"routing",
"table",
"."
] | python | train |
byt3bl33d3r/CrackMapExec | cme/modules/invoke_vnc.py | https://github.com/byt3bl33d3r/CrackMapExec/blob/333f1c4e06884e85b2776459963ef85d182aba8e/cme/modules/invoke_vnc.py#L15-L39 | def options(self, context, module_options):
'''
CONTYPE Specifies the VNC connection type, choices are: reverse, bind (default: reverse).
PORT VNC Port (default: 5900)
PASSWORD Specifies the connection password.
'''
self.contype = 'reverse'
self.port = 59... | [
"def",
"options",
"(",
"self",
",",
"context",
",",
"module_options",
")",
":",
"self",
".",
"contype",
"=",
"'reverse'",
"self",
".",
"port",
"=",
"5900",
"self",
".",
"password",
"=",
"None",
"if",
"'PASSWORD'",
"not",
"in",
"module_options",
":",
"con... | CONTYPE Specifies the VNC connection type, choices are: reverse, bind (default: reverse).
PORT VNC Port (default: 5900)
PASSWORD Specifies the connection password. | [
"CONTYPE",
"Specifies",
"the",
"VNC",
"connection",
"type",
"choices",
"are",
":",
"reverse",
"bind",
"(",
"default",
":",
"reverse",
")",
".",
"PORT",
"VNC",
"Port",
"(",
"default",
":",
"5900",
")",
"PASSWORD",
"Specifies",
"the",
"connection",
"password",... | python | train |
genialis/resolwe | resolwe/flow/utils/stats.py | https://github.com/genialis/resolwe/blob/f7bb54932c81ec0cfc5b5e80d238fceaeaa48d86/resolwe/flow/utils/stats.py#L30-L46 | def update(self, num):
"""Update metrics with the new number."""
num = float(num)
self.count += 1
self.low = min(self.low, num)
self.high = max(self.high, num)
# Welford's online mean and variance algorithm.
delta = num - self.mean
self.mean = self.mean +... | [
"def",
"update",
"(",
"self",
",",
"num",
")",
":",
"num",
"=",
"float",
"(",
"num",
")",
"self",
".",
"count",
"+=",
"1",
"self",
".",
"low",
"=",
"min",
"(",
"self",
".",
"low",
",",
"num",
")",
"self",
".",
"high",
"=",
"max",
"(",
"self",... | Update metrics with the new number. | [
"Update",
"metrics",
"with",
"the",
"new",
"number",
"."
] | python | train |
saltstack/salt | salt/modules/zabbix.py | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/zabbix.py#L2305-L2343 | def mediatype_update(mediatypeid, name=False, mediatype=False, **kwargs):
'''
Update existing mediatype
.. note::
This function accepts all standard mediatype properties: keyword
argument names differ depending on your zabbix version, see here__.
.. __: https://www.zabbix.com/docum... | [
"def",
"mediatype_update",
"(",
"mediatypeid",
",",
"name",
"=",
"False",
",",
"mediatype",
"=",
"False",
",",
"*",
"*",
"kwargs",
")",
":",
"conn_args",
"=",
"_login",
"(",
"*",
"*",
"kwargs",
")",
"ret",
"=",
"{",
"}",
"try",
":",
"if",
"conn_args"... | Update existing mediatype
.. note::
This function accepts all standard mediatype properties: keyword
argument names differ depending on your zabbix version, see here__.
.. __: https://www.zabbix.com/documentation/3.0/manual/api/reference/mediatype/object
:param mediatypeid: ID of the ... | [
"Update",
"existing",
"mediatype"
] | python | train |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.