repo stringlengths 7 55 | path stringlengths 4 223 | url stringlengths 87 315 | code stringlengths 75 104k | code_tokens list | docstring stringlengths 1 46.9k | docstring_tokens list | language stringclasses 1
value | partition stringclasses 3
values | avg_line_len float64 7.91 980 |
|---|---|---|---|---|---|---|---|---|---|
jmcgeheeiv/pyfakefs | pyfakefs/fake_pathlib.py | https://github.com/jmcgeheeiv/pyfakefs/blob/6c36fb8987108107fc861fc3013620d46c7d2f9c/pyfakefs/fake_pathlib.py#L229-L233 | def casefold_parts(self, parts):
"""Return the lower-case version of parts for a Windows filesystem."""
if self.filesystem.is_windows_fs:
return [p.lower() for p in parts]
return parts | [
"def",
"casefold_parts",
"(",
"self",
",",
"parts",
")",
":",
"if",
"self",
".",
"filesystem",
".",
"is_windows_fs",
":",
"return",
"[",
"p",
".",
"lower",
"(",
")",
"for",
"p",
"in",
"parts",
"]",
"return",
"parts"
] | Return the lower-case version of parts for a Windows filesystem. | [
"Return",
"the",
"lower",
"-",
"case",
"version",
"of",
"parts",
"for",
"a",
"Windows",
"filesystem",
"."
] | python | train | 43.2 |
hazelcast/hazelcast-python-client | hazelcast/proxy/map.py | https://github.com/hazelcast/hazelcast-python-client/blob/3f6639443c23d6d036aa343f8e094f052250d2c1/hazelcast/proxy/map.py#L331-L350 | def get(self, key):
"""
Returns the value for the specified key, or ``None`` if this map does not contain this key.
**Warning:
This method returns a clone of original value, modifying the returned value does not change the actual value in
the map. One should put modified value b... | [
"def",
"get",
"(",
"self",
",",
"key",
")",
":",
"check_not_none",
"(",
"key",
",",
"\"key can't be None\"",
")",
"key_data",
"=",
"self",
".",
"_to_data",
"(",
"key",
")",
"return",
"self",
".",
"_get_internal",
"(",
"key_data",
")"
] | Returns the value for the specified key, or ``None`` if this map does not contain this key.
**Warning:
This method returns a clone of original value, modifying the returned value does not change the actual value in
the map. One should put modified value back to make changes visible to all nodes... | [
"Returns",
"the",
"value",
"for",
"the",
"specified",
"key",
"or",
"None",
"if",
"this",
"map",
"does",
"not",
"contain",
"this",
"key",
"."
] | python | train | 44.8 |
inasafe/inasafe | safe/utilities/profiling.py | https://github.com/inasafe/inasafe/blob/831d60abba919f6d481dc94a8d988cc205130724/safe/utilities/profiling.py#L83-L91 | def append(self, node):
"""To append a new child."""
if node.parent == self.key and not self.elapsed_time:
self.children.append(node)
else:
# Recursive call
for child in self.children:
if not child.elapsed_time:
child.append... | [
"def",
"append",
"(",
"self",
",",
"node",
")",
":",
"if",
"node",
".",
"parent",
"==",
"self",
".",
"key",
"and",
"not",
"self",
".",
"elapsed_time",
":",
"self",
".",
"children",
".",
"append",
"(",
"node",
")",
"else",
":",
"# Recursive call",
"fo... | To append a new child. | [
"To",
"append",
"a",
"new",
"child",
"."
] | python | train | 35.333333 |
scanny/python-pptx | pptx/chart/xlsx.py | https://github.com/scanny/python-pptx/blob/d6ab8234f8b03953d2f831ff9394b1852db34130/pptx/chart/xlsx.py#L269-L298 | def _populate_worksheet(self, workbook, worksheet):
"""
Write chart data contents to *worksheet* in the bubble chart layout.
Write the data for each series to a separate three-column table with
X values in column A, Y values in column B, and bubble sizes in
column C. Place the se... | [
"def",
"_populate_worksheet",
"(",
"self",
",",
"workbook",
",",
"worksheet",
")",
":",
"chart_num_format",
"=",
"workbook",
".",
"add_format",
"(",
"{",
"'num_format'",
":",
"self",
".",
"_chart_data",
".",
"number_format",
"}",
")",
"for",
"series",
"in",
... | Write chart data contents to *worksheet* in the bubble chart layout.
Write the data for each series to a separate three-column table with
X values in column A, Y values in column B, and bubble sizes in
column C. Place the series label in the first (heading) cell of the
values column. | [
"Write",
"chart",
"data",
"contents",
"to",
"*",
"worksheet",
"*",
"in",
"the",
"bubble",
"chart",
"layout",
".",
"Write",
"the",
"data",
"for",
"each",
"series",
"to",
"a",
"separate",
"three",
"-",
"column",
"table",
"with",
"X",
"values",
"in",
"colum... | python | train | 41.4 |
singularityhub/singularity-cli | spython/oci/__init__.py | https://github.com/singularityhub/singularity-cli/blob/cb36b4504812ca87e29c6a40b222a545d1865799/spython/oci/__init__.py#L47-L64 | def get_container_id(self, container_id=None):
''' a helper function shared between functions that will return a
container_id. First preference goes to a container_id provided by
the user at runtime. Second preference goes to the container_id
instantiated with the client.
... | [
"def",
"get_container_id",
"(",
"self",
",",
"container_id",
"=",
"None",
")",
":",
"# The user must provide a container_id, or have one with the client",
"if",
"container_id",
"==",
"None",
"and",
"self",
".",
"container_id",
"==",
"None",
":",
"bot",
".",
"exit",
... | a helper function shared between functions that will return a
container_id. First preference goes to a container_id provided by
the user at runtime. Second preference goes to the container_id
instantiated with the client.
Parameters
==========
co... | [
"a",
"helper",
"function",
"shared",
"between",
"functions",
"that",
"will",
"return",
"a",
"container_id",
".",
"First",
"preference",
"goes",
"to",
"a",
"container_id",
"provided",
"by",
"the",
"user",
"at",
"runtime",
".",
"Second",
"preference",
"goes",
"t... | python | train | 43.111111 |
HPAC/matchpy | matchpy/matching/many_to_one.py | https://github.com/HPAC/matchpy/blob/06b2ec50ee0efdf3dd183768c0ffdb51b7efc393/matchpy/matching/many_to_one.py#L775-L804 | def replace(self, expression: Expression, max_count: int=math.inf) -> Union[Expression, Sequence[Expression]]:
"""Replace all occurrences of the patterns according to the replacement rules.
Args:
expression:
The expression to which the replacement rules are applied.
... | [
"def",
"replace",
"(",
"self",
",",
"expression",
":",
"Expression",
",",
"max_count",
":",
"int",
"=",
"math",
".",
"inf",
")",
"->",
"Union",
"[",
"Expression",
",",
"Sequence",
"[",
"Expression",
"]",
"]",
":",
"replaced",
"=",
"True",
"replace_count"... | Replace all occurrences of the patterns according to the replacement rules.
Args:
expression:
The expression to which the replacement rules are applied.
max_count:
If given, at most *max_count* applications of the rules are performed. Otherwise, the rules... | [
"Replace",
"all",
"occurrences",
"of",
"the",
"patterns",
"according",
"to",
"the",
"replacement",
"rules",
"."
] | python | train | 48.8 |
analytehealth/django-analytics | djanalytics/reports/utils.py | https://github.com/analytehealth/django-analytics/blob/7782d3f81249dcb1b266afb0cb1e90000108c74d/djanalytics/reports/utils.py#L12-L19 | def average_duration(total_duration, visits):
""" Method to calculate and format an average duration safely """
if not visits:
seconds = 0
else:
seconds = int(round(total_duration / Decimal(visits)))
duration = timedelta(seconds=seconds)
return str(duration) | [
"def",
"average_duration",
"(",
"total_duration",
",",
"visits",
")",
":",
"if",
"not",
"visits",
":",
"seconds",
"=",
"0",
"else",
":",
"seconds",
"=",
"int",
"(",
"round",
"(",
"total_duration",
"/",
"Decimal",
"(",
"visits",
")",
")",
")",
"duration",... | Method to calculate and format an average duration safely | [
"Method",
"to",
"calculate",
"and",
"format",
"an",
"average",
"duration",
"safely"
] | python | test | 35.875 |
googleapis/google-cloud-python | datastore/google/cloud/datastore/helpers.py | https://github.com/googleapis/google-cloud-python/blob/85e80125a59cb10f8cb105f25ecc099e4b940b50/datastore/google/cloud/datastore/helpers.py#L270-L299 | def key_from_protobuf(pb):
"""Factory method for creating a key based on a protobuf.
The protobuf should be one returned from the Cloud Datastore
Protobuf API.
:type pb: :class:`.entity_pb2.Key`
:param pb: The Protobuf representing the key.
:rtype: :class:`google.cloud.datastore.key.Key`
... | [
"def",
"key_from_protobuf",
"(",
"pb",
")",
":",
"path_args",
"=",
"[",
"]",
"for",
"element",
"in",
"pb",
".",
"path",
":",
"path_args",
".",
"append",
"(",
"element",
".",
"kind",
")",
"if",
"element",
".",
"id",
":",
"# Simple field (int64)",
"path_ar... | Factory method for creating a key based on a protobuf.
The protobuf should be one returned from the Cloud Datastore
Protobuf API.
:type pb: :class:`.entity_pb2.Key`
:param pb: The Protobuf representing the key.
:rtype: :class:`google.cloud.datastore.key.Key`
:returns: a new `Key` instance | [
"Factory",
"method",
"for",
"creating",
"a",
"key",
"based",
"on",
"a",
"protobuf",
"."
] | python | train | 34.266667 |
sentinel-hub/sentinelhub-py | sentinelhub/areas.py | https://github.com/sentinel-hub/sentinelhub-py/blob/08a83b7f1e289187159a643336995d8369860fea/sentinelhub/areas.py#L303-L325 | def _recursive_split(self, bbox, zoom_level, column, row):
"""Method that recursively creates bounding boxes of OSM grid that intersect the area.
:param bbox: Bounding box
:type bbox: BBox
:param zoom_level: OSM zoom level
:type zoom_level: int
:param column: Column in t... | [
"def",
"_recursive_split",
"(",
"self",
",",
"bbox",
",",
"zoom_level",
",",
"column",
",",
"row",
")",
":",
"if",
"zoom_level",
"==",
"self",
".",
"zoom_level",
":",
"self",
".",
"bbox_list",
".",
"append",
"(",
"bbox",
")",
"self",
".",
"info_list",
... | Method that recursively creates bounding boxes of OSM grid that intersect the area.
:param bbox: Bounding box
:type bbox: BBox
:param zoom_level: OSM zoom level
:type zoom_level: int
:param column: Column in the OSM grid
:type column: int
:param row: Row in the O... | [
"Method",
"that",
"recursively",
"creates",
"bounding",
"boxes",
"of",
"OSM",
"grid",
"that",
"intersect",
"the",
"area",
"."
] | python | train | 41.608696 |
LuminosoInsight/luminoso-api-client-python | luminoso_api/v5_download.py | https://github.com/LuminosoInsight/luminoso-api-client-python/blob/3bedf2a454aee39214c11fbf556ead3eecc27881/luminoso_api/v5_download.py#L70-L92 | def download_docs(client, output_filename=None, expanded=False):
"""
Given a LuminosoClient pointing to a project and a filename to write to,
retrieve all its documents in batches, and write them to a JSON lines
(.jsons) file with one document per line.
"""
if output_filename is None:
# ... | [
"def",
"download_docs",
"(",
"client",
",",
"output_filename",
"=",
"None",
",",
"expanded",
"=",
"False",
")",
":",
"if",
"output_filename",
"is",
"None",
":",
"# Find a default filename to download to, based on the project name.",
"projname",
"=",
"_sanitize_filename",
... | Given a LuminosoClient pointing to a project and a filename to write to,
retrieve all its documents in batches, and write them to a JSON lines
(.jsons) file with one document per line. | [
"Given",
"a",
"LuminosoClient",
"pointing",
"to",
"a",
"project",
"and",
"a",
"filename",
"to",
"write",
"to",
"retrieve",
"all",
"its",
"documents",
"in",
"batches",
"and",
"write",
"them",
"to",
"a",
"JSON",
"lines",
"(",
".",
"jsons",
")",
"file",
"wi... | python | test | 45.478261 |
dwavesystems/dwave-cloud-client | dwave/cloud/config.py | https://github.com/dwavesystems/dwave-cloud-client/blob/df3221a8385dc0c04d7b4d84f740bf3ad6706230/dwave/cloud/config.py#L336-L367 | def get_default_configfile_path():
"""Return the default configuration-file path.
Typically returns a user-local configuration file; e.g:
``~/.config/dwave/dwave.conf``.
Returns:
str:
Configuration file path.
Examples:
This example displays the default configuration fi... | [
"def",
"get_default_configfile_path",
"(",
")",
":",
"base",
"=",
"homebase",
".",
"user_config_dir",
"(",
"app_author",
"=",
"CONF_AUTHOR",
",",
"app_name",
"=",
"CONF_APP",
",",
"roaming",
"=",
"False",
",",
"use_virtualenv",
"=",
"False",
",",
"create",
"="... | Return the default configuration-file path.
Typically returns a user-local configuration file; e.g:
``~/.config/dwave/dwave.conf``.
Returns:
str:
Configuration file path.
Examples:
This example displays the default configuration file on an Ubuntu Unix system
runnin... | [
"Return",
"the",
"default",
"configuration",
"-",
"file",
"path",
"."
] | python | train | 33.9375 |
mlperf/training | reinforcement/tensorflow/minigo/mask_flags.py | https://github.com/mlperf/training/blob/1c6ae725a81d15437a2b2df05cac0673fde5c3a4/reinforcement/tensorflow/minigo/mask_flags.py#L103-L109 | def run(cmd):
"""Prepare and run a subprocess cmd, returning a CompletedProcess."""
print("Preparing the following cmd:")
cmd = prepare_subprocess_cmd(cmd)
print("Running the following cmd:")
print('\n'.join(cmd))
return subprocess.run(cmd, stdout=sys.stdout, stderr=sys.stderr) | [
"def",
"run",
"(",
"cmd",
")",
":",
"print",
"(",
"\"Preparing the following cmd:\"",
")",
"cmd",
"=",
"prepare_subprocess_cmd",
"(",
"cmd",
")",
"print",
"(",
"\"Running the following cmd:\"",
")",
"print",
"(",
"'\\n'",
".",
"join",
"(",
"cmd",
")",
")",
"... | Prepare and run a subprocess cmd, returning a CompletedProcess. | [
"Prepare",
"and",
"run",
"a",
"subprocess",
"cmd",
"returning",
"a",
"CompletedProcess",
"."
] | python | train | 42.285714 |
uber/rides-python-sdk | example/request_ride.py | https://github.com/uber/rides-python-sdk/blob/76ecd75ab5235d792ec1010e36eca679ba285127/example/request_ride.py#L122-L142 | def update_ride(api_client, ride_status, ride_id):
"""Use an UberRidesClient to update ride status and print the results.
Parameters
api_client (UberRidesClient)
An authorized UberRidesClient with 'request' scope.
ride_status (str)
New ride status to update to.
r... | [
"def",
"update_ride",
"(",
"api_client",
",",
"ride_status",
",",
"ride_id",
")",
":",
"try",
":",
"update_product",
"=",
"api_client",
".",
"update_sandbox_ride",
"(",
"ride_id",
",",
"ride_status",
")",
"except",
"(",
"ClientError",
",",
"ServerError",
")",
... | Use an UberRidesClient to update ride status and print the results.
Parameters
api_client (UberRidesClient)
An authorized UberRidesClient with 'request' scope.
ride_status (str)
New ride status to update to.
ride_id (str)
Unique identifier for ride to upd... | [
"Use",
"an",
"UberRidesClient",
"to",
"update",
"ride",
"status",
"and",
"print",
"the",
"results",
"."
] | python | train | 32.666667 |
icgood/pymap | pymap/backend/maildir/subscriptions.py | https://github.com/icgood/pymap/blob/e77d9a54d760e3cbe044a548883bb4299ed61dc2/pymap/backend/maildir/subscriptions.py#L41-L46 | def set(self, folder: str, subscribed: bool) -> None:
"""Set the subscribed status of a folder."""
if subscribed:
self.add(folder)
else:
self.remove(folder) | [
"def",
"set",
"(",
"self",
",",
"folder",
":",
"str",
",",
"subscribed",
":",
"bool",
")",
"->",
"None",
":",
"if",
"subscribed",
":",
"self",
".",
"add",
"(",
"folder",
")",
"else",
":",
"self",
".",
"remove",
"(",
"folder",
")"
] | Set the subscribed status of a folder. | [
"Set",
"the",
"subscribed",
"status",
"of",
"a",
"folder",
"."
] | python | train | 33.166667 |
quantopian/zipline | zipline/pipeline/graph.py | https://github.com/quantopian/zipline/blob/77ad15e6dc4c1cbcdc133653bac8a63fc704f7fe/zipline/pipeline/graph.py#L488-L493 | def _assert_all_loadable_terms_specialized_to(self, domain):
"""Make sure that we've specialized all loadable terms in the graph.
"""
for term in self.graph.node:
if isinstance(term, LoadableTerm):
assert term.domain is domain | [
"def",
"_assert_all_loadable_terms_specialized_to",
"(",
"self",
",",
"domain",
")",
":",
"for",
"term",
"in",
"self",
".",
"graph",
".",
"node",
":",
"if",
"isinstance",
"(",
"term",
",",
"LoadableTerm",
")",
":",
"assert",
"term",
".",
"domain",
"is",
"d... | Make sure that we've specialized all loadable terms in the graph. | [
"Make",
"sure",
"that",
"we",
"ve",
"specialized",
"all",
"loadable",
"terms",
"in",
"the",
"graph",
"."
] | python | train | 45.5 |
Yelp/kafka-utils | kafka_utils/kafka_cluster_manager/cluster_info/stats.py | https://github.com/Yelp/kafka-utils/blob/cdb4d64308f3079ee0873250bf7b34d0d94eca50/kafka_utils/kafka_cluster_manager/cluster_info/stats.py#L34-L39 | def variance(data, data_mean=None):
"""Return variance of a sequence of numbers.
:param data_mean: Precomputed mean of the sequence.
"""
data_mean = data_mean or mean(data)
return sum((x - data_mean) ** 2 for x in data) / len(data) | [
"def",
"variance",
"(",
"data",
",",
"data_mean",
"=",
"None",
")",
":",
"data_mean",
"=",
"data_mean",
"or",
"mean",
"(",
"data",
")",
"return",
"sum",
"(",
"(",
"x",
"-",
"data_mean",
")",
"**",
"2",
"for",
"x",
"in",
"data",
")",
"/",
"len",
"... | Return variance of a sequence of numbers.
:param data_mean: Precomputed mean of the sequence. | [
"Return",
"variance",
"of",
"a",
"sequence",
"of",
"numbers",
".",
":",
"param",
"data_mean",
":",
"Precomputed",
"mean",
"of",
"the",
"sequence",
"."
] | python | train | 41 |
bslatkin/dpxdt | dpxdt/client/workers.py | https://github.com/bslatkin/dpxdt/blob/9f860de1731021d99253670429e5f2157e1f6297/dpxdt/client/workers.py#L297-L314 | def get_item(self):
"""Returns the item to send back into the workflow generator."""
if self.was_list:
result = ResultList()
for item in self:
if isinstance(item, WorkflowItem):
if item.done and not item.error:
result.ap... | [
"def",
"get_item",
"(",
"self",
")",
":",
"if",
"self",
".",
"was_list",
":",
"result",
"=",
"ResultList",
"(",
")",
"for",
"item",
"in",
"self",
":",
"if",
"isinstance",
"(",
"item",
",",
"WorkflowItem",
")",
":",
"if",
"item",
".",
"done",
"and",
... | Returns the item to send back into the workflow generator. | [
"Returns",
"the",
"item",
"to",
"send",
"back",
"into",
"the",
"workflow",
"generator",
"."
] | python | train | 40.722222 |
hazelcast/hazelcast-python-client | hazelcast/proxy/list.py | https://github.com/hazelcast/hazelcast-python-client/blob/3f6639443c23d6d036aa343f8e094f052250d2c1/hazelcast/proxy/list.py#L73-L88 | def add_all_at(self, index, items):
"""
Adds all of the elements in the specified collection into this list at the specified position. Elements in this
positions and following elements are shifted to the right, if any. The order of new elements is determined by the
specified collection's... | [
"def",
"add_all_at",
"(",
"self",
",",
"index",
",",
"items",
")",
":",
"check_not_none",
"(",
"items",
",",
"\"Value can't be None\"",
")",
"data_items",
"=",
"[",
"]",
"for",
"item",
"in",
"items",
":",
"check_not_none",
"(",
"item",
",",
"\"Value can't be... | Adds all of the elements in the specified collection into this list at the specified position. Elements in this
positions and following elements are shifted to the right, if any. The order of new elements is determined by the
specified collection's iterator.
:param index: (int), the specified i... | [
"Adds",
"all",
"of",
"the",
"elements",
"in",
"the",
"specified",
"collection",
"into",
"this",
"list",
"at",
"the",
"specified",
"position",
".",
"Elements",
"in",
"this",
"positions",
"and",
"following",
"elements",
"are",
"shifted",
"to",
"the",
"right",
... | python | train | 59.1875 |
99designs/colorific | colorific/palette.py | https://github.com/99designs/colorific/blob/f83e59f61295500f5527dee5894207f2f033cf35/colorific/palette.py#L37-L52 | def color_stream_st(istream=sys.stdin, save_palette=False, **kwargs):
"""
Read filenames from the input stream and detect their palette.
"""
for line in istream:
filename = line.strip()
try:
palette = extract_colors(filename, **kwargs)
except Exception as e:
... | [
"def",
"color_stream_st",
"(",
"istream",
"=",
"sys",
".",
"stdin",
",",
"save_palette",
"=",
"False",
",",
"*",
"*",
"kwargs",
")",
":",
"for",
"line",
"in",
"istream",
":",
"filename",
"=",
"line",
".",
"strip",
"(",
")",
"try",
":",
"palette",
"="... | Read filenames from the input stream and detect their palette. | [
"Read",
"filenames",
"from",
"the",
"input",
"stream",
"and",
"detect",
"their",
"palette",
"."
] | python | train | 30.25 |
belbio/bel | bel/resources/resource.py | https://github.com/belbio/bel/blob/60333e8815625b942b4836903f3b618cf44b3771/bel/resources/resource.py#L23-L61 | def load_resource(resource_url: str, forceupdate: bool = False):
"""Load BEL Resource file
Forceupdate will create a new index in Elasticsearch regardless of whether
an index with the resource version already exists.
Args:
resource_url: URL from which to download the resource to load into the ... | [
"def",
"load_resource",
"(",
"resource_url",
":",
"str",
",",
"forceupdate",
":",
"bool",
"=",
"False",
")",
":",
"log",
".",
"info",
"(",
"f\"Loading resource {resource_url}\"",
")",
"try",
":",
"# Download resource",
"fo",
"=",
"bel",
".",
"utils",
".",
"d... | Load BEL Resource file
Forceupdate will create a new index in Elasticsearch regardless of whether
an index with the resource version already exists.
Args:
resource_url: URL from which to download the resource to load into the BEL API
forceupdate: force full update - e.g. don't leave Elasti... | [
"Load",
"BEL",
"Resource",
"file"
] | python | train | 34.512821 |
mailund/statusbar | statusbar/__init__.py | https://github.com/mailund/statusbar/blob/e42ac88cdaae281d47318dd8dcf156bfff2a7b2a/statusbar/__init__.py#L262-L291 | def format_table(self, width=None,
min_label_width=10, min_progress_width=10):
"""Format the entire table of progress bars.
The function first computes the widths of the fields so they can be
aligned across lines and then returns formatted lines as a list of
strings... | [
"def",
"format_table",
"(",
"self",
",",
"width",
"=",
"None",
",",
"min_label_width",
"=",
"10",
",",
"min_progress_width",
"=",
"10",
")",
":",
"# handle the special case of an empty table.",
"if",
"len",
"(",
"self",
".",
"_lines",
")",
"==",
"0",
":",
"r... | Format the entire table of progress bars.
The function first computes the widths of the fields so they can be
aligned across lines and then returns formatted lines as a list of
strings. | [
"Format",
"the",
"entire",
"table",
"of",
"progress",
"bars",
"."
] | python | train | 31.566667 |
tomplus/kubernetes_asyncio | kubernetes_asyncio/client/api/core_v1_api.py | https://github.com/tomplus/kubernetes_asyncio/blob/f9ab15317ec921409714c7afef11aeb0f579985d/kubernetes_asyncio/client/api/core_v1_api.py#L7427-L7456 | def delete_collection_namespaced_config_map(self, namespace, **kwargs): # noqa: E501
"""delete_collection_namespaced_config_map # noqa: E501
delete collection of ConfigMap # noqa: E501
This method makes a synchronous HTTP request by default. To make an
asynchronous HTTP request, plea... | [
"def",
"delete_collection_namespaced_config_map",
"(",
"self",
",",
"namespace",
",",
"*",
"*",
"kwargs",
")",
":",
"# noqa: E501",
"kwargs",
"[",
"'_return_http_data_only'",
"]",
"=",
"True",
"if",
"kwargs",
".",
"get",
"(",
"'async_req'",
")",
":",
"return",
... | delete_collection_namespaced_config_map # noqa: E501
delete collection of ConfigMap # noqa: E501
This method makes a synchronous HTTP request by default. To make an
asynchronous HTTP request, please pass async_req=True
>>> thread = api.delete_collection_namespaced_config_map(namespace... | [
"delete_collection_namespaced_config_map",
"#",
"noqa",
":",
"E501"
] | python | train | 164.2 |
inveniosoftware/invenio-celery | invenio_celery/ext.py | https://github.com/inveniosoftware/invenio-celery/blob/4d075d5dbdb7ee849abdb0c8d7e7a49cb7973474/invenio_celery/ext.py#L78-L81 | def get_queues(self):
"""Return a list of current active Celery queues."""
res = self.celery.control.inspect().active_queues() or dict()
return [result.get('name') for host in res.values() for result in host] | [
"def",
"get_queues",
"(",
"self",
")",
":",
"res",
"=",
"self",
".",
"celery",
".",
"control",
".",
"inspect",
"(",
")",
".",
"active_queues",
"(",
")",
"or",
"dict",
"(",
")",
"return",
"[",
"result",
".",
"get",
"(",
"'name'",
")",
"for",
"host",... | Return a list of current active Celery queues. | [
"Return",
"a",
"list",
"of",
"current",
"active",
"Celery",
"queues",
"."
] | python | train | 57.25 |
dssg/argcmdr | src/argcmdr.py | https://github.com/dssg/argcmdr/blob/346b6158987464c3d3a32d315f3800a4807744b4/src/argcmdr.py#L729-L757 | def cmd(*args, **kwargs):
"""Decorate a callable to replace it with a manufactured command
class.
Extends the interface of ``CommandDecorator``, allowing the same
``cmd`` to be used as a decorator or as a decorator factory::
@cmd(root=True)
def build():
...
@build.... | [
"def",
"cmd",
"(",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"try",
":",
"(",
"first",
",",
"*",
"remainder",
")",
"=",
"args",
"except",
"ValueError",
":",
"pass",
"else",
":",
"if",
"callable",
"(",
"first",
")",
":",
"return",
"CommandDeco... | Decorate a callable to replace it with a manufactured command
class.
Extends the interface of ``CommandDecorator``, allowing the same
``cmd`` to be used as a decorator or as a decorator factory::
@cmd(root=True)
def build():
...
@build.register
@cmd
def... | [
"Decorate",
"a",
"callable",
"to",
"replace",
"it",
"with",
"a",
"manufactured",
"command",
"class",
"."
] | python | train | 23.517241 |
pypa/pipenv | pipenv/vendor/jinja2/nativetypes.py | https://github.com/pypa/pipenv/blob/cae8d76c210b9777e90aab76e9c4b0e53bb19cde/pipenv/vendor/jinja2/nativetypes.py#L39-L195 | def visit_Output(self, node, frame):
"""Same as :meth:`CodeGenerator.visit_Output`, but do not call
``to_string`` on output nodes in generated code.
"""
if self.has_known_extends and frame.require_output_check:
return
finalize = self.environment.finalize
fina... | [
"def",
"visit_Output",
"(",
"self",
",",
"node",
",",
"frame",
")",
":",
"if",
"self",
".",
"has_known_extends",
"and",
"frame",
".",
"require_output_check",
":",
"return",
"finalize",
"=",
"self",
".",
"environment",
".",
"finalize",
"finalize_context",
"=",
... | Same as :meth:`CodeGenerator.visit_Output`, but do not call
``to_string`` on output nodes in generated code. | [
"Same",
"as",
":",
"meth",
":",
"CodeGenerator",
".",
"visit_Output",
"but",
"do",
"not",
"call",
"to_string",
"on",
"output",
"nodes",
"in",
"generated",
"code",
"."
] | python | train | 32.815287 |
osrg/ryu | ryu/services/protocols/bgp/peer.py | https://github.com/osrg/ryu/blob/6f906e72c92e10bd0264c9b91a2f7bb85b97780c/ryu/services/protocols/bgp/peer.py#L685-L707 | def _send_outgoing_route_refresh_msg(self, rr_msg):
"""Sends given message `rr_msg` to peer.
Parameters:
- rr_msg: (RouteRefresh) route refresh message to send to peer.
Update appropriate counters and set appropriate timers.
"""
assert rr_msg.type == BGP_MSG_ROUTE_R... | [
"def",
"_send_outgoing_route_refresh_msg",
"(",
"self",
",",
"rr_msg",
")",
":",
"assert",
"rr_msg",
".",
"type",
"==",
"BGP_MSG_ROUTE_REFRESH",
"self",
".",
"_protocol",
".",
"send",
"(",
"rr_msg",
")",
"LOG",
".",
"debug",
"(",
"'RouteRefresh %s>> %s'",
",",
... | Sends given message `rr_msg` to peer.
Parameters:
- rr_msg: (RouteRefresh) route refresh message to send to peer.
Update appropriate counters and set appropriate timers. | [
"Sends",
"given",
"message",
"rr_msg",
"to",
"peer",
"."
] | python | train | 45.478261 |
samjabrahams/anchorhub | anchorhub/lib/armedswitch.py | https://github.com/samjabrahams/anchorhub/blob/5ade359b08297d4003a5f477389c01de9e634b54/anchorhub/lib/armedswitch.py#L26-L43 | def switch(self, val=None):
"""
Set the state of the switch. If the armed state is set to False,
the function does nothing.
:param val: Boolean. The value to set the switch state to. When None,
the switch will be set to the opposite of its current state.
:return: Boo... | [
"def",
"switch",
"(",
"self",
",",
"val",
"=",
"None",
")",
":",
"if",
"self",
".",
"_armed",
":",
"if",
"val",
"is",
"None",
":",
"val",
"=",
"not",
"self",
".",
"_switched",
"self",
".",
"_switched",
"=",
"val",
"self",
".",
"_armed",
"=",
"Fal... | Set the state of the switch. If the armed state is set to False,
the function does nothing.
:param val: Boolean. The value to set the switch state to. When None,
the switch will be set to the opposite of its current state.
:return: Boolean. Returns True if operation was successful (... | [
"Set",
"the",
"state",
"of",
"the",
"switch",
".",
"If",
"the",
"armed",
"state",
"is",
"set",
"to",
"False",
"the",
"function",
"does",
"nothing",
"."
] | python | train | 35.833333 |
inspirehep/harvesting-kit | harvestingkit/etree_utils.py | https://github.com/inspirehep/harvesting-kit/blob/33a7f8aa9dade1d863110c6d8b27dfd955cb471f/harvestingkit/etree_utils.py#L60-L81 | def element_tree_collection_to_records(tree):
"""Take an ElementTree and converts the nodes into BibRecord records.
This function is for a tree root of collection as such:
<collection>
<record>
<!-- MARCXML -->
</record>
<record> ... </record>
</collection>
"""
... | [
"def",
"element_tree_collection_to_records",
"(",
"tree",
")",
":",
"from",
".",
"bibrecord",
"import",
"create_record",
"records",
"=",
"[",
"]",
"collection",
"=",
"tree",
".",
"getroot",
"(",
")",
"for",
"record_element",
"in",
"collection",
".",
"getchildren... | Take an ElementTree and converts the nodes into BibRecord records.
This function is for a tree root of collection as such:
<collection>
<record>
<!-- MARCXML -->
</record>
<record> ... </record>
</collection> | [
"Take",
"an",
"ElementTree",
"and",
"converts",
"the",
"nodes",
"into",
"BibRecord",
"records",
"."
] | python | valid | 30 |
ic-labs/django-icekit | icekit_events/admin.py | https://github.com/ic-labs/django-icekit/blob/c507ea5b1864303732c53ad7c5800571fca5fa94/icekit_events/admin.py#L224-L243 | def get_urls(self):
"""
Add a calendar URL.
"""
from django.conf.urls import patterns, url
urls = super(EventAdmin, self).get_urls()
my_urls = patterns(
'',
url(
r'^calendar/$',
self.admin_site.admin_view(self.calend... | [
"def",
"get_urls",
"(",
"self",
")",
":",
"from",
"django",
".",
"conf",
".",
"urls",
"import",
"patterns",
",",
"url",
"urls",
"=",
"super",
"(",
"EventAdmin",
",",
"self",
")",
".",
"get_urls",
"(",
")",
"my_urls",
"=",
"patterns",
"(",
"''",
",",
... | Add a calendar URL. | [
"Add",
"a",
"calendar",
"URL",
"."
] | python | train | 30.5 |
frictionlessdata/datapackage-py | datapackage/package.py | https://github.com/frictionlessdata/datapackage-py/blob/aca085ea54541b087140b58a81332f8728baeeb2/datapackage/package.py#L489-L495 | def _slugify_foreign_key(schema):
"""Slugify foreign key
"""
for foreign_key in schema.get('foreignKeys', []):
foreign_key['reference']['resource'] = _slugify_resource_name(
foreign_key['reference'].get('resource', ''))
return schema | [
"def",
"_slugify_foreign_key",
"(",
"schema",
")",
":",
"for",
"foreign_key",
"in",
"schema",
".",
"get",
"(",
"'foreignKeys'",
",",
"[",
"]",
")",
":",
"foreign_key",
"[",
"'reference'",
"]",
"[",
"'resource'",
"]",
"=",
"_slugify_resource_name",
"(",
"fore... | Slugify foreign key | [
"Slugify",
"foreign",
"key"
] | python | valid | 37.571429 |
lra/mackup | mackup/mackup.py | https://github.com/lra/mackup/blob/ed0b5626b033f232868900bfd5108df448873725/mackup/mackup.py#L53-L61 | def check_for_usable_restore_env(self):
"""Check if the current env can be used to restore files."""
self.check_for_usable_environment()
if not os.path.isdir(self.mackup_folder):
utils.error("Unable to find the Mackup folder: {}\n"
"You might want to back up ... | [
"def",
"check_for_usable_restore_env",
"(",
"self",
")",
":",
"self",
".",
"check_for_usable_environment",
"(",
")",
"if",
"not",
"os",
".",
"path",
".",
"isdir",
"(",
"self",
".",
"mackup_folder",
")",
":",
"utils",
".",
"error",
"(",
"\"Unable to find the Ma... | Check if the current env can be used to restore files. | [
"Check",
"if",
"the",
"current",
"env",
"can",
"be",
"used",
"to",
"restore",
"files",
"."
] | python | train | 49.666667 |
bretth/woven | woven/project.py | https://github.com/bretth/woven/blob/ec1da7b401a335f43129e7115fe7a4d145649f1e/woven/project.py#L166-L184 | def deploy_media():
"""
Deploy MEDIA_ROOT unversioned on host
"""
if not env.MEDIA_URL or not env.MEDIA_ROOT or 'http://' in env.MEDIA_URL: return
local_dir = env.MEDIA_ROOT
remote_dir = '/'.join([deployment_root(),'public'])
media_url = env.MEDIA_URL[1:]
if media_url:
remo... | [
"def",
"deploy_media",
"(",
")",
":",
"if",
"not",
"env",
".",
"MEDIA_URL",
"or",
"not",
"env",
".",
"MEDIA_ROOT",
"or",
"'http://'",
"in",
"env",
".",
"MEDIA_URL",
":",
"return",
"local_dir",
"=",
"env",
".",
"MEDIA_ROOT",
"remote_dir",
"=",
"'/'",
".",... | Deploy MEDIA_ROOT unversioned on host | [
"Deploy",
"MEDIA_ROOT",
"unversioned",
"on",
"host"
] | python | train | 33.526316 |
IdentityPython/pyop | src/pyop/provider.py | https://github.com/IdentityPython/pyop/blob/7b1385964f079c39752fce5f2dbcf458b8a92e56/src/pyop/provider.py#L331-L388 | def _do_code_exchange(self, request, # type: Dict[str, str]
extra_id_token_claims=None
# type: Optional[Union[Mapping[str, Union[str, List[str]]], Callable[[str, str], Mapping[str, Union[str, List[str]]]]]
):
# type: (...) -> oic.mes... | [
"def",
"_do_code_exchange",
"(",
"self",
",",
"request",
",",
"# type: Dict[str, str]",
"extra_id_token_claims",
"=",
"None",
"# type: Optional[Union[Mapping[str, Union[str, List[str]]], Callable[[str, str], Mapping[str, Union[str, List[str]]]]]",
")",
":",
"# type: (...) -> oic.message.... | Handles a token request for exchanging an authorization code for an access token
(grant_type=authorization_code).
:param request: parsed http request parameters
:param extra_id_token_claims: any extra parameters to include in the signed ID Token, either as a dict-like
object or as a ... | [
"Handles",
"a",
"token",
"request",
"for",
"exchanging",
"an",
"authorization",
"code",
"for",
"an",
"access",
"token",
"(",
"grant_type",
"=",
"authorization_code",
")",
".",
":",
"param",
"request",
":",
"parsed",
"http",
"request",
"parameters",
":",
"param... | python | train | 62.655172 |
mitsei/dlkit | dlkit/json_/authorization/sessions.py | https://github.com/mitsei/dlkit/blob/445f968a175d61c8d92c0f617a3c17dc1dc7c584/dlkit/json_/authorization/sessions.py#L896-L926 | def get_authorizations_for_resource_and_function(self, resource_id, function_id):
"""Gets a list of ``Authorizations`` associated with a given resource.
Authorizations related to the given resource, including those
related through an ``Agent,`` are returned. In plenary mode, the
returne... | [
"def",
"get_authorizations_for_resource_and_function",
"(",
"self",
",",
"resource_id",
",",
"function_id",
")",
":",
"# Implemented from template for",
"# osid.relationship.RelationshipLookupSession.get_relationships_for_peers",
"# NOTE: This implementation currently ignores plenary and eff... | Gets a list of ``Authorizations`` associated with a given resource.
Authorizations related to the given resource, including those
related through an ``Agent,`` are returned. In plenary mode, the
returned list contains all known authorizations or an error
results. Otherwise, the returned... | [
"Gets",
"a",
"list",
"of",
"Authorizations",
"associated",
"with",
"a",
"given",
"resource",
"."
] | python | train | 53.741935 |
loli/medpy | medpy/filter/image.py | https://github.com/loli/medpy/blob/95216b9e22e7ce301f0edf953ee2a2f1b6c6aee5/medpy/filter/image.py#L287-L337 | def sum_filter(input, size=None, footprint=None, output=None, mode="reflect", cval=0.0, origin=0):
r"""
Calculates a multi-dimensional sum filter.
Parameters
----------
input : array-like
input array to filter
size : scalar or tuple, optional
See footprint, below
footprint :... | [
"def",
"sum_filter",
"(",
"input",
",",
"size",
"=",
"None",
",",
"footprint",
"=",
"None",
",",
"output",
"=",
"None",
",",
"mode",
"=",
"\"reflect\"",
",",
"cval",
"=",
"0.0",
",",
"origin",
"=",
"0",
")",
":",
"footprint",
"=",
"__make_footprint",
... | r"""
Calculates a multi-dimensional sum filter.
Parameters
----------
input : array-like
input array to filter
size : scalar or tuple, optional
See footprint, below
footprint : array, optional
Either `size` or `footprint` must be defined. `size` gives
the shape t... | [
"r",
"Calculates",
"a",
"multi",
"-",
"dimensional",
"sum",
"filter",
"."
] | python | train | 39.333333 |
booktype/python-ooxml | ooxml/serialize.py | https://github.com/booktype/python-ooxml/blob/b56990a5bee2e1bc46839cec5161ff3726dc4d87/ooxml/serialize.py#L505-L523 | def get_css_classes(document, style):
"""Returns CSS classes for this style.
This function will check all the styles specified style is based on and return their CSS classes.
:Args:
- document (:class:`ooxml.doc.Document`): Document object
- style (:class:`ooxml.doc.Style`): Style object
... | [
"def",
"get_css_classes",
"(",
"document",
",",
"style",
")",
":",
"lst",
"=",
"[",
"st",
".",
"lower",
"(",
")",
"for",
"st",
"in",
"get_all_styles",
"(",
"document",
",",
"style",
")",
"[",
"-",
"1",
":",
"]",
"]",
"+",
"[",
"'{}-fontsize'",
".",... | Returns CSS classes for this style.
This function will check all the styles specified style is based on and return their CSS classes.
:Args:
- document (:class:`ooxml.doc.Document`): Document object
- style (:class:`ooxml.doc.Style`): Style object
:Returns:
String representing all the C... | [
"Returns",
"CSS",
"classes",
"for",
"this",
"style",
"."
] | python | train | 33.052632 |
dahlia/sqlalchemy-imageattach | sqlalchemy_imageattach/store.py | https://github.com/dahlia/sqlalchemy-imageattach/blob/b4bafa73f3bb576ecf67ed7b40b702704a0fbdc8/sqlalchemy_imageattach/store.py#L143-L165 | def store(self, image, file):
"""Stores the actual data ``file`` of the given ``image``.
::
with open(imagefile, 'rb') as f:
store.store(image, f)
:param image: the image to store its actual data file
:type image: :class:`sqlalchemy_imageattach.entity.Image`... | [
"def",
"store",
"(",
"self",
",",
"image",
",",
"file",
")",
":",
"from",
".",
"entity",
"import",
"Image",
"if",
"not",
"isinstance",
"(",
"image",
",",
"Image",
")",
":",
"raise",
"TypeError",
"(",
"'image must be a sqlalchemy_imageattach.entity.'",
"'Image ... | Stores the actual data ``file`` of the given ``image``.
::
with open(imagefile, 'rb') as f:
store.store(image, f)
:param image: the image to store its actual data file
:type image: :class:`sqlalchemy_imageattach.entity.Image`
:param file: the image file to p... | [
"Stores",
"the",
"actual",
"data",
"file",
"of",
"the",
"given",
"image",
".",
"::"
] | python | train | 43.608696 |
IdentityPython/pysaml2 | example/idp2/idp_uwsgi.py | https://github.com/IdentityPython/pysaml2/blob/d3aa78eeb7d37c12688f783cb4db1c7263a14ad6/example/idp2/idp_uwsgi.py#L462-L476 | def do_authentication(environ, start_response, authn_context, key,
redirect_uri):
"""
Display the login form
"""
logger.debug("Do authentication")
auth_info = AUTHN_BROKER.pick(authn_context)
if len(auth_info):
method, reference = auth_info[0]
logger.debug(... | [
"def",
"do_authentication",
"(",
"environ",
",",
"start_response",
",",
"authn_context",
",",
"key",
",",
"redirect_uri",
")",
":",
"logger",
".",
"debug",
"(",
"\"Do authentication\"",
")",
"auth_info",
"=",
"AUTHN_BROKER",
".",
"pick",
"(",
"authn_context",
")... | Display the login form | [
"Display",
"the",
"login",
"form"
] | python | train | 36.533333 |
python-cmd2/cmd2 | tasks.py | https://github.com/python-cmd2/cmd2/blob/b22c0bd891ed08c8b09df56df9d91f48166a5e2a/tasks.py#L112-L117 | def livehtml(context):
"Launch webserver on http://localhost:8000 with rendered documentation"
builder = 'html'
outputdir = os.path.join(DOCS_BUILDDIR, builder)
cmdline = 'sphinx-autobuild -b {} {} {}'.format(builder, DOCS_SRCDIR, outputdir)
context.run(cmdline, pty=True) | [
"def",
"livehtml",
"(",
"context",
")",
":",
"builder",
"=",
"'html'",
"outputdir",
"=",
"os",
".",
"path",
".",
"join",
"(",
"DOCS_BUILDDIR",
",",
"builder",
")",
"cmdline",
"=",
"'sphinx-autobuild -b {} {} {}'",
".",
"format",
"(",
"builder",
",",
"DOCS_SR... | Launch webserver on http://localhost:8000 with rendered documentation | [
"Launch",
"webserver",
"on",
"http",
":",
"//",
"localhost",
":",
"8000",
"with",
"rendered",
"documentation"
] | python | train | 47.833333 |
rstoneback/pysat | pysat/instruments/supermag_magnetometer.py | https://github.com/rstoneback/pysat/blob/4ae1afd80e15e4449397d39dce8c3e969c32c422/pysat/instruments/supermag_magnetometer.py#L197-L259 | def load_csv_data(fname, tag):
"""Load data from a comma separated SuperMAG file
Parameters
------------
fname : (str)
CSV SuperMAG file name
tag : (str)
Denotes type of file to load. Accepted types are 'indices', 'all',
'stations', and '' (for just magnetometer measurement... | [
"def",
"load_csv_data",
"(",
"fname",
",",
"tag",
")",
":",
"import",
"re",
"if",
"tag",
"==",
"\"stations\"",
":",
"# Because there may be multiple operators, the default pandas reader",
"# cannot be used.",
"ddict",
"=",
"dict",
"(",
")",
"dkeys",
"=",
"list",
"("... | Load data from a comma separated SuperMAG file
Parameters
------------
fname : (str)
CSV SuperMAG file name
tag : (str)
Denotes type of file to load. Accepted types are 'indices', 'all',
'stations', and '' (for just magnetometer measurements).
Returns
--------
data... | [
"Load",
"data",
"from",
"a",
"comma",
"separated",
"SuperMAG",
"file"
] | python | train | 34.650794 |
saltstack/salt | salt/modules/win_task.py | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/win_task.py#L1277-L1316 | def status(name, location='\\'):
r'''
Determine the status of a task. Is it Running, Queued, Ready, etc.
:param str name: The name of the task for which to return the status
:param str location: A string value representing the location of the task.
Default is '\\' which is the root for the tas... | [
"def",
"status",
"(",
"name",
",",
"location",
"=",
"'\\\\'",
")",
":",
"# Check for existing folder",
"if",
"name",
"not",
"in",
"list_tasks",
"(",
"location",
")",
":",
"return",
"'{0} not found in {1}'",
".",
"format",
"(",
"name",
",",
"location",
")",
"... | r'''
Determine the status of a task. Is it Running, Queued, Ready, etc.
:param str name: The name of the task for which to return the status
:param str location: A string value representing the location of the task.
Default is '\\' which is the root for the task scheduler
(C:\Windows\Syste... | [
"r",
"Determine",
"the",
"status",
"of",
"a",
"task",
".",
"Is",
"it",
"Running",
"Queued",
"Ready",
"etc",
"."
] | python | train | 26.7 |
OzymandiasTheGreat/python-libinput | libinput/device.py | https://github.com/OzymandiasTheGreat/python-libinput/blob/1f477ee9f1d56b284b20e0317ea8967c64ef1218/libinput/device.py#L1892-L1908 | def has_button(self, button):
"""Check if this device has a given button.
Args:
button (int): Button to check for, see ``input.h`` for button
definitions.
Returns:
bool: :obj:`True` if the device has this button, :obj:`False` if
it does not.
Raises:
AssertionError
"""
rc = self._libinput.l... | [
"def",
"has_button",
"(",
"self",
",",
"button",
")",
":",
"rc",
"=",
"self",
".",
"_libinput",
".",
"libinput_device_pointer_has_button",
"(",
"self",
".",
"_handle",
",",
"button",
")",
"assert",
"rc",
">=",
"0",
",",
"'This device is not a pointer device'",
... | Check if this device has a given button.
Args:
button (int): Button to check for, see ``input.h`` for button
definitions.
Returns:
bool: :obj:`True` if the device has this button, :obj:`False` if
it does not.
Raises:
AssertionError | [
"Check",
"if",
"this",
"device",
"has",
"a",
"given",
"button",
"."
] | python | train | 25.705882 |
cloudant/python-cloudant | src/cloudant/design_document.py | https://github.com/cloudant/python-cloudant/blob/e0ba190f6ba07fe3522a668747128214ad573c7e/src/cloudant/design_document.py#L510-L549 | def save(self):
"""
Saves changes made to the locally cached DesignDocument object's data
structures to the remote database. If the design document does not
exist remotely then it is created in the remote database. If the object
does exist remotely then the design document is u... | [
"def",
"save",
"(",
"self",
")",
":",
"if",
"self",
".",
"views",
":",
"if",
"self",
".",
"get",
"(",
"'language'",
",",
"None",
")",
"!=",
"QUERY_LANGUAGE",
":",
"for",
"view_name",
",",
"view",
"in",
"self",
".",
"iterviews",
"(",
")",
":",
"if",... | Saves changes made to the locally cached DesignDocument object's data
structures to the remote database. If the design document does not
exist remotely then it is created in the remote database. If the object
does exist remotely then the design document is updated remotely. In
either ... | [
"Saves",
"changes",
"made",
"to",
"the",
"locally",
"cached",
"DesignDocument",
"object",
"s",
"data",
"structures",
"to",
"the",
"remote",
"database",
".",
"If",
"the",
"design",
"document",
"does",
"not",
"exist",
"remotely",
"then",
"it",
"is",
"created",
... | python | train | 49.775 |
anchore/anchore | anchore/cli/logs.py | https://github.com/anchore/anchore/blob/8a4d5b9708e27856312d303aae3f04f3c72039d6/anchore/cli/logs.py#L39-L84 | def format(self, record):
"""
Modified from logging/__init__.py in python 2.7 lib
Format the specified record as text.
The record's attribute dictionary is used as the operand to a
string formatting operation which yields the returned string.
Before formatting the dicti... | [
"def",
"format",
"(",
"self",
",",
"record",
")",
":",
"record",
".",
"message",
"=",
"record",
".",
"getMessage",
"(",
")",
"if",
"self",
".",
"usesTime",
"(",
")",
":",
"record",
".",
"asctime",
"=",
"self",
".",
"formatTime",
"(",
"record",
",",
... | Modified from logging/__init__.py in python 2.7 lib
Format the specified record as text.
The record's attribute dictionary is used as the operand to a
string formatting operation which yields the returned string.
Before formatting the dictionary, a couple of preparatory steps
a... | [
"Modified",
"from",
"logging",
"/",
"__init__",
".",
"py",
"in",
"python",
"2",
".",
"7",
"lib"
] | python | train | 43.652174 |
joeferraro/mm | mm/sforce/base.py | https://github.com/joeferraro/mm/blob/43dce48a2249faab4d872c228ada9fbdbeec147b/mm/sforce/base.py#L523-L529 | def query(self, queryString):
'''
Executes a query against the specified object and returns data that matches
the specified criteria.
'''
self._setHeaders('query')
return self._sforce.service.query(queryString) | [
"def",
"query",
"(",
"self",
",",
"queryString",
")",
":",
"self",
".",
"_setHeaders",
"(",
"'query'",
")",
"return",
"self",
".",
"_sforce",
".",
"service",
".",
"query",
"(",
"queryString",
")"
] | Executes a query against the specified object and returns data that matches
the specified criteria. | [
"Executes",
"a",
"query",
"against",
"the",
"specified",
"object",
"and",
"returns",
"data",
"that",
"matches",
"the",
"specified",
"criteria",
"."
] | python | train | 32.571429 |
JarryShaw/PyPCAPKit | src/protocols/internet/hip.py | https://github.com/JarryShaw/PyPCAPKit/blob/c7f0da9aebc2cf210bf8f8b912f7d3cbb98ca10e/src/protocols/internet/hip.py#L299-L333 | def _read_para_unassigned(self, code, cbit, clen, *, desc, length, version):
"""Read HIP unassigned parameters.
Structure of HIP unassigned parameters [RFC 5201][RFC 7401]:
0 1 2 3
0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 ... | [
"def",
"_read_para_unassigned",
"(",
"self",
",",
"code",
",",
"cbit",
",",
"clen",
",",
"*",
",",
"desc",
",",
"length",
",",
"version",
")",
":",
"unassigned",
"=",
"dict",
"(",
"type",
"=",
"desc",
",",
"critical",
"=",
"cbit",
",",
"length",
"=",... | Read HIP unassigned parameters.
Structure of HIP unassigned parameters [RFC 5201][RFC 7401]:
0 1 2 3
0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-... | [
"Read",
"HIP",
"unassigned",
"parameters",
"."
] | python | train | 46.542857 |
gofed/gofedlib | gofedlib/go/symbolsextractor/extractor.py | https://github.com/gofed/gofedlib/blob/0674c248fe3d8706f98f912996b65af469f96b10/gofedlib/go/symbolsextractor/extractor.py#L203-L222 | def _mergeGoSymbols(self, jsons = []):
"""
Exported symbols for a given package does not have any prefix.
So I can drop all import paths that are file specific and merge
all symbols.
Assuming all files in the given package has mutual exclusive symbols.
"""
# <siXy> imports are per file, exports are per pa... | [
"def",
"_mergeGoSymbols",
"(",
"self",
",",
"jsons",
"=",
"[",
"]",
")",
":",
"# <siXy> imports are per file, exports are per package",
"# on the highest level we have: pkgname, types, funcs, vars, imports.",
"symbols",
"=",
"{",
"}",
"symbols",
"[",
"\"types\"",
"]",
"=",
... | Exported symbols for a given package does not have any prefix.
So I can drop all import paths that are file specific and merge
all symbols.
Assuming all files in the given package has mutual exclusive symbols. | [
"Exported",
"symbols",
"for",
"a",
"given",
"package",
"does",
"not",
"have",
"any",
"prefix",
".",
"So",
"I",
"can",
"drop",
"all",
"import",
"paths",
"that",
"are",
"file",
"specific",
"and",
"merge",
"all",
"symbols",
".",
"Assuming",
"all",
"files",
... | python | train | 31.75 |
marshmallow-code/marshmallow | src/marshmallow/fields.py | https://github.com/marshmallow-code/marshmallow/blob/a6b6c4151f1fbf16f3774d4052ca2bddf6903750/src/marshmallow/fields.py#L767-L772 | def _format_num(self, value):
"""Return the number value for value, given this field's `num_type`."""
# (value is True or value is False) is ~5x faster than isinstance(value, bool)
if value is True or value is False:
raise TypeError('value must be a Number, not a boolean.')
r... | [
"def",
"_format_num",
"(",
"self",
",",
"value",
")",
":",
"# (value is True or value is False) is ~5x faster than isinstance(value, bool)",
"if",
"value",
"is",
"True",
"or",
"value",
"is",
"False",
":",
"raise",
"TypeError",
"(",
"'value must be a Number, not a boolean.'"... | Return the number value for value, given this field's `num_type`. | [
"Return",
"the",
"number",
"value",
"for",
"value",
"given",
"this",
"field",
"s",
"num_type",
"."
] | python | train | 56.833333 |
mcs07/ChemDataExtractor | chemdataextractor/doc/text.py | https://github.com/mcs07/ChemDataExtractor/blob/349a3bea965f2073141d62043b89319222e46af1/chemdataextractor/doc/text.py#L505-L524 | def records(self):
"""Return a list of records for this sentence."""
compounds = ModelList()
seen_labels = set()
# Ensure no control characters are sent to a parser (need to be XML compatible)
tagged_tokens = [(CONTROL_RE.sub('', token), tag) for token, tag in self.tagged_tokens]... | [
"def",
"records",
"(",
"self",
")",
":",
"compounds",
"=",
"ModelList",
"(",
")",
"seen_labels",
"=",
"set",
"(",
")",
"# Ensure no control characters are sent to a parser (need to be XML compatible)",
"tagged_tokens",
"=",
"[",
"(",
"CONTROL_RE",
".",
"sub",
"(",
"... | Return a list of records for this sentence. | [
"Return",
"a",
"list",
"of",
"records",
"for",
"this",
"sentence",
"."
] | python | train | 48.6 |
ZELLMECHANIK-DRESDEN/dclab | dclab/rtdc_dataset/ancillaries/ancillary_feature.py | https://github.com/ZELLMECHANIK-DRESDEN/dclab/blob/79002c4356e7020c2ba73ab0a3819c9abd4affec/dclab/rtdc_dataset/ancillaries/ancillary_feature.py#L143-L149 | def get_instances(feature_name):
"""Return all all instances that compute `feature_name`"""
feats = []
for ft in AncillaryFeature.features:
if ft.feature_name == feature_name:
feats.append(ft)
return feats | [
"def",
"get_instances",
"(",
"feature_name",
")",
":",
"feats",
"=",
"[",
"]",
"for",
"ft",
"in",
"AncillaryFeature",
".",
"features",
":",
"if",
"ft",
".",
"feature_name",
"==",
"feature_name",
":",
"feats",
".",
"append",
"(",
"ft",
")",
"return",
"fea... | Return all all instances that compute `feature_name` | [
"Return",
"all",
"all",
"instances",
"that",
"compute",
"feature_name"
] | python | train | 37 |
Dullage/starlingbank | starlingbank/__init__.py | https://github.com/Dullage/starlingbank/blob/9495456980d5d6d85c4e999a17dc69481067af09/starlingbank/__init__.py#L111-L129 | def get_image(self, filename: str=None) -> None:
"""Download the photo associated with a Savings Goal."""
if filename is None:
filename = "{0}.png".format(self.name)
endpoint = "/account/{0}/savings-goals/{1}/photo".format(
self._account_uid,
self.uid
... | [
"def",
"get_image",
"(",
"self",
",",
"filename",
":",
"str",
"=",
"None",
")",
"->",
"None",
":",
"if",
"filename",
"is",
"None",
":",
"filename",
"=",
"\"{0}.png\"",
".",
"format",
"(",
"self",
".",
"name",
")",
"endpoint",
"=",
"\"/account/{0}/savings... | Download the photo associated with a Savings Goal. | [
"Download",
"the",
"photo",
"associated",
"with",
"a",
"Savings",
"Goal",
"."
] | python | train | 32.105263 |
wandb/client | wandb/vendor/prompt_toolkit/layout/prompt.py | https://github.com/wandb/client/blob/7d08954ed5674fee223cd85ed0d8518fe47266b2/wandb/vendor/prompt_toolkit/layout/prompt.py#L101-L111 | def _get_arg_tokens(cli):
"""
Tokens for the arg-prompt.
"""
arg = cli.input_processor.arg
return [
(Token.Prompt.Arg, '(arg: '),
(Token.Prompt.Arg.Text, str(arg)),
(Token.Prompt.Arg, ') '),
] | [
"def",
"_get_arg_tokens",
"(",
"cli",
")",
":",
"arg",
"=",
"cli",
".",
"input_processor",
".",
"arg",
"return",
"[",
"(",
"Token",
".",
"Prompt",
".",
"Arg",
",",
"'(arg: '",
")",
",",
"(",
"Token",
".",
"Prompt",
".",
"Arg",
".",
"Text",
",",
"st... | Tokens for the arg-prompt. | [
"Tokens",
"for",
"the",
"arg",
"-",
"prompt",
"."
] | python | train | 21 |
pudo-attic/scrapekit | scrapekit/tasks.py | https://github.com/pudo-attic/scrapekit/blob/cfd258120922fcd571430cdf00ba50f3cf18dc15/scrapekit/tasks.py#L38-L44 | def _spawn(self):
""" Initialize the queue and the threads. """
self.queue = Queue(maxsize=self.num_threads * 10)
for i in range(self.num_threads):
t = Thread(target=self._consume)
t.daemon = True
t.start() | [
"def",
"_spawn",
"(",
"self",
")",
":",
"self",
".",
"queue",
"=",
"Queue",
"(",
"maxsize",
"=",
"self",
".",
"num_threads",
"*",
"10",
")",
"for",
"i",
"in",
"range",
"(",
"self",
".",
"num_threads",
")",
":",
"t",
"=",
"Thread",
"(",
"target",
... | Initialize the queue and the threads. | [
"Initialize",
"the",
"queue",
"and",
"the",
"threads",
"."
] | python | train | 37.142857 |
foremast/foremast | src/foremast/configs/prepare_configs.py | https://github.com/foremast/foremast/blob/fb70f29b8ce532f061685a17d120486e47b215ba/src/foremast/configs/prepare_configs.py#L65-L93 | def process_configs(file_lookup, app_config_format, pipeline_config):
"""Processes the configs from lookup sources.
Args:
file_lookup (FileLookup): Source to look for file/config
app_config_format (str): The format for application config files.
pipeline_config (str): Name/path of the pi... | [
"def",
"process_configs",
"(",
"file_lookup",
",",
"app_config_format",
",",
"pipeline_config",
")",
":",
"app_configs",
"=",
"collections",
".",
"defaultdict",
"(",
"dict",
")",
"for",
"env",
"in",
"ENVS",
":",
"file_json",
"=",
"app_config_format",
".",
"forma... | Processes the configs from lookup sources.
Args:
file_lookup (FileLookup): Source to look for file/config
app_config_format (str): The format for application config files.
pipeline_config (str): Name/path of the pipeline config
Returns:
dict: Retreived application config | [
"Processes",
"the",
"configs",
"from",
"lookup",
"sources",
"."
] | python | train | 37.827586 |
inasafe/inasafe | safe/gui/tools/wizard/step_kw30_field.py | https://github.com/inasafe/inasafe/blob/831d60abba919f6d481dc94a8d988cc205130724/safe/gui/tools/wizard/step_kw30_field.py#L203-L306 | def set_widgets(self):
"""Set widgets on the Field tab."""
self.clear_further_steps()
purpose = self.parent.step_kw_purpose.selected_purpose()
subcategory = self.parent.step_kw_subcategory.selected_subcategory()
unit = self.parent.step_kw_unit.selected_unit()
layer_mode =... | [
"def",
"set_widgets",
"(",
"self",
")",
":",
"self",
".",
"clear_further_steps",
"(",
")",
"purpose",
"=",
"self",
".",
"parent",
".",
"step_kw_purpose",
".",
"selected_purpose",
"(",
")",
"subcategory",
"=",
"self",
".",
"parent",
".",
"step_kw_subcategory",
... | Set widgets on the Field tab. | [
"Set",
"widgets",
"on",
"the",
"Field",
"tab",
"."
] | python | train | 44.798077 |
jbeluch/xbmcswift2 | xbmcswift2/mockxbmc/utils.py | https://github.com/jbeluch/xbmcswift2/blob/0e7a3642499554edc8265fdf1ba6c5ee567daa78/xbmcswift2/mockxbmc/utils.py#L24-L28 | def get_addon_name(addonxml):
'''Parses an addon name from the given addon.xml filename.'''
xml = parse(addonxml)
addon_node = xml.getElementsByTagName('addon')[0]
return addon_node.getAttribute('name') | [
"def",
"get_addon_name",
"(",
"addonxml",
")",
":",
"xml",
"=",
"parse",
"(",
"addonxml",
")",
"addon_node",
"=",
"xml",
".",
"getElementsByTagName",
"(",
"'addon'",
")",
"[",
"0",
"]",
"return",
"addon_node",
".",
"getAttribute",
"(",
"'name'",
")"
] | Parses an addon name from the given addon.xml filename. | [
"Parses",
"an",
"addon",
"name",
"from",
"the",
"given",
"addon",
".",
"xml",
"filename",
"."
] | python | train | 42.8 |
saltstack/salt | salt/utils/roster_matcher.py | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/roster_matcher.py#L119-L130 | def get_data(self, minion):
'''
Return the configured ip
'''
ret = copy.deepcopy(__opts__.get('roster_defaults', {}))
if isinstance(self.raw[minion], six.string_types):
ret.update({'host': self.raw[minion]})
return ret
elif isinstance(self.raw[mini... | [
"def",
"get_data",
"(",
"self",
",",
"minion",
")",
":",
"ret",
"=",
"copy",
".",
"deepcopy",
"(",
"__opts__",
".",
"get",
"(",
"'roster_defaults'",
",",
"{",
"}",
")",
")",
"if",
"isinstance",
"(",
"self",
".",
"raw",
"[",
"minion",
"]",
",",
"six... | Return the configured ip | [
"Return",
"the",
"configured",
"ip"
] | python | train | 33.75 |
vaexio/vaex | packages/vaex-core/vaex/dataframe.py | https://github.com/vaexio/vaex/blob/a45b672f8287afca2ada8e36b74b604b9b28dd85/packages/vaex-core/vaex/dataframe.py#L4447-L4451 | def _hide_column(self, column):
'''Hides a column by prefixing the name with \'__\''''
column = _ensure_string_from_expression(column)
new_name = self._find_valid_name('__' + column)
self._rename(column, new_name) | [
"def",
"_hide_column",
"(",
"self",
",",
"column",
")",
":",
"column",
"=",
"_ensure_string_from_expression",
"(",
"column",
")",
"new_name",
"=",
"self",
".",
"_find_valid_name",
"(",
"'__'",
"+",
"column",
")",
"self",
".",
"_rename",
"(",
"column",
",",
... | Hides a column by prefixing the name with \'__\ | [
"Hides",
"a",
"column",
"by",
"prefixing",
"the",
"name",
"with",
"\\",
"__",
"\\"
] | python | test | 48.2 |
DataDog/integrations-core | datadog_checks_dev/datadog_checks/dev/tooling/utils.py | https://github.com/DataDog/integrations-core/blob/ebd41c873cf9f97a8c51bf9459bc6a7536af8acd/datadog_checks_dev/datadog_checks/dev/tooling/utils.py#L129-L135 | def get_version_string(check_name):
"""
Get the version string for the given check.
"""
version = VERSION.search(read_version_file(check_name))
if version:
return version.group(1) | [
"def",
"get_version_string",
"(",
"check_name",
")",
":",
"version",
"=",
"VERSION",
".",
"search",
"(",
"read_version_file",
"(",
"check_name",
")",
")",
"if",
"version",
":",
"return",
"version",
".",
"group",
"(",
"1",
")"
] | Get the version string for the given check. | [
"Get",
"the",
"version",
"string",
"for",
"the",
"given",
"check",
"."
] | python | train | 28.714286 |
tritemio/PyBroMo | pybromo/diffusion.py | https://github.com/tritemio/PyBroMo/blob/b75f82a4551ff37e7c7a7e6954c536451f3e6d06/pybromo/diffusion.py#L131-L135 | def add(self, num_particles, D):
"""Add particles with diffusion coefficient `D` at random positions.
"""
self._plist += self._generate(num_particles, D, box=self.box,
rs=self.rs) | [
"def",
"add",
"(",
"self",
",",
"num_particles",
",",
"D",
")",
":",
"self",
".",
"_plist",
"+=",
"self",
".",
"_generate",
"(",
"num_particles",
",",
"D",
",",
"box",
"=",
"self",
".",
"box",
",",
"rs",
"=",
"self",
".",
"rs",
")"
] | Add particles with diffusion coefficient `D` at random positions. | [
"Add",
"particles",
"with",
"diffusion",
"coefficient",
"D",
"at",
"random",
"positions",
"."
] | python | valid | 47.4 |
cloudnull/turbolift | turbolift/clouderator/utils.py | https://github.com/cloudnull/turbolift/blob/da33034e88959226529ce762e2895e6f6356c448/turbolift/clouderator/utils.py#L76-L84 | def unique_list_dicts(dlist, key):
"""Return a list of dictionaries which are sorted for only unique entries.
:param dlist:
:param key:
:return list:
"""
return list(dict((val[key], val) for val in dlist).values()) | [
"def",
"unique_list_dicts",
"(",
"dlist",
",",
"key",
")",
":",
"return",
"list",
"(",
"dict",
"(",
"(",
"val",
"[",
"key",
"]",
",",
"val",
")",
"for",
"val",
"in",
"dlist",
")",
".",
"values",
"(",
")",
")"
] | Return a list of dictionaries which are sorted for only unique entries.
:param dlist:
:param key:
:return list: | [
"Return",
"a",
"list",
"of",
"dictionaries",
"which",
"are",
"sorted",
"for",
"only",
"unique",
"entries",
"."
] | python | train | 25.777778 |
teepark/junction | junction/futures.py | https://github.com/teepark/junction/blob/481d135d9e53acb55c72686e2eb4483432f35fa6/junction/futures.py#L375-L401 | def wait_any(futures, timeout=None):
'''Wait for the completion of any (the first) one of multiple futures
:param list futures: A list of :class:`Future`\s
:param timeout:
The maximum time to wait. With ``None``, will block indefinitely.
:type timeout: float or None
:returns:
One o... | [
"def",
"wait_any",
"(",
"futures",
",",
"timeout",
"=",
"None",
")",
":",
"for",
"fut",
"in",
"futures",
":",
"if",
"fut",
".",
"complete",
":",
"return",
"fut",
"wait",
"=",
"_Wait",
"(",
"futures",
")",
"for",
"fut",
"in",
"futures",
":",
"fut",
... | Wait for the completion of any (the first) one of multiple futures
:param list futures: A list of :class:`Future`\s
:param timeout:
The maximum time to wait. With ``None``, will block indefinitely.
:type timeout: float or None
:returns:
One of the futures from the provided list -- the ... | [
"Wait",
"for",
"the",
"completion",
"of",
"any",
"(",
"the",
"first",
")",
"one",
"of",
"multiple",
"futures"
] | python | train | 27.592593 |
mikeboers/MultiMap | multimap.py | https://github.com/mikeboers/MultiMap/blob/0251e5d5df693cc247b4ac5b95adfdd10e3bec04/multimap.py#L399-L416 | def _insert_pairs(self, ids_and_pairs):
"""Insert some new pairs, and keep the _key_ids updated.
Params:
ids_and_pairs -- A list of (index, (key, value)) tuples.
"""
ids_to_insert = [x[0] for x in ids_and_pairs]
# We use the bisect to tell u... | [
"def",
"_insert_pairs",
"(",
"self",
",",
"ids_and_pairs",
")",
":",
"ids_to_insert",
"=",
"[",
"x",
"[",
"0",
"]",
"for",
"x",
"in",
"ids_and_pairs",
"]",
"# We use the bisect to tell us how many spots the given index is",
"# shifting up in the list.",
"for",
"ids",
... | Insert some new pairs, and keep the _key_ids updated.
Params:
ids_and_pairs -- A list of (index, (key, value)) tuples. | [
"Insert",
"some",
"new",
"pairs",
"and",
"keep",
"the",
"_key_ids",
"updated",
".",
"Params",
":",
"ids_and_pairs",
"--",
"A",
"list",
"of",
"(",
"index",
"(",
"key",
"value",
"))",
"tuples",
"."
] | python | train | 35.222222 |
angr/angr | angr/analyses/decompiler/clinic.py | https://github.com/angr/angr/blob/4e2f97d56af5419ee73bdb30482c8dd8ff5f3e40/angr/analyses/decompiler/clinic.py#L151-L167 | def _simplify_blocks(self, stack_pointer_tracker=None):
"""
Simplify all blocks in self._blocks.
:param stack_pointer_tracker: The RegisterDeltaTracker analysis instance.
:return: None
"""
# First of all, let's simplify blocks one by one
... | [
"def",
"_simplify_blocks",
"(",
"self",
",",
"stack_pointer_tracker",
"=",
"None",
")",
":",
"# First of all, let's simplify blocks one by one",
"for",
"key",
"in",
"self",
".",
"_blocks",
":",
"ail_block",
"=",
"self",
".",
"_blocks",
"[",
"key",
"]",
"simplified... | Simplify all blocks in self._blocks.
:param stack_pointer_tracker: The RegisterDeltaTracker analysis instance.
:return: None | [
"Simplify",
"all",
"blocks",
"in",
"self",
".",
"_blocks",
"."
] | python | train | 36.647059 |
lltk/lltk | lltk/nl/scrapers/vandale.py | https://github.com/lltk/lltk/blob/d171de55c1b97695fddedf4b02401ae27bf1d634/lltk/nl/scrapers/vandale.py#L56-L70 | def articles(self):
''' Tries to scrape the correct articles for singular and plural from vandale.nl. '''
result = [None, None]
element = self._first('NN')
if element:
if re.search('(de|het/?de|het);', element, re.U):
result[0] = re.findall('(de|het/?de|het);', element, re.U)[0].split('/')
if re.sear... | [
"def",
"articles",
"(",
"self",
")",
":",
"result",
"=",
"[",
"None",
",",
"None",
"]",
"element",
"=",
"self",
".",
"_first",
"(",
"'NN'",
")",
"if",
"element",
":",
"if",
"re",
".",
"search",
"(",
"'(de|het/?de|het);'",
",",
"element",
",",
"re",
... | Tries to scrape the correct articles for singular and plural from vandale.nl. | [
"Tries",
"to",
"scrape",
"the",
"correct",
"articles",
"for",
"singular",
"and",
"plural",
"from",
"vandale",
".",
"nl",
"."
] | python | train | 32.6 |
FNNDSC/pfurl | pfurl/pfurl.py | https://github.com/FNNDSC/pfurl/blob/572f634ab582b7b7b7a3fbfd5bf12aadc1ba7958/pfurl/pfurl.py#L776-L799 | def pullPath_copy(self, d_msg, **kwargs):
"""
Handle the "copy" pull operation
"""
# Parse "header" information
d_meta = d_msg['meta']
d_local = d_meta['local']
str_localPath = d_local['path']
d_remote = d_meta['r... | [
"def",
"pullPath_copy",
"(",
"self",
",",
"d_msg",
",",
"*",
"*",
"kwargs",
")",
":",
"# Parse \"header\" information",
"d_meta",
"=",
"d_msg",
"[",
"'meta'",
"]",
"d_local",
"=",
"d_meta",
"[",
"'local'",
"]",
"str_localPath",
"=",
"d_local",
"[",
"'path'",... | Handle the "copy" pull operation | [
"Handle",
"the",
"copy",
"pull",
"operation"
] | python | train | 37.166667 |
rigetti/pyquil | pyquil/device.py | https://github.com/rigetti/pyquil/blob/ec98e453084b0037d69d8c3245f6822a5422593d/pyquil/device.py#L265-L324 | def to_dict(self):
"""
Create a JSON-serializable representation of the device Specs.
The dictionary representation is of the form::
{
'1Q': {
"0": {
"f1QRB": 0.99,
"T1": 20e-6,
... | [
"def",
"to_dict",
"(",
"self",
")",
":",
"return",
"{",
"'1Q'",
":",
"{",
"\"{}\"",
".",
"format",
"(",
"qs",
".",
"id",
")",
":",
"{",
"'f1QRB'",
":",
"qs",
".",
"f1QRB",
",",
"'fRO'",
":",
"qs",
".",
"fRO",
",",
"'T1'",
":",
"qs",
".",
"T1"... | Create a JSON-serializable representation of the device Specs.
The dictionary representation is of the form::
{
'1Q': {
"0": {
"f1QRB": 0.99,
"T1": 20e-6,
...
},
... | [
"Create",
"a",
"JSON",
"-",
"serializable",
"representation",
"of",
"the",
"device",
"Specs",
"."
] | python | train | 29.383333 |
serge-sans-paille/pythran | pythran/utils.py | https://github.com/serge-sans-paille/pythran/blob/7e1b5af2dddfabc50bd2a977f0178be269b349b5/pythran/utils.py#L10-L23 | def attr_to_path(node):
""" Compute path and final object for an attribute node """
def get_intrinsic_path(modules, attr):
""" Get function path and intrinsic from an ast.Attribute. """
if isinstance(attr, ast.Name):
return modules[demangle(attr.id)], (demangle(attr.id),)
e... | [
"def",
"attr_to_path",
"(",
"node",
")",
":",
"def",
"get_intrinsic_path",
"(",
"modules",
",",
"attr",
")",
":",
"\"\"\" Get function path and intrinsic from an ast.Attribute. \"\"\"",
"if",
"isinstance",
"(",
"attr",
",",
"ast",
".",
"Name",
")",
":",
"return",
... | Compute path and final object for an attribute node | [
"Compute",
"path",
"and",
"final",
"object",
"for",
"an",
"attribute",
"node"
] | python | train | 45.214286 |
ubc/ubcpi | ubcpi/persistence.py | https://github.com/ubc/ubcpi/blob/7b6de03f93f3a4a8af4b92dfde7c69eeaf21f46e/ubcpi/persistence.py#L134-L145 | def add_answer(self, vote, rationale):
"""
Add an answer
Args:
vote (int): the option that student voted for
rationale (str): the reason why the student vote for the option
"""
self.raw_answers.append({
VOTE_KEY: vote,
RATIONALE_KE... | [
"def",
"add_answer",
"(",
"self",
",",
"vote",
",",
"rationale",
")",
":",
"self",
".",
"raw_answers",
".",
"append",
"(",
"{",
"VOTE_KEY",
":",
"vote",
",",
"RATIONALE_KEY",
":",
"rationale",
",",
"}",
")"
] | Add an answer
Args:
vote (int): the option that student voted for
rationale (str): the reason why the student vote for the option | [
"Add",
"an",
"answer"
] | python | train | 27.75 |
lesscpy/lesscpy | lesscpy/plib/mixin.py | https://github.com/lesscpy/lesscpy/blob/51e392fb4a3cd4ccfb6175e0e42ce7d2f6b78126/lesscpy/plib/mixin.py#L81-L116 | def _parse_arg(self, var, arg, scope):
""" Parse a single argument to mixin.
args:
var (Variable object): variable
arg (mixed): argument
scope (Scope object): current scope
returns:
Variable object or None
"""
if isinstance(var, Var... | [
"def",
"_parse_arg",
"(",
"self",
",",
"var",
",",
"arg",
",",
"scope",
")",
":",
"if",
"isinstance",
"(",
"var",
",",
"Variable",
")",
":",
"# kwarg",
"if",
"arg",
":",
"if",
"utility",
".",
"is_variable",
"(",
"arg",
"[",
"0",
"]",
")",
":",
"t... | Parse a single argument to mixin.
args:
var (Variable object): variable
arg (mixed): argument
scope (Scope object): current scope
returns:
Variable object or None | [
"Parse",
"a",
"single",
"argument",
"to",
"mixin",
".",
"args",
":",
"var",
"(",
"Variable",
"object",
")",
":",
"variable",
"arg",
"(",
"mixed",
")",
":",
"argument",
"scope",
"(",
"Scope",
"object",
")",
":",
"current",
"scope",
"returns",
":",
"Vari... | python | valid | 32.888889 |
mardix/Mocha | mocha/contrib/auth/models.py | https://github.com/mardix/Mocha/blob/bce481cb31a0972061dd99bc548701411dcb9de3/mocha/contrib/auth/models.py#L173-L177 | def get_by_email(cls, email):
"""
Return a User by email address
"""
return cls.query().filter(cls.email == email).first() | [
"def",
"get_by_email",
"(",
"cls",
",",
"email",
")",
":",
"return",
"cls",
".",
"query",
"(",
")",
".",
"filter",
"(",
"cls",
".",
"email",
"==",
"email",
")",
".",
"first",
"(",
")"
] | Return a User by email address | [
"Return",
"a",
"User",
"by",
"email",
"address"
] | python | train | 30 |
ArtoLabs/SimpleSteem | simplesteem/simplesteem.py | https://github.com/ArtoLabs/SimpleSteem/blob/ce8be0ae81f8878b460bc156693f1957f7dd34a3/simplesteem/simplesteem.py#L117-L135 | def steem_instance(self):
''' Returns the steem instance if it already exists
otherwise uses the goodnode method to fetch a node
and instantiate the Steem class.
'''
if self.s:
return self.s
for num_of_retries in range(default.max_retry):
node = se... | [
"def",
"steem_instance",
"(",
"self",
")",
":",
"if",
"self",
".",
"s",
":",
"return",
"self",
".",
"s",
"for",
"num_of_retries",
"in",
"range",
"(",
"default",
".",
"max_retry",
")",
":",
"node",
"=",
"self",
".",
"util",
".",
"goodnode",
"(",
"self... | Returns the steem instance if it already exists
otherwise uses the goodnode method to fetch a node
and instantiate the Steem class. | [
"Returns",
"the",
"steem",
"instance",
"if",
"it",
"already",
"exists",
"otherwise",
"uses",
"the",
"goodnode",
"method",
"to",
"fetch",
"a",
"node",
"and",
"instantiate",
"the",
"Steem",
"class",
"."
] | python | train | 36.105263 |
bokeh/bokeh | bokeh/resources.py | https://github.com/bokeh/bokeh/blob/dc8cf49e4e4302fd38537ad089ece81fbcca4737/bokeh/resources.py#L155-L171 | def _collect_external_resources(self, resource_attr):
""" Collect external resources set on resource_attr attribute of all models."""
external_resources = []
for _, cls in sorted(Model.model_class_reverse_map.items(), key=lambda arg: arg[0]):
external = getattr(cls, resource_attr, ... | [
"def",
"_collect_external_resources",
"(",
"self",
",",
"resource_attr",
")",
":",
"external_resources",
"=",
"[",
"]",
"for",
"_",
",",
"cls",
"in",
"sorted",
"(",
"Model",
".",
"model_class_reverse_map",
".",
"items",
"(",
")",
",",
"key",
"=",
"lambda",
... | Collect external resources set on resource_attr attribute of all models. | [
"Collect",
"external",
"resources",
"set",
"on",
"resource_attr",
"attribute",
"of",
"all",
"models",
"."
] | python | train | 40.705882 |
bitesofcode/projexui | projexui/widgets/xsnapshotwidget.py | https://github.com/bitesofcode/projexui/blob/f18a73bec84df90b034ca69b9deea118dbedfc4d/projexui/widgets/xsnapshotwidget.py#L104-L117 | def mouseMoveEvent(self, event):
"""
Drags the selection view for this widget.
:param event | <QMouseMoveEvent>
"""
w = event.pos().x() - self._region.x()
h = event.pos().y() - self._region.y()
self._region.setWidth(w)
self... | [
"def",
"mouseMoveEvent",
"(",
"self",
",",
"event",
")",
":",
"w",
"=",
"event",
".",
"pos",
"(",
")",
".",
"x",
"(",
")",
"-",
"self",
".",
"_region",
".",
"x",
"(",
")",
"h",
"=",
"event",
".",
"pos",
"(",
")",
".",
"y",
"(",
")",
"-",
... | Drags the selection view for this widget.
:param event | <QMouseMoveEvent> | [
"Drags",
"the",
"selection",
"view",
"for",
"this",
"widget",
".",
":",
"param",
"event",
"|",
"<QMouseMoveEvent",
">"
] | python | train | 30.142857 |
Numigi/gitoo | src/core.py | https://github.com/Numigi/gitoo/blob/0921f5fb8a948021760bb0373a40f9fbe8a4a2e5/src/core.py#L113-L122 | def _get_module_folders(self, temp_repo):
"""Get a list of module paths contained in a temp directory.
:param string temp_repo: the folder containing the modules.
"""
paths = (
os.path.join(temp_repo, path) for path in os.listdir(temp_repo)
if self._is_module_inc... | [
"def",
"_get_module_folders",
"(",
"self",
",",
"temp_repo",
")",
":",
"paths",
"=",
"(",
"os",
".",
"path",
".",
"join",
"(",
"temp_repo",
",",
"path",
")",
"for",
"path",
"in",
"os",
".",
"listdir",
"(",
"temp_repo",
")",
"if",
"self",
".",
"_is_mo... | Get a list of module paths contained in a temp directory.
:param string temp_repo: the folder containing the modules. | [
"Get",
"a",
"list",
"of",
"module",
"paths",
"contained",
"in",
"a",
"temp",
"directory",
"."
] | python | train | 39.5 |
paetzke/consolor | consolor/consolor.py | https://github.com/paetzke/consolor/blob/2d6b6063c181095ae9ec805cc4571ad1f960e5fd/consolor/consolor.py#L61-L87 | def get_line(s, bold=False, underline=False, blinking=False, color=None,
bgcolor=None, update_line=False):
"""
Returns a string with the given formatting.
"""
parts = []
if update_line:
parts.append(_UPDATE_LINE)
for val in [color, bgcolor]:
if val:
pa... | [
"def",
"get_line",
"(",
"s",
",",
"bold",
"=",
"False",
",",
"underline",
"=",
"False",
",",
"blinking",
"=",
"False",
",",
"color",
"=",
"None",
",",
"bgcolor",
"=",
"None",
",",
"update_line",
"=",
"False",
")",
":",
"parts",
"=",
"[",
"]",
"if",... | Returns a string with the given formatting. | [
"Returns",
"a",
"string",
"with",
"the",
"given",
"formatting",
"."
] | python | train | 22.259259 |
tanghaibao/jcvi | jcvi/variation/cnv.py | https://github.com/tanghaibao/jcvi/blob/d2e31a77b6ade7f41f3b321febc2b4744d1cdeca/jcvi/variation/cnv.py#L578-L613 | def vcf_to_df_worker(arg):
""" Convert CANVAS vcf to a dict, single thread
"""
canvasvcf, exonbed, i = arg
logging.debug("Working on job {}: {}".format(i, canvasvcf))
samplekey = op.basename(canvasvcf).split(".")[0].rsplit('_', 1)[0]
d = {'SampleKey': samplekey}
exons = BedTool(exonbed)
... | [
"def",
"vcf_to_df_worker",
"(",
"arg",
")",
":",
"canvasvcf",
",",
"exonbed",
",",
"i",
"=",
"arg",
"logging",
".",
"debug",
"(",
"\"Working on job {}: {}\"",
".",
"format",
"(",
"i",
",",
"canvasvcf",
")",
")",
"samplekey",
"=",
"op",
".",
"basename",
"... | Convert CANVAS vcf to a dict, single thread | [
"Convert",
"CANVAS",
"vcf",
"to",
"a",
"dict",
"single",
"thread"
] | python | train | 32.916667 |
askedrelic/libgreader | libgreader/googlereader.py | https://github.com/askedrelic/libgreader/blob/7b668ee291c2464ea172ef44393100c369efa970/libgreader/googlereader.py#L136-L162 | def _getFeedContent(self, url, excludeRead=False, continuation=None, loadLimit=20, since=None, until=None):
"""
A list of items (from a feed, a category or from URLs made with SPECIAL_ITEMS_URL)
Returns a dict with
:param id: (str, feed's id)
:param continuation: (str, to be u... | [
"def",
"_getFeedContent",
"(",
"self",
",",
"url",
",",
"excludeRead",
"=",
"False",
",",
"continuation",
"=",
"None",
",",
"loadLimit",
"=",
"20",
",",
"since",
"=",
"None",
",",
"until",
"=",
"None",
")",
":",
"parameters",
"=",
"{",
"}",
"if",
"ex... | A list of items (from a feed, a category or from URLs made with SPECIAL_ITEMS_URL)
Returns a dict with
:param id: (str, feed's id)
:param continuation: (str, to be used to fetch more items)
:param items: array of dits with :
- update (update timestamp)
- auth... | [
"A",
"list",
"of",
"items",
"(",
"from",
"a",
"feed",
"a",
"category",
"or",
"from",
"URLs",
"made",
"with",
"SPECIAL_ITEMS_URL",
")"
] | python | train | 40.592593 |
danilobellini/dose | dose/misc.py | https://github.com/danilobellini/dose/blob/141f48322f7812b7d32e3d5f065d4473a11102a4/dose/misc.py#L114-L124 | def read_plain_text(fname, encoding="utf-8"):
"""Reads a file as a list of strings."""
with io.open(fname, encoding=encoding) as f:
result = list(f)
if result:
if result[-1][-1:] == "\n":
result.append("\n")
else:
result[-1] += "\n"
return [line[:-1] f... | [
"def",
"read_plain_text",
"(",
"fname",
",",
"encoding",
"=",
"\"utf-8\"",
")",
":",
"with",
"io",
".",
"open",
"(",
"fname",
",",
"encoding",
"=",
"encoding",
")",
"as",
"f",
":",
"result",
"=",
"list",
"(",
"f",
")",
"if",
"result",
":",
"if",
"r... | Reads a file as a list of strings. | [
"Reads",
"a",
"file",
"as",
"a",
"list",
"of",
"strings",
"."
] | python | train | 31.090909 |
JdeRobot/base | src/drivers/MAVLinkServer/MAVProxy/pymavlink/mavutil.py | https://github.com/JdeRobot/base/blob/303b18992785b2fe802212f2d758a60873007f1f/src/drivers/MAVLinkServer/MAVProxy/pymavlink/mavutil.py#L581-L588 | def set_mode_loiter(self):
'''enter LOITER mode'''
if self.mavlink10():
self.mav.command_long_send(self.target_system, self.target_component,
mavlink.MAV_CMD_NAV_LOITER_UNLIM, 0, 0, 0, 0, 0, 0, 0, 0)
else:
MAV_ACTION_LOITER = 27
... | [
"def",
"set_mode_loiter",
"(",
"self",
")",
":",
"if",
"self",
".",
"mavlink10",
"(",
")",
":",
"self",
".",
"mav",
".",
"command_long_send",
"(",
"self",
".",
"target_system",
",",
"self",
".",
"target_component",
",",
"mavlink",
".",
"MAV_CMD_NAV_LOITER_UN... | enter LOITER mode | [
"enter",
"LOITER",
"mode"
] | python | train | 50.375 |
Vital-Fernandez/dazer | bin/lib/Plotting_Libraries/dazer_plotter.py | https://github.com/Vital-Fernandez/dazer/blob/3c9ae8ae6d40ea33f22cc20dc11365d6d6e65244/bin/lib/Plotting_Libraries/dazer_plotter.py#L42-L163 | def define_format(self, plotStyle, plotSize):
#Default sizes for computer
sizing_dict = {}
sizing_dict['figure.figsize'] = (14, 8)
sizing_dict['legend.fontsize'] = 15
sizing_dict['axes.labelsize'] = 20
sizing_dict['axes.titlesize'] = 24
sizing_dict['xtick.labelsi... | [
"def",
"define_format",
"(",
"self",
",",
"plotStyle",
",",
"plotSize",
")",
":",
"#Default sizes for computer",
"sizing_dict",
"=",
"{",
"}",
"sizing_dict",
"[",
"'figure.figsize'",
"]",
"=",
"(",
"14",
",",
"8",
")",
"sizing_dict",
"[",
"'legend.fontsize'",
... | Seaborn color blind
#0072B2 dark blue
#009E73 green
#D55E00 orangish
#CC79A7 pink
#F0E442 yellow
#56B4E9 cyan
#bcbd22 olive #adicional
#7f7f7f grey
#FFB5B8 skin | [
"Seaborn",
"color",
"blind",
"#0072B2",
"dark",
"blue",
"#009E73",
"green",
"#D55E00",
"orangish",
"#CC79A7",
"pink",
"#F0E442",
"yellow",
"#56B4E9",
"cyan",
"#bcbd22",
"olive",
"#adicional",
"#7f7f7f",
"grey",
"#FFB5B8",
"skin"
] | python | train | 27.540984 |
ejhigson/nestcheck | nestcheck/estimators.py | https://github.com/ejhigson/nestcheck/blob/29151c314deb89746fd674f27f6ce54b77603189/nestcheck/estimators.py#L78-L98 | def evidence(ns_run, logw=None, simulate=False):
r"""Bayesian evidence :math:`\log \mathcal{Z}`.
Parameters
----------
ns_run: dict
Nested sampling run dict (see the data_processing module
docstring for more details).
logw: None or 1d numpy array, optional
Log weights of sam... | [
"def",
"evidence",
"(",
"ns_run",
",",
"logw",
"=",
"None",
",",
"simulate",
"=",
"False",
")",
":",
"if",
"logw",
"is",
"None",
":",
"logw",
"=",
"nestcheck",
".",
"ns_run_utils",
".",
"get_logw",
"(",
"ns_run",
",",
"simulate",
"=",
"simulate",
")",
... | r"""Bayesian evidence :math:`\log \mathcal{Z}`.
Parameters
----------
ns_run: dict
Nested sampling run dict (see the data_processing module
docstring for more details).
logw: None or 1d numpy array, optional
Log weights of samples.
simulate: bool, optional
Passed to ... | [
"r",
"Bayesian",
"evidence",
":",
"math",
":",
"\\",
"log",
"\\",
"mathcal",
"{",
"Z",
"}",
"."
] | python | train | 28.619048 |
Chilipp/psyplot | psyplot/config/rcsetup.py | https://github.com/Chilipp/psyplot/blob/75a0a15a9a1dd018e79d2df270d56c4bf5f311d5/psyplot/config/rcsetup.py#L761-L854 | def load_plugins(self, raise_error=False):
"""
Load the plotters and defaultParams from the plugins
This method loads the `plotters` attribute and `defaultParams`
attribute from the plugins that use the entry point specified by
`group`. Entry points must be objects (or modules) ... | [
"def",
"load_plugins",
"(",
"self",
",",
"raise_error",
"=",
"False",
")",
":",
"pm_env",
"=",
"os",
".",
"getenv",
"(",
"'PSYPLOT_PLOTMETHODS'",
",",
"''",
")",
".",
"split",
"(",
"'::'",
")",
"include_pms",
"=",
"[",
"s",
"[",
"4",
":",
"]",
"for",... | Load the plotters and defaultParams from the plugins
This method loads the `plotters` attribute and `defaultParams`
attribute from the plugins that use the entry point specified by
`group`. Entry points must be objects (or modules) that have a
`defaultParams` and a `plotters` attribute.... | [
"Load",
"the",
"plotters",
"and",
"defaultParams",
"from",
"the",
"plugins"
] | python | train | 42.776596 |
Parsl/parsl | parsl/app/app.py | https://github.com/Parsl/parsl/blob/d7afb3bc37f50dcf224ae78637944172edb35dac/parsl/app/app.py#L78-L116 | def App(apptype, data_flow_kernel=None, walltime=60, cache=False, executors='all'):
"""The App decorator function.
Args:
- apptype (string) : Apptype can be bash|python
Kwargs:
- data_flow_kernel (DataFlowKernel): The :class:`~parsl.dataflow.dflow.DataFlowKernel` responsible for
... | [
"def",
"App",
"(",
"apptype",
",",
"data_flow_kernel",
"=",
"None",
",",
"walltime",
"=",
"60",
",",
"cache",
"=",
"False",
",",
"executors",
"=",
"'all'",
")",
":",
"from",
"parsl",
".",
"app",
".",
"python",
"import",
"PythonApp",
"from",
"parsl",
".... | The App decorator function.
Args:
- apptype (string) : Apptype can be bash|python
Kwargs:
- data_flow_kernel (DataFlowKernel): The :class:`~parsl.dataflow.dflow.DataFlowKernel` responsible for
managing this app. This can be omitted only
after calling :meth:`parsl.dataflow.d... | [
"The",
"App",
"decorator",
"function",
"."
] | python | valid | 38.153846 |
brocade/pynos | pynos/versions/base/yang/brocade_ras.py | https://github.com/brocade/pynos/blob/bd8a34e98f322de3fc06750827d8bbc3a0c00380/pynos/versions/base/yang/brocade_ras.py#L465-L474 | def support_autoupload_enable(self, **kwargs):
"""Auto Generated Code
"""
config = ET.Element("config")
support = ET.SubElement(config, "support", xmlns="urn:brocade.com:mgmt:brocade-ras")
autoupload = ET.SubElement(support, "autoupload")
enable = ET.SubElement(autoupload... | [
"def",
"support_autoupload_enable",
"(",
"self",
",",
"*",
"*",
"kwargs",
")",
":",
"config",
"=",
"ET",
".",
"Element",
"(",
"\"config\"",
")",
"support",
"=",
"ET",
".",
"SubElement",
"(",
"config",
",",
"\"support\"",
",",
"xmlns",
"=",
"\"urn:brocade.c... | Auto Generated Code | [
"Auto",
"Generated",
"Code"
] | python | train | 41.3 |
dnanexus/dx-toolkit | src/python/dxpy/api.py | https://github.com/dnanexus/dx-toolkit/blob/74befb53ad90fcf902d8983ae6d74580f402d619/src/python/dxpy/api.py#L1219-L1225 | def system_find_apps(input_params={}, always_retry=True, **kwargs):
"""
Invokes the /system/findApps API method.
For more info, see: https://wiki.dnanexus.com/API-Specification-v1.0.0/Search#API-method%3A-%2Fsystem%2FfindApps
"""
return DXHTTPRequest('/system/findApps', input_params, always_retry=a... | [
"def",
"system_find_apps",
"(",
"input_params",
"=",
"{",
"}",
",",
"always_retry",
"=",
"True",
",",
"*",
"*",
"kwargs",
")",
":",
"return",
"DXHTTPRequest",
"(",
"'/system/findApps'",
",",
"input_params",
",",
"always_retry",
"=",
"always_retry",
",",
"*",
... | Invokes the /system/findApps API method.
For more info, see: https://wiki.dnanexus.com/API-Specification-v1.0.0/Search#API-method%3A-%2Fsystem%2FfindApps | [
"Invokes",
"the",
"/",
"system",
"/",
"findApps",
"API",
"method",
"."
] | python | train | 48 |
MacHu-GWU/uszipcode-project | uszipcode/pkg/sqlalchemy_mate/orm/extended_declarative_base.py | https://github.com/MacHu-GWU/uszipcode-project/blob/96282b779a3efb422802de83c48ca284598ba952/uszipcode/pkg/sqlalchemy_mate/orm/extended_declarative_base.py#L107-L114 | def items(self):
"""
return list of pair of name and value of all declared columns.
"""
return [
(c.name, getattr(self, c.name, None))
for c in self.__table__._columns
] | [
"def",
"items",
"(",
"self",
")",
":",
"return",
"[",
"(",
"c",
".",
"name",
",",
"getattr",
"(",
"self",
",",
"c",
".",
"name",
",",
"None",
")",
")",
"for",
"c",
"in",
"self",
".",
"__table__",
".",
"_columns",
"]"
] | return list of pair of name and value of all declared columns. | [
"return",
"list",
"of",
"pair",
"of",
"name",
"and",
"value",
"of",
"all",
"declared",
"columns",
"."
] | python | train | 28.25 |
damnit/pymite | pymite/adapters.py | https://github.com/damnit/pymite/blob/1e9b9bf6aef790af2d8781f9f77c098c54ca0342/pymite/adapters.py#L261-L265 | def stop(self, id):
""" stop the tracker. """
path = partial(_path, self.adapter)
path = path(id)
return self._delete(path) | [
"def",
"stop",
"(",
"self",
",",
"id",
")",
":",
"path",
"=",
"partial",
"(",
"_path",
",",
"self",
".",
"adapter",
")",
"path",
"=",
"path",
"(",
"id",
")",
"return",
"self",
".",
"_delete",
"(",
"path",
")"
] | stop the tracker. | [
"stop",
"the",
"tracker",
"."
] | python | train | 30.2 |
YosaiProject/yosai | yosai/core/mgt/mgt.py | https://github.com/YosaiProject/yosai/blob/7f96aa6b837ceae9bf3d7387cd7e35f5ab032575/yosai/core/mgt/mgt.py#L514-L582 | def create_subject(self,
authc_token=None,
account_id=None,
existing_subject=None,
subject_context=None):
"""
Creates a ``Subject`` instance for the user represented by the given method
arguments.
... | [
"def",
"create_subject",
"(",
"self",
",",
"authc_token",
"=",
"None",
",",
"account_id",
"=",
"None",
",",
"existing_subject",
"=",
"None",
",",
"subject_context",
"=",
"None",
")",
":",
"if",
"subject_context",
"is",
"None",
":",
"# this that means a successfu... | Creates a ``Subject`` instance for the user represented by the given method
arguments.
It is an overloaded method, due to porting java to python, and is
consequently highly likely to be refactored.
It gets called in one of two ways:
1) when creating an anonymous subject, passin... | [
"Creates",
"a",
"Subject",
"instance",
"for",
"the",
"user",
"represented",
"by",
"the",
"given",
"method",
"arguments",
"."
] | python | train | 41.898551 |
ella/ella | ella/photos/models.py | https://github.com/ella/ella/blob/4a1414991f649dc21c4b777dc6b41a922a13faa7/ella/photos/models.py#L427-L432 | def file(self):
""" Method returns formated photo path - derived from format.id and source Photo filename """
if photos_settings.FORMATED_PHOTO_FILENAME is not None:
return photos_settings.FORMATED_PHOTO_FILENAME(self)
source_file = path.split(self.photo.image.name)
return pa... | [
"def",
"file",
"(",
"self",
")",
":",
"if",
"photos_settings",
".",
"FORMATED_PHOTO_FILENAME",
"is",
"not",
"None",
":",
"return",
"photos_settings",
".",
"FORMATED_PHOTO_FILENAME",
"(",
"self",
")",
"source_file",
"=",
"path",
".",
"split",
"(",
"self",
".",
... | Method returns formated photo path - derived from format.id and source Photo filename | [
"Method",
"returns",
"formated",
"photo",
"path",
"-",
"derived",
"from",
"format",
".",
"id",
"and",
"source",
"Photo",
"filename"
] | python | train | 63.666667 |
ellmetha/django-machina | machina/apps/forum_conversation/views.py | https://github.com/ellmetha/django-machina/blob/89ac083c1eaf1cfdeae6686ee094cc86362e8c69/machina/apps/forum_conversation/views.py#L493-L510 | def form_valid(self, post_form, attachment_formset, poll_option_formset, **kwargs):
""" Processes valid forms. """
save_poll_option_formset = poll_option_formset is not None \
and not self.preview
valid = super().form_valid(
post_form, attachment_formset, poll_option_for... | [
"def",
"form_valid",
"(",
"self",
",",
"post_form",
",",
"attachment_formset",
",",
"poll_option_formset",
",",
"*",
"*",
"kwargs",
")",
":",
"save_poll_option_formset",
"=",
"poll_option_formset",
"is",
"not",
"None",
"and",
"not",
"self",
".",
"preview",
"vali... | Processes valid forms. | [
"Processes",
"valid",
"forms",
"."
] | python | train | 47.222222 |
calocan/rescape-python-helpers | rescape_python_helpers/functional/ramda.py | https://github.com/calocan/rescape-python-helpers/blob/91a1724f062ee40a25aa60fc96b2d7acadd99618/rescape_python_helpers/functional/ramda.py#L306-L313 | def map_with_obj_deep(f, dct):
"""
Implementation of map that recurses. This tests the same keys at every level of dict and in lists
:param f: 2-ary function expecting a key and value and returns a modified value
:param dct: Dict for deep processing
:return: Modified dct with matching props mapped
... | [
"def",
"map_with_obj_deep",
"(",
"f",
",",
"dct",
")",
":",
"return",
"_map_deep",
"(",
"lambda",
"k",
",",
"v",
":",
"[",
"k",
",",
"f",
"(",
"k",
",",
"v",
")",
"]",
",",
"dct",
")"
] | Implementation of map that recurses. This tests the same keys at every level of dict and in lists
:param f: 2-ary function expecting a key and value and returns a modified value
:param dct: Dict for deep processing
:return: Modified dct with matching props mapped | [
"Implementation",
"of",
"map",
"that",
"recurses",
".",
"This",
"tests",
"the",
"same",
"keys",
"at",
"every",
"level",
"of",
"dict",
"and",
"in",
"lists",
":",
"param",
"f",
":",
"2",
"-",
"ary",
"function",
"expecting",
"a",
"key",
"and",
"value",
"a... | python | train | 46.5 |
apache/incubator-heron | heron/statemgrs/src/python/zkstatemanager.py | https://github.com/apache/incubator-heron/blob/ad10325a0febe89ad337e561ebcbe37ec5d9a5ac/heron/statemgrs/src/python/zkstatemanager.py#L426-L450 | def create_execution_state(self, topologyName, executionState):
""" create execution state """
if not executionState or not executionState.IsInitialized():
raise_(StateException("Execution State protobuf not init properly",
StateException.EX_TYPE_PROTOBUF_ERROR), sys.exc_info()... | [
"def",
"create_execution_state",
"(",
"self",
",",
"topologyName",
",",
"executionState",
")",
":",
"if",
"not",
"executionState",
"or",
"not",
"executionState",
".",
"IsInitialized",
"(",
")",
":",
"raise_",
"(",
"StateException",
"(",
"\"Execution State protobuf n... | create execution state | [
"create",
"execution",
"state"
] | python | valid | 49.72 |
AtomHash/evernode | evernode/models/session_model.py | https://github.com/AtomHash/evernode/blob/b2fb91555fb937a3f3eba41db56dee26f9b034be/evernode/models/session_model.py#L40-L43 | def count(cls, user_id):
""" Count sessions with user_id """
return cls.query.with_entities(
cls.user_id).filter_by(user_id=user_id).count() | [
"def",
"count",
"(",
"cls",
",",
"user_id",
")",
":",
"return",
"cls",
".",
"query",
".",
"with_entities",
"(",
"cls",
".",
"user_id",
")",
".",
"filter_by",
"(",
"user_id",
"=",
"user_id",
")",
".",
"count",
"(",
")"
] | Count sessions with user_id | [
"Count",
"sessions",
"with",
"user_id"
] | python | train | 42 |
chrisjrn/registrasion | registrasion/views.py | https://github.com/chrisjrn/registrasion/blob/461d5846c6f9f3b7099322a94f5d9911564448e4/registrasion/views.py#L1095-L1128 | def badges(request):
''' Either displays a form containing a list of users with badges to
render, or returns a .zip file containing their badges. '''
category = request.GET.getlist("category", [])
product = request.GET.getlist("product", [])
status = request.GET.get("status")
form = forms.Invo... | [
"def",
"badges",
"(",
"request",
")",
":",
"category",
"=",
"request",
".",
"GET",
".",
"getlist",
"(",
"\"category\"",
",",
"[",
"]",
")",
"product",
"=",
"request",
".",
"GET",
".",
"getlist",
"(",
"\"product\"",
",",
"[",
"]",
")",
"status",
"=",
... | Either displays a form containing a list of users with badges to
render, or returns a .zip file containing their badges. | [
"Either",
"displays",
"a",
"form",
"containing",
"a",
"list",
"of",
"users",
"with",
"badges",
"to",
"render",
"or",
"returns",
"a",
".",
"zip",
"file",
"containing",
"their",
"badges",
"."
] | python | test | 29.029412 |
AltSchool/dynamic-rest | dynamic_rest/serializers.py | https://github.com/AltSchool/dynamic-rest/blob/5b0338c3dd8bc638d60c3bb92645857c5b89c920/dynamic_rest/serializers.py#L710-L727 | def save(self, *args, **kwargs):
"""Serializer save that address prefetch issues."""
update = getattr(self, 'instance', None) is not None
instance = super(
WithDynamicSerializerMixin,
self
).save(
*args,
**kwargs
)
view = se... | [
"def",
"save",
"(",
"self",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"update",
"=",
"getattr",
"(",
"self",
",",
"'instance'",
",",
"None",
")",
"is",
"not",
"None",
"instance",
"=",
"super",
"(",
"WithDynamicSerializerMixin",
",",
"self",
... | Serializer save that address prefetch issues. | [
"Serializer",
"save",
"that",
"address",
"prefetch",
"issues",
"."
] | python | train | 36 |
bmweiner/skillful | skillful/interface.py | https://github.com/bmweiner/skillful/blob/8646f54faf62cb63f165f7699b8ace5b4a08233c/skillful/interface.py#L45-L80 | def to_dict(self, drop_null=True, camel=False):
"""Serialize self as dict.
Args:
drop_null: bool, default True. Remove 'empty' attributes.
camel: bool, default True. Convert keys to camelCase.
Return:
dict: object params.
"""
#return _to_dict... | [
"def",
"to_dict",
"(",
"self",
",",
"drop_null",
"=",
"True",
",",
"camel",
"=",
"False",
")",
":",
"#return _to_dict(self, drop_null, camel)",
"def",
"to_dict",
"(",
"obj",
",",
"drop_null",
",",
"camel",
")",
":",
"\"\"\"Recursively constructs the dict.\"\"\"",
... | Serialize self as dict.
Args:
drop_null: bool, default True. Remove 'empty' attributes.
camel: bool, default True. Convert keys to camelCase.
Return:
dict: object params. | [
"Serialize",
"self",
"as",
"dict",
"."
] | python | train | 41.722222 |
manns/pyspread | pyspread/src/model/model.py | https://github.com/manns/pyspread/blob/0e2fd44c2e0f06605efc3058c20a43a8c1f9e7e0/pyspread/src/model/model.py#L720-L752 | def cell_array_generator(self, key):
"""Generator traversing cells specified in key
Parameters
----------
key: Iterable of Integer or slice
\tThe key specifies the cell keys of the generator
"""
for i, key_ele in enumerate(key):
# Get first element... | [
"def",
"cell_array_generator",
"(",
"self",
",",
"key",
")",
":",
"for",
"i",
",",
"key_ele",
"in",
"enumerate",
"(",
"key",
")",
":",
"# Get first element of key that is a slice",
"if",
"type",
"(",
"key_ele",
")",
"is",
"SliceType",
":",
"slc_keys",
"=",
"... | Generator traversing cells specified in key
Parameters
----------
key: Iterable of Integer or slice
\tThe key specifies the cell keys of the generator | [
"Generator",
"traversing",
"cells",
"specified",
"in",
"key"
] | python | train | 30 |
rameshg87/pyremotevbox | pyremotevbox/ZSI/schema.py | https://github.com/rameshg87/pyremotevbox/blob/123dffff27da57c8faa3ac1dd4c68b1cf4558b1a/pyremotevbox/ZSI/schema.py#L387-L397 | def RegisterAnyElement(cls):
'''If find registered TypeCode instance, add Wrapper class
to TypeCode class serialmap and Re-RegisterType. Provides
Any serialzation of any instances of the Wrapper.
'''
for k,v in cls.types_dict.items():
what = Any.serialmap.get(k)
... | [
"def",
"RegisterAnyElement",
"(",
"cls",
")",
":",
"for",
"k",
",",
"v",
"in",
"cls",
".",
"types_dict",
".",
"items",
"(",
")",
":",
"what",
"=",
"Any",
".",
"serialmap",
".",
"get",
"(",
"k",
")",
"if",
"what",
"is",
"None",
":",
"continue",
"i... | If find registered TypeCode instance, add Wrapper class
to TypeCode class serialmap and Re-RegisterType. Provides
Any serialzation of any instances of the Wrapper. | [
"If",
"find",
"registered",
"TypeCode",
"instance",
"add",
"Wrapper",
"class",
"to",
"TypeCode",
"class",
"serialmap",
"and",
"Re",
"-",
"RegisterType",
".",
"Provides",
"Any",
"serialzation",
"of",
"any",
"instances",
"of",
"the",
"Wrapper",
"."
] | python | train | 47 |
MrYsLab/pymata-aio | pymata_aio/pymata_iot.py | https://github.com/MrYsLab/pymata-aio/blob/015081a4628b9d47dfe3f8d6c698ff903f107810/pymata_aio/pymata_iot.py#L557-L566 | async def stepper_step(self, command):
"""
This method activates a stepper motor motion.
This is a FirmataPlus feature.
:param command: {"method": "stepper_step", "params": [SPEED, NUMBER_OF_STEPS]}
:returns:No message returned.
"""
speed = int(command[0])
... | [
"async",
"def",
"stepper_step",
"(",
"self",
",",
"command",
")",
":",
"speed",
"=",
"int",
"(",
"command",
"[",
"0",
"]",
")",
"num_steps",
"=",
"int",
"(",
"command",
"[",
"1",
"]",
")",
"await",
"self",
".",
"core",
".",
"stepper_step",
"(",
"sp... | This method activates a stepper motor motion.
This is a FirmataPlus feature.
:param command: {"method": "stepper_step", "params": [SPEED, NUMBER_OF_STEPS]}
:returns:No message returned. | [
"This",
"method",
"activates",
"a",
"stepper",
"motor",
"motion",
".",
"This",
"is",
"a",
"FirmataPlus",
"feature",
".",
":",
"param",
"command",
":",
"{",
"method",
":",
"stepper_step",
"params",
":",
"[",
"SPEED",
"NUMBER_OF_STEPS",
"]",
"}",
":",
"retur... | python | train | 39.4 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.