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 |
|---|---|---|---|---|---|---|---|---|---|
StackStorm/pybind | pybind/slxos/v17r_1_01a/brocade_mpls_rpc/__init__.py | https://github.com/StackStorm/pybind/blob/44c467e71b2b425be63867aba6e6fa28b2cfe7fb/pybind/slxos/v17r_1_01a/brocade_mpls_rpc/__init__.py#L2103-L2124 | def _set_show_mpls_ldp(self, v, load=False):
"""
Setter method for show_mpls_ldp, mapped from YANG variable /brocade_mpls_rpc/show_mpls_ldp (rpc)
If this variable is read-only (config: false) in the
source YANG file, then _set_show_mpls_ldp is considered as a private
method. Backends looking to popu... | [
"def",
"_set_show_mpls_ldp",
"(",
"self",
",",
"v",
",",
"load",
"=",
"False",
")",
":",
"if",
"hasattr",
"(",
"v",
",",
"\"_utype\"",
")",
":",
"v",
"=",
"v",
".",
"_utype",
"(",
"v",
")",
"try",
":",
"t",
"=",
"YANGDynClass",
"(",
"v",
",",
"... | Setter method for show_mpls_ldp, mapped from YANG variable /brocade_mpls_rpc/show_mpls_ldp (rpc)
If this variable is read-only (config: false) in the
source YANG file, then _set_show_mpls_ldp is considered as a private
method. Backends looking to populate this variable should
do so via calling thisObj._... | [
"Setter",
"method",
"for",
"show_mpls_ldp",
"mapped",
"from",
"YANG",
"variable",
"/",
"brocade_mpls_rpc",
"/",
"show_mpls_ldp",
"(",
"rpc",
")",
"If",
"this",
"variable",
"is",
"read",
"-",
"only",
"(",
"config",
":",
"false",
")",
"in",
"the",
"source",
... | python | train | 72.181818 |
Cadair/jupyter_environment_kernels | environment_kernels/activate_helper.py | https://github.com/Cadair/jupyter_environment_kernels/blob/3da304550b511bda7d5d39280379b5ca39bb31bc/environment_kernels/activate_helper.py#L158-L166 | def escape_windows_cmd_string(s):
"""Returns a string that is usable by the Windows cmd.exe.
The escaping is based on details here and emperical testing:
http://www.robvanderwoude.com/escapechars.php
"""
for c in '()%!^<>&|"':
s = s.replace(c, '^' + c)
s = s.replace('/?', '/.')
retur... | [
"def",
"escape_windows_cmd_string",
"(",
"s",
")",
":",
"for",
"c",
"in",
"'()%!^<>&|\"'",
":",
"s",
"=",
"s",
".",
"replace",
"(",
"c",
",",
"'^'",
"+",
"c",
")",
"s",
"=",
"s",
".",
"replace",
"(",
"'/?'",
",",
"'/.'",
")",
"return",
"s"
] | Returns a string that is usable by the Windows cmd.exe.
The escaping is based on details here and emperical testing:
http://www.robvanderwoude.com/escapechars.php | [
"Returns",
"a",
"string",
"that",
"is",
"usable",
"by",
"the",
"Windows",
"cmd",
".",
"exe",
".",
"The",
"escaping",
"is",
"based",
"on",
"details",
"here",
"and",
"emperical",
"testing",
":",
"http",
":",
"//",
"www",
".",
"robvanderwoude",
".",
"com",
... | python | train | 35 |
scraperwiki/scraperwiki-python | scraperwiki/sql.py | https://github.com/scraperwiki/scraperwiki-python/blob/75f77e27071ba667df93e740b61bbb0383ba0843/scraperwiki/sql.py#L238-L268 | def save_var(name, value):
"""
Save a variable to the table specified by _State.vars_table_name. Key is
the name of the variable, and value is the value.
"""
connection = _State.connection()
_State.reflect_metadata()
vars_table = sqlalchemy.Table(
_State.vars_table_name, _State.meta... | [
"def",
"save_var",
"(",
"name",
",",
"value",
")",
":",
"connection",
"=",
"_State",
".",
"connection",
"(",
")",
"_State",
".",
"reflect_metadata",
"(",
")",
"vars_table",
"=",
"sqlalchemy",
".",
"Table",
"(",
"_State",
".",
"vars_table_name",
",",
"_Stat... | Save a variable to the table specified by _State.vars_table_name. Key is
the name of the variable, and value is the value. | [
"Save",
"a",
"variable",
"to",
"the",
"table",
"specified",
"by",
"_State",
".",
"vars_table_name",
".",
"Key",
"is",
"the",
"name",
"of",
"the",
"variable",
"and",
"value",
"is",
"the",
"value",
"."
] | python | train | 33 |
adafruit/Adafruit_Python_LED_Backpack | Adafruit_LED_Backpack/BicolorMatrix8x8.py | https://github.com/adafruit/Adafruit_Python_LED_Backpack/blob/7356b4dd8b4bb162d60987878c2cb752fdd017d5/Adafruit_LED_Backpack/BicolorMatrix8x8.py#L41-L51 | def set_pixel(self, x, y, value):
"""Set pixel at position x, y to the given value. X and Y should be values
of 0 to 8. Value should be OFF, GREEN, RED, or YELLOW.
"""
if x < 0 or x > 7 or y < 0 or y > 7:
# Ignore out of bounds pixels.
return
# Set green... | [
"def",
"set_pixel",
"(",
"self",
",",
"x",
",",
"y",
",",
"value",
")",
":",
"if",
"x",
"<",
"0",
"or",
"x",
">",
"7",
"or",
"y",
"<",
"0",
"or",
"y",
">",
"7",
":",
"# Ignore out of bounds pixels.",
"return",
"# Set green LED based on 1st bit in value."... | Set pixel at position x, y to the given value. X and Y should be values
of 0 to 8. Value should be OFF, GREEN, RED, or YELLOW. | [
"Set",
"pixel",
"at",
"position",
"x",
"y",
"to",
"the",
"given",
"value",
".",
"X",
"and",
"Y",
"should",
"be",
"values",
"of",
"0",
"to",
"8",
".",
"Value",
"should",
"be",
"OFF",
"GREEN",
"RED",
"or",
"YELLOW",
"."
] | python | train | 47.272727 |
gunthercox/ChatterBot | chatterbot/parsing.py | https://github.com/gunthercox/ChatterBot/blob/1a03dcb45cba7bdc24d3db5e750582e0cb1518e2/chatterbot/parsing.py#L506-L517 | def convert_string_to_number(value):
"""
Convert strings to numbers
"""
if value is None:
return 1
if isinstance(value, int):
return value
if value.isdigit():
return int(value)
num_list = map(lambda s: NUMBERS[s], re.findall(numbers + '+', value.lower()))
return s... | [
"def",
"convert_string_to_number",
"(",
"value",
")",
":",
"if",
"value",
"is",
"None",
":",
"return",
"1",
"if",
"isinstance",
"(",
"value",
",",
"int",
")",
":",
"return",
"value",
"if",
"value",
".",
"isdigit",
"(",
")",
":",
"return",
"int",
"(",
... | Convert strings to numbers | [
"Convert",
"strings",
"to",
"numbers"
] | python | train | 26.75 |
mitsei/dlkit | dlkit/records/adaptive/magic_parts/assessment_part_records.py | https://github.com/mitsei/dlkit/blob/445f968a175d61c8d92c0f617a3c17dc1dc7c584/dlkit/records/adaptive/magic_parts/assessment_part_records.py#L728-L732 | def get_allow_repeat_items_metadata(self):
"""get the metadata for allow repeat items"""
metadata = dict(self._allow_repeat_items_metadata)
metadata.update({'existing_id_values': self.my_osid_object_form._my_map['allowRepeatItems']})
return Metadata(**metadata) | [
"def",
"get_allow_repeat_items_metadata",
"(",
"self",
")",
":",
"metadata",
"=",
"dict",
"(",
"self",
".",
"_allow_repeat_items_metadata",
")",
"metadata",
".",
"update",
"(",
"{",
"'existing_id_values'",
":",
"self",
".",
"my_osid_object_form",
".",
"_my_map",
"... | get the metadata for allow repeat items | [
"get",
"the",
"metadata",
"for",
"allow",
"repeat",
"items"
] | python | train | 57.8 |
saltstack/salt | salt/modules/boto_dynamodb.py | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/boto_dynamodb.py#L257-L267 | def describe(table_name, region=None, key=None, keyid=None, profile=None):
'''
Describe a DynamoDB table.
CLI example::
salt myminion boto_dynamodb.describe table_name region=us-east-1
'''
conn = _get_conn(region=region, key=key, keyid=keyid, profile=profile)
table = Table(table_name, ... | [
"def",
"describe",
"(",
"table_name",
",",
"region",
"=",
"None",
",",
"key",
"=",
"None",
",",
"keyid",
"=",
"None",
",",
"profile",
"=",
"None",
")",
":",
"conn",
"=",
"_get_conn",
"(",
"region",
"=",
"region",
",",
"key",
"=",
"key",
",",
"keyid... | Describe a DynamoDB table.
CLI example::
salt myminion boto_dynamodb.describe table_name region=us-east-1 | [
"Describe",
"a",
"DynamoDB",
"table",
"."
] | python | train | 32.181818 |
opengisch/pum | pum/core/upgrader.py | https://github.com/opengisch/pum/blob/eaf6af92d723ace60b9e982d7f69b98e00606959/pum/core/upgrader.py#L505-L527 | def is_valid_delta_name(file):
"""Return if a file has a valid name
A delta file name can be:
- pre-all.py
- pre-all.sql
- delta_x.x.x_ddmmyyyy.pre.py
- delta_x.x.x_ddmmyyyy.pre.sql
- delta_x.x.x_ddmmyyyy.py
- delta_x.x.x_ddmmyyyy.sql
- delta_x.x.... | [
"def",
"is_valid_delta_name",
"(",
"file",
")",
":",
"filename",
"=",
"basename",
"(",
"file",
")",
"pattern",
"=",
"re",
".",
"compile",
"(",
"Delta",
".",
"FILENAME_PATTERN",
")",
"if",
"re",
".",
"match",
"(",
"pattern",
",",
"filename",
")",
":",
"... | Return if a file has a valid name
A delta file name can be:
- pre-all.py
- pre-all.sql
- delta_x.x.x_ddmmyyyy.pre.py
- delta_x.x.x_ddmmyyyy.pre.sql
- delta_x.x.x_ddmmyyyy.py
- delta_x.x.x_ddmmyyyy.sql
- delta_x.x.x_ddmmyyyy.post.py
- delta_x.x.x_d... | [
"Return",
"if",
"a",
"file",
"has",
"a",
"valid",
"name"
] | python | train | 31.565217 |
ipfs/py-ipfs-api | ipfsapi/multipart.py | https://github.com/ipfs/py-ipfs-api/blob/7574dad04877b45dbe4ad321dcfa9e880eb2d90c/ipfsapi/multipart.py#L578-L604 | def stream_directory(directory,
recursive=False,
patterns='**',
chunk_size=default_chunk_size):
"""Gets a buffered generator for streaming directories.
Returns a buffered generator which encodes a directory as
:mimetype:`multipart/form-data` wi... | [
"def",
"stream_directory",
"(",
"directory",
",",
"recursive",
"=",
"False",
",",
"patterns",
"=",
"'**'",
",",
"chunk_size",
"=",
"default_chunk_size",
")",
":",
"stream",
"=",
"DirectoryStream",
"(",
"directory",
",",
"recursive",
"=",
"recursive",
",",
"pat... | Gets a buffered generator for streaming directories.
Returns a buffered generator which encodes a directory as
:mimetype:`multipart/form-data` with the corresponding headers.
Parameters
----------
directory : str
The filepath of the directory to stream
recursive : bool
Stream a... | [
"Gets",
"a",
"buffered",
"generator",
"for",
"streaming",
"directories",
"."
] | python | train | 36.111111 |
havardgulldahl/jottalib | src/jottalib/jottacloud.py | https://github.com/havardgulldahl/jottalib/blob/4d015e4309b1d9055e561ec757363fb2632b4eb7/src/jottalib/jottacloud.py#L72-L81 | def filelist(jottapath, JFS):
"""Get a set() of files from a jottapath (a folder)"""
log.debug("filelist %r", jottapath)
try:
jf = JFS.getObject(jottapath)
except JFSNotFoundError:
return set() # folder does not exist, so pretend it is an empty folder
if not isinstance(jf, JFSFolder)... | [
"def",
"filelist",
"(",
"jottapath",
",",
"JFS",
")",
":",
"log",
".",
"debug",
"(",
"\"filelist %r\"",
",",
"jottapath",
")",
"try",
":",
"jf",
"=",
"JFS",
".",
"getObject",
"(",
"jottapath",
")",
"except",
"JFSNotFoundError",
":",
"return",
"set",
"(",... | Get a set() of files from a jottapath (a folder) | [
"Get",
"a",
"set",
"()",
"of",
"files",
"from",
"a",
"jottapath",
"(",
"a",
"folder",
")"
] | python | train | 40 |
disqus/django-mailviews | mailviews/messages.py | https://github.com/disqus/django-mailviews/blob/9993d5e911d545b3bc038433986c5f6812e7e965/mailviews/messages.py#L223-L245 | def render_to_message(self, extra_context=None, *args, **kwargs):
"""
Renders and returns an unsent message with the given context.
Any extra keyword arguments passed will be passed through as keyword
arguments to the message constructor.
:param extra_context: Any additional co... | [
"def",
"render_to_message",
"(",
"self",
",",
"extra_context",
"=",
"None",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"message",
"=",
"super",
"(",
"TemplatedHTMLEmailMessageView",
",",
"self",
")",
".",
"render_to_message",
"(",
"extra_context",
... | Renders and returns an unsent message with the given context.
Any extra keyword arguments passed will be passed through as keyword
arguments to the message constructor.
:param extra_context: Any additional context to use when rendering
templated content.
:type extra_context... | [
"Renders",
"and",
"returns",
"an",
"unsent",
"message",
"with",
"the",
"given",
"context",
"."
] | python | valid | 38.043478 |
KyleJamesWalker/yamlsettings | yamlsettings/helpers.py | https://github.com/KyleJamesWalker/yamlsettings/blob/ddd7df2ca995ddf191b24c4d35e9dd28186e4535/yamlsettings/helpers.py#L28-L35 | def update_from_file(yaml_dict, filepaths):
'''
Override YAML settings with loaded values from filepaths.
- File paths in the list gets the priority by their orders of the list.
'''
# load YAML settings with only fields in yaml_dict
yaml_dict.update(registry.load(filepaths, list(yaml_dict))... | [
"def",
"update_from_file",
"(",
"yaml_dict",
",",
"filepaths",
")",
":",
"# load YAML settings with only fields in yaml_dict",
"yaml_dict",
".",
"update",
"(",
"registry",
".",
"load",
"(",
"filepaths",
",",
"list",
"(",
"yaml_dict",
")",
")",
")"
] | Override YAML settings with loaded values from filepaths.
- File paths in the list gets the priority by their orders of the list. | [
"Override",
"YAML",
"settings",
"with",
"loaded",
"values",
"from",
"filepaths",
"."
] | python | train | 39.25 |
atlassian-api/atlassian-python-api | atlassian/jira.py | https://github.com/atlassian-api/atlassian-python-api/blob/540d269905c3e7547b666fe30c647b2d512cf358/atlassian/jira.py#L78-L87 | def csv(self, jql, limit=1000):
"""
Get issues from jql search result with all related fields
:param jql: JQL query
:param limit: max results in the output file
:return: CSV file
"""
url = 'sr/jira.issueviews:searchrequest-csv-all-fields/temp/SearchRequest.csv?tem... | [
"def",
"csv",
"(",
"self",
",",
"jql",
",",
"limit",
"=",
"1000",
")",
":",
"url",
"=",
"'sr/jira.issueviews:searchrequest-csv-all-fields/temp/SearchRequest.csv?tempMax={limit}&jqlQuery={jql}'",
".",
"format",
"(",
"limit",
"=",
"limit",
",",
"jql",
"=",
"jql",
")",... | Get issues from jql search result with all related fields
:param jql: JQL query
:param limit: max results in the output file
:return: CSV file | [
"Get",
"issues",
"from",
"jql",
"search",
"result",
"with",
"all",
"related",
"fields",
":",
"param",
"jql",
":",
"JQL",
"query",
":",
"param",
"limit",
":",
"max",
"results",
"in",
"the",
"output",
"file",
":",
"return",
":",
"CSV",
"file"
] | python | train | 47.3 |
yaml/pyyaml | lib/yaml/__init__.py | https://github.com/yaml/pyyaml/blob/e471e86bf6dabdad45a1438c20a4a5c033eb9034/lib/yaml/__init__.py#L322-L330 | def add_path_resolver(tag, path, kind=None, Loader=Loader, Dumper=Dumper):
"""
Add a path based resolver for the given tag.
A path is a list of keys that forms a path
to a node in the representation tree.
Keys can be string values, integers, or None.
"""
Loader.add_path_resolver(tag, path, k... | [
"def",
"add_path_resolver",
"(",
"tag",
",",
"path",
",",
"kind",
"=",
"None",
",",
"Loader",
"=",
"Loader",
",",
"Dumper",
"=",
"Dumper",
")",
":",
"Loader",
".",
"add_path_resolver",
"(",
"tag",
",",
"path",
",",
"kind",
")",
"Dumper",
".",
"add_path... | Add a path based resolver for the given tag.
A path is a list of keys that forms a path
to a node in the representation tree.
Keys can be string values, integers, or None. | [
"Add",
"a",
"path",
"based",
"resolver",
"for",
"the",
"given",
"tag",
".",
"A",
"path",
"is",
"a",
"list",
"of",
"keys",
"that",
"forms",
"a",
"path",
"to",
"a",
"node",
"in",
"the",
"representation",
"tree",
".",
"Keys",
"can",
"be",
"string",
"val... | python | train | 40.222222 |
JasonKessler/scattertext | scattertext/diachronic/DiachronicTermMiner.py | https://github.com/JasonKessler/scattertext/blob/cacf1f687d218ee8cae3fc05cc901db824bb1b81/scattertext/diachronic/DiachronicTermMiner.py#L37-L122 | def get_display_dataframe(self):
'''
Gets list of terms to display that have some interesting diachronic variation.
Returns
-------
pd.DataFrame
e.g.,
term variable frequency trending
2 in 200310 1.0 0.000000
19 for 200310 1.0 0.000000
20 ... | [
"def",
"get_display_dataframe",
"(",
"self",
")",
":",
"X",
"=",
"self",
".",
"corpus_",
".",
"get_term_doc_mat",
"(",
")",
"categories",
"=",
"pd",
".",
"Series",
"(",
"self",
".",
"corpus_",
".",
"get_category_ids",
"(",
")",
")",
"cat_ar",
"=",
"np",
... | Gets list of terms to display that have some interesting diachronic variation.
Returns
-------
pd.DataFrame
e.g.,
term variable frequency trending
2 in 200310 1.0 0.000000
19 for 200310 1.0 0.000000
20 to 200311 1.0 0.000000 | [
"Gets",
"list",
"of",
"terms",
"to",
"display",
"that",
"have",
"some",
"interesting",
"diachronic",
"variation",
"."
] | python | train | 40.802326 |
pgmpy/pgmpy | pgmpy/factors/continuous/LinearGaussianCPD.py | https://github.com/pgmpy/pgmpy/blob/9381a66aba3c3871d3ccd00672b148d17d63239e/pgmpy/factors/continuous/LinearGaussianCPD.py#L204-L225 | def copy(self):
"""
Returns a copy of the distribution.
Returns
-------
LinearGaussianCPD: copy of the distribution
Examples
--------
>>> from pgmpy.factors.continuous import LinearGaussianCPD
>>> cpd = LinearGaussianCPD('Y', [0.2, -2, 3, 7], 9.... | [
"def",
"copy",
"(",
"self",
")",
":",
"copy_cpd",
"=",
"LinearGaussianCPD",
"(",
"self",
".",
"variable",
",",
"self",
".",
"beta",
",",
"self",
".",
"variance",
",",
"list",
"(",
"self",
".",
"evidence",
")",
")",
"return",
"copy_cpd"
] | Returns a copy of the distribution.
Returns
-------
LinearGaussianCPD: copy of the distribution
Examples
--------
>>> from pgmpy.factors.continuous import LinearGaussianCPD
>>> cpd = LinearGaussianCPD('Y', [0.2, -2, 3, 7], 9.6, ['X1', 'X2', 'X3'])
>>> c... | [
"Returns",
"a",
"copy",
"of",
"the",
"distribution",
"."
] | python | train | 28.5 |
pydata/xarray | xarray/coding/cftimeindex.py | https://github.com/pydata/xarray/blob/6d93a95d05bdbfc33fff24064f67d29dd891ab58/xarray/coding/cftimeindex.py#L312-L318 | def get_loc(self, key, method=None, tolerance=None):
"""Adapted from pandas.tseries.index.DatetimeIndex.get_loc"""
if isinstance(key, str):
return self._get_string_slice(key)
else:
return pd.Index.get_loc(self, key, method=method,
toler... | [
"def",
"get_loc",
"(",
"self",
",",
"key",
",",
"method",
"=",
"None",
",",
"tolerance",
"=",
"None",
")",
":",
"if",
"isinstance",
"(",
"key",
",",
"str",
")",
":",
"return",
"self",
".",
"_get_string_slice",
"(",
"key",
")",
"else",
":",
"return",
... | Adapted from pandas.tseries.index.DatetimeIndex.get_loc | [
"Adapted",
"from",
"pandas",
".",
"tseries",
".",
"index",
".",
"DatetimeIndex",
".",
"get_loc"
] | python | train | 47 |
ChristianTremblay/BAC0 | BAC0/core/devices/Device.py | https://github.com/ChristianTremblay/BAC0/blob/8d95b065ea068524a08f5b0c34322ebeeba95d06/BAC0/core/devices/Device.py#L484-L527 | def _buildPointList(self):
"""
Upon connection to build the device point list and properties.
"""
try:
self.properties.pss.value = self.properties.network.read(
"{} device {} protocolServicesSupported".format(
self.properties.address... | [
"def",
"_buildPointList",
"(",
"self",
")",
":",
"try",
":",
"self",
".",
"properties",
".",
"pss",
".",
"value",
"=",
"self",
".",
"properties",
".",
"network",
".",
"read",
"(",
"\"{} device {} protocolServicesSupported\"",
".",
"format",
"(",
"self",
".",... | Upon connection to build the device point list and properties. | [
"Upon",
"connection",
"to",
"build",
"the",
"device",
"point",
"list",
"and",
"properties",
"."
] | python | train | 40.386364 |
chovanecm/sacredboard | sacredboard/app/data/pymongo/genericdao.py | https://github.com/chovanecm/sacredboard/blob/47e1c99e3be3c1b099d3772bc077f5666020eb0b/sacredboard/app/data/pymongo/genericdao.py#L76-L87 | def _get_database(self, database_name):
"""
Get PyMongo client pointing to the current database.
:return: MongoDB client of the current database.
:raise DataSourceError
"""
try:
return self._client[database_name]
except InvalidName as ex:
... | [
"def",
"_get_database",
"(",
"self",
",",
"database_name",
")",
":",
"try",
":",
"return",
"self",
".",
"_client",
"[",
"database_name",
"]",
"except",
"InvalidName",
"as",
"ex",
":",
"raise",
"DataSourceError",
"(",
"\"Cannot connect to database %s!\"",
"%",
"s... | Get PyMongo client pointing to the current database.
:return: MongoDB client of the current database.
:raise DataSourceError | [
"Get",
"PyMongo",
"client",
"pointing",
"to",
"the",
"current",
"database",
"."
] | python | train | 35.25 |
chaoss/grimoirelab-sirmordred | sirmordred/task_panels.py | https://github.com/chaoss/grimoirelab-sirmordred/blob/d6ac94d28d707fae23170064d078f1edf937d13e/sirmordred/task_panels.py#L481-L517 | def __upload_title(self, kibiter_major):
"""Upload to Kibiter the title for the dashboard.
The title is shown on top of the dashboard menu, and is Usually
the name of the project being dashboarded.
This is done only for Kibiter 6.x.
:param kibiter_major: major version of kibite... | [
"def",
"__upload_title",
"(",
"self",
",",
"kibiter_major",
")",
":",
"if",
"kibiter_major",
"==",
"\"6\"",
":",
"resource",
"=",
"\".kibana/doc/projectname\"",
"data",
"=",
"{",
"\"projectname\"",
":",
"{",
"\"name\"",
":",
"self",
".",
"project_name",
"}",
"... | Upload to Kibiter the title for the dashboard.
The title is shown on top of the dashboard menu, and is Usually
the name of the project being dashboarded.
This is done only for Kibiter 6.x.
:param kibiter_major: major version of kibiter | [
"Upload",
"to",
"Kibiter",
"the",
"title",
"for",
"the",
"dashboard",
"."
] | python | valid | 42.081081 |
berkerpeksag/astor | astor/source_repr.py | https://github.com/berkerpeksag/astor/blob/d9e893eb49d9eb2e30779680f90cd632c30e0ba1/astor/source_repr.py#L27-L55 | def split_lines(source, maxline=79):
"""Split inputs according to lines.
If a line is short enough, just yield it.
Otherwise, fix it.
"""
result = []
extend = result.extend
append = result.append
line = []
multiline = False
count = 0
find = str.find
for item in sour... | [
"def",
"split_lines",
"(",
"source",
",",
"maxline",
"=",
"79",
")",
":",
"result",
"=",
"[",
"]",
"extend",
"=",
"result",
".",
"extend",
"append",
"=",
"result",
".",
"append",
"line",
"=",
"[",
"]",
"multiline",
"=",
"False",
"count",
"=",
"0",
... | Split inputs according to lines.
If a line is short enough, just yield it.
Otherwise, fix it. | [
"Split",
"inputs",
"according",
"to",
"lines",
".",
"If",
"a",
"line",
"is",
"short",
"enough",
"just",
"yield",
"it",
".",
"Otherwise",
"fix",
"it",
"."
] | python | train | 26.310345 |
google/grr | grr/server/grr_response_server/aff4.py | https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/aff4.py#L243-L264 | def root_urns_for_deletion(self):
"""Roots of the graph of urns marked for deletion."""
roots = set()
for urn in self._urns_for_deletion:
new_root = True
str_urn = utils.SmartUnicode(urn)
fake_roots = []
for root in roots:
str_root = utils.SmartUnicode(root)
if str_... | [
"def",
"root_urns_for_deletion",
"(",
"self",
")",
":",
"roots",
"=",
"set",
"(",
")",
"for",
"urn",
"in",
"self",
".",
"_urns_for_deletion",
":",
"new_root",
"=",
"True",
"str_urn",
"=",
"utils",
".",
"SmartUnicode",
"(",
"urn",
")",
"fake_roots",
"=",
... | Roots of the graph of urns marked for deletion. | [
"Roots",
"of",
"the",
"graph",
"of",
"urns",
"marked",
"for",
"deletion",
"."
] | python | train | 24.454545 |
semiversus/python-broqer | broqer/publisher.py | https://github.com/semiversus/python-broqer/blob/8957110b034f982451392072d9fa16761adc9c9e/broqer/publisher.py#L133-L139 | def wait_for(self, timeout=None):
""" When a timeout should be applied for awaiting use this method.
:param timeout: optional timeout in seconds.
:returns: a future returning the emitted value
"""
from broqer.op import OnEmitFuture # due circular dependency
return self |... | [
"def",
"wait_for",
"(",
"self",
",",
"timeout",
"=",
"None",
")",
":",
"from",
"broqer",
".",
"op",
"import",
"OnEmitFuture",
"# due circular dependency",
"return",
"self",
"|",
"OnEmitFuture",
"(",
"timeout",
"=",
"timeout",
")"
] | When a timeout should be applied for awaiting use this method.
:param timeout: optional timeout in seconds.
:returns: a future returning the emitted value | [
"When",
"a",
"timeout",
"should",
"be",
"applied",
"for",
"awaiting",
"use",
"this",
"method",
".",
":",
"param",
"timeout",
":",
"optional",
"timeout",
"in",
"seconds",
".",
":",
"returns",
":",
"a",
"future",
"returning",
"the",
"emitted",
"value"
] | python | train | 49.142857 |
skioo/django-customer-billing | billing/models.py | https://github.com/skioo/django-customer-billing/blob/6ac1ed9ef9d1d7eee0379de7f0c4b76919ae1f2d/billing/models.py#L133-L140 | def due(self):
"""
The amount due for this invoice. Takes into account all entities in the invoice.
Can be < 0 if the invoice was overpaid.
"""
invoice_charges = Charge.objects.filter(invoice=self)
invoice_transactions = Transaction.successful.filter(invoice=self)
... | [
"def",
"due",
"(",
"self",
")",
":",
"invoice_charges",
"=",
"Charge",
".",
"objects",
".",
"filter",
"(",
"invoice",
"=",
"self",
")",
"invoice_transactions",
"=",
"Transaction",
".",
"successful",
".",
"filter",
"(",
"invoice",
"=",
"self",
")",
"return"... | The amount due for this invoice. Takes into account all entities in the invoice.
Can be < 0 if the invoice was overpaid. | [
"The",
"amount",
"due",
"for",
"this",
"invoice",
".",
"Takes",
"into",
"account",
"all",
"entities",
"in",
"the",
"invoice",
".",
"Can",
"be",
"<",
"0",
"if",
"the",
"invoice",
"was",
"overpaid",
"."
] | python | train | 48.375 |
ValvePython/steam | steam/core/cm.py | https://github.com/ValvePython/steam/blob/2de1364c47598410b572114e6129eab8fff71d5b/steam/core/cm.py#L97-L143 | def connect(self, retry=0, delay=0):
"""Initiate connection to CM. Blocks until connected unless ``retry`` is specified.
:param retry: number of retries before returning. Unlimited when set to ``None``
:type retry: :class:`int`
:param delay: delay in secnds before connection attempt
... | [
"def",
"connect",
"(",
"self",
",",
"retry",
"=",
"0",
",",
"delay",
"=",
"0",
")",
":",
"if",
"self",
".",
"connected",
":",
"self",
".",
"_LOG",
".",
"debug",
"(",
"\"Connect called, but we are connected?\"",
")",
"return",
"if",
"self",
".",
"_connect... | Initiate connection to CM. Blocks until connected unless ``retry`` is specified.
:param retry: number of retries before returning. Unlimited when set to ``None``
:type retry: :class:`int`
:param delay: delay in secnds before connection attempt
:type delay: :class:`int`
:return: ... | [
"Initiate",
"connection",
"to",
"CM",
".",
"Blocks",
"until",
"connected",
"unless",
"retry",
"is",
"specified",
"."
] | python | train | 31.744681 |
mapillary/mapillary_tools | mapillary_tools/exif_read.py | https://github.com/mapillary/mapillary_tools/blob/816785e90c589cae6e8e34a5530ce8417d29591c/mapillary_tools/exif_read.py#L105-L129 | def exif_name(self):
'''
Name of file in the form {lat}_{lon}_{ca}_{datetime}_{filename}_{hash}
'''
mapillary_description = json.loads(self.extract_image_description())
lat = None
lon = None
ca = None
date_time = None
if "MAPLatitude" in mapillar... | [
"def",
"exif_name",
"(",
"self",
")",
":",
"mapillary_description",
"=",
"json",
".",
"loads",
"(",
"self",
".",
"extract_image_description",
"(",
")",
")",
"lat",
"=",
"None",
"lon",
"=",
"None",
"ca",
"=",
"None",
"date_time",
"=",
"None",
"if",
"\"MAP... | Name of file in the form {lat}_{lon}_{ca}_{datetime}_{filename}_{hash} | [
"Name",
"of",
"file",
"in",
"the",
"form",
"{",
"lat",
"}",
"_",
"{",
"lon",
"}",
"_",
"{",
"ca",
"}",
"_",
"{",
"datetime",
"}",
"_",
"{",
"filename",
"}",
"_",
"{",
"hash",
"}"
] | python | train | 41.2 |
aeguana/PyFileMaker | PyFileMaker/FMServer.py | https://github.com/aeguana/PyFileMaker/blob/ef269b52a97e329d91da3c4851ddac800d7fd7e6/PyFileMaker/FMServer.py#L451-L468 | def doDelete(self, WHAT={}):
"""This function will perform the command -delete."""
if hasattr(WHAT, '_modified'):
self._addDBParam('RECORDID', WHAT.RECORDID)
self._addDBParam('MODID', WHAT.MODID)
elif type(WHAT) == dict and WHAT.has_key('RECORDID'):
self._addDBParam('RECORDID', WHAT['RECORDID'])
else:... | [
"def",
"doDelete",
"(",
"self",
",",
"WHAT",
"=",
"{",
"}",
")",
":",
"if",
"hasattr",
"(",
"WHAT",
",",
"'_modified'",
")",
":",
"self",
".",
"_addDBParam",
"(",
"'RECORDID'",
",",
"WHAT",
".",
"RECORDID",
")",
"self",
".",
"_addDBParam",
"(",
"'MOD... | This function will perform the command -delete. | [
"This",
"function",
"will",
"perform",
"the",
"command",
"-",
"delete",
"."
] | python | train | 33.777778 |
phoebe-project/phoebe2 | phoebe/backend/mesh.py | https://github.com/phoebe-project/phoebe2/blob/e64b8be683977064e2d55dd1b3ac400f64c3e379/phoebe/backend/mesh.py#L1576-L1587 | def get_column_flat(self, field, components=None, computed_type='for_observations'):
"""
TODO: add documentation
return a single merged value (hstacked) from all meshes
:parameter str field: name of the mesh columnname
:parameter components:
"""
return self.pack... | [
"def",
"get_column_flat",
"(",
"self",
",",
"field",
",",
"components",
"=",
"None",
",",
"computed_type",
"=",
"'for_observations'",
")",
":",
"return",
"self",
".",
"pack_column_flat",
"(",
"self",
".",
"get_column",
"(",
"field",
",",
"components",
",",
"... | TODO: add documentation
return a single merged value (hstacked) from all meshes
:parameter str field: name of the mesh columnname
:parameter components: | [
"TODO",
":",
"add",
"documentation"
] | python | train | 40.416667 |
alexhayes/django-toolkit | django_toolkit/markup/html.py | https://github.com/alexhayes/django-toolkit/blob/b64106392fad596defc915b8235fe6e1d0013b5b/django_toolkit/markup/html.py#L3-L8 | def get_anchor_href(markup):
"""
Given HTML markup, return a list of hrefs for each anchor tag.
"""
soup = BeautifulSoup(markup, 'lxml')
return ['%s' % link.get('href') for link in soup.find_all('a')] | [
"def",
"get_anchor_href",
"(",
"markup",
")",
":",
"soup",
"=",
"BeautifulSoup",
"(",
"markup",
",",
"'lxml'",
")",
"return",
"[",
"'%s'",
"%",
"link",
".",
"get",
"(",
"'href'",
")",
"for",
"link",
"in",
"soup",
".",
"find_all",
"(",
"'a'",
")",
"]"... | Given HTML markup, return a list of hrefs for each anchor tag. | [
"Given",
"HTML",
"markup",
"return",
"a",
"list",
"of",
"hrefs",
"for",
"each",
"anchor",
"tag",
"."
] | python | train | 35.833333 |
portfors-lab/sparkle | sparkle/gui/stim/stimulusview.py | https://github.com/portfors-lab/sparkle/blob/5fad1cf2bec58ec6b15d91da20f6236a74826110/sparkle/gui/stim/stimulusview.py#L338-L349 | def grabImage(self, index):
"""Gets an image of the item at *index*
:param index: index of an item in the view
:type index: :qtdoc:`QModelIndex`
:returns: :qtdoc:`QPixmap`
"""
# rect = self._rects[index.row()][index.column()]
rect = self.visualRect(index)
... | [
"def",
"grabImage",
"(",
"self",
",",
"index",
")",
":",
"# rect = self._rects[index.row()][index.column()]",
"rect",
"=",
"self",
".",
"visualRect",
"(",
"index",
")",
"pixmap",
"=",
"QtGui",
".",
"QPixmap",
"(",
")",
"pixmap",
"=",
"pixmap",
".",
"grabWidget... | Gets an image of the item at *index*
:param index: index of an item in the view
:type index: :qtdoc:`QModelIndex`
:returns: :qtdoc:`QPixmap` | [
"Gets",
"an",
"image",
"of",
"the",
"item",
"at",
"*",
"index",
"*"
] | python | train | 34 |
deepmind/pysc2 | pysc2/lib/sc_process.py | https://github.com/deepmind/pysc2/blob/df4cc4b00f07a2242be9ba153d4a7f4ad2017897/pysc2/lib/sc_process.py#L195-L206 | def _shutdown_proc(p, timeout):
"""Wait for a proc to shut down, then terminate or kill it after `timeout`."""
freq = 10 # how often to check per second
for _ in range(1 + timeout * freq):
ret = p.poll()
if ret is not None:
logging.info("Shutdown gracefully.")
return ret
time.sleep(1 / fr... | [
"def",
"_shutdown_proc",
"(",
"p",
",",
"timeout",
")",
":",
"freq",
"=",
"10",
"# how often to check per second",
"for",
"_",
"in",
"range",
"(",
"1",
"+",
"timeout",
"*",
"freq",
")",
":",
"ret",
"=",
"p",
".",
"poll",
"(",
")",
"if",
"ret",
"is",
... | Wait for a proc to shut down, then terminate or kill it after `timeout`. | [
"Wait",
"for",
"a",
"proc",
"to",
"shut",
"down",
"then",
"terminate",
"or",
"kill",
"it",
"after",
"timeout",
"."
] | python | train | 31.916667 |
bokeh/bokeh | bokeh/model.py | https://github.com/bokeh/bokeh/blob/dc8cf49e4e4302fd38537ad089ece81fbcca4737/bokeh/model.py#L62-L103 | def collect_filtered_models(discard, *input_values):
''' Collect a duplicate-free list of all other Bokeh models referred to by
this model, or by any of its references, etc, unless filtered-out by the
provided callable.
Iterate over ``input_values`` and descend through their structure
collecting al... | [
"def",
"collect_filtered_models",
"(",
"discard",
",",
"*",
"input_values",
")",
":",
"ids",
"=",
"set",
"(",
"[",
"]",
")",
"collected",
"=",
"[",
"]",
"queued",
"=",
"[",
"]",
"def",
"queue_one",
"(",
"obj",
")",
":",
"if",
"obj",
".",
"id",
"not... | Collect a duplicate-free list of all other Bokeh models referred to by
this model, or by any of its references, etc, unless filtered-out by the
provided callable.
Iterate over ``input_values`` and descend through their structure
collecting all nested ``Models`` on the go.
Args:
*discard (C... | [
"Collect",
"a",
"duplicate",
"-",
"free",
"list",
"of",
"all",
"other",
"Bokeh",
"models",
"referred",
"to",
"by",
"this",
"model",
"or",
"by",
"any",
"of",
"its",
"references",
"etc",
"unless",
"filtered",
"-",
"out",
"by",
"the",
"provided",
"callable",
... | python | train | 30.47619 |
Devoxin/Lavalink.py | lavalink/PlayerManager.py | https://github.com/Devoxin/Lavalink.py/blob/63f55c3d726d24c4cfd3674d3cd6aab6f5be110d/lavalink/PlayerManager.py#L158-L164 | async def set_volume(self, vol: int):
""" Sets the player's volume (150% or 1000% limit imposed by lavalink depending on the version). """
if self._lavalink._server_version <= 2:
self.volume = max(min(vol, 150), 0)
else:
self.volume = max(min(vol, 1000), 0)
... | [
"async",
"def",
"set_volume",
"(",
"self",
",",
"vol",
":",
"int",
")",
":",
"if",
"self",
".",
"_lavalink",
".",
"_server_version",
"<=",
"2",
":",
"self",
".",
"volume",
"=",
"max",
"(",
"min",
"(",
"vol",
",",
"150",
")",
",",
"0",
")",
"else"... | Sets the player's volume (150% or 1000% limit imposed by lavalink depending on the version). | [
"Sets",
"the",
"player",
"s",
"volume",
"(",
"150%",
"or",
"1000%",
"limit",
"imposed",
"by",
"lavalink",
"depending",
"on",
"the",
"version",
")",
"."
] | python | valid | 56.857143 |
Hironsan/anago | anago/preprocessing.py | https://github.com/Hironsan/anago/blob/66a97f91c41f9613b736892e9762dccb9c28f623/anago/preprocessing.py#L115-L128 | def fit_transform(self, X, y=None, **params):
"""Learn vocabulary and return document id matrix.
This is equivalent to fit followed by transform.
Args:
X : iterable
an iterable which yields either str, unicode or file objects.
Returns:
list : docume... | [
"def",
"fit_transform",
"(",
"self",
",",
"X",
",",
"y",
"=",
"None",
",",
"*",
"*",
"params",
")",
":",
"return",
"self",
".",
"fit",
"(",
"X",
",",
"y",
")",
".",
"transform",
"(",
"X",
",",
"y",
")"
] | Learn vocabulary and return document id matrix.
This is equivalent to fit followed by transform.
Args:
X : iterable
an iterable which yields either str, unicode or file objects.
Returns:
list : document id matrix.
list: label id matrix. | [
"Learn",
"vocabulary",
"and",
"return",
"document",
"id",
"matrix",
"."
] | python | train | 29.5 |
TkTech/Jawa | jawa/util/bytecode.py | https://github.com/TkTech/Jawa/blob/94c8424e699029ac33fbc0e866fff0ecb2742289/jawa/util/bytecode.py#L61-L76 | def wide(self):
"""
``True`` if this instruction needs to be prefixed by the WIDE
opcode.
"""
if not opcode_table[self.opcode].get('can_be_wide'):
return False
if self.operands[0].value >= 255:
return True
if self.opcode == 0x84:
... | [
"def",
"wide",
"(",
"self",
")",
":",
"if",
"not",
"opcode_table",
"[",
"self",
".",
"opcode",
"]",
".",
"get",
"(",
"'can_be_wide'",
")",
":",
"return",
"False",
"if",
"self",
".",
"operands",
"[",
"0",
"]",
".",
"value",
">=",
"255",
":",
"return... | ``True`` if this instruction needs to be prefixed by the WIDE
opcode. | [
"True",
"if",
"this",
"instruction",
"needs",
"to",
"be",
"prefixed",
"by",
"the",
"WIDE",
"opcode",
"."
] | python | train | 24.5 |
inasafe/inasafe | safe/gui/widgets/message_viewer.py | https://github.com/inasafe/inasafe/blob/831d60abba919f6d481dc94a8d988cc205130724/safe/gui/widgets/message_viewer.py#L399-L432 | def load_html(self, mode, html):
"""Load HTML to this class with the mode specified.
There are two modes that can be used:
* HTML_FILE_MODE: Directly from a local HTML file.
* HTML_STR_MODE: From a valid HTML string.
:param mode: The mode.
:type mode: int
... | [
"def",
"load_html",
"(",
"self",
",",
"mode",
",",
"html",
")",
":",
"# noinspection PyCallByClass,PyTypeChecker,PyArgumentList",
"self",
".",
"_html_loaded_flag",
"=",
"False",
"if",
"mode",
"==",
"HTML_FILE_MODE",
":",
"self",
".",
"setUrl",
"(",
"QtCore",
".",
... | Load HTML to this class with the mode specified.
There are two modes that can be used:
* HTML_FILE_MODE: Directly from a local HTML file.
* HTML_STR_MODE: From a valid HTML string.
:param mode: The mode.
:type mode: int
:param html: The html that will be loaded... | [
"Load",
"HTML",
"to",
"this",
"class",
"with",
"the",
"mode",
"specified",
"."
] | python | train | 36.558824 |
dbrgn/RPLCD | RPLCD/lcd.py | https://github.com/dbrgn/RPLCD/blob/95fe5da1354d466d661cdc84e1637ce557700c8c/RPLCD/lcd.py#L332-L375 | def create_char(self, location, bitmap):
"""Create a new character.
The HD44780 supports up to 8 custom characters (location 0-7).
:param location: The place in memory where the character is stored.
Values need to be integers between 0 and 7.
:type location: int
:pa... | [
"def",
"create_char",
"(",
"self",
",",
"location",
",",
"bitmap",
")",
":",
"assert",
"0",
"<=",
"location",
"<=",
"7",
",",
"'Only locations 0-7 are valid.'",
"assert",
"len",
"(",
"bitmap",
")",
"==",
"8",
",",
"'Bitmap should have exactly 8 rows.'",
"# Store... | Create a new character.
The HD44780 supports up to 8 custom characters (location 0-7).
:param location: The place in memory where the character is stored.
Values need to be integers between 0 and 7.
:type location: int
:param bitmap: The bitmap containing the character. Thi... | [
"Create",
"a",
"new",
"character",
"."
] | python | train | 31.090909 |
DataDog/integrations-core | tokumx/datadog_checks/tokumx/vendor/bson/json_util.py | https://github.com/DataDog/integrations-core/blob/ebd41c873cf9f97a8c51bf9459bc6a7536af8acd/tokumx/datadog_checks/tokumx/vendor/bson/json_util.py#L642-L650 | def _parse_canonical_regex(doc):
"""Decode a JSON regex to bson.regex.Regex."""
regex = doc['$regularExpression']
if len(doc) != 1:
raise TypeError('Bad $regularExpression, extra field(s): %s' % (doc,))
if len(regex) != 2:
raise TypeError('Bad $regularExpression must include only "patter... | [
"def",
"_parse_canonical_regex",
"(",
"doc",
")",
":",
"regex",
"=",
"doc",
"[",
"'$regularExpression'",
"]",
"if",
"len",
"(",
"doc",
")",
"!=",
"1",
":",
"raise",
"TypeError",
"(",
"'Bad $regularExpression, extra field(s): %s'",
"%",
"(",
"doc",
",",
")",
... | Decode a JSON regex to bson.regex.Regex. | [
"Decode",
"a",
"JSON",
"regex",
"to",
"bson",
".",
"regex",
".",
"Regex",
"."
] | python | train | 48.111111 |
pybel/pybel | src/pybel/tokens.py | https://github.com/pybel/pybel/blob/c8a7a1bdae4c475fa2a8c77f3a9a5f6d79556ca0/src/pybel/tokens.py#L183-L193 | def _list_po_to_dict(tokens) -> ListAbundance:
"""Convert a list parse object to a node.
:type tokens: ParseResult
"""
func = tokens[FUNCTION]
dsl = FUNC_TO_LIST_DSL[func]
members = [parse_result_to_dsl(token) for token in tokens[MEMBERS]]
return dsl(members) | [
"def",
"_list_po_to_dict",
"(",
"tokens",
")",
"->",
"ListAbundance",
":",
"func",
"=",
"tokens",
"[",
"FUNCTION",
"]",
"dsl",
"=",
"FUNC_TO_LIST_DSL",
"[",
"func",
"]",
"members",
"=",
"[",
"parse_result_to_dsl",
"(",
"token",
")",
"for",
"token",
"in",
"... | Convert a list parse object to a node.
:type tokens: ParseResult | [
"Convert",
"a",
"list",
"parse",
"object",
"to",
"a",
"node",
"."
] | python | train | 25.454545 |
noahbenson/neuropythy | neuropythy/vision/retinotopy.py | https://github.com/noahbenson/neuropythy/blob/b588889f6db36ddb9602ae4a72c1c0d3f41586b2/neuropythy/vision/retinotopy.py#L1119-L1145 | def calc_model(cortex, model_argument, model_hemi=Ellipsis, radius=np.pi/3):
'''
calc_model loads the appropriate model object given the model argument, which may given the name
of the model or a model object itself.
Required afferent parameters:
@ model_argument Must be either a RegisteredRetino... | [
"def",
"calc_model",
"(",
"cortex",
",",
"model_argument",
",",
"model_hemi",
"=",
"Ellipsis",
",",
"radius",
"=",
"np",
".",
"pi",
"/",
"3",
")",
":",
"if",
"pimms",
".",
"is_str",
"(",
"model_argument",
")",
":",
"h",
"=",
"cortex",
".",
"chirality",... | calc_model loads the appropriate model object given the model argument, which may given the name
of the model or a model object itself.
Required afferent parameters:
@ model_argument Must be either a RegisteredRetinotopyModel object or the name of a model that
can be loaded.
Optional afferen... | [
"calc_model",
"loads",
"the",
"appropriate",
"model",
"object",
"given",
"the",
"model",
"argument",
"which",
"may",
"given",
"the",
"name",
"of",
"the",
"model",
"or",
"a",
"model",
"object",
"itself",
"."
] | python | train | 47.037037 |
openstack/networking-cisco | networking_cisco/ml2_drivers/nexus/nexus_restapi_network_driver.py | https://github.com/openstack/networking-cisco/blob/aa58a30aec25b86f9aa5952b0863045975debfa9/networking_cisco/ml2_drivers/nexus/nexus_restapi_network_driver.py#L859-L894 | def enable_vxlan_feature(self, nexus_host, nve_int_num, src_intf):
"""Enable VXLAN on the switch."""
# Configure the "feature" commands and NVE interface
# (without "member" subcommand configuration).
# The Nexus 9K will not allow the "interface nve" configuration
# until the "f... | [
"def",
"enable_vxlan_feature",
"(",
"self",
",",
"nexus_host",
",",
"nve_int_num",
",",
"src_intf",
")",
":",
"# Configure the \"feature\" commands and NVE interface",
"# (without \"member\" subcommand configuration).",
"# The Nexus 9K will not allow the \"interface nve\" configuration",... | Enable VXLAN on the switch. | [
"Enable",
"VXLAN",
"on",
"the",
"switch",
"."
] | python | train | 39.916667 |
openvax/sercol | sercol/collection.py | https://github.com/openvax/sercol/blob/e66a8e8c3c0b21e53eb8f73be4d23409fab311ae/sercol/collection.py#L99-L108 | def source(self):
"""
Returns the single source name for a variant collection if it is unique,
otherwise raises an error.
"""
if len(self.sources) == 0:
raise ValueError("No source associated with %s" % self.__class__.__name__)
elif len(self.sources) > 1:
... | [
"def",
"source",
"(",
"self",
")",
":",
"if",
"len",
"(",
"self",
".",
"sources",
")",
"==",
"0",
":",
"raise",
"ValueError",
"(",
"\"No source associated with %s\"",
"%",
"self",
".",
"__class__",
".",
"__name__",
")",
"elif",
"len",
"(",
"self",
".",
... | Returns the single source name for a variant collection if it is unique,
otherwise raises an error. | [
"Returns",
"the",
"single",
"source",
"name",
"for",
"a",
"variant",
"collection",
"if",
"it",
"is",
"unique",
"otherwise",
"raises",
"an",
"error",
"."
] | python | train | 42.5 |
maceoutliner/django-fiction-outlines | fiction_outlines/receivers.py | https://github.com/maceoutliner/django-fiction-outlines/blob/6c58e356af3fbe7b23557643ba27e46eaef9d4e3/fiction_outlines/receivers.py#L151-L166 | def validate_location_instance_valid_for_arc(sender, instance, action, reverse, pk_set, *args, **kwargs):
'''
Evaluates attempts to add location instances to arc, ensuring they are from same outline.
'''
if action == 'pre_add':
if reverse:
# Fetch arc definition through link.
... | [
"def",
"validate_location_instance_valid_for_arc",
"(",
"sender",
",",
"instance",
",",
"action",
",",
"reverse",
",",
"pk_set",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"action",
"==",
"'pre_add'",
":",
"if",
"reverse",
":",
"# Fetch arc d... | Evaluates attempts to add location instances to arc, ensuring they are from same outline. | [
"Evaluates",
"attempts",
"to",
"add",
"location",
"instances",
"to",
"arc",
"ensuring",
"they",
"are",
"from",
"same",
"outline",
"."
] | python | train | 53.3125 |
marrow/mongo | marrow/mongo/core/trait/queryable.py | https://github.com/marrow/mongo/blob/2066dc73e281b8a46cb5fc965267d6b8e1b18467/marrow/mongo/core/trait/queryable.py#L209-L227 | def find_one(cls, *args, **kw):
"""Get a single document from the collection this class is bound to.
Additional arguments are processed according to `_prepare_find` prior to passing to PyMongo, where positional
parameters are interpreted as query fragments, parametric keyword arguments combined, and other keyw... | [
"def",
"find_one",
"(",
"cls",
",",
"*",
"args",
",",
"*",
"*",
"kw",
")",
":",
"if",
"len",
"(",
"args",
")",
"==",
"1",
"and",
"not",
"isinstance",
"(",
"args",
"[",
"0",
"]",
",",
"Filter",
")",
":",
"args",
"=",
"(",
"getattr",
"(",
"cls"... | Get a single document from the collection this class is bound to.
Additional arguments are processed according to `_prepare_find` prior to passing to PyMongo, where positional
parameters are interpreted as query fragments, parametric keyword arguments combined, and other keyword
arguments passed along with min... | [
"Get",
"a",
"single",
"document",
"from",
"the",
"collection",
"this",
"class",
"is",
"bound",
"to",
".",
"Additional",
"arguments",
"are",
"processed",
"according",
"to",
"_prepare_find",
"prior",
"to",
"passing",
"to",
"PyMongo",
"where",
"positional",
"parame... | python | train | 42.052632 |
PmagPy/PmagPy | dialogs/grid_frame3.py | https://github.com/PmagPy/PmagPy/blob/c7984f8809bf40fe112e53dcc311a33293b62d0b/dialogs/grid_frame3.py#L743-L759 | def onCancelButton(self, event):
"""
Quit grid with warning if unsaved changes present
"""
if self.grid.changes:
dlg1 = wx.MessageDialog(self, caption="Message:",
message="Are you sure you want to exit this grid?\nYour changes will not be s... | [
"def",
"onCancelButton",
"(",
"self",
",",
"event",
")",
":",
"if",
"self",
".",
"grid",
".",
"changes",
":",
"dlg1",
"=",
"wx",
".",
"MessageDialog",
"(",
"self",
",",
"caption",
"=",
"\"Message:\"",
",",
"message",
"=",
"\"Are you sure you want to exit thi... | Quit grid with warning if unsaved changes present | [
"Quit",
"grid",
"with",
"warning",
"if",
"unsaved",
"changes",
"present"
] | python | train | 38.117647 |
RRZE-HPC/kerncraft | kerncraft/kernel.py | https://github.com/RRZE-HPC/kerncraft/blob/c60baf8043e4da8d8d66da7575021c2f4c6c78af/kerncraft/kernel.py#L138-L148 | def find_node_type(ast, node_type):
"""Return list of array references in AST."""
if type(ast) is node_type:
return [ast]
elif type(ast) is list:
return reduce(operator.add, list(map(lambda a: find_node_type(a, node_type), ast)), [])
elif ast is None:
return []
else:
... | [
"def",
"find_node_type",
"(",
"ast",
",",
"node_type",
")",
":",
"if",
"type",
"(",
"ast",
")",
"is",
"node_type",
":",
"return",
"[",
"ast",
"]",
"elif",
"type",
"(",
"ast",
")",
"is",
"list",
":",
"return",
"reduce",
"(",
"operator",
".",
"add",
... | Return list of array references in AST. | [
"Return",
"list",
"of",
"array",
"references",
"in",
"AST",
"."
] | python | test | 38.363636 |
wright-group/WrightTools | WrightTools/kit/_interpolate.py | https://github.com/wright-group/WrightTools/blob/80d3ddd5074d8d5c1bc03fd5a0e0f10d4b424aeb/WrightTools/kit/_interpolate.py#L24-L50 | def zoom2D(xi, yi, zi, xi_zoom=3., yi_zoom=3., order=3, mode="nearest", cval=0.):
"""Zoom a 2D array, with axes.
Parameters
----------
xi : 1D array
x axis points.
yi : 1D array
y axis points.
zi : 2D array
array values. Shape of (x, y).
xi_zoom : float (optional)
... | [
"def",
"zoom2D",
"(",
"xi",
",",
"yi",
",",
"zi",
",",
"xi_zoom",
"=",
"3.",
",",
"yi_zoom",
"=",
"3.",
",",
"order",
"=",
"3",
",",
"mode",
"=",
"\"nearest\"",
",",
"cval",
"=",
"0.",
")",
":",
"xi",
"=",
"ndimage",
".",
"interpolation",
".",
... | Zoom a 2D array, with axes.
Parameters
----------
xi : 1D array
x axis points.
yi : 1D array
y axis points.
zi : 2D array
array values. Shape of (x, y).
xi_zoom : float (optional)
Zoom factor along x axis. Default is 3.
yi_zoom : float (optional)
Zoom... | [
"Zoom",
"a",
"2D",
"array",
"with",
"axes",
"."
] | python | train | 39.37037 |
CalebBell/fluids | fluids/geometry.py | https://github.com/CalebBell/fluids/blob/57f556752e039f1d3e5a822f408c184783db2828/fluids/geometry.py#L923-L1018 | def V_vertical_torispherical_concave(D, f, k, h):
r'''Calculates volume of a vertical tank with a concave torispherical bottom,
according to [1]_. No provision for the top of the tank is made here.
.. math::
V = \frac{\pi D^2 h}{4} - v_1(h=a_1+a_2) + v_1(h=a_1 + a_2 -h),\; 0 \le h < a_2
.. mat... | [
"def",
"V_vertical_torispherical_concave",
"(",
"D",
",",
"f",
",",
"k",
",",
"h",
")",
":",
"alpha",
"=",
"asin",
"(",
"(",
"1",
"-",
"2",
"*",
"k",
")",
"/",
"(",
"2.",
"*",
"(",
"f",
"-",
"k",
")",
")",
")",
"a1",
"=",
"f",
"*",
"D",
"... | r'''Calculates volume of a vertical tank with a concave torispherical bottom,
according to [1]_. No provision for the top of the tank is made here.
.. math::
V = \frac{\pi D^2 h}{4} - v_1(h=a_1+a_2) + v_1(h=a_1 + a_2 -h),\; 0 \le h < a_2
.. math::
V = \frac{\pi D^2 h}{4} - v_1(h=a_1+a_2) +... | [
"r",
"Calculates",
"volume",
"of",
"a",
"vertical",
"tank",
"with",
"a",
"concave",
"torispherical",
"bottom",
"according",
"to",
"[",
"1",
"]",
"_",
".",
"No",
"provision",
"for",
"the",
"top",
"of",
"the",
"tank",
"is",
"made",
"here",
"."
] | python | train | 28.520833 |
MacHu-GWU/docfly-project | docfly/api_reference_doc.py | https://github.com/MacHu-GWU/docfly-project/blob/46da8a9793211301c3ebc12d195228dbf79fdfec/docfly/api_reference_doc.py#L109-L142 | def fly(self):
"""
Generate doc tree.
"""
dst_dir = Path(self.conf_file).parent.abspath
package_dir = Path(dst_dir, self.package.shortname)
# delete existing api document
try:
if package_dir.exists():
shutil.rmtree(package_dir.abspath... | [
"def",
"fly",
"(",
"self",
")",
":",
"dst_dir",
"=",
"Path",
"(",
"self",
".",
"conf_file",
")",
".",
"parent",
".",
"abspath",
"package_dir",
"=",
"Path",
"(",
"dst_dir",
",",
"self",
".",
"package",
".",
"shortname",
")",
"# delete existing api document"... | Generate doc tree. | [
"Generate",
"doc",
"tree",
"."
] | python | train | 36.117647 |
mbr/flask-nav | flask_nav/elements.py | https://github.com/mbr/flask-nav/blob/06f3b5b2addad29c2fc531a7e8e74958e9e4b793/flask_nav/elements.py#L16-L24 | def render(self, renderer=None, **kwargs):
"""Render the navigational item using a renderer.
:param renderer: An object implementing the :class:`~.Renderer`
interface.
:return: A markupsafe string with the rendered result.
"""
return Markup(get_renderer(... | [
"def",
"render",
"(",
"self",
",",
"renderer",
"=",
"None",
",",
"*",
"*",
"kwargs",
")",
":",
"return",
"Markup",
"(",
"get_renderer",
"(",
"current_app",
",",
"renderer",
")",
"(",
"*",
"*",
"kwargs",
")",
".",
"visit",
"(",
"self",
")",
")"
] | Render the navigational item using a renderer.
:param renderer: An object implementing the :class:`~.Renderer`
interface.
:return: A markupsafe string with the rendered result. | [
"Render",
"the",
"navigational",
"item",
"using",
"a",
"renderer",
"."
] | python | train | 41.111111 |
PmagPy/PmagPy | programs/fishqq.py | https://github.com/PmagPy/PmagPy/blob/c7984f8809bf40fe112e53dcc311a33293b62d0b/programs/fishqq.py#L12-L157 | def main():
"""
NAME
fishqq.py
DESCRIPTION
makes qq plot from dec,inc input data
INPUT FORMAT
takes dec/inc pairs in space delimited file
SYNTAX
fishqq.py [command line options]
OPTIONS
-h help message
-f FILE, specify file on command line
... | [
"def",
"main",
"(",
")",
":",
"fmt",
",",
"plot",
"=",
"'svg'",
",",
"0",
"outfile",
"=",
"\"\"",
"if",
"'-h'",
"in",
"sys",
".",
"argv",
":",
"# check if help is needed",
"print",
"(",
"main",
".",
"__doc__",
")",
"sys",
".",
"exit",
"(",
")",
"# ... | NAME
fishqq.py
DESCRIPTION
makes qq plot from dec,inc input data
INPUT FORMAT
takes dec/inc pairs in space delimited file
SYNTAX
fishqq.py [command line options]
OPTIONS
-h help message
-f FILE, specify file on command line
-F FILE, specify output ... | [
"NAME",
"fishqq",
".",
"py"
] | python | train | 35.69863 |
brocade/pynos | pynos/versions/ver_7/ver_7_1_0/yang/brocade_vcs.py | https://github.com/brocade/pynos/blob/bd8a34e98f322de3fc06750827d8bbc3a0c00380/pynos/versions/ver_7/ver_7_1_0/yang/brocade_vcs.py#L368-L381 | def show_vcs_output_vcs_nodes_vcs_node_info_switch_fcf_mac(self, **kwargs):
"""Auto Generated Code
"""
config = ET.Element("config")
show_vcs = ET.Element("show_vcs")
config = show_vcs
output = ET.SubElement(show_vcs, "output")
vcs_nodes = ET.SubElement(output, "v... | [
"def",
"show_vcs_output_vcs_nodes_vcs_node_info_switch_fcf_mac",
"(",
"self",
",",
"*",
"*",
"kwargs",
")",
":",
"config",
"=",
"ET",
".",
"Element",
"(",
"\"config\"",
")",
"show_vcs",
"=",
"ET",
".",
"Element",
"(",
"\"show_vcs\"",
")",
"config",
"=",
"show_... | Auto Generated Code | [
"Auto",
"Generated",
"Code"
] | python | train | 43.214286 |
michigan-com/linkGrabber | linkGrabber/__init__.py | https://github.com/michigan-com/linkGrabber/blob/f5295a2dd357d63d38d6ad6090da3904a580d8ce/linkGrabber/__init__.py#L143-L149 | def seoify_hyperlink(hyperlink):
"""Modify a hyperlink to make it SEO-friendly by replacing
hyphens with spaces and trimming multiple spaces.
:param hyperlink: URL to attempt to grab SEO from """
last_slash = hyperlink.rfind('/')
return re.sub(r' +|-', ' ', hyperlink[last_slash + 1:]) | [
"def",
"seoify_hyperlink",
"(",
"hyperlink",
")",
":",
"last_slash",
"=",
"hyperlink",
".",
"rfind",
"(",
"'/'",
")",
"return",
"re",
".",
"sub",
"(",
"r' +|-'",
",",
"' '",
",",
"hyperlink",
"[",
"last_slash",
"+",
"1",
":",
"]",
")"
] | Modify a hyperlink to make it SEO-friendly by replacing
hyphens with spaces and trimming multiple spaces.
:param hyperlink: URL to attempt to grab SEO from | [
"Modify",
"a",
"hyperlink",
"to",
"make",
"it",
"SEO",
"-",
"friendly",
"by",
"replacing",
"hyphens",
"with",
"spaces",
"and",
"trimming",
"multiple",
"spaces",
"."
] | python | train | 42.857143 |
lesscpy/lesscpy | lesscpy/lessc/scope.py | https://github.com/lesscpy/lesscpy/blob/51e392fb4a3cd4ccfb6175e0e42ce7d2f6b78126/lesscpy/lessc/scope.py#L161-L172 | def update(self, scope, at=0):
"""Update scope. Add another scope to this one.
Args:
scope (Scope): Scope object
Kwargs:
at (int): Level to update
"""
if hasattr(scope, '_mixins') and not at:
self._mixins.update(scope._mixins)
self[at][... | [
"def",
"update",
"(",
"self",
",",
"scope",
",",
"at",
"=",
"0",
")",
":",
"if",
"hasattr",
"(",
"scope",
",",
"'_mixins'",
")",
"and",
"not",
"at",
":",
"self",
".",
"_mixins",
".",
"update",
"(",
"scope",
".",
"_mixins",
")",
"self",
"[",
"at",... | Update scope. Add another scope to this one.
Args:
scope (Scope): Scope object
Kwargs:
at (int): Level to update | [
"Update",
"scope",
".",
"Add",
"another",
"scope",
"to",
"this",
"one",
".",
"Args",
":",
"scope",
"(",
"Scope",
")",
":",
"Scope",
"object",
"Kwargs",
":",
"at",
"(",
"int",
")",
":",
"Level",
"to",
"update"
] | python | valid | 40.333333 |
softlayer/softlayer-python | SoftLayer/CLI/formatting.py | https://github.com/softlayer/softlayer-python/blob/9f181be08cc3668353b05a6de0cb324f52cff6fa/SoftLayer/CLI/formatting.py#L162-L172 | def transaction_status(transaction):
"""Returns a FormattedItem describing the given transaction.
:param item: An object capable of having an active transaction
"""
if not transaction or not transaction.get('transactionStatus'):
return blank()
return FormattedItem(
transaction[... | [
"def",
"transaction_status",
"(",
"transaction",
")",
":",
"if",
"not",
"transaction",
"or",
"not",
"transaction",
".",
"get",
"(",
"'transactionStatus'",
")",
":",
"return",
"blank",
"(",
")",
"return",
"FormattedItem",
"(",
"transaction",
"[",
"'transactionSta... | Returns a FormattedItem describing the given transaction.
:param item: An object capable of having an active transaction | [
"Returns",
"a",
"FormattedItem",
"describing",
"the",
"given",
"transaction",
"."
] | python | train | 36.818182 |
pytroll/satpy | satpy/readers/yaml_reader.py | https://github.com/pytroll/satpy/blob/1f21d20ac686b745fb0da9b4030d139893e066dd/satpy/readers/yaml_reader.py#L56-L68 | def listify_string(something):
"""Takes *something* and make it a list.
*something* is either a list of strings or a string, in which case the
function returns a list containing the string.
If *something* is None, an empty list is returned.
"""
if isinstance(something, (str, six.text_type)):
... | [
"def",
"listify_string",
"(",
"something",
")",
":",
"if",
"isinstance",
"(",
"something",
",",
"(",
"str",
",",
"six",
".",
"text_type",
")",
")",
":",
"return",
"[",
"something",
"]",
"elif",
"something",
"is",
"not",
"None",
":",
"return",
"list",
"... | Takes *something* and make it a list.
*something* is either a list of strings or a string, in which case the
function returns a list containing the string.
If *something* is None, an empty list is returned. | [
"Takes",
"*",
"something",
"*",
"and",
"make",
"it",
"a",
"list",
"."
] | python | train | 32.846154 |
mitsei/dlkit | dlkit/json_/grading/managers.py | https://github.com/mitsei/dlkit/blob/445f968a175d61c8d92c0f617a3c17dc1dc7c584/dlkit/json_/grading/managers.py#L1638-L1657 | def get_gradebook_column_gradebook_assignment_session(self, proxy):
"""Gets the session for assigning gradebook column to gradebook mappings.
arg: proxy (osid.proxy.Proxy): a proxy
return: (osid.grading.GradebookColumnGradebookAssignmentSession)
- a ``GradebookColumnGradebook... | [
"def",
"get_gradebook_column_gradebook_assignment_session",
"(",
"self",
",",
"proxy",
")",
":",
"if",
"not",
"self",
".",
"supports_gradebook_column_gradebook_assignment",
"(",
")",
":",
"raise",
"errors",
".",
"Unimplemented",
"(",
")",
"# pylint: disable=no-member",
... | Gets the session for assigning gradebook column to gradebook mappings.
arg: proxy (osid.proxy.Proxy): a proxy
return: (osid.grading.GradebookColumnGradebookAssignmentSession)
- a ``GradebookColumnGradebookAssignmentSession``
raise: NullArgument - ``proxy`` is ``null``
... | [
"Gets",
"the",
"session",
"for",
"assigning",
"gradebook",
"column",
"to",
"gradebook",
"mappings",
"."
] | python | train | 48.85 |
saltstack/salt | salt/modules/lxd.py | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/lxd.py#L2204-L2260 | def profile_config_set(name, config_key, config_value,
remote_addr=None,
cert=None, key=None, verify_cert=True):
''' Set a profile config item.
name :
The name of the profile to set the config item to.
config_key :
The items key... | [
"def",
"profile_config_set",
"(",
"name",
",",
"config_key",
",",
"config_value",
",",
"remote_addr",
"=",
"None",
",",
"cert",
"=",
"None",
",",
"key",
"=",
"None",
",",
"verify_cert",
"=",
"True",
")",
":",
"profile",
"=",
"profile_get",
"(",
"name",
"... | Set a profile config item.
name :
The name of the profile to set the config item to.
config_key :
The items key.
config_value :
Its items value.
remote_addr :
An URL to a remote Server, you also have to give cert and key if
... | [
"Set",
"a",
"profile",
"config",
"item",
"."
] | python | train | 24.368421 |
fprimex/zdesk | zdesk/zdesk_api.py | https://github.com/fprimex/zdesk/blob/851611c13b4d530e9df31390b3ec709baf0a0188/zdesk/zdesk_api.py#L881-L885 | def community_post_votes(self, post_id, **kwargs):
"https://developer.zendesk.com/rest_api/docs/help_center/votes#list-votes"
api_path = "/api/v2/community/posts/{post_id}/votes.json"
api_path = api_path.format(post_id=post_id)
return self.call(api_path, **kwargs) | [
"def",
"community_post_votes",
"(",
"self",
",",
"post_id",
",",
"*",
"*",
"kwargs",
")",
":",
"api_path",
"=",
"\"/api/v2/community/posts/{post_id}/votes.json\"",
"api_path",
"=",
"api_path",
".",
"format",
"(",
"post_id",
"=",
"post_id",
")",
"return",
"self",
... | https://developer.zendesk.com/rest_api/docs/help_center/votes#list-votes | [
"https",
":",
"//",
"developer",
".",
"zendesk",
".",
"com",
"/",
"rest_api",
"/",
"docs",
"/",
"help_center",
"/",
"votes#list",
"-",
"votes"
] | python | train | 58.4 |
PythonCharmers/python-future | src/future/backports/email/message.py | https://github.com/PythonCharmers/python-future/blob/c423752879acc05eebc29b0bb9909327bd5c7308/src/future/backports/email/message.py#L833-L861 | def get_content_charset(self, failobj=None):
"""Return the charset parameter of the Content-Type header.
The returned string is always coerced to lower case. If there is no
Content-Type header, or if that header has no charset parameter,
failobj is returned.
"""
missing... | [
"def",
"get_content_charset",
"(",
"self",
",",
"failobj",
"=",
"None",
")",
":",
"missing",
"=",
"object",
"(",
")",
"charset",
"=",
"self",
".",
"get_param",
"(",
"'charset'",
",",
"missing",
")",
"if",
"charset",
"is",
"missing",
":",
"return",
"failo... | Return the charset parameter of the Content-Type header.
The returned string is always coerced to lower case. If there is no
Content-Type header, or if that header has no charset parameter,
failobj is returned. | [
"Return",
"the",
"charset",
"parameter",
"of",
"the",
"Content",
"-",
"Type",
"header",
"."
] | python | train | 43.586207 |
ergo/ziggurat_foundations | ziggurat_foundations/permissions.py | https://github.com/ergo/ziggurat_foundations/blob/9eeec894d08e8d7defa60ddc04b63f69cd4cbeba/ziggurat_foundations/permissions.py#L204-L216 | def permission_to_pyramid_acls(permissions):
"""
Returns a list of permissions in a format understood by pyramid
:param permissions:
:return:
"""
acls = []
for perm in permissions:
if perm.type == "user":
acls.append((Allow, perm.user.id, perm.perm_name))
elif per... | [
"def",
"permission_to_pyramid_acls",
"(",
"permissions",
")",
":",
"acls",
"=",
"[",
"]",
"for",
"perm",
"in",
"permissions",
":",
"if",
"perm",
".",
"type",
"==",
"\"user\"",
":",
"acls",
".",
"append",
"(",
"(",
"Allow",
",",
"perm",
".",
"user",
"."... | Returns a list of permissions in a format understood by pyramid
:param permissions:
:return: | [
"Returns",
"a",
"list",
"of",
"permissions",
"in",
"a",
"format",
"understood",
"by",
"pyramid",
":",
"param",
"permissions",
":",
":",
"return",
":"
] | python | train | 32.230769 |
bitlabstudio/django-development-fabfile | development_fabfile/fabfile/remote.py | https://github.com/bitlabstudio/django-development-fabfile/blob/a135c6eb5bdd0b496a7eccfd271aca558dd99243/development_fabfile/fabfile/remote.py#L287-L306 | def run_rsync_project():
"""
Copies the project from the git repository to it's destination folder.
This has the nice side effect of rsync deleting all ``.pyc`` files and
removing other files that might have been left behind by sys admins messing
around on the server.
Usage::
fab <ser... | [
"def",
"run_rsync_project",
"(",
")",
":",
"excludes",
"=",
"''",
"for",
"exclude",
"in",
"settings",
".",
"RSYNC_EXCLUDES",
":",
"excludes",
"+=",
"\" --exclude '{0}'\"",
".",
"format",
"(",
"exclude",
")",
"command",
"=",
"\"rsync -avz --stats --delete {0} {1} {2}... | Copies the project from the git repository to it's destination folder.
This has the nice side effect of rsync deleting all ``.pyc`` files and
removing other files that might have been left behind by sys admins messing
around on the server.
Usage::
fab <server> run_rsync_project | [
"Copies",
"the",
"project",
"from",
"the",
"git",
"repository",
"to",
"it",
"s",
"destination",
"folder",
"."
] | python | train | 32.35 |
ultrabug/py3status | py3status/core.py | https://github.com/ultrabug/py3status/blob/4c105f1b44f7384ca4f7da5f821a47e468c7dee2/py3status/core.py#L717-L749 | def refresh_modules(self, module_string=None, exact=True):
"""
Update modules.
if module_string is None all modules are refreshed
if module_string then modules with the exact name or those starting
with the given string depending on exact parameter will be refreshed.
If a... | [
"def",
"refresh_modules",
"(",
"self",
",",
"module_string",
"=",
"None",
",",
"exact",
"=",
"True",
")",
":",
"if",
"not",
"module_string",
":",
"if",
"time",
".",
"time",
"(",
")",
">",
"(",
"self",
".",
"last_refresh_ts",
"+",
"0.1",
")",
":",
"se... | Update modules.
if module_string is None all modules are refreshed
if module_string then modules with the exact name or those starting
with the given string depending on exact parameter will be refreshed.
If a module is an i3status one then we refresh i3status.
To prevent abuse, ... | [
"Update",
"modules",
".",
"if",
"module_string",
"is",
"None",
"all",
"modules",
"are",
"refreshed",
"if",
"module_string",
"then",
"modules",
"with",
"the",
"exact",
"name",
"or",
"those",
"starting",
"with",
"the",
"given",
"string",
"depending",
"on",
"exac... | python | train | 43.151515 |
project-ncl/pnc-cli | pnc_cli/productmilestones.py | https://github.com/project-ncl/pnc-cli/blob/3dc149bf84928f60a8044ac50b58bbaddd451902/pnc_cli/productmilestones.py#L121-L127 | def update_milestone(id, **kwargs):
"""
Update a ProductMilestone
"""
data = update_milestone_raw(id, **kwargs)
if data:
return utils.format_json(data) | [
"def",
"update_milestone",
"(",
"id",
",",
"*",
"*",
"kwargs",
")",
":",
"data",
"=",
"update_milestone_raw",
"(",
"id",
",",
"*",
"*",
"kwargs",
")",
"if",
"data",
":",
"return",
"utils",
".",
"format_json",
"(",
"data",
")"
] | Update a ProductMilestone | [
"Update",
"a",
"ProductMilestone"
] | python | train | 24.714286 |
broadinstitute/fiss | firecloud/fiss.py | https://github.com/broadinstitute/fiss/blob/dddf91547479506dbbafb69ec84d44dcc4a94ab4/firecloud/fiss.py#L40-L59 | def space_list(args):
''' List accessible workspaces, in TSV form: <namespace><TAB>workspace'''
r = fapi.list_workspaces()
fapi._check_response_code(r, 200)
spaces = []
project = args.project
if project:
project = re.compile('^' + project)
for space in r.json():
ns = space... | [
"def",
"space_list",
"(",
"args",
")",
":",
"r",
"=",
"fapi",
".",
"list_workspaces",
"(",
")",
"fapi",
".",
"_check_response_code",
"(",
"r",
",",
"200",
")",
"spaces",
"=",
"[",
"]",
"project",
"=",
"args",
".",
"project",
"if",
"project",
":",
"pr... | List accessible workspaces, in TSV form: <namespace><TAB>workspace | [
"List",
"accessible",
"workspaces",
"in",
"TSV",
"form",
":",
"<namespace",
">",
"<TAB",
">",
"workspace"
] | python | train | 29 |
hyperledger-archives/indy-anoncreds | anoncreds/protocol/prover.py | https://github.com/hyperledger-archives/indy-anoncreds/blob/9d9cda3d505c312257d99a13d74d8f05dac3091a/anoncreds/protocol/prover.py#L90-L100 | async def processClaims(self, allClaims: Dict[ID, Claims]):
"""
Processes and saves received Claims.
:param claims: claims to be processed and saved for each claim
definition.
"""
res = []
for schemaId, (claim_signature, claim_attributes) in allClaims.items():
... | [
"async",
"def",
"processClaims",
"(",
"self",
",",
"allClaims",
":",
"Dict",
"[",
"ID",
",",
"Claims",
"]",
")",
":",
"res",
"=",
"[",
"]",
"for",
"schemaId",
",",
"(",
"claim_signature",
",",
"claim_attributes",
")",
"in",
"allClaims",
".",
"items",
"... | Processes and saves received Claims.
:param claims: claims to be processed and saved for each claim
definition. | [
"Processes",
"and",
"saves",
"received",
"Claims",
"."
] | python | train | 38.090909 |
codelv/enaml-native | src/enamlnative/core/app.py | https://github.com/codelv/enaml-native/blob/c33986e9eda468c508806e0a3e73c771401e5718/src/enamlnative/core/app.py#L236-L253 | def add_done_callback(self, future, callback):
""" Add a callback on a future object put here so it can be
implemented with different event loops.
Parameters
-----------
future: Future or Deferred
Future implementation for the current EventLoop
... | [
"def",
"add_done_callback",
"(",
"self",
",",
"future",
",",
"callback",
")",
":",
"if",
"future",
"is",
"None",
":",
"raise",
"bridge",
".",
"BridgeReferenceError",
"(",
"\"Tried to add a callback to a nonexistent Future. \"",
"\"Make sure you pass the `returns` argument t... | Add a callback on a future object put here so it can be
implemented with different event loops.
Parameters
-----------
future: Future or Deferred
Future implementation for the current EventLoop
callback: callable
Callback ... | [
"Add",
"a",
"callback",
"on",
"a",
"future",
"object",
"put",
"here",
"so",
"it",
"can",
"be",
"implemented",
"with",
"different",
"event",
"loops",
"."
] | python | train | 39.277778 |
python-openxml/python-docx | docx/image/tiff.py | https://github.com/python-openxml/python-docx/blob/6756f6cd145511d3eb6d1d188beea391b1ddfd53/docx/image/tiff.py#L215-L231 | def _IfdEntryFactory(stream_rdr, offset):
"""
Return an |_IfdEntry| subclass instance containing the value of the
directory entry at *offset* in *stream_rdr*.
"""
ifd_entry_classes = {
TIFF_FLD.ASCII: _AsciiIfdEntry,
TIFF_FLD.SHORT: _ShortIfdEntry,
TIFF_FLD.LONG: _L... | [
"def",
"_IfdEntryFactory",
"(",
"stream_rdr",
",",
"offset",
")",
":",
"ifd_entry_classes",
"=",
"{",
"TIFF_FLD",
".",
"ASCII",
":",
"_AsciiIfdEntry",
",",
"TIFF_FLD",
".",
"SHORT",
":",
"_ShortIfdEntry",
",",
"TIFF_FLD",
".",
"LONG",
":",
"_LongIfdEntry",
","... | Return an |_IfdEntry| subclass instance containing the value of the
directory entry at *offset* in *stream_rdr*. | [
"Return",
"an",
"|_IfdEntry|",
"subclass",
"instance",
"containing",
"the",
"value",
"of",
"the",
"directory",
"entry",
"at",
"*",
"offset",
"*",
"in",
"*",
"stream_rdr",
"*",
"."
] | python | train | 35.352941 |
dedupeio/dedupe | dedupe/api.py | https://github.com/dedupeio/dedupe/blob/9f7c9f84473a4bcacf0f2b11152d8ed3eb35d48b/dedupe/api.py#L772-L791 | def sample(self, data, sample_size=15000,
blocked_proportion=0.5, original_length=None):
'''Draw a sample of record pairs from the dataset
(a mix of random pairs & pairs of similar records)
and initialize active learning with this sample
Arguments: data -- Dictionary of r... | [
"def",
"sample",
"(",
"self",
",",
"data",
",",
"sample_size",
"=",
"15000",
",",
"blocked_proportion",
"=",
"0.5",
",",
"original_length",
"=",
"None",
")",
":",
"self",
".",
"_checkData",
"(",
"data",
")",
"self",
".",
"active_learner",
"=",
"self",
".... | Draw a sample of record pairs from the dataset
(a mix of random pairs & pairs of similar records)
and initialize active learning with this sample
Arguments: data -- Dictionary of records, where the keys are
record_ids and the values are dictionaries with the keys being
field nam... | [
"Draw",
"a",
"sample",
"of",
"record",
"pairs",
"from",
"the",
"dataset",
"(",
"a",
"mix",
"of",
"random",
"pairs",
"&",
"pairs",
"of",
"similar",
"records",
")",
"and",
"initialize",
"active",
"learning",
"with",
"this",
"sample"
] | python | train | 46.85 |
SBRG/ssbio | ssbio/protein/structure/structprop.py | https://github.com/SBRG/ssbio/blob/e9449e64ffc1a1f5ad07e5849aa12a650095f8a2/ssbio/protein/structure/structprop.py#L319-L349 | def find_disulfide_bridges(self, threshold=3.0):
"""Run Biopython's search_ss_bonds to find potential disulfide bridges for each chain and store in ChainProp.
Will add a list of tuple pairs into the annotations field, looks like this::
[ ((' ', 79, ' '), (' ', 110, ' ')),
(('... | [
"def",
"find_disulfide_bridges",
"(",
"self",
",",
"threshold",
"=",
"3.0",
")",
":",
"if",
"self",
".",
"structure",
":",
"parsed",
"=",
"self",
".",
"structure",
"else",
":",
"parsed",
"=",
"self",
".",
"parse_structure",
"(",
")",
"if",
"not",
"parsed... | Run Biopython's search_ss_bonds to find potential disulfide bridges for each chain and store in ChainProp.
Will add a list of tuple pairs into the annotations field, looks like this::
[ ((' ', 79, ' '), (' ', 110, ' ')),
((' ', 174, ' '), (' ', 180, ' ')),
((' ', 369, '... | [
"Run",
"Biopython",
"s",
"search_ss_bonds",
"to",
"find",
"potential",
"disulfide",
"bridges",
"for",
"each",
"chain",
"and",
"store",
"in",
"ChainProp",
"."
] | python | train | 45.548387 |
aichaos/rivescript-python | rivescript/rivescript.py | https://github.com/aichaos/rivescript-python/blob/b55c820cf02a194605fd66af1f070e239f84ed31/rivescript/rivescript.py#L194-L206 | def load_file(self, filename):
"""Load and parse a RiveScript document.
:param str filename: The path to a RiveScript file.
"""
self._say("Loading file: " + filename)
fh = codecs.open(filename, 'r', 'utf-8')
lines = fh.readlines()
fh.close()
self._sa... | [
"def",
"load_file",
"(",
"self",
",",
"filename",
")",
":",
"self",
".",
"_say",
"(",
"\"Loading file: \"",
"+",
"filename",
")",
"fh",
"=",
"codecs",
".",
"open",
"(",
"filename",
",",
"'r'",
",",
"'utf-8'",
")",
"lines",
"=",
"fh",
".",
"readlines",
... | Load and parse a RiveScript document.
:param str filename: The path to a RiveScript file. | [
"Load",
"and",
"parse",
"a",
"RiveScript",
"document",
"."
] | python | train | 31.692308 |
Parisson/TimeSide | timeside/plugins/decoder/utils.py | https://github.com/Parisson/TimeSide/blob/0618d75cd2f16021afcfd3d5b77f692adad76ea5/timeside/plugins/decoder/utils.py#L100-L119 | def get_uri(source):
"""
Check a media source as a valid file or uri and return the proper uri
"""
import gst
src_info = source_info(source)
if src_info['is_file']: # Is this a file?
return get_uri(src_info['uri'])
elif gst.uri_is_valid(source): # Is this a valid URI source for... | [
"def",
"get_uri",
"(",
"source",
")",
":",
"import",
"gst",
"src_info",
"=",
"source_info",
"(",
"source",
")",
"if",
"src_info",
"[",
"'is_file'",
"]",
":",
"# Is this a file?",
"return",
"get_uri",
"(",
"src_info",
"[",
"'uri'",
"]",
")",
"elif",
"gst",
... | Check a media source as a valid file or uri and return the proper uri | [
"Check",
"a",
"media",
"source",
"as",
"a",
"valid",
"file",
"or",
"uri",
"and",
"return",
"the",
"proper",
"uri"
] | python | train | 31.15 |
SoCo/SoCo | soco/events.py | https://github.com/SoCo/SoCo/blob/671937e07d7973b78c0cbee153d4f3ad68ec48c6/soco/events.py#L418-L526 | def subscribe(self, requested_timeout=None, auto_renew=False):
"""Subscribe to the service.
If requested_timeout is provided, a subscription valid for that number
of seconds will be requested, but not guaranteed. Check
`timeout` on return to find out what period of validity is
a... | [
"def",
"subscribe",
"(",
"self",
",",
"requested_timeout",
"=",
"None",
",",
"auto_renew",
"=",
"False",
")",
":",
"class",
"AutoRenewThread",
"(",
"threading",
".",
"Thread",
")",
":",
"\"\"\"Used by the auto_renew code to renew a subscription from within\n a ... | Subscribe to the service.
If requested_timeout is provided, a subscription valid for that number
of seconds will be requested, but not guaranteed. Check
`timeout` on return to find out what period of validity is
actually allocated.
Note:
SoCo will try to unsubscribe... | [
"Subscribe",
"to",
"the",
"service",
"."
] | python | train | 40.944954 |
desbma/web_cache | web_cache/__init__.py | https://github.com/desbma/web_cache/blob/7cd4ef40d9c41f7fa70192759294f2cc724e8c9c/web_cache/__init__.py#L104-L117 | def getDatabaseFileSize(self):
""" Return the file size of the database as a pretty string. """
if DISABLE_PERSISTENT_CACHING:
return "?"
size = os.path.getsize(self.__db_filepath)
if size > 1000000000:
size = "%0.3fGB" % (size / 1000000000)
elif size > 1000000:
size = "%0.2fMB" % ... | [
"def",
"getDatabaseFileSize",
"(",
"self",
")",
":",
"if",
"DISABLE_PERSISTENT_CACHING",
":",
"return",
"\"?\"",
"size",
"=",
"os",
".",
"path",
".",
"getsize",
"(",
"self",
".",
"__db_filepath",
")",
"if",
"size",
">",
"1000000000",
":",
"size",
"=",
"\"%... | Return the file size of the database as a pretty string. | [
"Return",
"the",
"file",
"size",
"of",
"the",
"database",
"as",
"a",
"pretty",
"string",
"."
] | python | train | 31.142857 |
chrisspen/webarticle2text | webarticle2text/webarticle2text.py | https://github.com/chrisspen/webarticle2text/blob/3c88e948e31aedf1eccfea2106e5848d224771eb/webarticle2text/webarticle2text.py#L477-L595 | def extractFromURL(url,
cache=False,
cacheDir='_cache',
verbose=False,
encoding=None,
filters=None,
userAgent=None,
timeout=5,
blur=5,
ignore_robotstxt=False,
only_mime_types=None,
raw=False):
"""
Extracts text from a URL.
Parameters:
url := string
Re... | [
"def",
"extractFromURL",
"(",
"url",
",",
"cache",
"=",
"False",
",",
"cacheDir",
"=",
"'_cache'",
",",
"verbose",
"=",
"False",
",",
"encoding",
"=",
"None",
",",
"filters",
"=",
"None",
",",
"userAgent",
"=",
"None",
",",
"timeout",
"=",
"5",
",",
... | Extracts text from a URL.
Parameters:
url := string
Remote URL or local filename where HTML will be read.
cache := bool
True=store and retrieve url from cache
False=always retrieve url from the web
cacheDir := str
Directory where cached url contents will be stored.
v... | [
"Extracts",
"text",
"from",
"a",
"URL",
"."
] | python | train | 29.495798 |
mosdef-hub/mbuild | mbuild/compound.py | https://github.com/mosdef-hub/mbuild/blob/dcb80a2becd5d0e6a7e3e7bcb1b59793c46a2dd3/mbuild/compound.py#L311-L327 | def successors(self):
"""Yield Compounds below self in the hierarchy.
Yields
-------
mb.Compound
The next Particle below self in the hierarchy
"""
if not self.children:
return
for part in self.children:
# Parts local to the cu... | [
"def",
"successors",
"(",
"self",
")",
":",
"if",
"not",
"self",
".",
"children",
":",
"return",
"for",
"part",
"in",
"self",
".",
"children",
":",
"# Parts local to the current Compound.",
"yield",
"part",
"# Parts further down the hierarchy.",
"for",
"subpart",
... | Yield Compounds below self in the hierarchy.
Yields
-------
mb.Compound
The next Particle below self in the hierarchy | [
"Yield",
"Compounds",
"below",
"self",
"in",
"the",
"hierarchy",
"."
] | python | train | 27.411765 |
googleads/googleads-python-lib | googleads/common.py | https://github.com/googleads/googleads-python-lib/blob/aa3b1b474b0f9789ca55ca46f4b2b57aeae38874/googleads/common.py#L1331-L1358 | def _CreateComplexTypeFromData(
self, elem_type, type_is_override, data, set_type_attrs):
"""Initialize a SOAP element with specific data.
Args:
elem_type: The type of the element to create.
type_is_override: A boolean specifying if the type is being overridden.
data: The data to hydrat... | [
"def",
"_CreateComplexTypeFromData",
"(",
"self",
",",
"elem_type",
",",
"type_is_override",
",",
"data",
",",
"set_type_attrs",
")",
":",
"elem_arguments",
"=",
"dict",
"(",
"elem_type",
".",
"elements",
")",
"# A post order traversal of the original data, need to instan... | Initialize a SOAP element with specific data.
Args:
elem_type: The type of the element to create.
type_is_override: A boolean specifying if the type is being overridden.
data: The data to hydrate the type with.
set_type_attrs: A boolean indicating whether or not attributes that end
... | [
"Initialize",
"a",
"SOAP",
"element",
"with",
"specific",
"data",
"."
] | python | train | 43.75 |
apple/turicreate | src/unity/python/turicreate/toolkits/style_transfer/style_transfer.py | https://github.com/apple/turicreate/blob/74514c3f99e25b46f22c6e02977fe3da69221c2e/src/unity/python/turicreate/toolkits/style_transfer/style_transfer.py#L559-L754 | def stylize(self, images, style=None, verbose=True, max_size=800, batch_size = 4):
"""
Stylize an SFrame of Images given a style index or a list of
styles.
Parameters
----------
images : SFrame | Image
A dataset that has the same content image column that was... | [
"def",
"stylize",
"(",
"self",
",",
"images",
",",
"style",
"=",
"None",
",",
"verbose",
"=",
"True",
",",
"max_size",
"=",
"800",
",",
"batch_size",
"=",
"4",
")",
":",
"if",
"(",
"batch_size",
"<",
"1",
")",
":",
"raise",
"_ToolkitError",
"(",
"\... | Stylize an SFrame of Images given a style index or a list of
styles.
Parameters
----------
images : SFrame | Image
A dataset that has the same content image column that was used
during training.
style : int or list, optional
The selected styl... | [
"Stylize",
"an",
"SFrame",
"of",
"Images",
"given",
"a",
"style",
"index",
"or",
"a",
"list",
"of",
"styles",
"."
] | python | train | 42.795918 |
Titan-C/slaveparticles | slaveparticles/utils/plotter.py | https://github.com/Titan-C/slaveparticles/blob/e4c2f5afb1a7b195517ef2f1b5cc758965036aab/slaveparticles/utils/plotter.py#L67-L73 | def pick_flat_z(data):
"""Generate a 2D array of the quasiparticle weight by only selecting the
first particle data"""
zmes = []
for i in data['zeta']:
zmes.append(i[:, 0])
return np.asarray(zmes) | [
"def",
"pick_flat_z",
"(",
"data",
")",
":",
"zmes",
"=",
"[",
"]",
"for",
"i",
"in",
"data",
"[",
"'zeta'",
"]",
":",
"zmes",
".",
"append",
"(",
"i",
"[",
":",
",",
"0",
"]",
")",
"return",
"np",
".",
"asarray",
"(",
"zmes",
")"
] | Generate a 2D array of the quasiparticle weight by only selecting the
first particle data | [
"Generate",
"a",
"2D",
"array",
"of",
"the",
"quasiparticle",
"weight",
"by",
"only",
"selecting",
"the",
"first",
"particle",
"data"
] | python | train | 31.142857 |
materialsproject/pymatgen | pymatgen/core/structure.py | https://github.com/materialsproject/pymatgen/blob/4ca558cf72f8d5f8a1f21dfdfc0181a971c186da/pymatgen/core/structure.py#L2100-L2115 | def get_covalent_bonds(self, tol=0.2):
"""
Determines the covalent bonds in a molecule.
Args:
tol (float): The tol to determine bonds in a structure. See
CovalentBond.is_bonded.
Returns:
List of bonds
"""
bonds = []
for si... | [
"def",
"get_covalent_bonds",
"(",
"self",
",",
"tol",
"=",
"0.2",
")",
":",
"bonds",
"=",
"[",
"]",
"for",
"site1",
",",
"site2",
"in",
"itertools",
".",
"combinations",
"(",
"self",
".",
"_sites",
",",
"2",
")",
":",
"if",
"CovalentBond",
".",
"is_b... | Determines the covalent bonds in a molecule.
Args:
tol (float): The tol to determine bonds in a structure. See
CovalentBond.is_bonded.
Returns:
List of bonds | [
"Determines",
"the",
"covalent",
"bonds",
"in",
"a",
"molecule",
"."
] | python | train | 30.875 |
mitsei/dlkit | dlkit/records/assessment/mecqbank/mecqbank_base_records.py | https://github.com/mitsei/dlkit/blob/445f968a175d61c8d92c0f617a3c17dc1dc7c584/dlkit/records/assessment/mecqbank/mecqbank_base_records.py#L137-L154 | def clear_preview(self):
"""stub"""
try:
rm = self.my_osid_object._get_provider_manager('REPOSITORY')
except AttributeError:
rm = self.my_osid_object_form._get_provider_manager('REPOSITORY')
try:
aas = rm.get_asset_admin_session_for_repository(
... | [
"def",
"clear_preview",
"(",
"self",
")",
":",
"try",
":",
"rm",
"=",
"self",
".",
"my_osid_object",
".",
"_get_provider_manager",
"(",
"'REPOSITORY'",
")",
"except",
"AttributeError",
":",
"rm",
"=",
"self",
".",
"my_osid_object_form",
".",
"_get_provider_manag... | stub | [
"stub"
] | python | train | 46.833333 |
DomBennett/TaxonNamesResolver | taxon_names_resolver/manip_tools.py | https://github.com/DomBennett/TaxonNamesResolver/blob/a2556cc0f8b7442d83990715c92fdf6f787e1f41/taxon_names_resolver/manip_tools.py#L171-L188 | def _contextualise(self):
'''Determine contextual idents (cidents)'''
# loop through hierarchy identifying unique lineages
# TODO: gain other contextual information, not just ident
deja_vues = []
for rank in reversed(self.taxonomy):
# return named clades -- '' are ign... | [
"def",
"_contextualise",
"(",
"self",
")",
":",
"# loop through hierarchy identifying unique lineages",
"# TODO: gain other contextual information, not just ident",
"deja_vues",
"=",
"[",
"]",
"for",
"rank",
"in",
"reversed",
"(",
"self",
".",
"taxonomy",
")",
":",
"# ret... | Determine contextual idents (cidents) | [
"Determine",
"contextual",
"idents",
"(",
"cidents",
")"
] | python | train | 47.833333 |
Projectplace/basepage | basepage/base_page.py | https://github.com/Projectplace/basepage/blob/735476877eb100db0981590a6d12140e68652167/basepage/base_page.py#L613-L629 | def close_hover(self, element, use_js=False):
"""
Close hover by moving to a set offset "away" from the element being hovered.
:param element: element that triggered the hover to open
:param use_js: use javascript to close hover
:return: None
"""
try:
... | [
"def",
"close_hover",
"(",
"self",
",",
"element",
",",
"use_js",
"=",
"False",
")",
":",
"try",
":",
"if",
"use_js",
":",
"self",
".",
"_js_hover",
"(",
"'mouseout'",
",",
"element",
")",
"else",
":",
"actions",
"=",
"ActionChains",
"(",
"self",
".",
... | Close hover by moving to a set offset "away" from the element being hovered.
:param element: element that triggered the hover to open
:param use_js: use javascript to close hover
:return: None | [
"Close",
"hover",
"by",
"moving",
"to",
"a",
"set",
"offset",
"away",
"from",
"the",
"element",
"being",
"hovered",
"."
] | python | train | 38.529412 |
kolypto/py-flask-jsontools | flask_jsontools/formatting.py | https://github.com/kolypto/py-flask-jsontools/blob/1abee2d40e6db262e43f0c534e90faaa9b26246a/flask_jsontools/formatting.py#L31-L43 | def get_entity_propnames(entity):
""" Get entity property names
:param entity: Entity
:type entity: sqlalchemy.ext.declarative.api.DeclarativeMeta
:returns: Set of entity property names
:rtype: set
"""
ins = entity if isinstance(entity, InstanceState) else inspect(entity)
... | [
"def",
"get_entity_propnames",
"(",
"entity",
")",
":",
"ins",
"=",
"entity",
"if",
"isinstance",
"(",
"entity",
",",
"InstanceState",
")",
"else",
"inspect",
"(",
"entity",
")",
"return",
"set",
"(",
"ins",
".",
"mapper",
".",
"column_attrs",
".",
"keys",... | Get entity property names
:param entity: Entity
:type entity: sqlalchemy.ext.declarative.api.DeclarativeMeta
:returns: Set of entity property names
:rtype: set | [
"Get",
"entity",
"property",
"names"
] | python | train | 33.538462 |
Skype4Py/Skype4Py | Skype4Py/skype.py | https://github.com/Skype4Py/Skype4Py/blob/c48d83f7034109fe46315d45a066126002c6e0d4/Skype4Py/skype.py#L569-L586 | def CreateGroup(self, GroupName):
"""Creates a custom contact group.
:Parameters:
GroupName : unicode
Group name.
:return: A group object.
:rtype: `Group`
:see: `DeleteGroup`
"""
groups = self.CustomGroups
self._DoCommand('CREATE G... | [
"def",
"CreateGroup",
"(",
"self",
",",
"GroupName",
")",
":",
"groups",
"=",
"self",
".",
"CustomGroups",
"self",
".",
"_DoCommand",
"(",
"'CREATE GROUP %s'",
"%",
"tounicode",
"(",
"GroupName",
")",
")",
"for",
"g",
"in",
"self",
".",
"CustomGroups",
":"... | Creates a custom contact group.
:Parameters:
GroupName : unicode
Group name.
:return: A group object.
:rtype: `Group`
:see: `DeleteGroup` | [
"Creates",
"a",
"custom",
"contact",
"group",
"."
] | python | train | 28.444444 |
openxc/openxc-python | openxc/vehicle.py | https://github.com/openxc/openxc-python/blob/4becb4a6310bd658c125195ef6ffea4deaf7d7e7/openxc/vehicle.py#L78-L89 | def add_sink(self, sink):
"""Add a vehicle data sink to the instance. ``sink`` should be a
sub-class of ``DataSink`` or at least have a ``receive(message,
**kwargs)`` method.
The sink will be started if it is startable. (i.e. it has a ``start()``
method).
"""
if ... | [
"def",
"add_sink",
"(",
"self",
",",
"sink",
")",
":",
"if",
"sink",
"is",
"not",
"None",
":",
"self",
".",
"sinks",
".",
"add",
"(",
"sink",
")",
"if",
"hasattr",
"(",
"sink",
",",
"'start'",
")",
":",
"sink",
".",
"start",
"(",
")"
] | Add a vehicle data sink to the instance. ``sink`` should be a
sub-class of ``DataSink`` or at least have a ``receive(message,
**kwargs)`` method.
The sink will be started if it is startable. (i.e. it has a ``start()``
method). | [
"Add",
"a",
"vehicle",
"data",
"sink",
"to",
"the",
"instance",
".",
"sink",
"should",
"be",
"a",
"sub",
"-",
"class",
"of",
"DataSink",
"or",
"at",
"least",
"have",
"a",
"receive",
"(",
"message",
"**",
"kwargs",
")",
"method",
"."
] | python | train | 35.583333 |
saltstack/salt | salt/states/virtualenv_mod.py | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/states/virtualenv_mod.py#L33-L337 | def managed(name,
venv_bin=None,
requirements=None,
system_site_packages=False,
distribute=False,
use_wheel=False,
clear=False,
python=None,
extra_search_dir=None,
never_download=None,
prompt=None,
... | [
"def",
"managed",
"(",
"name",
",",
"venv_bin",
"=",
"None",
",",
"requirements",
"=",
"None",
",",
"system_site_packages",
"=",
"False",
",",
"distribute",
"=",
"False",
",",
"use_wheel",
"=",
"False",
",",
"clear",
"=",
"False",
",",
"python",
"=",
"No... | Create a virtualenv and optionally manage it with pip
name
Path to the virtualenv.
venv_bin: virtualenv
The name (and optionally path) of the virtualenv command. This can also
be set globally in the minion config file as ``virtualenv.venv_bin``.
requirements: None
Path to ... | [
"Create",
"a",
"virtualenv",
"and",
"optionally",
"manage",
"it",
"with",
"pip"
] | python | train | 35.540984 |
TheClimateCorporation/properscoring | properscoring/_crps.py | https://github.com/TheClimateCorporation/properscoring/blob/1ca13dcbc1abf53d07474b74fbe3567fd4045668/properscoring/_crps.py#L97-L146 | def _crps_cdf_single(x, cdf_or_dist, xmin=None, xmax=None, tol=1e-6):
"""
See crps_cdf for docs.
"""
# TODO: this function is pretty slow. Look for clever ways to speed it up.
# allow for directly passing in scipy.stats distribution objects.
cdf = getattr(cdf_or_dist, 'cdf', cdf_or_dist)
a... | [
"def",
"_crps_cdf_single",
"(",
"x",
",",
"cdf_or_dist",
",",
"xmin",
"=",
"None",
",",
"xmax",
"=",
"None",
",",
"tol",
"=",
"1e-6",
")",
":",
"# TODO: this function is pretty slow. Look for clever ways to speed it up.",
"# allow for directly passing in scipy.stats distri... | See crps_cdf for docs. | [
"See",
"crps_cdf",
"for",
"docs",
"."
] | python | train | 45.86 |
jrmontag/STLDecompose | stldecompose/forecast_funcs.py | https://github.com/jrmontag/STLDecompose/blob/f53f89dab4b13618c1cf13f88a01e3e3dc8abdec/stldecompose/forecast_funcs.py#L41-L58 | def mean(data, n=3, **kwargs):
"""The mean forecast for the next point is the mean value of the previous ``n`` points in
the series.
Args:
data (np.array): Observed data, presumed to be ordered in time.
n (int): period over which to calculate the mean
Returns:
float: a single... | [
"def",
"mean",
"(",
"data",
",",
"n",
"=",
"3",
",",
"*",
"*",
"kwargs",
")",
":",
"# don't start averaging until we've seen n points",
"if",
"len",
"(",
"data",
"[",
"-",
"n",
":",
"]",
")",
"<",
"n",
":",
"forecast",
"=",
"np",
".",
"nan",
"else",
... | The mean forecast for the next point is the mean value of the previous ``n`` points in
the series.
Args:
data (np.array): Observed data, presumed to be ordered in time.
n (int): period over which to calculate the mean
Returns:
float: a single-valued forecast for the next value in... | [
"The",
"mean",
"forecast",
"for",
"the",
"next",
"point",
"is",
"the",
"mean",
"value",
"of",
"the",
"previous",
"n",
"points",
"in",
"the",
"series",
"."
] | python | train | 32.5 |
awslabs/aws-greengrass-group-setup | gg_group_setup/cmd.py | https://github.com/awslabs/aws-greengrass-group-setup/blob/06189ceccb794fedf80e0e7649938c18792e16c9/gg_group_setup/cmd.py#L679-L733 | def create_core(self, thing_name, config_file, region=None,
cert_dir=None, account_id=None,
policy_name='ggc-default-policy', profile_name=None):
"""
Using the `thing_name` value, creates a Thing in AWS IoT, attaches and
downloads new keys & certs to the c... | [
"def",
"create_core",
"(",
"self",
",",
"thing_name",
",",
"config_file",
",",
"region",
"=",
"None",
",",
"cert_dir",
"=",
"None",
",",
"account_id",
"=",
"None",
",",
"policy_name",
"=",
"'ggc-default-policy'",
",",
"profile_name",
"=",
"None",
")",
":",
... | Using the `thing_name` value, creates a Thing in AWS IoT, attaches and
downloads new keys & certs to the certificate directory, then records
the created information in the local config file for inclusion in the
Greengrass Group as a Greengrass Core.
:param thing_name: the name of the th... | [
"Using",
"the",
"thing_name",
"value",
"creates",
"a",
"Thing",
"in",
"AWS",
"IoT",
"attaches",
"and",
"downloads",
"new",
"keys",
"&",
"certs",
"to",
"the",
"certificate",
"directory",
"then",
"records",
"the",
"created",
"information",
"in",
"the",
"local",
... | python | train | 45.309091 |
elkiwy/paynter | paynter/layer.py | https://github.com/elkiwy/paynter/blob/f73cb5bb010a6b32ee41640a50396ed0bae8d496/paynter/layer.py#L65-L78 | def showLayer(self, title='', debugText=''):
"""
Shows the single layer.
:param title: A string with the title of the window where to render the image.
:param debugText: A string with some text to render over the image.
:rtype: Nothing.
"""
img = PIL.Image.fromarray(self.data, 'RGBA')
if debugText!='... | [
"def",
"showLayer",
"(",
"self",
",",
"title",
"=",
"''",
",",
"debugText",
"=",
"''",
")",
":",
"img",
"=",
"PIL",
".",
"Image",
".",
"fromarray",
"(",
"self",
".",
"data",
",",
"'RGBA'",
")",
"if",
"debugText",
"!=",
"''",
":",
"draw",
"=",
"PI... | Shows the single layer.
:param title: A string with the title of the window where to render the image.
:param debugText: A string with some text to render over the image.
:rtype: Nothing. | [
"Shows",
"the",
"single",
"layer",
".",
":",
"param",
"title",
":",
"A",
"string",
"with",
"the",
"title",
"of",
"the",
"window",
"where",
"to",
"render",
"the",
"image",
".",
":",
"param",
"debugText",
":",
"A",
"string",
"with",
"some",
"text",
"to",... | python | train | 34.357143 |
econ-ark/HARK | HARK/ConsumptionSaving/ConsPrefShockModel.py | https://github.com/econ-ark/HARK/blob/3d184153a189e618a87c9540df1cd12044039cc5/HARK/ConsumptionSaving/ConsPrefShockModel.py#L395-L457 | def solveConsPrefShock(solution_next,IncomeDstn,PrefShkDstn,
LivPrb,DiscFac,CRRA,Rfree,PermGroFac,BoroCnstArt,
aXtraGrid,vFuncBool,CubicBool):
'''
Solves a single period of a consumption-saving model with preference shocks
to marginal utility. Problem is solved... | [
"def",
"solveConsPrefShock",
"(",
"solution_next",
",",
"IncomeDstn",
",",
"PrefShkDstn",
",",
"LivPrb",
",",
"DiscFac",
",",
"CRRA",
",",
"Rfree",
",",
"PermGroFac",
",",
"BoroCnstArt",
",",
"aXtraGrid",
",",
"vFuncBool",
",",
"CubicBool",
")",
":",
"solver",... | Solves a single period of a consumption-saving model with preference shocks
to marginal utility. Problem is solved using the method of endogenous gridpoints.
Parameters
----------
solution_next : ConsumerSolution
The solution to the succeeding one period problem.
IncomeDstn : [np.array]
... | [
"Solves",
"a",
"single",
"period",
"of",
"a",
"consumption",
"-",
"saving",
"model",
"with",
"preference",
"shocks",
"to",
"marginal",
"utility",
".",
"Problem",
"is",
"solved",
"using",
"the",
"method",
"of",
"endogenous",
"gridpoints",
"."
] | python | train | 47.444444 |
JarryShaw/PyPCAPKit | src/foundation/extraction.py | https://github.com/JarryShaw/PyPCAPKit/blob/c7f0da9aebc2cf210bf8f8b912f7d3cbb98ca10e/src/foundation/extraction.py#L876-L914 | def _pyshark_read_frame(self):
"""Read frames."""
from pcapkit.toolkit.pyshark import packet2dict, tcp_traceflow
# fetch PyShark packet
packet = next(self._extmp)
# def _pyshark_packet2chain(packet):
# """Fetch PyShark packet protocol chain."""
# return ... | [
"def",
"_pyshark_read_frame",
"(",
"self",
")",
":",
"from",
"pcapkit",
".",
"toolkit",
".",
"pyshark",
"import",
"packet2dict",
",",
"tcp_traceflow",
"# fetch PyShark packet",
"packet",
"=",
"next",
"(",
"self",
".",
"_extmp",
")",
"# def _pyshark_packet2chain(pack... | Read frames. | [
"Read",
"frames",
"."
] | python | train | 31.051282 |
daler/gffutils | gffutils/pybedtools_integration.py | https://github.com/daler/gffutils/blob/6f7f547cad898738a1bd0a999fd68ba68db2c524/gffutils/pybedtools_integration.py#L12-L23 | def to_bedtool(iterator):
"""
Convert any iterator into a pybedtools.BedTool object.
Note that the supplied iterator is not consumed by this function. To save
to a temp file or to a known location, use the `.saveas()` method of the
returned BedTool object.
"""
def gen():
for i in it... | [
"def",
"to_bedtool",
"(",
"iterator",
")",
":",
"def",
"gen",
"(",
")",
":",
"for",
"i",
"in",
"iterator",
":",
"yield",
"helpers",
".",
"asinterval",
"(",
"i",
")",
"return",
"pybedtools",
".",
"BedTool",
"(",
"gen",
"(",
")",
")"
] | Convert any iterator into a pybedtools.BedTool object.
Note that the supplied iterator is not consumed by this function. To save
to a temp file or to a known location, use the `.saveas()` method of the
returned BedTool object. | [
"Convert",
"any",
"iterator",
"into",
"a",
"pybedtools",
".",
"BedTool",
"object",
"."
] | python | train | 32.75 |
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#L72-L122 | def get_next_step(self):
"""Find the proper step when user clicks the Next button.
:returns: The step to be switched to
:rtype: WizardStep
"""
layer_purpose = self.parent.step_kw_purpose.selected_purpose()
if layer_purpose != layer_purpose_aggregation:
subcat... | [
"def",
"get_next_step",
"(",
"self",
")",
":",
"layer_purpose",
"=",
"self",
".",
"parent",
".",
"step_kw_purpose",
".",
"selected_purpose",
"(",
")",
"if",
"layer_purpose",
"!=",
"layer_purpose_aggregation",
":",
"subcategory",
"=",
"self",
".",
"parent",
".",
... | Find the proper step when user clicks the Next button.
:returns: The step to be switched to
:rtype: WizardStep | [
"Find",
"the",
"proper",
"step",
"when",
"user",
"clicks",
"the",
"Next",
"button",
"."
] | python | train | 40.470588 |
kieferk/dfply | dfply/summary_functions.py | https://github.com/kieferk/dfply/blob/6a858f066602735a90f8b6b85106bc39ceadc282/dfply/summary_functions.py#L64-L82 | def nth(series, n, order_by=None):
"""
Returns the nth value of a series.
Args:
series (pandas.Series): column to summarize.
n (integer): position of desired value. Returns `NaN` if out of range.
Kwargs:
order_by: a pandas.Series or list of series (can be symbolic) to order
... | [
"def",
"nth",
"(",
"series",
",",
"n",
",",
"order_by",
"=",
"None",
")",
":",
"if",
"order_by",
"is",
"not",
"None",
":",
"series",
"=",
"order_series_by",
"(",
"series",
",",
"order_by",
")",
"try",
":",
"return",
"series",
".",
"iloc",
"[",
"n",
... | Returns the nth value of a series.
Args:
series (pandas.Series): column to summarize.
n (integer): position of desired value. Returns `NaN` if out of range.
Kwargs:
order_by: a pandas.Series or list of series (can be symbolic) to order
the input series by before summarizati... | [
"Returns",
"the",
"nth",
"value",
"of",
"a",
"series",
"."
] | python | train | 27.052632 |
obulpathi/cdn-fastly-python | fastly/__init__.py | https://github.com/obulpathi/cdn-fastly-python/blob/db2564b047e8af4bce72c3b88d6c27d3d0291425/fastly/__init__.py#L315-L318 | def list_customer_users(self, customer_id):
"""List all users from a specified customer id."""
content = self._fetch("/customer/users/%s" % customer_id)
return map(lambda x: FastlyUser(self, x), content) | [
"def",
"list_customer_users",
"(",
"self",
",",
"customer_id",
")",
":",
"content",
"=",
"self",
".",
"_fetch",
"(",
"\"/customer/users/%s\"",
"%",
"customer_id",
")",
"return",
"map",
"(",
"lambda",
"x",
":",
"FastlyUser",
"(",
"self",
",",
"x",
")",
",",... | List all users from a specified customer id. | [
"List",
"all",
"users",
"from",
"a",
"specified",
"customer",
"id",
"."
] | python | train | 51.5 |
Iotic-Labs/py-IoticAgent | src/IoticAgent/IOT/Thing.py | https://github.com/Iotic-Labs/py-IoticAgent/blob/893e8582ad1dacfe32dfc0ee89452bbd6f57d28d/src/IoticAgent/IOT/Thing.py#L380-L417 | def create_control(self, pid, callback, callback_parsed=None):
"""Create a control for this Thing with a local point id (pid) and a control request feedback
Returns a new [Control](Point.m.html#IoticAgent.IOT.Point.Control) object
or the existing one if the Control already exists
Raise... | [
"def",
"create_control",
"(",
"self",
",",
"pid",
",",
"callback",
",",
"callback_parsed",
"=",
"None",
")",
":",
"logger",
".",
"info",
"(",
"\"create_control(pid=\\\"%s\\\", control_cb=%s) [lid=%s]\"",
",",
"pid",
",",
"callback",
",",
"self",
".",
"__lid",
")... | Create a control for this Thing with a local point id (pid) and a control request feedback
Returns a new [Control](Point.m.html#IoticAgent.IOT.Point.Control) object
or the existing one if the Control already exists
Raises [IOTException](./Exceptions.m.html#IoticAgent.IOT.Exceptions.IOTExceptio... | [
"Create",
"a",
"control",
"for",
"this",
"Thing",
"with",
"a",
"local",
"point",
"id",
"(",
"pid",
")",
"and",
"a",
"control",
"request",
"feedback"
] | python | train | 60.052632 |
honzajavorek/redis-collections | redis_collections/sortedsets.py | https://github.com/honzajavorek/redis-collections/blob/07ca8efe88fb128f7dc7319dfa6a26cd39b3776b/redis_collections/sortedsets.py#L59-L64 | def discard_member(self, member, pipe=None):
"""
Remove *member* from the collection, unconditionally.
"""
pipe = self.redis if pipe is None else pipe
pipe.zrem(self.key, self._pickle(member)) | [
"def",
"discard_member",
"(",
"self",
",",
"member",
",",
"pipe",
"=",
"None",
")",
":",
"pipe",
"=",
"self",
".",
"redis",
"if",
"pipe",
"is",
"None",
"else",
"pipe",
"pipe",
".",
"zrem",
"(",
"self",
".",
"key",
",",
"self",
".",
"_pickle",
"(",
... | Remove *member* from the collection, unconditionally. | [
"Remove",
"*",
"member",
"*",
"from",
"the",
"collection",
"unconditionally",
"."
] | python | train | 37.833333 |
postmanlabs/httpbin | httpbin/helpers.py | https://github.com/postmanlabs/httpbin/blob/f8ec666b4d1b654e4ff6aedd356f510dcac09f83/httpbin/helpers.py#L290-L308 | def HA2(credentials, request, algorithm):
"""Create HA2 md5 hash
If the qop directive's value is "auth" or is unspecified, then HA2:
HA2 = md5(A2) = MD5(method:digestURI)
If the qop directive's value is "auth-int" , then HA2 is
HA2 = md5(A2) = MD5(method:digestURI:MD5(entityBody))
"""
... | [
"def",
"HA2",
"(",
"credentials",
",",
"request",
",",
"algorithm",
")",
":",
"if",
"credentials",
".",
"get",
"(",
"\"qop\"",
")",
"==",
"\"auth\"",
"or",
"credentials",
".",
"get",
"(",
"'qop'",
")",
"is",
"None",
":",
"return",
"H",
"(",
"b\":\"",
... | Create HA2 md5 hash
If the qop directive's value is "auth" or is unspecified, then HA2:
HA2 = md5(A2) = MD5(method:digestURI)
If the qop directive's value is "auth-int" , then HA2 is
HA2 = md5(A2) = MD5(method:digestURI:MD5(entityBody)) | [
"Create",
"HA2",
"md5",
"hash"
] | python | train | 47.210526 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.