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 |
|---|---|---|---|---|---|---|---|---|
alphagov/performanceplatform-collector | performanceplatform/collector/gcloud/sales_parser.py | https://github.com/alphagov/performanceplatform-collector/blob/de68ab4aa500c31e436e050fa1268fa928c522a5/performanceplatform/collector/gcloud/sales_parser.py#L71-L90 | def process_csv(f):
"""
Take a file-like object and yield OrderedDicts to be inserted into raw
spending database.
"""
reader = unicodecsv.DictReader(f, encoding=_ENCODING)
for row in reader:
month, year = parse_month_year(row['Return Month'])
yield OrderedDict([
('cu... | [
"def",
"process_csv",
"(",
"f",
")",
":",
"reader",
"=",
"unicodecsv",
".",
"DictReader",
"(",
"f",
",",
"encoding",
"=",
"_ENCODING",
")",
"for",
"row",
"in",
"reader",
":",
"month",
",",
"year",
"=",
"parse_month_year",
"(",
"row",
"[",
"'Return Month'... | Take a file-like object and yield OrderedDicts to be inserted into raw
spending database. | [
"Take",
"a",
"file",
"-",
"like",
"object",
"and",
"yield",
"OrderedDicts",
"to",
"be",
"inserted",
"into",
"raw",
"spending",
"database",
"."
] | python | train |
saltstack/salt | salt/modules/neutronng.py | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/neutronng.py#L191-L207 | def network_get(auth=None, **kwargs):
'''
Get a single network
filters
A Python dictionary of filter conditions to push down
CLI Example:
.. code-block:: bash
salt '*' neutronng.network_get name=XLB4
'''
cloud = get_operator_cloud(auth)
kwargs = _clean_kwargs(**kwarg... | [
"def",
"network_get",
"(",
"auth",
"=",
"None",
",",
"*",
"*",
"kwargs",
")",
":",
"cloud",
"=",
"get_operator_cloud",
"(",
"auth",
")",
"kwargs",
"=",
"_clean_kwargs",
"(",
"*",
"*",
"kwargs",
")",
"return",
"cloud",
".",
"get_network",
"(",
"*",
"*",... | Get a single network
filters
A Python dictionary of filter conditions to push down
CLI Example:
.. code-block:: bash
salt '*' neutronng.network_get name=XLB4 | [
"Get",
"a",
"single",
"network"
] | python | train |
richardkiss/pycoin | pycoin/networks/ParseAPI.py | https://github.com/richardkiss/pycoin/blob/1e8d0d9fe20ce0347b97847bb529cd1bd84c7442/pycoin/networks/ParseAPI.py#L96-L105 | def electrum_prv(self, s):
"""
Parse an electrum private key from a text string in seed form ("E:xxx" where xxx
is a 64-character hex string).
Return a :class:`ElectrumWallet <pycoin.key.electrum.ElectrumWallet>` or None.
"""
blob = self._electrum_to_blob(s)
if bl... | [
"def",
"electrum_prv",
"(",
"self",
",",
"s",
")",
":",
"blob",
"=",
"self",
".",
"_electrum_to_blob",
"(",
"s",
")",
"if",
"blob",
"and",
"len",
"(",
"blob",
")",
"==",
"32",
":",
"mpk",
"=",
"from_bytes_32",
"(",
"blob",
")",
"return",
"self",
".... | Parse an electrum private key from a text string in seed form ("E:xxx" where xxx
is a 64-character hex string).
Return a :class:`ElectrumWallet <pycoin.key.electrum.ElectrumWallet>` or None. | [
"Parse",
"an",
"electrum",
"private",
"key",
"from",
"a",
"text",
"string",
"in",
"seed",
"form",
"(",
"E",
":",
"xxx",
"where",
"xxx",
"is",
"a",
"64",
"-",
"character",
"hex",
"string",
")",
".",
"Return",
"a",
":",
"class",
":",
"ElectrumWallet",
... | python | train |
fred49/argtoolbox | argtoolbox/argtoolbox.py | https://github.com/fred49/argtoolbox/blob/e32ad6265567d5a1891df3c3425423774dafab41/argtoolbox/argtoolbox.py#L815-L844 | def write_config_file(self, f, comments):
"""This method write a sample file, with attributes, descriptions,
sample values, required flags, using the configuration object
properties.
"""
if self.conf_hidden:
return False
if comments:
f.write("\n")... | [
"def",
"write_config_file",
"(",
"self",
",",
"f",
",",
"comments",
")",
":",
"if",
"self",
".",
"conf_hidden",
":",
"return",
"False",
"if",
"comments",
":",
"f",
".",
"write",
"(",
"\"\\n\"",
")",
"f",
".",
"write",
"(",
"\"# Attribute (\"",
")",
"f"... | This method write a sample file, with attributes, descriptions,
sample values, required flags, using the configuration object
properties. | [
"This",
"method",
"write",
"a",
"sample",
"file",
"with",
"attributes",
"descriptions",
"sample",
"values",
"required",
"flags",
"using",
"the",
"configuration",
"object",
"properties",
"."
] | python | train |
joealcorn/xbox | xbox/vendor/requests/packages/urllib3/response.py | https://github.com/joealcorn/xbox/blob/3d2aeba10244dcb58d714d76fc88487c74bd1510/xbox/vendor/requests/packages/urllib3/response.py#L143-L237 | def read(self, amt=None, decode_content=None, cache_content=False):
"""
Similar to :meth:`httplib.HTTPResponse.read`, but with two additional
parameters: ``decode_content`` and ``cache_content``.
:param amt:
How much of the content to read. If specified, caching is skipped
... | [
"def",
"read",
"(",
"self",
",",
"amt",
"=",
"None",
",",
"decode_content",
"=",
"None",
",",
"cache_content",
"=",
"False",
")",
":",
"# Note: content-encoding value should be case-insensitive, per RFC 7230",
"# Section 3.2",
"content_encoding",
"=",
"self",
".",
"he... | Similar to :meth:`httplib.HTTPResponse.read`, but with two additional
parameters: ``decode_content`` and ``cache_content``.
:param amt:
How much of the content to read. If specified, caching is skipped
because it doesn't make sense to cache partial content as the full
... | [
"Similar",
"to",
":",
"meth",
":",
"httplib",
".",
"HTTPResponse",
".",
"read",
"but",
"with",
"two",
"additional",
"parameters",
":",
"decode_content",
"and",
"cache_content",
"."
] | python | train |
yyuu/botornado | boto/ec2/connection.py | https://github.com/yyuu/botornado/blob/fffb056f5ff2324d1d5c1304014cfb1d899f602e/boto/ec2/connection.py#L1863-L1894 | def create_security_group(self, name, description, vpc_id=None):
"""
Create a new security group for your account.
This will create the security group within the region you
are currently connected to.
:type name: string
:param name: The name of the new security group
... | [
"def",
"create_security_group",
"(",
"self",
",",
"name",
",",
"description",
",",
"vpc_id",
"=",
"None",
")",
":",
"params",
"=",
"{",
"'GroupName'",
":",
"name",
",",
"'GroupDescription'",
":",
"description",
"}",
"if",
"vpc_id",
"is",
"not",
"None",
":"... | Create a new security group for your account.
This will create the security group within the region you
are currently connected to.
:type name: string
:param name: The name of the new security group
:type description: string
:param description: The description of the ne... | [
"Create",
"a",
"new",
"security",
"group",
"for",
"your",
"account",
".",
"This",
"will",
"create",
"the",
"security",
"group",
"within",
"the",
"region",
"you",
"are",
"currently",
"connected",
"to",
"."
] | python | train |
polysquare/polysquare-generic-file-linter | polysquarelinter/linter.py | https://github.com/polysquare/polysquare-generic-file-linter/blob/cfc88771acd3d5551c28fa5d917bb0aeb584c4cc/polysquarelinter/linter.py#L801-L813 | def _run_lint_on_file_stamped(*args):
"""Run linter functions on file_path, stamping in stamp_file_path."""
# We pass an empty dictionary as keyword arguments here to work
# around a bug in frosted, which crashes when no keyword arguments
# are passed
#
# suppress(E204)
stamp_args, stamp_kwa... | [
"def",
"_run_lint_on_file_stamped",
"(",
"*",
"args",
")",
":",
"# We pass an empty dictionary as keyword arguments here to work",
"# around a bug in frosted, which crashes when no keyword arguments",
"# are passed",
"#",
"# suppress(E204)",
"stamp_args",
",",
"stamp_kwargs",
"=",
"_... | Run linter functions on file_path, stamping in stamp_file_path. | [
"Run",
"linter",
"functions",
"on",
"file_path",
"stamping",
"in",
"stamp_file_path",
"."
] | python | train |
BeyondTheClouds/enoslib | enoslib/infra/enos_g5k/g5k_api_utils.py | https://github.com/BeyondTheClouds/enoslib/blob/fb00be58e56a7848cfe482187d659744919fe2f7/enoslib/infra/enos_g5k/g5k_api_utils.py#L493-L543 | def _do_synchronise_jobs(walltime, machines):
""" This returns a common reservation date for all the jobs.
This reservation date is really only a hint and will be supplied to each
oar server. Without this *common* reservation_date, one oar server can
decide to postpone the start of the job while the ot... | [
"def",
"_do_synchronise_jobs",
"(",
"walltime",
",",
"machines",
")",
":",
"offset",
"=",
"SYNCHRONISATION_OFFSET",
"start",
"=",
"time",
".",
"time",
"(",
")",
"+",
"offset",
"_t",
"=",
"time",
".",
"strptime",
"(",
"walltime",
",",
"\"%H:%M:%S\"",
")",
"... | This returns a common reservation date for all the jobs.
This reservation date is really only a hint and will be supplied to each
oar server. Without this *common* reservation_date, one oar server can
decide to postpone the start of the job while the other are already
running. But this doens't prevent ... | [
"This",
"returns",
"a",
"common",
"reservation",
"date",
"for",
"all",
"the",
"jobs",
"."
] | python | train |
funilrys/PyFunceble | PyFunceble/core.py | https://github.com/funilrys/PyFunceble/blob/cdf69cbde120199171f7158e1c33635753e6e2f5/PyFunceble/core.py#L844-L893 | def colorify_logo(cls, home=False):
"""
Print the colored logo based on global results.
:param home: Tell us if we have to print the initial coloration.
:type home: bool
"""
if not PyFunceble.CONFIGURATION["quiet"]:
# The quiet mode is not activated.
... | [
"def",
"colorify_logo",
"(",
"cls",
",",
"home",
"=",
"False",
")",
":",
"if",
"not",
"PyFunceble",
".",
"CONFIGURATION",
"[",
"\"quiet\"",
"]",
":",
"# The quiet mode is not activated.",
"to_print",
"=",
"[",
"]",
"if",
"home",
":",
"# We have to print the init... | Print the colored logo based on global results.
:param home: Tell us if we have to print the initial coloration.
:type home: bool | [
"Print",
"the",
"colored",
"logo",
"based",
"on",
"global",
"results",
"."
] | python | test |
mozilla-releng/scriptworker | scriptworker/cot/verify.py | https://github.com/mozilla-releng/scriptworker/blob/8e97bbd83b9b578565ec57904c966dd6ae4ef0ae/scriptworker/cot/verify.py#L1866-L1886 | async def verify_task_types(chain):
"""Verify the task type (e.g. decision, build) of each link in the chain.
Args:
chain (ChainOfTrust): the chain we're operating on
Returns:
dict: mapping task type to the number of links.
"""
valid_task_types = get_valid_task_types()
task_co... | [
"async",
"def",
"verify_task_types",
"(",
"chain",
")",
":",
"valid_task_types",
"=",
"get_valid_task_types",
"(",
")",
"task_count",
"=",
"{",
"}",
"for",
"obj",
"in",
"chain",
".",
"get_all_links_in_chain",
"(",
")",
":",
"task_type",
"=",
"obj",
".",
"tas... | Verify the task type (e.g. decision, build) of each link in the chain.
Args:
chain (ChainOfTrust): the chain we're operating on
Returns:
dict: mapping task type to the number of links. | [
"Verify",
"the",
"task",
"type",
"(",
"e",
".",
"g",
".",
"decision",
"build",
")",
"of",
"each",
"link",
"in",
"the",
"chain",
"."
] | python | train |
thespacedoctor/sherlock | sherlock/transient_classifier.py | https://github.com/thespacedoctor/sherlock/blob/2c80fb6fa31b04e7820e6928e3d437a21e692dd3/sherlock/transient_classifier.py#L479-L540 | def _update_ned_stream(
self,
transientsMetadataList
):
""" update the NED stream within the catalogues database at the locations of the transients
**Key Arguments:**
- ``transientsMetadataList`` -- the list of transient metadata lifted from the database.
.. tod... | [
"def",
"_update_ned_stream",
"(",
"self",
",",
"transientsMetadataList",
")",
":",
"self",
".",
"log",
".",
"debug",
"(",
"'starting the ``_update_ned_stream`` method'",
")",
"coordinateList",
"=",
"[",
"]",
"for",
"i",
"in",
"transientsMetadataList",
":",
"# thisLi... | update the NED stream within the catalogues database at the locations of the transients
**Key Arguments:**
- ``transientsMetadataList`` -- the list of transient metadata lifted from the database.
.. todo ::
- update key arguments values and definitions with defaults
... | [
"update",
"the",
"NED",
"stream",
"within",
"the",
"catalogues",
"database",
"at",
"the",
"locations",
"of",
"the",
"transients"
] | python | train |
mozillazg/python-shanbay | shanbay/__init__.py | https://github.com/mozillazg/python-shanbay/blob/d505ba614dc13a36afce46969d13fc64e10dde0d/shanbay/__init__.py#L68-L82 | def login(self, **kwargs):
"""登录"""
payload = {
'username': self.username,
'password': self.password,
}
headers = kwargs.setdefault('headers', {})
headers.setdefault(
'Referer',
'https://www.shanbay.com/web/account/login'
)
... | [
"def",
"login",
"(",
"self",
",",
"*",
"*",
"kwargs",
")",
":",
"payload",
"=",
"{",
"'username'",
":",
"self",
".",
"username",
",",
"'password'",
":",
"self",
".",
"password",
",",
"}",
"headers",
"=",
"kwargs",
".",
"setdefault",
"(",
"'headers'",
... | 登录 | [
"登录"
] | python | train |
horazont/aioxmpp | aioxmpp/muc/service.py | https://github.com/horazont/aioxmpp/blob/22a68e5e1d23f2a4dee470092adbd4672f9ef061/aioxmpp/muc/service.py#L986-L997 | def members(self):
"""
A copy of the list of occupants. The local user is always the first
item in the list, unless the :meth:`on_enter` has not fired yet.
"""
if self._this_occupant is not None:
items = [self._this_occupant]
else:
items = []
... | [
"def",
"members",
"(",
"self",
")",
":",
"if",
"self",
".",
"_this_occupant",
"is",
"not",
"None",
":",
"items",
"=",
"[",
"self",
".",
"_this_occupant",
"]",
"else",
":",
"items",
"=",
"[",
"]",
"items",
"+=",
"list",
"(",
"self",
".",
"_occupant_in... | A copy of the list of occupants. The local user is always the first
item in the list, unless the :meth:`on_enter` has not fired yet. | [
"A",
"copy",
"of",
"the",
"list",
"of",
"occupants",
".",
"The",
"local",
"user",
"is",
"always",
"the",
"first",
"item",
"in",
"the",
"list",
"unless",
"the",
":",
"meth",
":",
"on_enter",
"has",
"not",
"fired",
"yet",
"."
] | python | train |
jlmadurga/permabots | permabots/views/api/hook.py | https://github.com/jlmadurga/permabots/blob/781a91702529a23fe7bc2aa84c5d88e961412466/permabots/views/api/hook.py#L192-L204 | def delete(self, request, bot_id, hook_id, id, format=None):
"""
Delete an existing telegram recipient
---
responseMessages:
- code: 401
message: Not authenticated
"""
bot = self.get_bot(bot_id, request.user)
hook = self.get_hook(hook_... | [
"def",
"delete",
"(",
"self",
",",
"request",
",",
"bot_id",
",",
"hook_id",
",",
"id",
",",
"format",
"=",
"None",
")",
":",
"bot",
"=",
"self",
".",
"get_bot",
"(",
"bot_id",
",",
"request",
".",
"user",
")",
"hook",
"=",
"self",
".",
"get_hook",... | Delete an existing telegram recipient
---
responseMessages:
- code: 401
message: Not authenticated | [
"Delete",
"an",
"existing",
"telegram",
"recipient",
"---",
"responseMessages",
":",
"-",
"code",
":",
"401",
"message",
":",
"Not",
"authenticated"
] | python | train |
the01/python-floscraper | floscraper/webscraper.py | https://github.com/the01/python-floscraper/blob/d578cd3d6381070d9a07dade1e10387ae33e9a65/floscraper/webscraper.py#L111-L129 | def _browser_init(self):
"""
Init the browsing instance if not setup
:rtype: None
"""
if self.session:
return
self.session = requests.Session()
headers = {}
if self.user_agent:
headers['User-agent'] = self.user_agent
self... | [
"def",
"_browser_init",
"(",
"self",
")",
":",
"if",
"self",
".",
"session",
":",
"return",
"self",
".",
"session",
"=",
"requests",
".",
"Session",
"(",
")",
"headers",
"=",
"{",
"}",
"if",
"self",
".",
"user_agent",
":",
"headers",
"[",
"'User-agent'... | Init the browsing instance if not setup
:rtype: None | [
"Init",
"the",
"browsing",
"instance",
"if",
"not",
"setup"
] | python | train |
obriencj/python-javatools | javatools/jarutil.py | https://github.com/obriencj/python-javatools/blob/9e2332b452ddc508bed0615937dddcb2cf051557/javatools/jarutil.py#L70-L174 | def verify(certificate, jar_file, sf_name=None):
"""
Verifies signature of a JAR file.
Limitations:
- diagnostic is less verbose than of jarsigner
:return None if verification succeeds.
:exception SignatureBlockFileVerificationError, ManifestChecksumError,
JarChecksumError, JarSignature... | [
"def",
"verify",
"(",
"certificate",
",",
"jar_file",
",",
"sf_name",
"=",
"None",
")",
":",
"# noqua",
"# Step 0: get the \"key alias\", used also for naming of sig-related files.",
"zip_file",
"=",
"ZipFile",
"(",
"jar_file",
")",
"sf_files",
"=",
"[",
"f",
"for",
... | Verifies signature of a JAR file.
Limitations:
- diagnostic is less verbose than of jarsigner
:return None if verification succeeds.
:exception SignatureBlockFileVerificationError, ManifestChecksumError,
JarChecksumError, JarSignatureMissingError
Reference:
http://docs.oracle.com/javas... | [
"Verifies",
"signature",
"of",
"a",
"JAR",
"file",
"."
] | python | train |
sorgerlab/indra | indra/sources/reach/processor.py | https://github.com/sorgerlab/indra/blob/79a70415832c5702d7a820c7c9ccc8e25010124b/indra/sources/reach/processor.py#L835-L862 | def determine_reach_subtype(event_name):
"""Returns the category of reach rule from the reach rule instance.
Looks at a list of regular
expressions corresponding to reach rule types, and returns the longest
regexp that matches, or None if none of them match.
Parameters
----------
evidence ... | [
"def",
"determine_reach_subtype",
"(",
"event_name",
")",
":",
"best_match_length",
"=",
"None",
"best_match",
"=",
"None",
"for",
"ss",
"in",
"reach_rule_regexps",
":",
"if",
"re",
".",
"search",
"(",
"ss",
",",
"event_name",
")",
":",
"if",
"best_match",
"... | Returns the category of reach rule from the reach rule instance.
Looks at a list of regular
expressions corresponding to reach rule types, and returns the longest
regexp that matches, or None if none of them match.
Parameters
----------
evidence : indra.statements.Evidence
A reach evid... | [
"Returns",
"the",
"category",
"of",
"reach",
"rule",
"from",
"the",
"reach",
"rule",
"instance",
"."
] | python | train |
KeplerGO/K2fov | K2fov/greatcircle.py | https://github.com/KeplerGO/K2fov/blob/fb122b35687340e0357cba9e0dd47b3be0760693/K2fov/greatcircle.py#L10-L42 | def sphericalAngSep(ra0, dec0, ra1, dec1, radians=False):
"""
Compute the spherical angular separation between two
points on the sky.
//Taken from http://www.movable-type.co.uk/scripts/gis-faq-5.1.html
NB: For small distances you can probably use
sqrt( dDec**2 + cos^2(dec)*... | [
"def",
"sphericalAngSep",
"(",
"ra0",
",",
"dec0",
",",
"ra1",
",",
"dec1",
",",
"radians",
"=",
"False",
")",
":",
"if",
"radians",
"==",
"False",
":",
"ra0",
"=",
"np",
".",
"radians",
"(",
"ra0",
")",
"dec0",
"=",
"np",
".",
"radians",
"(",
"d... | Compute the spherical angular separation between two
points on the sky.
//Taken from http://www.movable-type.co.uk/scripts/gis-faq-5.1.html
NB: For small distances you can probably use
sqrt( dDec**2 + cos^2(dec)*dRa)
where dDec = dec1 - dec0 and
dRa = ra1 - ra0
... | [
"Compute",
"the",
"spherical",
"angular",
"separation",
"between",
"two",
"points",
"on",
"the",
"sky",
"."
] | python | train |
mlperf/training | single_stage_detector/ssd/utils.py | https://github.com/mlperf/training/blob/1c6ae725a81d15437a2b2df05cac0673fde5c3a4/single_stage_detector/ssd/utils.py#L120-L156 | def scale_back_batch(self, bboxes_in, scores_in):
"""
Do scale and transform from xywh to ltrb
suppose input Nx4xnum_bbox Nxlabel_numxnum_bbox
"""
if bboxes_in.device == torch.device("cpu"):
self.dboxes = self.dboxes.cpu()
self.dboxes_xywh = self.d... | [
"def",
"scale_back_batch",
"(",
"self",
",",
"bboxes_in",
",",
"scores_in",
")",
":",
"if",
"bboxes_in",
".",
"device",
"==",
"torch",
".",
"device",
"(",
"\"cpu\"",
")",
":",
"self",
".",
"dboxes",
"=",
"self",
".",
"dboxes",
".",
"cpu",
"(",
")",
"... | Do scale and transform from xywh to ltrb
suppose input Nx4xnum_bbox Nxlabel_numxnum_bbox | [
"Do",
"scale",
"and",
"transform",
"from",
"xywh",
"to",
"ltrb",
"suppose",
"input",
"Nx4xnum_bbox",
"Nxlabel_numxnum_bbox"
] | python | train |
explosion/thinc | thinc/check.py | https://github.com/explosion/thinc/blob/90129be5f0d6c665344245a7c37dbe1b8afceea2/thinc/check.py#L48-L71 | def has_shape(shape):
"""Check that a particular argument is an array with a given shape. The
shape may contain string attributes, which will be fetched from arg0 to
the function (usually self).
"""
def has_shape_inner(arg_id, args, kwargs):
self = args[0]
arg = args[arg_id]
... | [
"def",
"has_shape",
"(",
"shape",
")",
":",
"def",
"has_shape_inner",
"(",
"arg_id",
",",
"args",
",",
"kwargs",
")",
":",
"self",
"=",
"args",
"[",
"0",
"]",
"arg",
"=",
"args",
"[",
"arg_id",
"]",
"if",
"not",
"hasattr",
"(",
"arg",
",",
"\"shape... | Check that a particular argument is an array with a given shape. The
shape may contain string attributes, which will be fetched from arg0 to
the function (usually self). | [
"Check",
"that",
"a",
"particular",
"argument",
"is",
"an",
"array",
"with",
"a",
"given",
"shape",
".",
"The",
"shape",
"may",
"contain",
"string",
"attributes",
"which",
"will",
"be",
"fetched",
"from",
"arg0",
"to",
"the",
"function",
"(",
"usually",
"s... | python | train |
Aplopio/django_rip | rip/generic_steps/default_entity_actions.py | https://github.com/Aplopio/django_rip/blob/6b03962ccb778c1a95950a3803e5170c7a2392df/rip/generic_steps/default_entity_actions.py#L33-L54 | def read_list(self, request):
"""
:param request: an apiv2 request object
:return: request if successful with entities set on request
"""
request_filters = request.context_params.get(
self.request_filters_property, {})
request_filters.update(**self.get_limit_a... | [
"def",
"read_list",
"(",
"self",
",",
"request",
")",
":",
"request_filters",
"=",
"request",
".",
"context_params",
".",
"get",
"(",
"self",
".",
"request_filters_property",
",",
"{",
"}",
")",
"request_filters",
".",
"update",
"(",
"*",
"*",
"self",
".",... | :param request: an apiv2 request object
:return: request if successful with entities set on request | [
":",
"param",
"request",
":",
"an",
"apiv2",
"request",
"object",
":",
"return",
":",
"request",
"if",
"successful",
"with",
"entities",
"set",
"on",
"request"
] | python | train |
sentinel-hub/sentinelhub-py | sentinelhub/geometry.py | https://github.com/sentinel-hub/sentinelhub-py/blob/08a83b7f1e289187159a643336995d8369860fea/sentinelhub/geometry.py#L258-L273 | def get_polygon(self, reverse=False):
""" Returns a tuple of coordinates of 5 points describing a polygon. Points are listed in clockwise order, first
point is the same as the last.
:param reverse: `True` if x and y coordinates should be switched and `False` otherwise
:type reverse: boo... | [
"def",
"get_polygon",
"(",
"self",
",",
"reverse",
"=",
"False",
")",
":",
"bbox",
"=",
"self",
".",
"reverse",
"(",
")",
"if",
"reverse",
"else",
"self",
"polygon",
"=",
"(",
"(",
"bbox",
".",
"min_x",
",",
"bbox",
".",
"min_y",
")",
",",
"(",
"... | Returns a tuple of coordinates of 5 points describing a polygon. Points are listed in clockwise order, first
point is the same as the last.
:param reverse: `True` if x and y coordinates should be switched and `False` otherwise
:type reverse: bool
:return: `((x_1, y_1), ... , (x_5, y_5))... | [
"Returns",
"a",
"tuple",
"of",
"coordinates",
"of",
"5",
"points",
"describing",
"a",
"polygon",
".",
"Points",
"are",
"listed",
"in",
"clockwise",
"order",
"first",
"point",
"is",
"the",
"same",
"as",
"the",
"last",
"."
] | python | train |
cdumay/kser | src/kser/tracing/task.py | https://github.com/cdumay/kser/blob/fbd6fe9ab34b8b89d9937e5ff727614304af48c1/src/kser/tracing/task.py#L20-L34 | def unsafe_execute(self, result=None):
""" un-wrapped execution, can raise excepetion
:return: Execution result
:rtype: kser.result.Result
"""
if result:
self.result += result
with opentracing.tracer.start_span(
obj=self, child_of=KserSpan.ex... | [
"def",
"unsafe_execute",
"(",
"self",
",",
"result",
"=",
"None",
")",
":",
"if",
"result",
":",
"self",
".",
"result",
"+=",
"result",
"with",
"opentracing",
".",
"tracer",
".",
"start_span",
"(",
"obj",
"=",
"self",
",",
"child_of",
"=",
"KserSpan",
... | un-wrapped execution, can raise excepetion
:return: Execution result
:rtype: kser.result.Result | [
"un",
"-",
"wrapped",
"execution",
"can",
"raise",
"excepetion"
] | python | train |
marcomusy/vtkplotter | vtkplotter/utils.py | https://github.com/marcomusy/vtkplotter/blob/692c3396782722ec525bc1346a26999868c650c6/vtkplotter/utils.py#L35-L43 | def isSequence(arg):
"""Check if input is iterable."""
if hasattr(arg, "strip"):
return False
if hasattr(arg, "__getslice__"):
return True
if hasattr(arg, "__iter__"):
return True
return False | [
"def",
"isSequence",
"(",
"arg",
")",
":",
"if",
"hasattr",
"(",
"arg",
",",
"\"strip\"",
")",
":",
"return",
"False",
"if",
"hasattr",
"(",
"arg",
",",
"\"__getslice__\"",
")",
":",
"return",
"True",
"if",
"hasattr",
"(",
"arg",
",",
"\"__iter__\"",
"... | Check if input is iterable. | [
"Check",
"if",
"input",
"is",
"iterable",
"."
] | python | train |
broadinstitute/fiss | firecloud/api.py | https://github.com/broadinstitute/fiss/blob/dddf91547479506dbbafb69ec84d44dcc4a94ab4/firecloud/api.py#L259-L273 | def get_entities(namespace, workspace, etype):
"""List entities of given type in a workspace.
Response content will be in JSON format.
Args:
namespace (str): project to which workspace belongs
workspace (str): Workspace name
etype (str): Entity type
Swagger:
https://ap... | [
"def",
"get_entities",
"(",
"namespace",
",",
"workspace",
",",
"etype",
")",
":",
"uri",
"=",
"\"workspaces/{0}/{1}/entities/{2}\"",
".",
"format",
"(",
"namespace",
",",
"workspace",
",",
"etype",
")",
"return",
"__get",
"(",
"uri",
")"
] | List entities of given type in a workspace.
Response content will be in JSON format.
Args:
namespace (str): project to which workspace belongs
workspace (str): Workspace name
etype (str): Entity type
Swagger:
https://api.firecloud.org/#!/Entities/getEntities | [
"List",
"entities",
"of",
"given",
"type",
"in",
"a",
"workspace",
"."
] | python | train |
mitsei/dlkit | dlkit/json_/assessment/objects.py | https://github.com/mitsei/dlkit/blob/445f968a175d61c8d92c0f617a3c17dc1dc7c584/dlkit/json_/assessment/objects.py#L479-L491 | def get_answers(self):
"""Gets the answers.
return: (osid.assessment.AnswerList) - the answers
raise: OperationFailed - unable to complete request
*compliance: mandatory -- This method must be implemented.*
"""
# Implemented from template for osid.repository.Asset.get_... | [
"def",
"get_answers",
"(",
"self",
")",
":",
"# Implemented from template for osid.repository.Asset.get_asset_contents_template",
"return",
"AnswerList",
"(",
"self",
".",
"_my_map",
"[",
"'answers'",
"]",
",",
"runtime",
"=",
"self",
".",
"_runtime",
",",
"proxy",
"=... | Gets the answers.
return: (osid.assessment.AnswerList) - the answers
raise: OperationFailed - unable to complete request
*compliance: mandatory -- This method must be implemented.* | [
"Gets",
"the",
"answers",
"."
] | python | train |
pip-services3-python/pip-services3-components-python | pip_services3_components/log/Logger.py | https://github.com/pip-services3-python/pip-services3-components-python/blob/1de9c1bb544cf1891111e9a5f5d67653f62c9b52/pip_services3_components/log/Logger.py#L138-L152 | def error(self, correlation_id, error, message, *args, **kwargs):
"""
Logs recoverable application error.
:param correlation_id: (optional) transaction id to trace execution through call chain.
:param error: an error object associated with this message.
:param message: a human... | [
"def",
"error",
"(",
"self",
",",
"correlation_id",
",",
"error",
",",
"message",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"self",
".",
"_format_and_write",
"(",
"LogLevel",
".",
"Error",
",",
"correlation_id",
",",
"error",
",",
"message",
... | Logs recoverable application error.
:param correlation_id: (optional) transaction id to trace execution through call chain.
:param error: an error object associated with this message.
:param message: a human-readable message to log.
:param args: arguments to parameterize the message.... | [
"Logs",
"recoverable",
"application",
"error",
"."
] | python | train |
Grunny/zap-cli | zapcli/commands/scanners.py | https://github.com/Grunny/zap-cli/blob/d58d4850ecfc5467badfac5e5bcc841d064bd419/zapcli/commands/scanners.py#L31-L41 | def list_scanners(zap_helper, scanners):
"""Get a list of scanners and whether or not they are enabled."""
scanner_list = zap_helper.zap.ascan.scanners()
if scanners is not None and 'all' not in scanners:
scanner_list = filter_by_ids(scanner_list, scanners)
click.echo(tabulate([[s['id'], s['na... | [
"def",
"list_scanners",
"(",
"zap_helper",
",",
"scanners",
")",
":",
"scanner_list",
"=",
"zap_helper",
".",
"zap",
".",
"ascan",
".",
"scanners",
"(",
")",
"if",
"scanners",
"is",
"not",
"None",
"and",
"'all'",
"not",
"in",
"scanners",
":",
"scanner_list... | Get a list of scanners and whether or not they are enabled. | [
"Get",
"a",
"list",
"of",
"scanners",
"and",
"whether",
"or",
"not",
"they",
"are",
"enabled",
"."
] | python | train |
Riffstation/flask-philo | flask_philo/serializers.py | https://github.com/Riffstation/flask-philo/blob/76c9d562edb4a77010c8da6dfdb6489fa29cbc9e/flask_philo/serializers.py#L102-L119 | def to_json(self):
"""
Returns a json representation
"""
data = {}
for k, v in self.__dict__.items():
if not k.startswith('_'):
# values not serializable, should be converted to strings
if isinstance(v, datetime):
v ... | [
"def",
"to_json",
"(",
"self",
")",
":",
"data",
"=",
"{",
"}",
"for",
"k",
",",
"v",
"in",
"self",
".",
"__dict__",
".",
"items",
"(",
")",
":",
"if",
"not",
"k",
".",
"startswith",
"(",
"'_'",
")",
":",
"# values not serializable, should be converted... | Returns a json representation | [
"Returns",
"a",
"json",
"representation"
] | python | train |
tcalmant/ipopo | pelix/framework.py | https://github.com/tcalmant/ipopo/blob/2f9ae0c44cd9c34ef1a9d50837b3254e75678eb1/pelix/framework.py#L810-L819 | def get_property(self, name):
# type: (str) -> object
"""
Retrieves a framework or system property. As framework properties don't
change while it's running, this method don't need to be protected.
:param name: The property name
"""
with self.__properties_lock:
... | [
"def",
"get_property",
"(",
"self",
",",
"name",
")",
":",
"# type: (str) -> object",
"with",
"self",
".",
"__properties_lock",
":",
"return",
"self",
".",
"__properties",
".",
"get",
"(",
"name",
",",
"os",
".",
"getenv",
"(",
"name",
")",
")"
] | Retrieves a framework or system property. As framework properties don't
change while it's running, this method don't need to be protected.
:param name: The property name | [
"Retrieves",
"a",
"framework",
"or",
"system",
"property",
".",
"As",
"framework",
"properties",
"don",
"t",
"change",
"while",
"it",
"s",
"running",
"this",
"method",
"don",
"t",
"need",
"to",
"be",
"protected",
"."
] | python | train |
RudolfCardinal/pythonlib | cardinal_pythonlib/interval.py | https://github.com/RudolfCardinal/pythonlib/blob/0b84cb35f38bd7d8723958dae51b480a829b7227/cardinal_pythonlib/interval.py#L528-L545 | def saturdays_of_weekends(self) -> Set[datetime.date]:
"""
Returns the dates of all Saturdays that are part of weekends that this
interval covers (each Saturday representing a unique identifier for
that weekend). The Saturday itself isn't necessarily the part of the
weekend that ... | [
"def",
"saturdays_of_weekends",
"(",
"self",
")",
"->",
"Set",
"[",
"datetime",
".",
"date",
"]",
":",
"startdate",
"=",
"self",
".",
"start",
".",
"date",
"(",
")",
"enddate",
"=",
"self",
".",
"end",
".",
"date",
"(",
")",
"ndays",
"=",
"(",
"end... | Returns the dates of all Saturdays that are part of weekends that this
interval covers (each Saturday representing a unique identifier for
that weekend). The Saturday itself isn't necessarily the part of the
weekend that the interval covers! | [
"Returns",
"the",
"dates",
"of",
"all",
"Saturdays",
"that",
"are",
"part",
"of",
"weekends",
"that",
"this",
"interval",
"covers",
"(",
"each",
"Saturday",
"representing",
"a",
"unique",
"identifier",
"for",
"that",
"weekend",
")",
".",
"The",
"Saturday",
"... | python | train |
Erotemic/utool | utool/util_list.py | https://github.com/Erotemic/utool/blob/3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a/utool/util_list.py#L923-L929 | def ziptake(items_list, indexes_list):
"""
SeeAlso:
vt.ziptake
"""
return [take(list_, index_list)
for list_, index_list in zip(items_list, indexes_list)] | [
"def",
"ziptake",
"(",
"items_list",
",",
"indexes_list",
")",
":",
"return",
"[",
"take",
"(",
"list_",
",",
"index_list",
")",
"for",
"list_",
",",
"index_list",
"in",
"zip",
"(",
"items_list",
",",
"indexes_list",
")",
"]"
] | SeeAlso:
vt.ziptake | [
"SeeAlso",
":",
"vt",
".",
"ziptake"
] | python | train |
sentinel-hub/sentinelhub-py | sentinelhub/geopedia.py | https://github.com/sentinel-hub/sentinelhub-py/blob/08a83b7f1e289187159a643336995d8369860fea/sentinelhub/geopedia.py#L30-L49 | def _parse_layer(layer, return_wms_name=False):
""" Helper function for parsing Geopedia layer name. If WMS name is required and wrong form is given it will
return a string with 'ttl' at the beginning. (WMS name can also start with something else, e.g. only 't'
instead 'ttl', therefore anything ... | [
"def",
"_parse_layer",
"(",
"layer",
",",
"return_wms_name",
"=",
"False",
")",
":",
"if",
"not",
"isinstance",
"(",
"layer",
",",
"(",
"int",
",",
"str",
")",
")",
":",
"raise",
"ValueError",
"(",
"\"Parameter 'layer' should be an integer or a string, but {} foun... | Helper function for parsing Geopedia layer name. If WMS name is required and wrong form is given it will
return a string with 'ttl' at the beginning. (WMS name can also start with something else, e.g. only 't'
instead 'ttl', therefore anything else is also allowed.) Otherwise it will parse it into a num... | [
"Helper",
"function",
"for",
"parsing",
"Geopedia",
"layer",
"name",
".",
"If",
"WMS",
"name",
"is",
"required",
"and",
"wrong",
"form",
"is",
"given",
"it",
"will",
"return",
"a",
"string",
"with",
"ttl",
"at",
"the",
"beginning",
".",
"(",
"WMS",
"name... | python | train |
cmbruns/pyopenvr | src/openvr/__init__.py | https://github.com/cmbruns/pyopenvr/blob/68395d26bb3df6ab1f0f059c38d441f962938be6/src/openvr/__init__.py#L2883-L2888 | def isTrackedDeviceConnected(self, unDeviceIndex):
"""Returns true if there is a device connected in this slot."""
fn = self.function_table.isTrackedDeviceConnected
result = fn(unDeviceIndex)
return result | [
"def",
"isTrackedDeviceConnected",
"(",
"self",
",",
"unDeviceIndex",
")",
":",
"fn",
"=",
"self",
".",
"function_table",
".",
"isTrackedDeviceConnected",
"result",
"=",
"fn",
"(",
"unDeviceIndex",
")",
"return",
"result"
] | Returns true if there is a device connected in this slot. | [
"Returns",
"true",
"if",
"there",
"is",
"a",
"device",
"connected",
"in",
"this",
"slot",
"."
] | python | train |
inveniosoftware/invenio-communities | invenio_communities/models.py | https://github.com/inveniosoftware/invenio-communities/blob/5c4de6783724d276ae1b6dd13a399a9e22fadc7a/invenio_communities/models.py#L257-L284 | def filter_communities(cls, p, so, with_deleted=False):
"""Search for communities.
Helper function which takes from database only those communities which
match search criteria. Uses parameter 'so' to set communities in the
correct order.
Parameter 'page' is introduced to restri... | [
"def",
"filter_communities",
"(",
"cls",
",",
"p",
",",
"so",
",",
"with_deleted",
"=",
"False",
")",
":",
"query",
"=",
"cls",
".",
"query",
"if",
"with_deleted",
"else",
"cls",
".",
"query",
".",
"filter",
"(",
"cls",
".",
"deleted_at",
".",
"is_",
... | Search for communities.
Helper function which takes from database only those communities which
match search criteria. Uses parameter 'so' to set communities in the
correct order.
Parameter 'page' is introduced to restrict results and return only
slice of them for the current pa... | [
"Search",
"for",
"communities",
"."
] | python | train |
vertexproject/synapse | synapse/common.py | https://github.com/vertexproject/synapse/blob/22e67c5a8f6d7caddbcf34b39ab1bd2d6c4a6e0b/synapse/common.py#L196-L214 | def genfile(*paths):
'''
Create or open ( for read/write ) a file path join.
Args:
*paths: A list of paths to join together to make the file.
Notes:
If the file already exists, the fd returned is opened in ``r+b`` mode.
Otherwise, the fd is opened in ``w+b`` mode.
Returns:... | [
"def",
"genfile",
"(",
"*",
"paths",
")",
":",
"path",
"=",
"genpath",
"(",
"*",
"paths",
")",
"gendir",
"(",
"os",
".",
"path",
".",
"dirname",
"(",
"path",
")",
")",
"if",
"not",
"os",
".",
"path",
".",
"isfile",
"(",
"path",
")",
":",
"retur... | Create or open ( for read/write ) a file path join.
Args:
*paths: A list of paths to join together to make the file.
Notes:
If the file already exists, the fd returned is opened in ``r+b`` mode.
Otherwise, the fd is opened in ``w+b`` mode.
Returns:
io.BufferedRandom: A fil... | [
"Create",
"or",
"open",
"(",
"for",
"read",
"/",
"write",
")",
"a",
"file",
"path",
"join",
"."
] | python | train |
klahnakoski/pyLibrary | pyLibrary/env/emailer.py | https://github.com/klahnakoski/pyLibrary/blob/fa2dcbc48fda8d26999baef400e9a98149e0b982/pyLibrary/env/emailer.py#L63-L111 | def send_email(self,
from_address=None,
to_address=None,
subject=None,
text_data=None,
html_data=None
):
"""Sends an email.
from_addr is an email address; to_addrs is a list of email adresses.
Addresses can be plain (e.g. "jsmith@e... | [
"def",
"send_email",
"(",
"self",
",",
"from_address",
"=",
"None",
",",
"to_address",
"=",
"None",
",",
"subject",
"=",
"None",
",",
"text_data",
"=",
"None",
",",
"html_data",
"=",
"None",
")",
":",
"settings",
"=",
"self",
".",
"settings",
"from_addre... | Sends an email.
from_addr is an email address; to_addrs is a list of email adresses.
Addresses can be plain (e.g. "jsmith@example.com") or with real names
(e.g. "John Smith <jsmith@example.com>").
text_data and html_data are both strings. You can specify one or both.
If you sp... | [
"Sends",
"an",
"email",
"."
] | python | train |
tgbugs/pyontutils | pyontutils/sheets.py | https://github.com/tgbugs/pyontutils/blob/3d913db29c177db39151592909a4f56170ef8b35/pyontutils/sheets.py#L32-L59 | def update_sheet_values(spreadsheet_name, sheet_name, values, spreadsheet_service=None):
SPREADSHEET_ID = devconfig.secrets(spreadsheet_name)
if spreadsheet_service is None:
service = get_oauth_service(readonly=False)
ss = service.spreadsheets()
else:
ss = spreadsheet_service
"""... | [
"def",
"update_sheet_values",
"(",
"spreadsheet_name",
",",
"sheet_name",
",",
"values",
",",
"spreadsheet_service",
"=",
"None",
")",
":",
"SPREADSHEET_ID",
"=",
"devconfig",
".",
"secrets",
"(",
"spreadsheet_name",
")",
"if",
"spreadsheet_service",
"is",
"None",
... | requests = [
{'updateCells': {
'start': {'sheetId': TODO,
'rowIndex': 0,
'columnIndex': 0}
'rows': {'values'}
}
}]
response = ss.batchUpdate(
spreadsheetId=SPREADSHEET_ID, range=sheet_name,
body=body).execute... | [
"requests",
"=",
"[",
"{",
"updateCells",
":",
"{",
"start",
":",
"{",
"sheetId",
":",
"TODO",
"rowIndex",
":",
"0",
"columnIndex",
":",
"0",
"}",
"rows",
":",
"{",
"values",
"}",
"}",
"}",
"]",
"response",
"=",
"ss",
".",
"batchUpdate",
"(",
"spre... | python | train |
serkanyersen/underscore.py | src/underscore.py | https://github.com/serkanyersen/underscore.py/blob/07c25c3f0f789536e4ad47aa315faccc0da9602f/src/underscore.py#L1438-L1553 | def template(self, data=None, settings=None):
"""
Python micro-templating, similar to John Resig's implementation.
Underscore templating handles arbitrary delimiters, preserves
whitespace, and correctly escapes quotes within interpolated code.
"""
if settings is None:
... | [
"def",
"template",
"(",
"self",
",",
"data",
"=",
"None",
",",
"settings",
"=",
"None",
")",
":",
"if",
"settings",
"is",
"None",
":",
"settings",
"=",
"{",
"}",
"ts",
"=",
"_",
".",
"templateSettings",
"_",
".",
"defaults",
"(",
"ts",
",",
"self",... | Python micro-templating, similar to John Resig's implementation.
Underscore templating handles arbitrary delimiters, preserves
whitespace, and correctly escapes quotes within interpolated code. | [
"Python",
"micro",
"-",
"templating",
"similar",
"to",
"John",
"Resig",
"s",
"implementation",
".",
"Underscore",
"templating",
"handles",
"arbitrary",
"delimiters",
"preserves",
"whitespace",
"and",
"correctly",
"escapes",
"quotes",
"within",
"interpolated",
"code",
... | python | train |
Shapeways/coyote_framework | coyote_framework/webdriver/webdriverwrapper/WebDriverWrapper.py | https://github.com/Shapeways/coyote_framework/blob/cb29899b984a21d56bf65d0b1d907073948fe16c/coyote_framework/webdriver/webdriverwrapper/WebDriverWrapper.py#L201-L224 | def visit(self, url=''):
"""
Driver gets the provided url in the browser, returns True if successful
url -- An absolute or relative url stored as a string
"""
def _visit(url):
if len(url) > 0 and url[0] == '/':
# url's first character is a forward sla... | [
"def",
"visit",
"(",
"self",
",",
"url",
"=",
"''",
")",
":",
"def",
"_visit",
"(",
"url",
")",
":",
"if",
"len",
"(",
"url",
")",
">",
"0",
"and",
"url",
"[",
"0",
"]",
"==",
"'/'",
":",
"# url's first character is a forward slash; treat as relative pat... | Driver gets the provided url in the browser, returns True if successful
url -- An absolute or relative url stored as a string | [
"Driver",
"gets",
"the",
"provided",
"url",
"in",
"the",
"browser",
"returns",
"True",
"if",
"successful"
] | python | train |
Opentrons/opentrons | api/src/opentrons/protocol_api/contexts.py | https://github.com/Opentrons/opentrons/blob/a7c15cc2636ecb64ab56c7edc1d8a57163aaeadf/api/src/opentrons/protocol_api/contexts.py#L443-L448 | def home(self):
""" Homes the robot.
"""
self._log.debug("home")
self._location_cache = None
self._hw_manager.hardware.home() | [
"def",
"home",
"(",
"self",
")",
":",
"self",
".",
"_log",
".",
"debug",
"(",
"\"home\"",
")",
"self",
".",
"_location_cache",
"=",
"None",
"self",
".",
"_hw_manager",
".",
"hardware",
".",
"home",
"(",
")"
] | Homes the robot. | [
"Homes",
"the",
"robot",
"."
] | python | train |
pvlib/pvlib-python | pvlib/clearsky.py | https://github.com/pvlib/pvlib-python/blob/2e844a595b820b43d1170269781fa66bd0ccc8a3/pvlib/clearsky.py#L563-L570 | def _calc_d(aod700, p):
"""Calculate the d coefficient."""
p0 = 101325.
dp = 1/(18 + 152*aod700)
d = -0.337*aod700**2 + 0.63*aod700 + 0.116 + dp*np.log(p/p0)
return d | [
"def",
"_calc_d",
"(",
"aod700",
",",
"p",
")",
":",
"p0",
"=",
"101325.",
"dp",
"=",
"1",
"/",
"(",
"18",
"+",
"152",
"*",
"aod700",
")",
"d",
"=",
"-",
"0.337",
"*",
"aod700",
"**",
"2",
"+",
"0.63",
"*",
"aod700",
"+",
"0.116",
"+",
"dp",
... | Calculate the d coefficient. | [
"Calculate",
"the",
"d",
"coefficient",
"."
] | python | train |
bmuller/kademlia | kademlia/network.py | https://github.com/bmuller/kademlia/blob/4a8d445c9ee8f3ca10f56107e4445daed4933c8a/kademlia/network.py#L195-L211 | def save_state(self, fname):
"""
Save the state of this node (the alpha/ksize/id/immediate neighbors)
to a cache file with the given fname.
"""
log.info("Saving state to %s", fname)
data = {
'ksize': self.ksize,
'alpha': self.alpha,
'id... | [
"def",
"save_state",
"(",
"self",
",",
"fname",
")",
":",
"log",
".",
"info",
"(",
"\"Saving state to %s\"",
",",
"fname",
")",
"data",
"=",
"{",
"'ksize'",
":",
"self",
".",
"ksize",
",",
"'alpha'",
":",
"self",
".",
"alpha",
",",
"'id'",
":",
"self... | Save the state of this node (the alpha/ksize/id/immediate neighbors)
to a cache file with the given fname. | [
"Save",
"the",
"state",
"of",
"this",
"node",
"(",
"the",
"alpha",
"/",
"ksize",
"/",
"id",
"/",
"immediate",
"neighbors",
")",
"to",
"a",
"cache",
"file",
"with",
"the",
"given",
"fname",
"."
] | python | train |
bslatkin/dpxdt | dpxdt/server/auth.py | https://github.com/bslatkin/dpxdt/blob/9f860de1731021d99253670429e5f2157e1f6297/dpxdt/server/auth.py#L345-L359 | def superuser_api_key_required(f):
"""Decorator ensures only superuser API keys can request this function."""
@functools.wraps(f)
def wrapped(*args, **kwargs):
api_key = current_api_key()
g.api_key = api_key
utils.jsonify_assert(
api_key.superuser,
'API key=%... | [
"def",
"superuser_api_key_required",
"(",
"f",
")",
":",
"@",
"functools",
".",
"wraps",
"(",
"f",
")",
"def",
"wrapped",
"(",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"api_key",
"=",
"current_api_key",
"(",
")",
"g",
".",
"api_key",
"=",
"api... | Decorator ensures only superuser API keys can request this function. | [
"Decorator",
"ensures",
"only",
"superuser",
"API",
"keys",
"can",
"request",
"this",
"function",
"."
] | python | train |
zhanglab/psamm | psamm/importers/sbml.py | https://github.com/zhanglab/psamm/blob/dc427848c4f9d109ca590f0afa024c63b685b3f4/psamm/importers/sbml.py#L44-L54 | def _resolve_source(self, source):
"""Resolve source to filepath if it is a directory."""
if os.path.isdir(source):
sources = glob.glob(os.path.join(source, '*.sbml'))
if len(sources) == 0:
raise ModelLoadError('No .sbml file found in source directory')
... | [
"def",
"_resolve_source",
"(",
"self",
",",
"source",
")",
":",
"if",
"os",
".",
"path",
".",
"isdir",
"(",
"source",
")",
":",
"sources",
"=",
"glob",
".",
"glob",
"(",
"os",
".",
"path",
".",
"join",
"(",
"source",
",",
"'*.sbml'",
")",
")",
"i... | Resolve source to filepath if it is a directory. | [
"Resolve",
"source",
"to",
"filepath",
"if",
"it",
"is",
"a",
"directory",
"."
] | python | train |
archman/beamline | beamline/element.py | https://github.com/archman/beamline/blob/417bc5dc13e754bc89d246427984590fced64d07/beamline/element.py#L323-L338 | def _printCtrlConf(self):
""" get PV value and print out
"""
if self.ctrlinfo:
print("Control configs:")
for k, v in sorted(self.ctrlinfo.items(), reverse=True):
pv = v['pv']
rval = epics.caget(pv)
if rval is None:
... | [
"def",
"_printCtrlConf",
"(",
"self",
")",
":",
"if",
"self",
".",
"ctrlinfo",
":",
"print",
"(",
"\"Control configs:\"",
")",
"for",
"k",
",",
"v",
"in",
"sorted",
"(",
"self",
".",
"ctrlinfo",
".",
"items",
"(",
")",
",",
"reverse",
"=",
"True",
")... | get PV value and print out | [
"get",
"PV",
"value",
"and",
"print",
"out"
] | python | train |
mayfield/shellish | shellish/layout/table.py | https://github.com/mayfield/shellish/blob/df0f0e4612d138c34d8cb99b66ab5b8e47f1414a/shellish/layout/table.py#L472-L478 | def render_filter(self, next_filter):
""" Produce formatted output from the raw data stream. """
next(next_filter)
while True:
data = (yield)
res = [self.cell_format(access(data)) for access in self.accessors]
next_filter.send(res) | [
"def",
"render_filter",
"(",
"self",
",",
"next_filter",
")",
":",
"next",
"(",
"next_filter",
")",
"while",
"True",
":",
"data",
"=",
"(",
"yield",
")",
"res",
"=",
"[",
"self",
".",
"cell_format",
"(",
"access",
"(",
"data",
")",
")",
"for",
"acces... | Produce formatted output from the raw data stream. | [
"Produce",
"formatted",
"output",
"from",
"the",
"raw",
"data",
"stream",
"."
] | python | train |
tradenity/python-sdk | tradenity/resources/option_value.py | https://github.com/tradenity/python-sdk/blob/d13fbe23f4d6ff22554c6d8d2deaf209371adaf1/tradenity/resources/option_value.py#L644-L665 | def replace_option_value_by_id(cls, option_value_id, option_value, **kwargs):
"""Replace OptionValue
Replace all attributes of OptionValue
This method makes a synchronous HTTP request by default. To make an
asynchronous HTTP request, please pass async=True
>>> thread = api.repla... | [
"def",
"replace_option_value_by_id",
"(",
"cls",
",",
"option_value_id",
",",
"option_value",
",",
"*",
"*",
"kwargs",
")",
":",
"kwargs",
"[",
"'_return_http_data_only'",
"]",
"=",
"True",
"if",
"kwargs",
".",
"get",
"(",
"'async'",
")",
":",
"return",
"cls... | Replace OptionValue
Replace all attributes of OptionValue
This method makes a synchronous HTTP request by default. To make an
asynchronous HTTP request, please pass async=True
>>> thread = api.replace_option_value_by_id(option_value_id, option_value, async=True)
>>> result = thr... | [
"Replace",
"OptionValue"
] | python | train |
vladcalin/gemstone | gemstone/core/handlers.py | https://github.com/vladcalin/gemstone/blob/325a49d17621b9d45ffd2b5eca6f0de284de8ba4/gemstone/core/handlers.py#L119-L204 | def handle_single_request(self, request_object):
"""
Handles a single request object and returns the correct result as follows:
- A valid response object if it is a regular request (with ID)
- ``None`` if it was a notification (if None is returned, a response object with
"rece... | [
"def",
"handle_single_request",
"(",
"self",
",",
"request_object",
")",
":",
"# don't handle responses?",
"if",
"isinstance",
"(",
"request_object",
",",
"JsonRpcResponse",
")",
":",
"return",
"request_object",
"error",
"=",
"None",
"result",
"=",
"None",
"id_",
... | Handles a single request object and returns the correct result as follows:
- A valid response object if it is a regular request (with ID)
- ``None`` if it was a notification (if None is returned, a response object with
"received" body was already sent to the client.
:param request_ob... | [
"Handles",
"a",
"single",
"request",
"object",
"and",
"returns",
"the",
"correct",
"result",
"as",
"follows",
":"
] | python | train |
pandas-dev/pandas | pandas/core/indexes/base.py | https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/indexes/base.py#L1123-L1148 | def to_series(self, index=None, name=None):
"""
Create a Series with both index and values equal to the index keys
useful with map for returning an indexer based on an index.
Parameters
----------
index : Index, optional
index of resulting Series. If None, de... | [
"def",
"to_series",
"(",
"self",
",",
"index",
"=",
"None",
",",
"name",
"=",
"None",
")",
":",
"from",
"pandas",
"import",
"Series",
"if",
"index",
"is",
"None",
":",
"index",
"=",
"self",
".",
"_shallow_copy",
"(",
")",
"if",
"name",
"is",
"None",
... | Create a Series with both index and values equal to the index keys
useful with map for returning an indexer based on an index.
Parameters
----------
index : Index, optional
index of resulting Series. If None, defaults to original index
name : string, optional
... | [
"Create",
"a",
"Series",
"with",
"both",
"index",
"and",
"values",
"equal",
"to",
"the",
"index",
"keys",
"useful",
"with",
"map",
"for",
"returning",
"an",
"indexer",
"based",
"on",
"an",
"index",
"."
] | python | train |
barrust/mediawiki | mediawiki/utilities.py | https://github.com/barrust/mediawiki/blob/292e0be6c752409062dceed325d74839caf16a9b/mediawiki/utilities.py#L86-L93 | def is_relative_url(url):
""" simple method to determine if a url is relative or absolute """
if url.startswith("#"):
return None
if url.find("://") > 0 or url.startswith("//"):
# either 'http(s)://...' or '//cdn...' and therefore absolute
return False
return True | [
"def",
"is_relative_url",
"(",
"url",
")",
":",
"if",
"url",
".",
"startswith",
"(",
"\"#\"",
")",
":",
"return",
"None",
"if",
"url",
".",
"find",
"(",
"\"://\"",
")",
">",
"0",
"or",
"url",
".",
"startswith",
"(",
"\"//\"",
")",
":",
"# either 'htt... | simple method to determine if a url is relative or absolute | [
"simple",
"method",
"to",
"determine",
"if",
"a",
"url",
"is",
"relative",
"or",
"absolute"
] | python | train |
saltstack/salt | salt/modules/status.py | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/status.py#L268-L293 | def loadavg():
'''
Return the load averages for this minion
.. versionchanged:: 2016.11.4
Added support for AIX
CLI Example:
.. code-block:: bash
salt '*' status.loadavg
:raises CommandExecutionError: If the system cannot report loadaverages to Python
'''
if __gr... | [
"def",
"loadavg",
"(",
")",
":",
"if",
"__grains__",
"[",
"'kernel'",
"]",
"==",
"'AIX'",
":",
"return",
"_aix_loadavg",
"(",
")",
"try",
":",
"load_avg",
"=",
"os",
".",
"getloadavg",
"(",
")",
"except",
"AttributeError",
":",
"# Some UNIX-based operating s... | Return the load averages for this minion
.. versionchanged:: 2016.11.4
Added support for AIX
CLI Example:
.. code-block:: bash
salt '*' status.loadavg
:raises CommandExecutionError: If the system cannot report loadaverages to Python | [
"Return",
"the",
"load",
"averages",
"for",
"this",
"minion"
] | python | train |
twisted/epsilon | epsilon/amprouter.py | https://github.com/twisted/epsilon/blob/e85fa985a41983ef06e1d3bb26639181e1f78b24/epsilon/amprouter.py#L171-L183 | def startReceivingBoxes(self, sender):
"""
Initialize route tracking objects.
"""
self._sender = sender
for routeName, route in self._unstarted.iteritems():
# Any route which has been bound but which does not yet have a
# remote route name should not yet b... | [
"def",
"startReceivingBoxes",
"(",
"self",
",",
"sender",
")",
":",
"self",
".",
"_sender",
"=",
"sender",
"for",
"routeName",
",",
"route",
"in",
"self",
".",
"_unstarted",
".",
"iteritems",
"(",
")",
":",
"# Any route which has been bound but which does not yet ... | Initialize route tracking objects. | [
"Initialize",
"route",
"tracking",
"objects",
"."
] | python | train |
mitsei/dlkit | dlkit/json_/learning/objects.py | https://github.com/mitsei/dlkit/blob/445f968a175d61c8d92c0f617a3c17dc1dc7c584/dlkit/json_/learning/objects.py#L343-L353 | def get_cognitive_process_metadata(self):
"""Gets the metadata for a cognitive process.
return: (osid.Metadata) - metadata for the cognitive process
*compliance: mandatory -- This method must be implemented.*
"""
# Implemented from template for osid.resource.ResourceForm.get_gr... | [
"def",
"get_cognitive_process_metadata",
"(",
"self",
")",
":",
"# Implemented from template for osid.resource.ResourceForm.get_group_metadata_template",
"metadata",
"=",
"dict",
"(",
"self",
".",
"_mdata",
"[",
"'cognitive_process'",
"]",
")",
"metadata",
".",
"update",
"(... | Gets the metadata for a cognitive process.
return: (osid.Metadata) - metadata for the cognitive process
*compliance: mandatory -- This method must be implemented.* | [
"Gets",
"the",
"metadata",
"for",
"a",
"cognitive",
"process",
"."
] | python | train |
michaeljohnbarr/django-timezone-utils | timezone_utils/fields.py | https://github.com/michaeljohnbarr/django-timezone-utils/blob/61c8b50c59049cb7eccd4e3892f332f88b890f00/timezone_utils/fields.py#L77-L85 | def get_prep_value(self, value):
"""Converts timezone instances to strings for db storage."""
# pylint: disable=newstyle
value = super(TimeZoneField, self).get_prep_value(value)
if isinstance(value, tzinfo):
return value.zone
return value | [
"def",
"get_prep_value",
"(",
"self",
",",
"value",
")",
":",
"# pylint: disable=newstyle",
"value",
"=",
"super",
"(",
"TimeZoneField",
",",
"self",
")",
".",
"get_prep_value",
"(",
"value",
")",
"if",
"isinstance",
"(",
"value",
",",
"tzinfo",
")",
":",
... | Converts timezone instances to strings for db storage. | [
"Converts",
"timezone",
"instances",
"to",
"strings",
"for",
"db",
"storage",
"."
] | python | train |
bkg/greenwich | greenwich/raster.py | https://github.com/bkg/greenwich/blob/57ec644dadfe43ce0ecf2cfd32a2de71e0c8c141/greenwich/raster.py#L634-L637 | def shape(self):
"""Returns a tuple of row, column, (band count if multidimensional)."""
shp = (self.ds.RasterYSize, self.ds.RasterXSize, self.ds.RasterCount)
return shp[:2] if shp[2] <= 1 else shp | [
"def",
"shape",
"(",
"self",
")",
":",
"shp",
"=",
"(",
"self",
".",
"ds",
".",
"RasterYSize",
",",
"self",
".",
"ds",
".",
"RasterXSize",
",",
"self",
".",
"ds",
".",
"RasterCount",
")",
"return",
"shp",
"[",
":",
"2",
"]",
"if",
"shp",
"[",
"... | Returns a tuple of row, column, (band count if multidimensional). | [
"Returns",
"a",
"tuple",
"of",
"row",
"column",
"(",
"band",
"count",
"if",
"multidimensional",
")",
"."
] | python | test |
Autodesk/aomi | aomi/helpers.py | https://github.com/Autodesk/aomi/blob/84da2dfb0424837adf9c4ddc1aa352e942bb7a4a/aomi/helpers.py#L56-L68 | def is_tagged(required_tags, has_tags):
"""Checks if tags match"""
if not required_tags and not has_tags:
return True
elif not required_tags:
return False
found_tags = []
for tag in required_tags:
if tag in has_tags:
found_tags.append(tag)
return len(found_t... | [
"def",
"is_tagged",
"(",
"required_tags",
",",
"has_tags",
")",
":",
"if",
"not",
"required_tags",
"and",
"not",
"has_tags",
":",
"return",
"True",
"elif",
"not",
"required_tags",
":",
"return",
"False",
"found_tags",
"=",
"[",
"]",
"for",
"tag",
"in",
"re... | Checks if tags match | [
"Checks",
"if",
"tags",
"match"
] | python | train |
aiortc/aiortc | aiortc/rtcsctptransport.py | https://github.com/aiortc/aiortc/blob/60ed036abf4575bd63985724b4493d569e6da29b/aiortc/rtcsctptransport.py#L1485-L1493 | def _data_channel_close(self, channel, transmit=True):
"""
Request closing the datachannel by sending an Outgoing Stream Reset Request.
"""
if channel.readyState not in ['closing', 'closed']:
channel._setReadyState('closing')
self._reconfig_queue.append(channel.id... | [
"def",
"_data_channel_close",
"(",
"self",
",",
"channel",
",",
"transmit",
"=",
"True",
")",
":",
"if",
"channel",
".",
"readyState",
"not",
"in",
"[",
"'closing'",
",",
"'closed'",
"]",
":",
"channel",
".",
"_setReadyState",
"(",
"'closing'",
")",
"self"... | Request closing the datachannel by sending an Outgoing Stream Reset Request. | [
"Request",
"closing",
"the",
"datachannel",
"by",
"sending",
"an",
"Outgoing",
"Stream",
"Reset",
"Request",
"."
] | python | train |
marshmallow-code/apispec | src/apispec/ext/marshmallow/openapi.py | https://github.com/marshmallow-code/apispec/blob/e92ceffd12b2e392b8d199ed314bd2a7e6512dff/src/apispec/ext/marshmallow/openapi.py#L696-L706 | def get_ref_dict(self, schema):
"""Method to create a dictionary containing a JSON reference to the
schema in the spec
"""
schema_key = make_schema_key(schema)
ref_schema = build_reference(
"schema", self.openapi_version.major, self.refs[schema_key]
)
... | [
"def",
"get_ref_dict",
"(",
"self",
",",
"schema",
")",
":",
"schema_key",
"=",
"make_schema_key",
"(",
"schema",
")",
"ref_schema",
"=",
"build_reference",
"(",
"\"schema\"",
",",
"self",
".",
"openapi_version",
".",
"major",
",",
"self",
".",
"refs",
"[",
... | Method to create a dictionary containing a JSON reference to the
schema in the spec | [
"Method",
"to",
"create",
"a",
"dictionary",
"containing",
"a",
"JSON",
"reference",
"to",
"the",
"schema",
"in",
"the",
"spec"
] | python | train |
Yelp/kafka-utils | kafka_utils/kafka_corruption_check/main.py | https://github.com/Yelp/kafka-utils/blob/cdb4d64308f3079ee0873250bf7b34d0d94eca50/kafka_utils/kafka_corruption_check/main.py#L206-L226 | def check_corrupted_files_cmd(java_home, files):
"""Check the file corruption of the specified files.
:param java_home: the JAVA_HOME
:type java_home: string
:param files: list of files to be checked
:type files: list of string
"""
files_str = ",".join(files)
check_command = CHECK_COMMA... | [
"def",
"check_corrupted_files_cmd",
"(",
"java_home",
",",
"files",
")",
":",
"files_str",
"=",
"\",\"",
".",
"join",
"(",
"files",
")",
"check_command",
"=",
"CHECK_COMMAND",
".",
"format",
"(",
"ionice",
"=",
"IONICE",
",",
"java_home",
"=",
"java_home",
"... | Check the file corruption of the specified files.
:param java_home: the JAVA_HOME
:type java_home: string
:param files: list of files to be checked
:type files: list of string | [
"Check",
"the",
"file",
"corruption",
"of",
"the",
"specified",
"files",
"."
] | python | train |
TissueMAPS/TmClient | src/python/tmclient/auth.py | https://github.com/TissueMAPS/TmClient/blob/6fb40622af19142cb5169a64b8c2965993a25ab1/src/python/tmclient/auth.py#L23-L69 | def load_credentials_from_file(username):
'''Loads password for `username` from a file.
The file must be called ``.tm_pass`` and stored in
the home directory. It must provide a YAML mapping where
keys are usernames and values the corresponding passwords.
Parameters
----------
username: str... | [
"def",
"load_credentials_from_file",
"(",
"username",
")",
":",
"filename",
"=",
"os",
".",
"path",
".",
"expandvars",
"(",
"os",
".",
"path",
".",
"join",
"(",
"'$HOME'",
",",
"'.tm_pass'",
")",
")",
"try",
":",
"with",
"open",
"(",
"filename",
")",
"... | Loads password for `username` from a file.
The file must be called ``.tm_pass`` and stored in
the home directory. It must provide a YAML mapping where
keys are usernames and values the corresponding passwords.
Parameters
----------
username: str
name of the TissueMAPS user
Returns... | [
"Loads",
"password",
"for",
"username",
"from",
"a",
"file",
"."
] | python | train |
sorgerlab/indra | indra/assemblers/english/assembler.py | https://github.com/sorgerlab/indra/blob/79a70415832c5702d7a820c7c9ccc8e25010124b/indra/assemblers/english/assembler.py#L306-L314 | def _assemble_translocation(stmt):
"""Assemble Translocation statements into text."""
agent_str = _assemble_agent_str(stmt.agent)
stmt_str = agent_str + ' translocates'
if stmt.from_location is not None:
stmt_str += ' from the ' + stmt.from_location
if stmt.to_location is not None:
s... | [
"def",
"_assemble_translocation",
"(",
"stmt",
")",
":",
"agent_str",
"=",
"_assemble_agent_str",
"(",
"stmt",
".",
"agent",
")",
"stmt_str",
"=",
"agent_str",
"+",
"' translocates'",
"if",
"stmt",
".",
"from_location",
"is",
"not",
"None",
":",
"stmt_str",
"+... | Assemble Translocation statements into text. | [
"Assemble",
"Translocation",
"statements",
"into",
"text",
"."
] | python | train |
inasafe/inasafe | safe/definitions/utilities.py | https://github.com/inasafe/inasafe/blob/831d60abba919f6d481dc94a8d988cc205130724/safe/definitions/utilities.py#L770-L801 | def is_affected(hazard, classification, hazard_class, qsettings=None):
"""Get affected flag for hazard in classification in hazard class.
:param hazard: The hazard key.
:type hazard: basestring
:param classification: The classification key.
:type classification: basestring
:param hazard_class... | [
"def",
"is_affected",
"(",
"hazard",
",",
"classification",
",",
"hazard_class",
",",
"qsettings",
"=",
"None",
")",
":",
"preference_data",
"=",
"setting",
"(",
"'population_preference'",
",",
"default",
"=",
"generate_default_profile",
"(",
")",
",",
"qsettings"... | Get affected flag for hazard in classification in hazard class.
:param hazard: The hazard key.
:type hazard: basestring
:param classification: The classification key.
:type classification: basestring
:param hazard_class: The hazard class key.
:type hazard_class: basestring
:param qsettin... | [
"Get",
"affected",
"flag",
"for",
"hazard",
"in",
"classification",
"in",
"hazard",
"class",
"."
] | python | train |
econ-ark/HARK | HARK/ConsumptionSaving/ConsAggShockModel.py | https://github.com/econ-ark/HARK/blob/3d184153a189e618a87c9540df1cd12044039cc5/HARK/ConsumptionSaving/ConsAggShockModel.py#L1343-L1362 | def update(self):
'''
Use primitive parameters (and perfect foresight calibrations) to make
interest factor and wage rate functions (of capital to labor ratio),
as well as discrete approximations to the aggregate shock distributions.
Parameters
----------
None
... | [
"def",
"update",
"(",
"self",
")",
":",
"CobbDouglasEconomy",
".",
"update",
"(",
"self",
")",
"StateCount",
"=",
"self",
".",
"MrkvArray",
".",
"shape",
"[",
"0",
"]",
"AFunc_all",
"=",
"[",
"]",
"for",
"i",
"in",
"range",
"(",
"StateCount",
")",
":... | Use primitive parameters (and perfect foresight calibrations) to make
interest factor and wage rate functions (of capital to labor ratio),
as well as discrete approximations to the aggregate shock distributions.
Parameters
----------
None
Returns
-------
... | [
"Use",
"primitive",
"parameters",
"(",
"and",
"perfect",
"foresight",
"calibrations",
")",
"to",
"make",
"interest",
"factor",
"and",
"wage",
"rate",
"functions",
"(",
"of",
"capital",
"to",
"labor",
"ratio",
")",
"as",
"well",
"as",
"discrete",
"approximation... | python | train |
tensorflow/hub | examples/image_retraining/retrain.py | https://github.com/tensorflow/hub/blob/09f45963f6787322967b6fec61459f3ac56fbb27/examples/image_retraining/retrain.py#L317-L340 | def run_bottleneck_on_image(sess, image_data, image_data_tensor,
decoded_image_tensor, resized_input_tensor,
bottleneck_tensor):
"""Runs inference on an image to extract the 'bottleneck' summary layer.
Args:
sess: Current active TensorFlow Session.
im... | [
"def",
"run_bottleneck_on_image",
"(",
"sess",
",",
"image_data",
",",
"image_data_tensor",
",",
"decoded_image_tensor",
",",
"resized_input_tensor",
",",
"bottleneck_tensor",
")",
":",
"# First decode the JPEG image, resize it, and rescale the pixel values.",
"resized_input_values... | Runs inference on an image to extract the 'bottleneck' summary layer.
Args:
sess: Current active TensorFlow Session.
image_data: String of raw JPEG data.
image_data_tensor: Input data layer in the graph.
decoded_image_tensor: Output of initial image resizing and preprocessing.
resized_input_tenso... | [
"Runs",
"inference",
"on",
"an",
"image",
"to",
"extract",
"the",
"bottleneck",
"summary",
"layer",
"."
] | python | train |
pywbem/pywbem | pywbem/tupleparse.py | https://github.com/pywbem/pywbem/blob/e54ecb82c2211e289a268567443d60fdd489f1e4/pywbem/tupleparse.py#L1888-L1914 | def parse_returnvalue(self, tup_tree):
"""
Parse the RETURNVALUE element. Returns name, attributes, and
one child as a tuple.
::
<!ELEMENT RETURNVALUE (VALUE | VALUE.REFERENCE)?>
<!ATTLIST RETURNVALUE
%EmbeddedObject;
%ParamType... | [
"def",
"parse_returnvalue",
"(",
"self",
",",
"tup_tree",
")",
":",
"# Version 2.1.1 of the DTD lacks the %ParamType attribute but it",
"# is present in version 2.2. Make it optional to be backwards",
"# compatible.",
"self",
".",
"check_node",
"(",
"tup_tree",
",",
"'RETURNVALUE'... | Parse the RETURNVALUE element. Returns name, attributes, and
one child as a tuple.
::
<!ELEMENT RETURNVALUE (VALUE | VALUE.REFERENCE)?>
<!ATTLIST RETURNVALUE
%EmbeddedObject;
%ParamType; #IMPLIED> | [
"Parse",
"the",
"RETURNVALUE",
"element",
".",
"Returns",
"name",
"attributes",
"and",
"one",
"child",
"as",
"a",
"tuple",
"."
] | python | train |
pyBookshelf/bookshelf | bookshelf/api_v1.py | https://github.com/pyBookshelf/bookshelf/blob/a6770678e735de95b194f6e6989223970db5f654/bookshelf/api_v1.py#L81-L91 | def add_firewalld_service(service, permanent=True):
""" adds a firewall rule """
yum_install(packages=['firewalld'])
with settings(hide('warnings', 'running', 'stdout', 'stderr'),
warn_only=True, capture=True):
p = ''
if permanent:
p = '--permanent'
sud... | [
"def",
"add_firewalld_service",
"(",
"service",
",",
"permanent",
"=",
"True",
")",
":",
"yum_install",
"(",
"packages",
"=",
"[",
"'firewalld'",
"]",
")",
"with",
"settings",
"(",
"hide",
"(",
"'warnings'",
",",
"'running'",
",",
"'stdout'",
",",
"'stderr'"... | adds a firewall rule | [
"adds",
"a",
"firewall",
"rule"
] | python | train |
baruwa-enterprise/BaruwaAPI | BaruwaAPI/resource.py | https://github.com/baruwa-enterprise/BaruwaAPI/blob/53335b377ccfd388e42f4f240f181eed72f51180/BaruwaAPI/resource.py#L464-L469 | def delete_fallbackserver(self, serverid, data):
"""Delete Fallback server"""
return self.api_call(
ENDPOINTS['fallbackservers']['delete'],
dict(serverid=serverid),
body=data) | [
"def",
"delete_fallbackserver",
"(",
"self",
",",
"serverid",
",",
"data",
")",
":",
"return",
"self",
".",
"api_call",
"(",
"ENDPOINTS",
"[",
"'fallbackservers'",
"]",
"[",
"'delete'",
"]",
",",
"dict",
"(",
"serverid",
"=",
"serverid",
")",
",",
"body",
... | Delete Fallback server | [
"Delete",
"Fallback",
"server"
] | python | train |
Sean1708/HipPy | hippy/compiler.py | https://github.com/Sean1708/HipPy/blob/d0ea8fb1e417f1fedaa8e215e3d420b90c4de691/hippy/compiler.py#L82-L103 | def _compile_key_val(self, data, indent_level):
"""Compile a dictionary."""
buffer = ''
for (key, val) in data.items():
buffer += self._indent * indent_level
# TODO: assumes key is a string
buffer += key + ':'
if isinstance(val, dict):
... | [
"def",
"_compile_key_val",
"(",
"self",
",",
"data",
",",
"indent_level",
")",
":",
"buffer",
"=",
"''",
"for",
"(",
"key",
",",
"val",
")",
"in",
"data",
".",
"items",
"(",
")",
":",
"buffer",
"+=",
"self",
".",
"_indent",
"*",
"indent_level",
"# TO... | Compile a dictionary. | [
"Compile",
"a",
"dictionary",
"."
] | python | train |
brocade/pynos | pynos/versions/ver_6/ver_6_0_1/yang/brocade_interface_ext.py | https://github.com/brocade/pynos/blob/bd8a34e98f322de3fc06750827d8bbc3a0c00380/pynos/versions/ver_6/ver_6_0_1/yang/brocade_interface_ext.py#L629-L645 | def get_ip_interface_output_interface_vrf(self, **kwargs):
"""Auto Generated Code
"""
config = ET.Element("config")
get_ip_interface = ET.Element("get_ip_interface")
config = get_ip_interface
output = ET.SubElement(get_ip_interface, "output")
interface = ET.SubEle... | [
"def",
"get_ip_interface_output_interface_vrf",
"(",
"self",
",",
"*",
"*",
"kwargs",
")",
":",
"config",
"=",
"ET",
".",
"Element",
"(",
"\"config\"",
")",
"get_ip_interface",
"=",
"ET",
".",
"Element",
"(",
"\"get_ip_interface\"",
")",
"config",
"=",
"get_ip... | Auto Generated Code | [
"Auto",
"Generated",
"Code"
] | python | train |
portfoliome/foil | foil/iteration.py | https://github.com/portfoliome/foil/blob/b66d8cf4ab048a387d8c7a033b47e922ed6917d6/foil/iteration.py#L5-L12 | def chunks(items, chunksize):
"""Turn generator sequence into sequence of chunks."""
items = iter(items)
for first in items:
chunk = chain((first,), islice(items, chunksize - 1))
yield chunk
deque(chunk, 0) | [
"def",
"chunks",
"(",
"items",
",",
"chunksize",
")",
":",
"items",
"=",
"iter",
"(",
"items",
")",
"for",
"first",
"in",
"items",
":",
"chunk",
"=",
"chain",
"(",
"(",
"first",
",",
")",
",",
"islice",
"(",
"items",
",",
"chunksize",
"-",
"1",
"... | Turn generator sequence into sequence of chunks. | [
"Turn",
"generator",
"sequence",
"into",
"sequence",
"of",
"chunks",
"."
] | python | train |
quantmind/dynts | dynts/dsl/__init__.py | https://github.com/quantmind/dynts/blob/21ac57c648bfec402fa6b1fe569496cf098fb5e8/dynts/dsl/__init__.py#L18-L43 | def parse(timeseries_expression, method=None, functions=None, debug=False):
'''Function for parsing :ref:`timeseries expressions <dsl-script>`.
If succesful, it returns an instance of :class:`dynts.dsl.Expr` which
can be used to to populate timeseries or scatters once data is available.
Parsing is... | [
"def",
"parse",
"(",
"timeseries_expression",
",",
"method",
"=",
"None",
",",
"functions",
"=",
"None",
",",
"debug",
"=",
"False",
")",
":",
"if",
"not",
"parsefunc",
":",
"raise",
"ExpressionError",
"(",
"'Could not parse. No parser installed.'",
")",
"functi... | Function for parsing :ref:`timeseries expressions <dsl-script>`.
If succesful, it returns an instance of :class:`dynts.dsl.Expr` which
can be used to to populate timeseries or scatters once data is available.
Parsing is implemented using the ply_ module,
an implementation of lex and yacc parsing t... | [
"Function",
"for",
"parsing",
":",
"ref",
":",
"timeseries",
"expressions",
"<dsl",
"-",
"script",
">",
".",
"If",
"succesful",
"it",
"returns",
"an",
"instance",
"of",
":",
"class",
":",
"dynts",
".",
"dsl",
".",
"Expr",
"which",
"can",
"be",
"used",
... | python | train |
Capitains/MyCapytain | MyCapytain/resolvers/dts/api_v1.py | https://github.com/Capitains/MyCapytain/blob/b11bbf6b6ae141fc02be70471e3fbf6907be6593/MyCapytain/resolvers/dts/api_v1.py#L147-L172 | def getTextualNode(
self,
textId: str,
subreference: Union[str, BaseReference]=None,
prevnext: bool=False,
metadata: bool=False
) -> DtsResolverDocument:
""" Retrieve a text node from the API
:param textId: CtsTextMetadata Identifier
... | [
"def",
"getTextualNode",
"(",
"self",
",",
"textId",
":",
"str",
",",
"subreference",
":",
"Union",
"[",
"str",
",",
"BaseReference",
"]",
"=",
"None",
",",
"prevnext",
":",
"bool",
"=",
"False",
",",
"metadata",
":",
"bool",
"=",
"False",
")",
"->",
... | Retrieve a text node from the API
:param textId: CtsTextMetadata Identifier
:type textId: str
:param subreference: CapitainsCtsPassage Reference
:type subreference: str
:param prevnext: Retrieve graph representing previous and next passage
:type prevnext: boolean
... | [
"Retrieve",
"a",
"text",
"node",
"from",
"the",
"API"
] | python | train |
googleapis/google-cloud-python | datalabeling/google/cloud/datalabeling_v1beta1/gapic/data_labeling_service_client.py | https://github.com/googleapis/google-cloud-python/blob/85e80125a59cb10f8cb105f25ecc099e4b940b50/datalabeling/google/cloud/datalabeling_v1beta1/gapic/data_labeling_service_client.py#L109-L116 | def annotated_dataset_path(cls, project, dataset, annotated_dataset):
"""Return a fully-qualified annotated_dataset string."""
return google.api_core.path_template.expand(
"projects/{project}/datasets/{dataset}/annotatedDatasets/{annotated_dataset}",
project=project,
... | [
"def",
"annotated_dataset_path",
"(",
"cls",
",",
"project",
",",
"dataset",
",",
"annotated_dataset",
")",
":",
"return",
"google",
".",
"api_core",
".",
"path_template",
".",
"expand",
"(",
"\"projects/{project}/datasets/{dataset}/annotatedDatasets/{annotated_dataset}\"",... | Return a fully-qualified annotated_dataset string. | [
"Return",
"a",
"fully",
"-",
"qualified",
"annotated_dataset",
"string",
"."
] | python | train |
MichaelAquilina/S4 | s4/clients/local.py | https://github.com/MichaelAquilina/S4/blob/05d74697e6ec683f0329c983f7c3f05ab75fd57e/s4/clients/local.py#L77-L86 | def unlock(self):
"""
Unlock the active advisory lock.
"""
logger.debug("Releasing lock %s", self.lock_file)
self._lock.release()
try:
os.unlink(self.lock_file)
except FileNotFoundError:
pass | [
"def",
"unlock",
"(",
"self",
")",
":",
"logger",
".",
"debug",
"(",
"\"Releasing lock %s\"",
",",
"self",
".",
"lock_file",
")",
"self",
".",
"_lock",
".",
"release",
"(",
")",
"try",
":",
"os",
".",
"unlink",
"(",
"self",
".",
"lock_file",
")",
"ex... | Unlock the active advisory lock. | [
"Unlock",
"the",
"active",
"advisory",
"lock",
"."
] | python | train |
GoogleCloudPlatform/python-repo-tools | gcp_devrel/tools/pylint.py | https://github.com/GoogleCloudPlatform/python-repo-tools/blob/87422ba91814529848a2b8bf8be4294283a3e041/gcp_devrel/tools/pylint.py#L148-L167 | def determine_final_config(config_module):
"""Determines the final additions and replacements.
Combines the config module with the defaults.
Args:
config_module: The loaded local configuration module.
Returns:
Config: the final configuration.
"""
config = Config(
DEFAU... | [
"def",
"determine_final_config",
"(",
"config_module",
")",
":",
"config",
"=",
"Config",
"(",
"DEFAULT_LIBRARY_RC_ADDITIONS",
",",
"DEFAULT_LIBRARY_RC_REPLACEMENTS",
",",
"DEFAULT_TEST_RC_ADDITIONS",
",",
"DEFAULT_TEST_RC_REPLACEMENTS",
")",
"for",
"field",
"in",
"config",... | Determines the final additions and replacements.
Combines the config module with the defaults.
Args:
config_module: The loaded local configuration module.
Returns:
Config: the final configuration. | [
"Determines",
"the",
"final",
"additions",
"and",
"replacements",
"."
] | python | train |
sethmlarson/virtualbox-python | virtualbox/library.py | https://github.com/sethmlarson/virtualbox-python/blob/706c8e3f6e3aee17eb06458e73cbb4bc2d37878b/virtualbox/library.py#L25291-L25320 | def get_screen_resolution(self, screen_id):
"""Queries certain attributes such as display width, height, color depth
and the X and Y origin for a given guest screen.
The parameters @a xOrigin and @a yOrigin return the X and Y
coordinates of the framebuffer's origin.
... | [
"def",
"get_screen_resolution",
"(",
"self",
",",
"screen_id",
")",
":",
"if",
"not",
"isinstance",
"(",
"screen_id",
",",
"baseinteger",
")",
":",
"raise",
"TypeError",
"(",
"\"screen_id can only be an instance of type baseinteger\"",
")",
"(",
"width",
",",
"heigh... | Queries certain attributes such as display width, height, color depth
and the X and Y origin for a given guest screen.
The parameters @a xOrigin and @a yOrigin return the X and Y
coordinates of the framebuffer's origin.
All return parameters are optional.
in sc... | [
"Queries",
"certain",
"attributes",
"such",
"as",
"display",
"width",
"height",
"color",
"depth",
"and",
"the",
"X",
"and",
"Y",
"origin",
"for",
"a",
"given",
"guest",
"screen",
".",
"The",
"parameters",
"@a",
"xOrigin",
"and",
"@a",
"yOrigin",
"return",
... | python | train |
wakatime/wakatime | wakatime/packages/configparser/__init__.py | https://github.com/wakatime/wakatime/blob/74519ace04e8472f3a3993269963732b9946a01d/wakatime/packages/configparser/__init__.py#L1235-L1239 | def set(self, section, option, value=None):
"""Set an option. Extends RawConfigParser.set by validating type and
interpolation syntax on the value."""
_, option, value = self._validate_value_types(option=option, value=value)
super(ConfigParser, self).set(section, option, value) | [
"def",
"set",
"(",
"self",
",",
"section",
",",
"option",
",",
"value",
"=",
"None",
")",
":",
"_",
",",
"option",
",",
"value",
"=",
"self",
".",
"_validate_value_types",
"(",
"option",
"=",
"option",
",",
"value",
"=",
"value",
")",
"super",
"(",
... | Set an option. Extends RawConfigParser.set by validating type and
interpolation syntax on the value. | [
"Set",
"an",
"option",
".",
"Extends",
"RawConfigParser",
".",
"set",
"by",
"validating",
"type",
"and",
"interpolation",
"syntax",
"on",
"the",
"value",
"."
] | python | train |
xtuml/pyxtuml | bridgepoint/prebuild.py | https://github.com/xtuml/pyxtuml/blob/7dd9343b9a0191d1db1887ab9288d0a026608d9a/bridgepoint/prebuild.py#L46-L61 | def get_defining_component(pe_pe):
'''
get the C_C in which pe_pe is defined
'''
if pe_pe is None:
return None
if pe_pe.__class__.__name__ != 'PE_PE':
pe_pe = xtuml.navigate_one(pe_pe).PE_PE[8001]()
ep_pkg = xtuml.navigate_one(pe_pe).EP_PKG[8000]()
if ep_pkg:
... | [
"def",
"get_defining_component",
"(",
"pe_pe",
")",
":",
"if",
"pe_pe",
"is",
"None",
":",
"return",
"None",
"if",
"pe_pe",
".",
"__class__",
".",
"__name__",
"!=",
"'PE_PE'",
":",
"pe_pe",
"=",
"xtuml",
".",
"navigate_one",
"(",
"pe_pe",
")",
".",
"PE_P... | get the C_C in which pe_pe is defined | [
"get",
"the",
"C_C",
"in",
"which",
"pe_pe",
"is",
"defined"
] | python | test |
kiliankoe/dvbpy | dvb/dvb.py | https://github.com/kiliankoe/dvbpy/blob/d499706ae56386d680f78975d3512d56f848e9dc/dvb/dvb.py#L14-L52 | def monitor(stop, offset=0, limit=10, city='Dresden', *, raw=False):
"""
VVO Online Monitor
(GET http://widgets.vvo-online.de/abfahrtsmonitor/Abfahrten.do)
:param stop: Name of Stop
:param offset: Minimum time of arrival
:param limit: Count of returned results
:param city: Name of City
... | [
"def",
"monitor",
"(",
"stop",
",",
"offset",
"=",
"0",
",",
"limit",
"=",
"10",
",",
"city",
"=",
"'Dresden'",
",",
"*",
",",
"raw",
"=",
"False",
")",
":",
"try",
":",
"r",
"=",
"requests",
".",
"get",
"(",
"url",
"=",
"'http://widgets.vvo-online... | VVO Online Monitor
(GET http://widgets.vvo-online.de/abfahrtsmonitor/Abfahrten.do)
:param stop: Name of Stop
:param offset: Minimum time of arrival
:param limit: Count of returned results
:param city: Name of City
:param raw: Return raw response
:return: Dict of stops | [
"VVO",
"Online",
"Monitor",
"(",
"GET",
"http",
":",
"//",
"widgets",
".",
"vvo",
"-",
"online",
".",
"de",
"/",
"abfahrtsmonitor",
"/",
"Abfahrten",
".",
"do",
")"
] | python | train |
Yelp/py_zipkin | py_zipkin/thrift/__init__.py | https://github.com/Yelp/py_zipkin/blob/0944d9a3fb1f1798dbb276694aeed99f2b4283ba/py_zipkin/thrift/__init__.py#L24-L34 | def create_annotation(timestamp, value, host):
"""
Create a zipkin annotation object
:param timestamp: timestamp of when the annotation occured in microseconds
:param value: name of the annotation, such as 'sr'
:param host: zipkin endpoint object
:returns: zipkin annotation object
"""
... | [
"def",
"create_annotation",
"(",
"timestamp",
",",
"value",
",",
"host",
")",
":",
"return",
"zipkin_core",
".",
"Annotation",
"(",
"timestamp",
"=",
"timestamp",
",",
"value",
"=",
"value",
",",
"host",
"=",
"host",
")"
] | Create a zipkin annotation object
:param timestamp: timestamp of when the annotation occured in microseconds
:param value: name of the annotation, such as 'sr'
:param host: zipkin endpoint object
:returns: zipkin annotation object | [
"Create",
"a",
"zipkin",
"annotation",
"object"
] | python | test |
fabioz/PyDev.Debugger | third_party/isort_container/isort/natural.py | https://github.com/fabioz/PyDev.Debugger/blob/ed9c4307662a5593b8a7f1f3389ecd0e79b8c503/third_party/isort_container/isort/natural.py#L39-L47 | def nsorted(to_sort, key=None):
"""Returns a naturally sorted list"""
if key is None:
key_callback = _natural_keys
else:
def key_callback(item):
return _natural_keys(key(item))
return sorted(to_sort, key=key_callback) | [
"def",
"nsorted",
"(",
"to_sort",
",",
"key",
"=",
"None",
")",
":",
"if",
"key",
"is",
"None",
":",
"key_callback",
"=",
"_natural_keys",
"else",
":",
"def",
"key_callback",
"(",
"item",
")",
":",
"return",
"_natural_keys",
"(",
"key",
"(",
"item",
")... | Returns a naturally sorted list | [
"Returns",
"a",
"naturally",
"sorted",
"list"
] | python | train |
shalabhms/reliable-collections-cli | rcctl/rcctl/config.py | https://github.com/shalabhms/reliable-collections-cli/blob/195d69816fb5a6e1e9ab0ab66b606b1248b4780d/rcctl/rcctl/config.py#L27-L31 | def get_config_bool(name):
"""Checks if a config value is set to a valid bool value."""
cli_config = CLIConfig(SF_CLI_CONFIG_DIR, SF_CLI_ENV_VAR_PREFIX)
return cli_config.getboolean('servicefabric', name, False) | [
"def",
"get_config_bool",
"(",
"name",
")",
":",
"cli_config",
"=",
"CLIConfig",
"(",
"SF_CLI_CONFIG_DIR",
",",
"SF_CLI_ENV_VAR_PREFIX",
")",
"return",
"cli_config",
".",
"getboolean",
"(",
"'servicefabric'",
",",
"name",
",",
"False",
")"
] | Checks if a config value is set to a valid bool value. | [
"Checks",
"if",
"a",
"config",
"value",
"is",
"set",
"to",
"a",
"valid",
"bool",
"value",
"."
] | python | valid |
sdispater/orator | orator/dbal/index.py | https://github.com/sdispater/orator/blob/bd90bf198ee897751848f9a92e49d18e60a74136/orator/dbal/index.py#L65-L84 | def get_quoted_columns(self, platform):
"""
Returns the quoted representation of the column names
the constraint is associated with.
But only if they were defined with one or a column name
is a keyword reserved by the platform.
Otherwise the plain unquoted value as inser... | [
"def",
"get_quoted_columns",
"(",
"self",
",",
"platform",
")",
":",
"columns",
"=",
"[",
"]",
"for",
"column",
"in",
"self",
".",
"_columns",
".",
"values",
"(",
")",
":",
"columns",
".",
"append",
"(",
"column",
".",
"get_quoted_name",
"(",
"platform",... | Returns the quoted representation of the column names
the constraint is associated with.
But only if they were defined with one or a column name
is a keyword reserved by the platform.
Otherwise the plain unquoted value as inserted is returned.
:param platform: The platform to u... | [
"Returns",
"the",
"quoted",
"representation",
"of",
"the",
"column",
"names",
"the",
"constraint",
"is",
"associated",
"with",
"."
] | python | train |
OpenAgInitiative/openag_python | openag/couch.py | https://github.com/OpenAgInitiative/openag_python/blob/f6202340292bbf7185e1a7d4290188c0dacbb8d0/openag/couch.py#L54-L79 | def create_user(self, username, password):
"""
Creates a user in the CouchDB instance with the username `username` and
password `password`
"""
user_id = "org.couchdb.user:" + username
res = self["_users"].resource.put(
user_id, body=json.dumps({
... | [
"def",
"create_user",
"(",
"self",
",",
"username",
",",
"password",
")",
":",
"user_id",
"=",
"\"org.couchdb.user:\"",
"+",
"username",
"res",
"=",
"self",
"[",
"\"_users\"",
"]",
".",
"resource",
".",
"put",
"(",
"user_id",
",",
"body",
"=",
"json",
".... | Creates a user in the CouchDB instance with the username `username` and
password `password` | [
"Creates",
"a",
"user",
"in",
"the",
"CouchDB",
"instance",
"with",
"the",
"username",
"username",
"and",
"password",
"password"
] | python | train |
iterative/dvc | dvc/config.py | https://github.com/iterative/dvc/blob/8bb21261e34c9632453e09090de7ebe50e38d341/dvc/config.py#L567-L579 | def set(config, section, opt, value):
"""Sets specified option in the config.
Args:
config (configobj.ConfigObj): config to work on.
section (str): section name.
opt (str): option name.
value: value to set option to.
"""
if section not in ... | [
"def",
"set",
"(",
"config",
",",
"section",
",",
"opt",
",",
"value",
")",
":",
"if",
"section",
"not",
"in",
"config",
".",
"keys",
"(",
")",
":",
"config",
"[",
"section",
"]",
"=",
"{",
"}",
"config",
"[",
"section",
"]",
"[",
"opt",
"]",
"... | Sets specified option in the config.
Args:
config (configobj.ConfigObj): config to work on.
section (str): section name.
opt (str): option name.
value: value to set option to. | [
"Sets",
"specified",
"option",
"in",
"the",
"config",
"."
] | python | train |
OLC-Bioinformatics/sipprverse | pointfinder/PointFinder.py | https://github.com/OLC-Bioinformatics/sipprverse/blob/d4f10cdf8e1a39dac0953db61c21c97efc6006de/pointfinder/PointFinder.py#L643-L696 | def name_indel_mutation(sbjct_seq, indel, sbjct_rf_indel, qry_rf_indel, codon_no, mut, start_offset):
"""
This function serves to name the individual mutations dependently on
the type of the mutation.
"""
# Get the subject and query sequences without gaps
sbjct_nucs = sbjct_rf_indel.replace("-"... | [
"def",
"name_indel_mutation",
"(",
"sbjct_seq",
",",
"indel",
",",
"sbjct_rf_indel",
",",
"qry_rf_indel",
",",
"codon_no",
",",
"mut",
",",
"start_offset",
")",
":",
"# Get the subject and query sequences without gaps",
"sbjct_nucs",
"=",
"sbjct_rf_indel",
".",
"replace... | This function serves to name the individual mutations dependently on
the type of the mutation. | [
"This",
"function",
"serves",
"to",
"name",
"the",
"individual",
"mutations",
"dependently",
"on",
"the",
"type",
"of",
"the",
"mutation",
"."
] | python | train |
Alignak-monitoring/alignak | alignak/objects/hostgroup.py | https://github.com/Alignak-monitoring/alignak/blob/f3c145207e83159b799d3714e4241399c7740a64/alignak/objects/hostgroup.py#L380-L405 | def explode(self):
"""
Fill members with hostgroup_members
:return: None
"""
# We do not want a same hostgroup to be exploded again and again
# so we tag it
for tmp_hg in list(self.items.values()):
tmp_hg.already_exploded = False
for hostgrou... | [
"def",
"explode",
"(",
"self",
")",
":",
"# We do not want a same hostgroup to be exploded again and again",
"# so we tag it",
"for",
"tmp_hg",
"in",
"list",
"(",
"self",
".",
"items",
".",
"values",
"(",
")",
")",
":",
"tmp_hg",
".",
"already_exploded",
"=",
"Fal... | Fill members with hostgroup_members
:return: None | [
"Fill",
"members",
"with",
"hostgroup_members"
] | python | train |
topic2k/pygcgen | pygcgen/reader.py | https://github.com/topic2k/pygcgen/blob/c41701815df2c8c3a57fd5f7b8babe702127c8a1/pygcgen/reader.py#L36-L60 | def parse_heading(heading):
"""
Parse a single heading and return a Hash
The following heading structures are currently valid:
- ## [v1.0.2](https://github.com/zanui/chef-thumbor/tree/v1.0.1) (2015-03-24)
- ## [v1.0.2](https://github.com/zanui/chef-thumbor/tree/v1.0.1)
- ## v1.0.2 (2015-03-24)
... | [
"def",
"parse_heading",
"(",
"heading",
")",
":",
"heading_structures",
"=",
"[",
"r\"^## \\[(?P<version>.+?)\\]\\((?P<url>.+?)\\)( \\((?P<date>.+?)\\))?$\"",
",",
"r\"^## (?P<version>.+?)( \\((?P<date>.+?)\\))?$\"",
",",
"]",
"captures",
"=",
"{",
"\"version\"",
":",
"None",
... | Parse a single heading and return a Hash
The following heading structures are currently valid:
- ## [v1.0.2](https://github.com/zanui/chef-thumbor/tree/v1.0.1) (2015-03-24)
- ## [v1.0.2](https://github.com/zanui/chef-thumbor/tree/v1.0.1)
- ## v1.0.2 (2015-03-24)
- ## v1.0.2
@param [String] head... | [
"Parse",
"a",
"single",
"heading",
"and",
"return",
"a",
"Hash",
"The",
"following",
"heading",
"structures",
"are",
"currently",
"valid",
":",
"-",
"##",
"[",
"v1",
".",
"0",
".",
"2",
"]",
"(",
"https",
":",
"//",
"github",
".",
"com",
"/",
"zanui"... | python | valid |
pycontribs/pyrax | pyrax/utils.py | https://github.com/pycontribs/pyrax/blob/9ddfd5064b3a292d7337906f3b2d5dce95b50b99/pyrax/utils.py#L565-L576 | def get_id(id_or_obj):
"""
Returns the 'id' attribute of 'id_or_obj' if present; if not,
returns 'id_or_obj'.
"""
if isinstance(id_or_obj, six.string_types + (int,)):
# It's an ID
return id_or_obj
try:
return id_or_obj.id
except AttributeError:
return id_or_ob... | [
"def",
"get_id",
"(",
"id_or_obj",
")",
":",
"if",
"isinstance",
"(",
"id_or_obj",
",",
"six",
".",
"string_types",
"+",
"(",
"int",
",",
")",
")",
":",
"# It's an ID",
"return",
"id_or_obj",
"try",
":",
"return",
"id_or_obj",
".",
"id",
"except",
"Attri... | Returns the 'id' attribute of 'id_or_obj' if present; if not,
returns 'id_or_obj'. | [
"Returns",
"the",
"id",
"attribute",
"of",
"id_or_obj",
"if",
"present",
";",
"if",
"not",
"returns",
"id_or_obj",
"."
] | python | train |
viralogic/py-enumerable | py_linq/py_linq3.py | https://github.com/viralogic/py-enumerable/blob/63363649bccef223379e1e87056747240c83aa9d/py_linq/py_linq3.py#L447-L462 | def union(self, enumerable, key=lambda x: x):
"""
Returns enumerable that is a union of elements between self and given
enumerable
:param enumerable: enumerable to union self to
:param key: key selector used to determine uniqueness
:return: new Enumerable object
"... | [
"def",
"union",
"(",
"self",
",",
"enumerable",
",",
"key",
"=",
"lambda",
"x",
":",
"x",
")",
":",
"if",
"not",
"isinstance",
"(",
"enumerable",
",",
"Enumerable3",
")",
":",
"raise",
"TypeError",
"(",
"u\"enumerable parameter must be an instance of Enumerable\... | Returns enumerable that is a union of elements between self and given
enumerable
:param enumerable: enumerable to union self to
:param key: key selector used to determine uniqueness
:return: new Enumerable object | [
"Returns",
"enumerable",
"that",
"is",
"a",
"union",
"of",
"elements",
"between",
"self",
"and",
"given",
"enumerable",
":",
"param",
"enumerable",
":",
"enumerable",
"to",
"union",
"self",
"to",
":",
"param",
"key",
":",
"key",
"selector",
"used",
"to",
"... | python | train |
hammerlab/cohorts | cohorts/cohort.py | https://github.com/hammerlab/cohorts/blob/278b05e609e6c4d4a77c57d49446460be53ea33e/cohorts/cohort.py#L790-L822 | def load_effects(self, patients=None, only_nonsynonymous=False,
all_effects=False, filter_fn=None, **kwargs):
"""Load a dictionary of patient_id to varcode.EffectCollection
Note that this only loads one effect per variant.
Parameters
----------
patients : s... | [
"def",
"load_effects",
"(",
"self",
",",
"patients",
"=",
"None",
",",
"only_nonsynonymous",
"=",
"False",
",",
"all_effects",
"=",
"False",
",",
"filter_fn",
"=",
"None",
",",
"*",
"*",
"kwargs",
")",
":",
"filter_fn",
"=",
"first_not_none_param",
"(",
"[... | Load a dictionary of patient_id to varcode.EffectCollection
Note that this only loads one effect per variant.
Parameters
----------
patients : str, optional
Filter to a subset of patients
only_nonsynonymous : bool, optional
If true, load only nonsynonymo... | [
"Load",
"a",
"dictionary",
"of",
"patient_id",
"to",
"varcode",
".",
"EffectCollection"
] | python | train |
aparo/pyes | performance/utils.py | https://github.com/aparo/pyes/blob/712eb6095961755067b2b5baa262008ade6584b3/performance/utils.py#L10-L14 | def get_names():
"""
Return a list of names.
"""
return [n.strip() for n in codecs.open(os.path.join("data", "names.txt"),"rb",'utf8').readlines()] | [
"def",
"get_names",
"(",
")",
":",
"return",
"[",
"n",
".",
"strip",
"(",
")",
"for",
"n",
"in",
"codecs",
".",
"open",
"(",
"os",
".",
"path",
".",
"join",
"(",
"\"data\"",
",",
"\"names.txt\"",
")",
",",
"\"rb\"",
",",
"'utf8'",
")",
".",
"read... | Return a list of names. | [
"Return",
"a",
"list",
"of",
"names",
"."
] | python | train |
cocaine/cocaine-framework-python | cocaine/detail/secadaptor.py | https://github.com/cocaine/cocaine-framework-python/blob/d8a30074b6338bac4389eb996e00d404338115e4/cocaine/detail/secadaptor.py#L54-L65 | def fetch_token(self):
"""Gains token from secure backend service.
:return: Token formatted for Cocaine protocol header.
"""
grant_type = 'client_credentials'
channel = yield self._tvm.ticket_full(
self._client_id, self._client_secret, grant_type, {})
ticket... | [
"def",
"fetch_token",
"(",
"self",
")",
":",
"grant_type",
"=",
"'client_credentials'",
"channel",
"=",
"yield",
"self",
".",
"_tvm",
".",
"ticket_full",
"(",
"self",
".",
"_client_id",
",",
"self",
".",
"_client_secret",
",",
"grant_type",
",",
"{",
"}",
... | Gains token from secure backend service.
:return: Token formatted for Cocaine protocol header. | [
"Gains",
"token",
"from",
"secure",
"backend",
"service",
"."
] | python | train |
pycontribs/pyrax | pyrax/manager.py | https://github.com/pycontribs/pyrax/blob/9ddfd5064b3a292d7337906f3b2d5dce95b50b99/pyrax/manager.py#L249-L256 | def action(self, item, action_type, body={}):
"""
Several API calls are lumped under the 'action' API. This
is the generic handler for such calls.
"""
uri = "/%s/%s/action" % (self.uri_base, utils.get_id(item))
action_body = {action_type: body}
return self.api.met... | [
"def",
"action",
"(",
"self",
",",
"item",
",",
"action_type",
",",
"body",
"=",
"{",
"}",
")",
":",
"uri",
"=",
"\"/%s/%s/action\"",
"%",
"(",
"self",
".",
"uri_base",
",",
"utils",
".",
"get_id",
"(",
"item",
")",
")",
"action_body",
"=",
"{",
"a... | Several API calls are lumped under the 'action' API. This
is the generic handler for such calls. | [
"Several",
"API",
"calls",
"are",
"lumped",
"under",
"the",
"action",
"API",
".",
"This",
"is",
"the",
"generic",
"handler",
"for",
"such",
"calls",
"."
] | python | train |
pandas-dev/pandas | scripts/validate_docstrings.py | https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/scripts/validate_docstrings.py#L314-L328 | def source_file_name(self):
"""
File name where the object is implemented (e.g. pandas/core/frame.py).
"""
try:
fname = inspect.getsourcefile(self.code_obj)
except TypeError:
# In some cases the object is something complex like a cython
# objec... | [
"def",
"source_file_name",
"(",
"self",
")",
":",
"try",
":",
"fname",
"=",
"inspect",
".",
"getsourcefile",
"(",
"self",
".",
"code_obj",
")",
"except",
"TypeError",
":",
"# In some cases the object is something complex like a cython",
"# object that can't be easily intr... | File name where the object is implemented (e.g. pandas/core/frame.py). | [
"File",
"name",
"where",
"the",
"object",
"is",
"implemented",
"(",
"e",
".",
"g",
".",
"pandas",
"/",
"core",
"/",
"frame",
".",
"py",
")",
"."
] | python | train |
ChrisCummins/labm8 | system.py | https://github.com/ChrisCummins/labm8/blob/dd10d67a757aefb180cb508f86696f99440c94f5/system.py#L237-L284 | def which(program, path=None):
"""
Returns the full path of shell commands.
Replicates the functionality of system which (1) command. Looks
for the named program in the directories indicated in the $PATH
environment variable, and returns the full path if found.
Examples:
>>> system.wh... | [
"def",
"which",
"(",
"program",
",",
"path",
"=",
"None",
")",
":",
"# If path is not given, read the $PATH environment variable.",
"path",
"=",
"path",
"or",
"os",
".",
"environ",
"[",
"\"PATH\"",
"]",
".",
"split",
"(",
"os",
".",
"pathsep",
")",
"abspath",
... | Returns the full path of shell commands.
Replicates the functionality of system which (1) command. Looks
for the named program in the directories indicated in the $PATH
environment variable, and returns the full path if found.
Examples:
>>> system.which("ls")
"/bin/ls"
>>> sy... | [
"Returns",
"the",
"full",
"path",
"of",
"shell",
"commands",
"."
] | python | train |
staticdev/django-sorting-bootstrap | sorting_bootstrap/util.py | https://github.com/staticdev/django-sorting-bootstrap/blob/cfdc6e671b1b57aad04e44b041b9df10ee8288d3/sorting_bootstrap/util.py#L17-L64 | def label_for_field(name, model, return_attr=False):
"""
Returns a sensible label for a field name. The name can be a callable,
property (but not created with @property decorator) or the name of an
object's attribute, as well as a genuine fields. If return_attr is
True, the resolved attribute (which... | [
"def",
"label_for_field",
"(",
"name",
",",
"model",
",",
"return_attr",
"=",
"False",
")",
":",
"attr",
"=",
"None",
"try",
":",
"field",
"=",
"model",
".",
"_meta",
".",
"get_field_by_name",
"(",
"name",
")",
"[",
"0",
"]",
"if",
"isinstance",
"(",
... | Returns a sensible label for a field name. The name can be a callable,
property (but not created with @property decorator) or the name of an
object's attribute, as well as a genuine fields. If return_attr is
True, the resolved attribute (which could be a callable) is also returned.
This will be None if ... | [
"Returns",
"a",
"sensible",
"label",
"for",
"a",
"field",
"name",
".",
"The",
"name",
"can",
"be",
"a",
"callable",
"property",
"(",
"but",
"not",
"created",
"with"
] | python | train |
crate/crash | src/crate/crash/command.py | https://github.com/crate/crash/blob/32d3ddc78fd2f7848ed2b99d9cd8889e322528d9/src/crate/crash/command.py#L321-L333 | def _show_tables(self, *args):
""" print the existing tables within the 'doc' schema """
v = self.connection.lowest_server_version
schema_name = \
"table_schema" if v >= TABLE_SCHEMA_MIN_VERSION else "schema_name"
table_filter = \
" AND table_type = 'BASE TABLE'" ... | [
"def",
"_show_tables",
"(",
"self",
",",
"*",
"args",
")",
":",
"v",
"=",
"self",
".",
"connection",
".",
"lowest_server_version",
"schema_name",
"=",
"\"table_schema\"",
"if",
"v",
">=",
"TABLE_SCHEMA_MIN_VERSION",
"else",
"\"schema_name\"",
"table_filter",
"=",
... | print the existing tables within the 'doc' schema | [
"print",
"the",
"existing",
"tables",
"within",
"the",
"doc",
"schema"
] | python | train |
ga4gh/ga4gh-server | ga4gh/server/datamodel/continuous.py | https://github.com/ga4gh/ga4gh-server/blob/1aa18922ef136db8604f6f098cb1732cba6f2a76/ga4gh/server/datamodel/continuous.py#L109-L152 | def readWiggleLine(self, line):
"""
Read a wiggle line. If it is a data line, add values to the
protocol object.
"""
if(line.isspace() or line.startswith("#")
or line.startswith("browser") or line.startswith("track")):
return
elif line.startswi... | [
"def",
"readWiggleLine",
"(",
"self",
",",
"line",
")",
":",
"if",
"(",
"line",
".",
"isspace",
"(",
")",
"or",
"line",
".",
"startswith",
"(",
"\"#\"",
")",
"or",
"line",
".",
"startswith",
"(",
"\"browser\"",
")",
"or",
"line",
".",
"startswith",
"... | Read a wiggle line. If it is a data line, add values to the
protocol object. | [
"Read",
"a",
"wiggle",
"line",
".",
"If",
"it",
"is",
"a",
"data",
"line",
"add",
"values",
"to",
"the",
"protocol",
"object",
"."
] | python | train |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.