repo stringlengths 7 54 | path stringlengths 4 192 | url stringlengths 87 284 | code stringlengths 78 104k | code_tokens list | docstring stringlengths 1 46.9k | docstring_tokens list | language stringclasses 1
value | partition stringclasses 3
values |
|---|---|---|---|---|---|---|---|---|
SBRG/ssbio | ssbio/protein/sequence/properties/scratch.py | https://github.com/SBRG/ssbio/blob/e9449e64ffc1a1f5ad07e5849aa12a650095f8a2/ssbio/protein/sequence/properties/scratch.py#L106-L109 | def sspro8_results(self):
"""Parse the SSpro8 output file and return a dict of secondary structure compositions.
"""
return ssbio.protein.sequence.utils.fasta.load_fasta_file_as_dict_of_seqs(self.out_sspro8) | [
"def",
"sspro8_results",
"(",
"self",
")",
":",
"return",
"ssbio",
".",
"protein",
".",
"sequence",
".",
"utils",
".",
"fasta",
".",
"load_fasta_file_as_dict_of_seqs",
"(",
"self",
".",
"out_sspro8",
")"
] | Parse the SSpro8 output file and return a dict of secondary structure compositions. | [
"Parse",
"the",
"SSpro8",
"output",
"file",
"and",
"return",
"a",
"dict",
"of",
"secondary",
"structure",
"compositions",
"."
] | python | train |
postlund/pyatv | scripts/autogen_protobuf_extensions.py | https://github.com/postlund/pyatv/blob/655dfcda4e2f9d1c501540e18da4f480d8bf0e70/scripts/autogen_protobuf_extensions.py#L54-L83 | def extract_message_info():
"""Get information about all messages of interest."""
base_path = BASE_PACKAGE.replace('.', '/')
filename = os.path.join(base_path, 'ProtocolMessage.proto')
with open(filename, 'r') as file:
types_found = False
for line in file:
stripped = line.l... | [
"def",
"extract_message_info",
"(",
")",
":",
"base_path",
"=",
"BASE_PACKAGE",
".",
"replace",
"(",
"'.'",
",",
"'/'",
")",
"filename",
"=",
"os",
".",
"path",
".",
"join",
"(",
"base_path",
",",
"'ProtocolMessage.proto'",
")",
"with",
"open",
"(",
"filen... | Get information about all messages of interest. | [
"Get",
"information",
"about",
"all",
"messages",
"of",
"interest",
"."
] | python | train |
RLBot/RLBot | src/main/python/rlbot/parsing/custom_config.py | https://github.com/RLBot/RLBot/blob/3f9b6bec8b9baf4dcfff0f6cf3103c8744ac6234/src/main/python/rlbot/parsing/custom_config.py#L167-L181 | def set_value(self, option, value, index=None):
"""
Sets the value on the given option.
:param option: The name of the option as it appears in the config file
:param value: The value that is being applied. If this section is indexed then the
value must be a list (to be applied di... | [
"def",
"set_value",
"(",
"self",
",",
"option",
",",
"value",
",",
"index",
"=",
"None",
")",
":",
"if",
"self",
".",
"is_indexed",
"and",
"index",
"is",
"None",
"and",
"not",
"isinstance",
"(",
"value",
",",
"list",
")",
":",
"raise",
"TypeError",
"... | Sets the value on the given option.
:param option: The name of the option as it appears in the config file
:param value: The value that is being applied. If this section is indexed then the
value must be a list (to be applied directly) or you must supply the index parameter,
which will c... | [
"Sets",
"the",
"value",
"on",
"the",
"given",
"option",
".",
":",
"param",
"option",
":",
"The",
"name",
"of",
"the",
"option",
"as",
"it",
"appears",
"in",
"the",
"config",
"file",
":",
"param",
"value",
":",
"The",
"value",
"that",
"is",
"being",
"... | python | train |
remix/partridge | partridge/gtfs.py | https://github.com/remix/partridge/blob/0ba80fa30035e5e09fd8d7a7bdf1f28b93d53d03/partridge/gtfs.py#L154-L164 | def _convert_types(self, filename: str, df: pd.DataFrame) -> None:
"""
Apply type conversions
"""
if df.empty:
return
converters = self._config.nodes.get(filename, {}).get("converters", {})
for col, converter in converters.items():
if col in df.co... | [
"def",
"_convert_types",
"(",
"self",
",",
"filename",
":",
"str",
",",
"df",
":",
"pd",
".",
"DataFrame",
")",
"->",
"None",
":",
"if",
"df",
".",
"empty",
":",
"return",
"converters",
"=",
"self",
".",
"_config",
".",
"nodes",
".",
"get",
"(",
"f... | Apply type conversions | [
"Apply",
"type",
"conversions"
] | python | train |
legoktm/fab | phabricator/__init__.py | https://github.com/legoktm/fab/blob/29a8aba9671ae661864cbdb24e2ac9b842f41633/phabricator/__init__.py#L78-L99 | def request(self, method, params=None):
"""
Make a request to a method in the phabricator API
:param method: Name of the API method to call
:type method: basestring
:param params: Optional dict of params to pass
:type params: dict
"""
if params is None:
... | [
"def",
"request",
"(",
"self",
",",
"method",
",",
"params",
"=",
"None",
")",
":",
"if",
"params",
"is",
"None",
":",
"params",
"=",
"{",
"}",
"if",
"not",
"self",
".",
"phab_session",
":",
"self",
".",
"connect",
"(",
")",
"url",
"=",
"'%s/api/%s... | Make a request to a method in the phabricator API
:param method: Name of the API method to call
:type method: basestring
:param params: Optional dict of params to pass
:type params: dict | [
"Make",
"a",
"request",
"to",
"a",
"method",
"in",
"the",
"phabricator",
"API",
":",
"param",
"method",
":",
"Name",
"of",
"the",
"API",
"method",
"to",
"call",
":",
"type",
"method",
":",
"basestring",
":",
"param",
"params",
":",
"Optional",
"dict",
... | python | train |
pypa/pipenv | pipenv/project.py | https://github.com/pypa/pipenv/blob/cae8d76c210b9777e90aab76e9c4b0e53bb19cde/pipenv/project.py#L898-L906 | def get_package_name_in_pipfile(self, package_name, dev=False):
"""Get the equivalent package name in pipfile"""
key = "dev-packages" if dev else "packages"
section = self.parsed_pipfile.get(key, {})
package_name = pep423_name(package_name)
for name in section.keys():
... | [
"def",
"get_package_name_in_pipfile",
"(",
"self",
",",
"package_name",
",",
"dev",
"=",
"False",
")",
":",
"key",
"=",
"\"dev-packages\"",
"if",
"dev",
"else",
"\"packages\"",
"section",
"=",
"self",
".",
"parsed_pipfile",
".",
"get",
"(",
"key",
",",
"{",
... | Get the equivalent package name in pipfile | [
"Get",
"the",
"equivalent",
"package",
"name",
"in",
"pipfile"
] | python | train |
cloudtools/troposphere | troposphere/template_generator.py | https://github.com/cloudtools/troposphere/blob/f7ea5591a7c287a843adc9c184d2f56064cfc632/troposphere/template_generator.py#L200-L299 | def _create_instance(self, cls, args, ref=None):
"""
Returns an instance of `cls` with `args` passed as arguments.
Recursively inspects `args` to create nested objects and functions as
necessary.
`cls` will only be considered only if it's an object we track
(i.e.: trop... | [
"def",
"_create_instance",
"(",
"self",
",",
"cls",
",",
"args",
",",
"ref",
"=",
"None",
")",
":",
"if",
"isinstance",
"(",
"cls",
",",
"Sequence",
")",
":",
"if",
"len",
"(",
"cls",
")",
"==",
"1",
":",
"# a list of 1 type means we must provide a list of... | Returns an instance of `cls` with `args` passed as arguments.
Recursively inspects `args` to create nested objects and functions as
necessary.
`cls` will only be considered only if it's an object we track
(i.e.: troposphere objects).
If `cls` has a `props` attribute, nested p... | [
"Returns",
"an",
"instance",
"of",
"cls",
"with",
"args",
"passed",
"as",
"arguments",
"."
] | python | train |
PmagPy/PmagPy | programs/aniso_magic.py | https://github.com/PmagPy/PmagPy/blob/c7984f8809bf40fe112e53dcc311a33293b62d0b/programs/aniso_magic.py#L16-L98 | def main():
"""
NAME
aniso_magic.py
DESCRIPTION
plots anisotropy data with either bootstrap or hext ellipses
SYNTAX
aniso_magic.py [-h] [command line options]
OPTIONS
-h plots help message and quits
-usr USER: set the user name
-f AFILE, specify spec... | [
"def",
"main",
"(",
")",
":",
"args",
"=",
"sys",
".",
"argv",
"if",
"\"-h\"",
"in",
"args",
":",
"print",
"(",
"main",
".",
"__doc__",
")",
"sys",
".",
"exit",
"(",
")",
"verbose",
"=",
"pmagplotlib",
".",
"verbose",
"dir_path",
"=",
"pmag",
".",
... | NAME
aniso_magic.py
DESCRIPTION
plots anisotropy data with either bootstrap or hext ellipses
SYNTAX
aniso_magic.py [-h] [command line options]
OPTIONS
-h plots help message and quits
-usr USER: set the user name
-f AFILE, specify specimens.txt formatted file... | [
"NAME",
"aniso_magic",
".",
"py"
] | python | train |
ambv/retype | retype.py | https://github.com/ambv/retype/blob/03137abd4d9c9845f3cced1006190b5cca64d879/retype.py#L205-L213 | def reapply_all(ast_node, lib2to3_node):
"""Reapplies the typed_ast node into the lib2to3 tree.
Also does post-processing. This is done in reverse order to enable placing
TypeVars and aliases that depend on one another.
"""
late_processing = reapply(ast_node, lib2to3_node)
for lazy_func in reve... | [
"def",
"reapply_all",
"(",
"ast_node",
",",
"lib2to3_node",
")",
":",
"late_processing",
"=",
"reapply",
"(",
"ast_node",
",",
"lib2to3_node",
")",
"for",
"lazy_func",
"in",
"reversed",
"(",
"late_processing",
")",
":",
"lazy_func",
"(",
")"
] | Reapplies the typed_ast node into the lib2to3 tree.
Also does post-processing. This is done in reverse order to enable placing
TypeVars and aliases that depend on one another. | [
"Reapplies",
"the",
"typed_ast",
"node",
"into",
"the",
"lib2to3",
"tree",
"."
] | python | valid |
astropy/regions | regions/_utils/examples.py | https://github.com/astropy/regions/blob/452d962c417e4ff20d1268f99535c6ff89c83437/regions/_utils/examples.py#L223-L229 | def _table_to_bintable(table):
"""Convert `~astropy.table.Table` to `astropy.io.fits.BinTable`."""
data = table.as_array()
header = fits.Header()
header.update(table.meta)
name = table.meta.pop('name', None)
return fits.BinTableHDU(data, header, name=name) | [
"def",
"_table_to_bintable",
"(",
"table",
")",
":",
"data",
"=",
"table",
".",
"as_array",
"(",
")",
"header",
"=",
"fits",
".",
"Header",
"(",
")",
"header",
".",
"update",
"(",
"table",
".",
"meta",
")",
"name",
"=",
"table",
".",
"meta",
".",
"... | Convert `~astropy.table.Table` to `astropy.io.fits.BinTable`. | [
"Convert",
"~astropy",
".",
"table",
".",
"Table",
"to",
"astropy",
".",
"io",
".",
"fits",
".",
"BinTable",
"."
] | python | train |
Alignak-monitoring/alignak | alignak/external_command.py | https://github.com/Alignak-monitoring/alignak/blob/f3c145207e83159b799d3714e4241399c7740a64/alignak/external_command.py#L1787-L1804 | def del_contact_downtime(self, downtime_id):
"""Delete a contact downtime
Format of the line that triggers function call::
DEL_CONTACT_DOWNTIME;<downtime_id>
:param downtime_id: downtime id to delete
:type downtime_id: int
:return: None
"""
for item in s... | [
"def",
"del_contact_downtime",
"(",
"self",
",",
"downtime_id",
")",
":",
"for",
"item",
"in",
"self",
".",
"daemon",
".",
"contacts",
":",
"if",
"downtime_id",
"in",
"item",
".",
"downtimes",
":",
"item",
".",
"downtimes",
"[",
"downtime_id",
"]",
".",
... | Delete a contact downtime
Format of the line that triggers function call::
DEL_CONTACT_DOWNTIME;<downtime_id>
:param downtime_id: downtime id to delete
:type downtime_id: int
:return: None | [
"Delete",
"a",
"contact",
"downtime",
"Format",
"of",
"the",
"line",
"that",
"triggers",
"function",
"call",
"::"
] | python | train |
serkanyersen/underscore.py | src/underscore.py | https://github.com/serkanyersen/underscore.py/blob/07c25c3f0f789536e4ad47aa315faccc0da9602f/src/underscore.py#L1592-L1614 | def makeStatic():
""" Provide static access to underscore class
"""
p = lambda value: inspect.ismethod(value) or inspect.isfunction(value)
for eachMethod in inspect.getmembers(underscore,
predicate=p):
m = eachMethod[0]
... | [
"def",
"makeStatic",
"(",
")",
":",
"p",
"=",
"lambda",
"value",
":",
"inspect",
".",
"ismethod",
"(",
"value",
")",
"or",
"inspect",
".",
"isfunction",
"(",
"value",
")",
"for",
"eachMethod",
"in",
"inspect",
".",
"getmembers",
"(",
"underscore",
",",
... | Provide static access to underscore class | [
"Provide",
"static",
"access",
"to",
"underscore",
"class"
] | python | train |
saltstack/salt | salt/utils/rsax931.py | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/rsax931.py#L150-L165 | def verify(self, signed):
'''
Recover the message (digest) from the signature using the public key
:param str signed: The signature created with the private key
:rtype: str
:return: The message (digest) recovered from the signature, or an empty
string if the decrypti... | [
"def",
"verify",
"(",
"self",
",",
"signed",
")",
":",
"# Allocate a buffer large enough for the signature. Freed by ctypes.",
"buf",
"=",
"create_string_buffer",
"(",
"libcrypto",
".",
"RSA_size",
"(",
"self",
".",
"_rsa",
")",
")",
"signed",
"=",
"salt",
".",
"u... | Recover the message (digest) from the signature using the public key
:param str signed: The signature created with the private key
:rtype: str
:return: The message (digest) recovered from the signature, or an empty
string if the decryption failed | [
"Recover",
"the",
"message",
"(",
"digest",
")",
"from",
"the",
"signature",
"using",
"the",
"public",
"key"
] | python | train |
google/jsonnet | case_studies/micro_fractal/tilegen/mandelbrot_service.py | https://github.com/google/jsonnet/blob/c323f5ce5b8aa663585d23dc0fb94d4b166c6f16/case_studies/micro_fractal/tilegen/mandelbrot_service.py#L66-L104 | def handle_fractal():
"""Get fractal coordinates from query string, call mandelbrot to generate image.
Returns:
The image, wrapped in an HTML response.
"""
if check_etag():
return flask.make_response(), 304
level = int(flask.request.args.get("l", "0"))
x = float(int(flask.requ... | [
"def",
"handle_fractal",
"(",
")",
":",
"if",
"check_etag",
"(",
")",
":",
"return",
"flask",
".",
"make_response",
"(",
")",
",",
"304",
"level",
"=",
"int",
"(",
"flask",
".",
"request",
".",
"args",
".",
"get",
"(",
"\"l\"",
",",
"\"0\"",
")",
"... | Get fractal coordinates from query string, call mandelbrot to generate image.
Returns:
The image, wrapped in an HTML response. | [
"Get",
"fractal",
"coordinates",
"from",
"query",
"string",
"call",
"mandelbrot",
"to",
"generate",
"image",
"."
] | python | train |
ga4gh/ga4gh-server | ga4gh/server/backend.py | https://github.com/ga4gh/ga4gh-server/blob/1aa18922ef136db8604f6f098cb1732cba6f2a76/ga4gh/server/backend.py#L188-L223 | def _readGroupSetsGenerator(self, request, numObjects, getByIndexMethod):
"""
Returns a generator over the results for the specified request, which
is over a set of objects of the specified size. The objects are
returned by call to the specified method, which must take a single
i... | [
"def",
"_readGroupSetsGenerator",
"(",
"self",
",",
"request",
",",
"numObjects",
",",
"getByIndexMethod",
")",
":",
"currentIndex",
"=",
"0",
"if",
"request",
".",
"page_token",
":",
"currentIndex",
",",
"=",
"paging",
".",
"_parsePageToken",
"(",
"request",
... | Returns a generator over the results for the specified request, which
is over a set of objects of the specified size. The objects are
returned by call to the specified method, which must take a single
integer as an argument. The returned generator yields a sequence of
(object, nextPageTo... | [
"Returns",
"a",
"generator",
"over",
"the",
"results",
"for",
"the",
"specified",
"request",
"which",
"is",
"over",
"a",
"set",
"of",
"objects",
"of",
"the",
"specified",
"size",
".",
"The",
"objects",
"are",
"returned",
"by",
"call",
"to",
"the",
"specifi... | python | train |
angr/angr | angr/exploration_techniques/unique.py | https://github.com/angr/angr/blob/4e2f97d56af5419ee73bdb30482c8dd8ff5f3e40/angr/exploration_techniques/unique.py#L78-L88 | def similarity(state_a, state_b):
"""
The (L2) distance between the counts of the state addresses in the history of the path.
:param state_a: The first state to compare
:param state_b: The second state to compare
"""
count_a = Counter(state_a.history.bbl_addrs)
co... | [
"def",
"similarity",
"(",
"state_a",
",",
"state_b",
")",
":",
"count_a",
"=",
"Counter",
"(",
"state_a",
".",
"history",
".",
"bbl_addrs",
")",
"count_b",
"=",
"Counter",
"(",
"state_b",
".",
"history",
".",
"bbl_addrs",
")",
"normal_distance",
"=",
"sum"... | The (L2) distance between the counts of the state addresses in the history of the path.
:param state_a: The first state to compare
:param state_b: The second state to compare | [
"The",
"(",
"L2",
")",
"distance",
"between",
"the",
"counts",
"of",
"the",
"state",
"addresses",
"in",
"the",
"history",
"of",
"the",
"path",
".",
":",
"param",
"state_a",
":",
"The",
"first",
"state",
"to",
"compare",
":",
"param",
"state_b",
":",
"T... | python | train |
spyder-ide/spyder | spyder/plugins/variableexplorer/widgets/collectionseditor.py | https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/plugins/variableexplorer/widgets/collectionseditor.py#L1311-L1314 | def get_len(self, key):
"""Return sequence length"""
data = self.model.get_data()
return len(data[key]) | [
"def",
"get_len",
"(",
"self",
",",
"key",
")",
":",
"data",
"=",
"self",
".",
"model",
".",
"get_data",
"(",
")",
"return",
"len",
"(",
"data",
"[",
"key",
"]",
")"
] | Return sequence length | [
"Return",
"sequence",
"length"
] | python | train |
mitsei/dlkit | dlkit/services/relationship.py | https://github.com/mitsei/dlkit/blob/445f968a175d61c8d92c0f617a3c17dc1dc7c584/dlkit/services/relationship.py#L414-L422 | def get_families(self):
"""Pass through to provider FamilyLookupSession.get_families"""
# Implemented from kitosid template for -
# osid.resource.BinLookupSession.get_bins_template
catalogs = self._get_provider_session('family_lookup_session').get_families()
cat_list = []
... | [
"def",
"get_families",
"(",
"self",
")",
":",
"# Implemented from kitosid template for -",
"# osid.resource.BinLookupSession.get_bins_template",
"catalogs",
"=",
"self",
".",
"_get_provider_session",
"(",
"'family_lookup_session'",
")",
".",
"get_families",
"(",
")",
"cat_lis... | Pass through to provider FamilyLookupSession.get_families | [
"Pass",
"through",
"to",
"provider",
"FamilyLookupSession",
".",
"get_families"
] | python | train |
siku2/Loglette | loglette/parser/__init__.py | https://github.com/siku2/Loglette/blob/d69f99c3ead2bb24f2aa491a61a7f82cb9ca8095/loglette/parser/__init__.py#L23-L41 | def can_handle(self, text: str) -> bool:
"""Check whether this parser can parse the text"""
try:
changelogs = self.split_changelogs(text)
if not changelogs:
return False
for changelog in changelogs:
_header, _changes = self.split_change... | [
"def",
"can_handle",
"(",
"self",
",",
"text",
":",
"str",
")",
"->",
"bool",
":",
"try",
":",
"changelogs",
"=",
"self",
".",
"split_changelogs",
"(",
"text",
")",
"if",
"not",
"changelogs",
":",
"return",
"False",
"for",
"changelog",
"in",
"changelogs"... | Check whether this parser can parse the text | [
"Check",
"whether",
"this",
"parser",
"can",
"parse",
"the",
"text"
] | python | train |
pyQode/pyqode.core | pyqode/core/panels/marker.py | https://github.com/pyQode/pyqode.core/blob/a99ec6cd22d519394f613309412f8329dc4e90cb/pyqode/core/panels/marker.py#L128-L146 | def add_marker(self, marker):
"""
Adds the marker to the panel.
:param marker: Marker to add
:type marker: pyqode.core.modes.Marker
"""
self._markers.append(marker)
doc = self.editor.document()
assert isinstance(doc, QtGui.QTextDocument)
block = d... | [
"def",
"add_marker",
"(",
"self",
",",
"marker",
")",
":",
"self",
".",
"_markers",
".",
"append",
"(",
"marker",
")",
"doc",
"=",
"self",
".",
"editor",
".",
"document",
"(",
")",
"assert",
"isinstance",
"(",
"doc",
",",
"QtGui",
".",
"QTextDocument",... | Adds the marker to the panel.
:param marker: Marker to add
:type marker: pyqode.core.modes.Marker | [
"Adds",
"the",
"marker",
"to",
"the",
"panel",
"."
] | python | train |
gunthercox/ChatterBot | chatterbot/parsing.py | https://github.com/gunthercox/ChatterBot/blob/1a03dcb45cba7bdc24d3db5e750582e0cb1518e2/chatterbot/parsing.py#L540-L554 | def date_from_quarter(base_date, ordinal, year):
"""
Extract date from quarter of a year
"""
interval = 3
month_start = interval * (ordinal - 1)
if month_start < 0:
month_start = 9
month_end = month_start + interval
if month_start == 0:
month_start = 1
return [
... | [
"def",
"date_from_quarter",
"(",
"base_date",
",",
"ordinal",
",",
"year",
")",
":",
"interval",
"=",
"3",
"month_start",
"=",
"interval",
"*",
"(",
"ordinal",
"-",
"1",
")",
"if",
"month_start",
"<",
"0",
":",
"month_start",
"=",
"9",
"month_end",
"=",
... | Extract date from quarter of a year | [
"Extract",
"date",
"from",
"quarter",
"of",
"a",
"year"
] | python | train |
PythonCharmers/python-future | src/future/backports/datetime.py | https://github.com/PythonCharmers/python-future/blob/c423752879acc05eebc29b0bb9909327bd5c7308/src/future/backports/datetime.py#L1245-L1260 | def replace(self, hour=None, minute=None, second=None, microsecond=None,
tzinfo=True):
"""Return a new time with new values for the specified fields."""
if hour is None:
hour = self.hour
if minute is None:
minute = self.minute
if second is None:
... | [
"def",
"replace",
"(",
"self",
",",
"hour",
"=",
"None",
",",
"minute",
"=",
"None",
",",
"second",
"=",
"None",
",",
"microsecond",
"=",
"None",
",",
"tzinfo",
"=",
"True",
")",
":",
"if",
"hour",
"is",
"None",
":",
"hour",
"=",
"self",
".",
"ho... | Return a new time with new values for the specified fields. | [
"Return",
"a",
"new",
"time",
"with",
"new",
"values",
"for",
"the",
"specified",
"fields",
"."
] | python | train |
jaraco/jaraco.path | jaraco/path.py | https://github.com/jaraco/jaraco.path/blob/39e4da09f325382e21b0917b1b5cd027edce8728/jaraco/path.py#L131-L154 | def recursive_glob(root, spec):
"""
Like iglob, but recurse directories
>>> any('path.py' in result for result in recursive_glob('.', '*.py'))
True
>>> all(result.startswith('.') for result in recursive_glob('.', '*.py'))
True
>>> len(list(recursive_glob('.', '*.foo')))
0
"""
specs = (
os... | [
"def",
"recursive_glob",
"(",
"root",
",",
"spec",
")",
":",
"specs",
"=",
"(",
"os",
".",
"path",
".",
"join",
"(",
"dirpath",
",",
"dirname",
",",
"spec",
")",
"for",
"dirpath",
",",
"dirnames",
",",
"filenames",
"in",
"os",
".",
"walk",
"(",
"ro... | Like iglob, but recurse directories
>>> any('path.py' in result for result in recursive_glob('.', '*.py'))
True
>>> all(result.startswith('.') for result in recursive_glob('.', '*.py'))
True
>>> len(list(recursive_glob('.', '*.foo')))
0 | [
"Like",
"iglob",
"but",
"recurse",
"directories",
">>>",
"any",
"(",
"path",
".",
"py",
"in",
"result",
"for",
"result",
"in",
"recursive_glob",
"(",
".",
"*",
".",
"py",
"))",
"True",
">>>",
"all",
"(",
"result",
".",
"startswith",
"(",
".",
")",
"f... | python | valid |
joke2k/faker | faker/providers/ssn/no_NO/__init__.py | https://github.com/joke2k/faker/blob/965824b61132e52d92d1a6ce470396dbbe01c96c/faker/providers/ssn/no_NO/__init__.py#L9-L25 | def checksum(digits, scale):
"""
Calculate checksum of Norwegian personal identity code.
Checksum is calculated with "Module 11" method using a scale.
The digits of the personal code are multiplied by the corresponding
number in the scale and summed;
if remainder of module 11 of the sum is less... | [
"def",
"checksum",
"(",
"digits",
",",
"scale",
")",
":",
"chk_nbr",
"=",
"11",
"-",
"(",
"sum",
"(",
"map",
"(",
"operator",
".",
"mul",
",",
"digits",
",",
"scale",
")",
")",
"%",
"11",
")",
"if",
"chk_nbr",
"==",
"11",
":",
"return",
"0",
"r... | Calculate checksum of Norwegian personal identity code.
Checksum is calculated with "Module 11" method using a scale.
The digits of the personal code are multiplied by the corresponding
number in the scale and summed;
if remainder of module 11 of the sum is less than 10, checksum is the
remainder.
... | [
"Calculate",
"checksum",
"of",
"Norwegian",
"personal",
"identity",
"code",
"."
] | python | train |
bitesofcode/projexui | projexui/widgets/xquerybuilderwidget/xqueryrule.py | https://github.com/bitesofcode/projexui/blob/f18a73bec84df90b034ca69b9deea118dbedfc4d/projexui/widgets/xquerybuilderwidget/xqueryrule.py#L46-L57 | def defineOperator( self, operator, widget = -1 ):
"""
Adds a new operator for this rule. If widget is supplied as -1, then \
a QLineEdit will be used by default.
:param operator | <str>
widget | <subclass of QWidget> || None || -1
"""
... | [
"def",
"defineOperator",
"(",
"self",
",",
"operator",
",",
"widget",
"=",
"-",
"1",
")",
":",
"if",
"(",
"widget",
"==",
"-",
"1",
")",
":",
"widget",
"=",
"QLineEdit",
"self",
".",
"_operators",
"[",
"nativestring",
"(",
"operator",
")",
"]",
"=",
... | Adds a new operator for this rule. If widget is supplied as -1, then \
a QLineEdit will be used by default.
:param operator | <str>
widget | <subclass of QWidget> || None || -1 | [
"Adds",
"a",
"new",
"operator",
"for",
"this",
"rule",
".",
"If",
"widget",
"is",
"supplied",
"as",
"-",
"1",
"then",
"\\",
"a",
"QLineEdit",
"will",
"be",
"used",
"by",
"default",
".",
":",
"param",
"operator",
"|",
"<str",
">",
"widget",
"|",
"<sub... | python | train |
timothydmorton/isochrones | isochrones/starmodel_old.py | https://github.com/timothydmorton/isochrones/blob/d84495573044c66db2fd6b959fe69e370757ea14/isochrones/starmodel_old.py#L1095-L1140 | def load_hdf(cls, filename, path='', name=None):
"""
A class method to load a saved StarModel from an HDF5 file.
File must have been created by a call to :func:`StarModel.save_hdf`.
:param filename:
H5 file to load.
:param path: (optional)
Path within H... | [
"def",
"load_hdf",
"(",
"cls",
",",
"filename",
",",
"path",
"=",
"''",
",",
"name",
"=",
"None",
")",
":",
"store",
"=",
"pd",
".",
"HDFStore",
"(",
"filename",
")",
"try",
":",
"samples",
"=",
"store",
"[",
"'{}/samples'",
".",
"format",
"(",
"pa... | A class method to load a saved StarModel from an HDF5 file.
File must have been created by a call to :func:`StarModel.save_hdf`.
:param filename:
H5 file to load.
:param path: (optional)
Path within HDF file.
:return:
:class:`StarModel` object. | [
"A",
"class",
"method",
"to",
"load",
"a",
"saved",
"StarModel",
"from",
"an",
"HDF5",
"file",
"."
] | python | train |
fastai/fastai | fastai/vision/transform.py | https://github.com/fastai/fastai/blob/9fb84a5cdefe5a766cdb792b8f5d8971737b7e67/fastai/vision/transform.py#L150-L156 | def _crop_default(x, size, row_pct:uniform=0.5, col_pct:uniform=0.5):
"Crop `x` to `size` pixels. `row_pct`,`col_pct` select focal point of crop."
rows,cols = tis2hw(size)
row_pct,col_pct = _minus_epsilon(row_pct,col_pct)
row = int((x.size(1)-rows+1) * row_pct)
col = int((x.size(2)-cols+1) * col_pct... | [
"def",
"_crop_default",
"(",
"x",
",",
"size",
",",
"row_pct",
":",
"uniform",
"=",
"0.5",
",",
"col_pct",
":",
"uniform",
"=",
"0.5",
")",
":",
"rows",
",",
"cols",
"=",
"tis2hw",
"(",
"size",
")",
"row_pct",
",",
"col_pct",
"=",
"_minus_epsilon",
"... | Crop `x` to `size` pixels. `row_pct`,`col_pct` select focal point of crop. | [
"Crop",
"x",
"to",
"size",
"pixels",
".",
"row_pct",
"col_pct",
"select",
"focal",
"point",
"of",
"crop",
"."
] | python | train |
apache/incubator-heron | third_party/python/cpplint/cpplint.py | https://github.com/apache/incubator-heron/blob/ad10325a0febe89ad337e561ebcbe37ec5d9a5ac/third_party/python/cpplint/cpplint.py#L6441-L6446 | def _FilterExcludedFiles(filenames):
"""Filters out files listed in the --exclude command line switch. File paths
in the switch are evaluated relative to the current working directory
"""
exclude_paths = [os.path.abspath(f) for f in _excludes]
return [f for f in filenames if os.path.abspath(f) not in exclude_... | [
"def",
"_FilterExcludedFiles",
"(",
"filenames",
")",
":",
"exclude_paths",
"=",
"[",
"os",
".",
"path",
".",
"abspath",
"(",
"f",
")",
"for",
"f",
"in",
"_excludes",
"]",
"return",
"[",
"f",
"for",
"f",
"in",
"filenames",
"if",
"os",
".",
"path",
".... | Filters out files listed in the --exclude command line switch. File paths
in the switch are evaluated relative to the current working directory | [
"Filters",
"out",
"files",
"listed",
"in",
"the",
"--",
"exclude",
"command",
"line",
"switch",
".",
"File",
"paths",
"in",
"the",
"switch",
"are",
"evaluated",
"relative",
"to",
"the",
"current",
"working",
"directory"
] | python | valid |
ralphje/imagemounter | imagemounter/volume.py | https://github.com/ralphje/imagemounter/blob/86213781c366cad65096447d91f522f0a3fb4b93/imagemounter/volume.py#L667-L734 | def _load_fsstat_data(self, timeout=3):
"""Using :command:`fsstat`, adds some additional information of the volume to the Volume."""
def stats_thread():
try:
cmd = ['fsstat', self.get_raw_path(), '-o', str(self.offset // self.disk.block_size)]
# Setting the ... | [
"def",
"_load_fsstat_data",
"(",
"self",
",",
"timeout",
"=",
"3",
")",
":",
"def",
"stats_thread",
"(",
")",
":",
"try",
":",
"cmd",
"=",
"[",
"'fsstat'",
",",
"self",
".",
"get_raw_path",
"(",
")",
",",
"'-o'",
",",
"str",
"(",
"self",
".",
"offs... | Using :command:`fsstat`, adds some additional information of the volume to the Volume. | [
"Using",
":",
"command",
":",
"fsstat",
"adds",
"some",
"additional",
"information",
"of",
"the",
"volume",
"to",
"the",
"Volume",
"."
] | python | train |
watson-developer-cloud/python-sdk | ibm_watson/assistant_v1.py | https://github.com/watson-developer-cloud/python-sdk/blob/4c2c9df4466fcde88975da9ecd834e6ba95eb353/ibm_watson/assistant_v1.py#L4639-L4678 | def _from_dict(cls, _dict):
"""Initialize a DialogRuntimeResponseGeneric object from a json dictionary."""
args = {}
if 'response_type' in _dict:
args['response_type'] = _dict.get('response_type')
else:
raise ValueError(
'Required property \'respon... | [
"def",
"_from_dict",
"(",
"cls",
",",
"_dict",
")",
":",
"args",
"=",
"{",
"}",
"if",
"'response_type'",
"in",
"_dict",
":",
"args",
"[",
"'response_type'",
"]",
"=",
"_dict",
".",
"get",
"(",
"'response_type'",
")",
"else",
":",
"raise",
"ValueError",
... | Initialize a DialogRuntimeResponseGeneric object from a json dictionary. | [
"Initialize",
"a",
"DialogRuntimeResponseGeneric",
"object",
"from",
"a",
"json",
"dictionary",
"."
] | python | train |
jtwhite79/pyemu | pyemu/pst/pst_handler.py | https://github.com/jtwhite79/pyemu/blob/c504d8e7a4097cec07655a6318d275739bd8148a/pyemu/pst/pst_handler.py#L238-L248 | def nprior(self):
"""number of prior information equations
Returns
-------
nprior : int
the number of prior info equations
"""
self.control_data.nprior = self.prior_information.shape[0]
return self.control_data.nprior | [
"def",
"nprior",
"(",
"self",
")",
":",
"self",
".",
"control_data",
".",
"nprior",
"=",
"self",
".",
"prior_information",
".",
"shape",
"[",
"0",
"]",
"return",
"self",
".",
"control_data",
".",
"nprior"
] | number of prior information equations
Returns
-------
nprior : int
the number of prior info equations | [
"number",
"of",
"prior",
"information",
"equations"
] | python | train |
etcher-be/epab | epab/cmd/_freeze.py | https://github.com/etcher-be/epab/blob/024cde74d058281aa66e6e4b7b71dccbe803b1c1/epab/cmd/_freeze.py#L120-L127 | def freeze(ctx, version: str, clean: bool):
"""
Freeze current package into a single file
"""
if clean:
_clean_spec()
ctx.invoke(epab.cmd.compile_qt_resources)
_freeze(version) | [
"def",
"freeze",
"(",
"ctx",
",",
"version",
":",
"str",
",",
"clean",
":",
"bool",
")",
":",
"if",
"clean",
":",
"_clean_spec",
"(",
")",
"ctx",
".",
"invoke",
"(",
"epab",
".",
"cmd",
".",
"compile_qt_resources",
")",
"_freeze",
"(",
"version",
")"... | Freeze current package into a single file | [
"Freeze",
"current",
"package",
"into",
"a",
"single",
"file"
] | python | train |
gwastro/pycbc | pycbc/inference/sampler/base_mcmc.py | https://github.com/gwastro/pycbc/blob/7a64cdd104d263f1b6ea0b01e6841837d05a4cb3/pycbc/inference/sampler/base_mcmc.py#L385-L427 | def set_p0(self, samples_file=None, prior=None):
"""Sets the initial position of the walkers.
Parameters
----------
samples_file : InferenceFile, optional
If provided, use the last iteration in the given file for the
starting positions.
prior : JointDistr... | [
"def",
"set_p0",
"(",
"self",
",",
"samples_file",
"=",
"None",
",",
"prior",
"=",
"None",
")",
":",
"# if samples are given then use those as initial positions",
"if",
"samples_file",
"is",
"not",
"None",
":",
"with",
"self",
".",
"io",
"(",
"samples_file",
","... | Sets the initial position of the walkers.
Parameters
----------
samples_file : InferenceFile, optional
If provided, use the last iteration in the given file for the
starting positions.
prior : JointDistribution, optional
Use the given prior to set the... | [
"Sets",
"the",
"initial",
"position",
"of",
"the",
"walkers",
"."
] | python | train |
rsenk330/pylibsass | pylibsass/sass.py | https://github.com/rsenk330/pylibsass/blob/f029490db8e4c2178c9564efeeace95bbf8cceff/pylibsass/sass.py#L50-L75 | def _load(self):
"""Loads the libsass library if it isn't already loaded."""
if self.clib is None:
root_path = os.path.normpath(os.path.join(os.path.dirname(os.path.realpath(__file__ )), '..'))
path1 = os.path.join(root_path, 'sass.so')
path2 = os.path.join(root_path,... | [
"def",
"_load",
"(",
"self",
")",
":",
"if",
"self",
".",
"clib",
"is",
"None",
":",
"root_path",
"=",
"os",
".",
"path",
".",
"normpath",
"(",
"os",
".",
"path",
".",
"join",
"(",
"os",
".",
"path",
".",
"dirname",
"(",
"os",
".",
"path",
".",... | Loads the libsass library if it isn't already loaded. | [
"Loads",
"the",
"libsass",
"library",
"if",
"it",
"isn",
"t",
"already",
"loaded",
"."
] | python | train |
OLC-Bioinformatics/ConFindr | confindr_src/confindr.py | https://github.com/OLC-Bioinformatics/ConFindr/blob/4c292617c3f270ebd5ff138cbc5a107f6d01200d/confindr_src/confindr.py#L147-L159 | def extract_rmlst_genes(pair, database, forward_out, reverse_out, threads=12, logfile=None):
"""
Given a pair of reads and an rMLST database, will extract reads that contain sequence from the database.
:param pair: List containing path to forward reads at index 0 and path to reverse reads at index 1.
:p... | [
"def",
"extract_rmlst_genes",
"(",
"pair",
",",
"database",
",",
"forward_out",
",",
"reverse_out",
",",
"threads",
"=",
"12",
",",
"logfile",
"=",
"None",
")",
":",
"out",
",",
"err",
",",
"cmd",
"=",
"bbtools",
".",
"bbduk_bait",
"(",
"database",
",",
... | Given a pair of reads and an rMLST database, will extract reads that contain sequence from the database.
:param pair: List containing path to forward reads at index 0 and path to reverse reads at index 1.
:param database: Path to rMLST database, in FASTA format.
:param forward_out:
:param reverse_out:
... | [
"Given",
"a",
"pair",
"of",
"reads",
"and",
"an",
"rMLST",
"database",
"will",
"extract",
"reads",
"that",
"contain",
"sequence",
"from",
"the",
"database",
".",
":",
"param",
"pair",
":",
"List",
"containing",
"path",
"to",
"forward",
"reads",
"at",
"inde... | python | train |
skyfielders/python-skyfield | skyfield/iokit.py | https://github.com/skyfielders/python-skyfield/blob/51d9e042e06457f6b1f2415296d50a38cb3a300f/skyfield/iokit.py#L338-L369 | def parse_deltat_preds(fileobj):
"""Parse the United States Naval Observatory ``deltat.preds`` file.
The old format supplies a floating point year, the value of Delta T,
and one or two other fields::
2015.75 67.97 0.210 0.02
The new format adds a modified Julian day as ... | [
"def",
"parse_deltat_preds",
"(",
"fileobj",
")",
":",
"lines",
"=",
"iter",
"(",
"fileobj",
")",
"header",
"=",
"next",
"(",
"lines",
")",
"if",
"header",
".",
"startswith",
"(",
"b'YEAR'",
")",
":",
"# Format in use until 2019 February",
"next",
"(",
"line... | Parse the United States Naval Observatory ``deltat.preds`` file.
The old format supplies a floating point year, the value of Delta T,
and one or two other fields::
2015.75 67.97 0.210 0.02
The new format adds a modified Julian day as the first field:
58484.000 2019.00... | [
"Parse",
"the",
"United",
"States",
"Naval",
"Observatory",
"deltat",
".",
"preds",
"file",
"."
] | python | train |
juju/charm-helpers | charmhelpers/contrib/network/ip.py | https://github.com/juju/charm-helpers/blob/aa785c40c3b7a8c69dbfbc7921d6b9f30142e171/charmhelpers/contrib/network/ip.py#L227-L233 | def resolve_network_cidr(ip_address):
'''
Resolves the full address cidr of an ip_address based on
configured network interfaces
'''
netmask = get_netmask_for_address(ip_address)
return str(netaddr.IPNetwork("%s/%s" % (ip_address, netmask)).cidr) | [
"def",
"resolve_network_cidr",
"(",
"ip_address",
")",
":",
"netmask",
"=",
"get_netmask_for_address",
"(",
"ip_address",
")",
"return",
"str",
"(",
"netaddr",
".",
"IPNetwork",
"(",
"\"%s/%s\"",
"%",
"(",
"ip_address",
",",
"netmask",
")",
")",
".",
"cidr",
... | Resolves the full address cidr of an ip_address based on
configured network interfaces | [
"Resolves",
"the",
"full",
"address",
"cidr",
"of",
"an",
"ip_address",
"based",
"on",
"configured",
"network",
"interfaces"
] | python | train |
pypa/pipenv | pipenv/vendor/requirementslib/utils.py | https://github.com/pypa/pipenv/blob/cae8d76c210b9777e90aab76e9c4b0e53bb19cde/pipenv/vendor/requirementslib/utils.py#L409-L458 | def get_path(root, path, default=_UNSET):
"""Retrieve a value from a nested object via a tuple representing the
lookup path.
>>> root = {'a': {'b': {'c': [[1], [2], [3]]}}}
>>> get_path(root, ('a', 'b', 'c', 2, 0))
3
The path format is intentionally consistent with that of
:func:`remap`.
... | [
"def",
"get_path",
"(",
"root",
",",
"path",
",",
"default",
"=",
"_UNSET",
")",
":",
"if",
"isinstance",
"(",
"path",
",",
"six",
".",
"string_types",
")",
":",
"path",
"=",
"path",
".",
"split",
"(",
"\".\"",
")",
"cur",
"=",
"root",
"try",
":",
... | Retrieve a value from a nested object via a tuple representing the
lookup path.
>>> root = {'a': {'b': {'c': [[1], [2], [3]]}}}
>>> get_path(root, ('a', 'b', 'c', 2, 0))
3
The path format is intentionally consistent with that of
:func:`remap`.
One of get_path's chief aims is improved error m... | [
"Retrieve",
"a",
"value",
"from",
"a",
"nested",
"object",
"via",
"a",
"tuple",
"representing",
"the",
"lookup",
"path",
".",
">>>",
"root",
"=",
"{",
"a",
":",
"{",
"b",
":",
"{",
"c",
":",
"[[",
"1",
"]",
"[",
"2",
"]",
"[",
"3",
"]]",
"}}}",... | python | train |
bukun/TorCMS | torcms/script/autocrud/fetch_html_dic.py | https://github.com/bukun/TorCMS/blob/6567c7fe2604a1d646d4570c017840958630ed2b/torcms/script/autocrud/fetch_html_dic.py#L89-L132 | def gen_array_crud():
'''
Return the dictionay of the switcher form XLXS file.
if valud of the column of the row is `1`, it will be added to the array.
'''
if WORK_BOOK:
pass
else:
return False
papa_id = 0
switch_dics = {}
kind_dics = {}
for work_sheet in WORK... | [
"def",
"gen_array_crud",
"(",
")",
":",
"if",
"WORK_BOOK",
":",
"pass",
"else",
":",
"return",
"False",
"papa_id",
"=",
"0",
"switch_dics",
"=",
"{",
"}",
"kind_dics",
"=",
"{",
"}",
"for",
"work_sheet",
"in",
"WORK_BOOK",
":",
"kind_sig",
"=",
"str",
... | Return the dictionay of the switcher form XLXS file.
if valud of the column of the row is `1`, it will be added to the array. | [
"Return",
"the",
"dictionay",
"of",
"the",
"switcher",
"form",
"XLXS",
"file",
".",
"if",
"valud",
"of",
"the",
"column",
"of",
"the",
"row",
"is",
"1",
"it",
"will",
"be",
"added",
"to",
"the",
"array",
"."
] | python | train |
JoelBender/bacpypes | py25/bacpypes/netservice.py | https://github.com/JoelBender/bacpypes/blob/4111b8604a16fa2b7f80d8104a43b9f3e28dfc78/py25/bacpypes/netservice.py#L190-L196 | def process_npdu(self, npdu):
"""Encode NPDUs from the service access point and send them downstream."""
if _debug: NetworkAdapter._debug("process_npdu %r (net=%r)", npdu, self.adapterNet)
pdu = PDU(user_data=npdu.pduUserData)
npdu.encode(pdu)
self.request(pdu) | [
"def",
"process_npdu",
"(",
"self",
",",
"npdu",
")",
":",
"if",
"_debug",
":",
"NetworkAdapter",
".",
"_debug",
"(",
"\"process_npdu %r (net=%r)\"",
",",
"npdu",
",",
"self",
".",
"adapterNet",
")",
"pdu",
"=",
"PDU",
"(",
"user_data",
"=",
"npdu",
".",
... | Encode NPDUs from the service access point and send them downstream. | [
"Encode",
"NPDUs",
"from",
"the",
"service",
"access",
"point",
"and",
"send",
"them",
"downstream",
"."
] | python | train |
saltstack/salt | salt/utils/openstack/nova.py | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/openstack/nova.py#L991-L1005 | def server_list_min(self):
'''
List minimal information about servers
'''
nt_ks = self.compute_conn
ret = {}
for item in nt_ks.servers.list(detailed=False):
try:
ret[item.name] = {
'id': item.id,
'state':... | [
"def",
"server_list_min",
"(",
"self",
")",
":",
"nt_ks",
"=",
"self",
".",
"compute_conn",
"ret",
"=",
"{",
"}",
"for",
"item",
"in",
"nt_ks",
".",
"servers",
".",
"list",
"(",
"detailed",
"=",
"False",
")",
":",
"try",
":",
"ret",
"[",
"item",
".... | List minimal information about servers | [
"List",
"minimal",
"information",
"about",
"servers"
] | python | train |
amperser/proselint | proselint/command_line.py | https://github.com/amperser/proselint/blob/cb619ee4023cc7856f5fb96aec2a33a2c9f1a2e2/proselint/command_line.py#L106-L150 | def proselint(paths=None, version=None, clean=None, debug=None,
output_json=None, time=None, demo=None, compact=None):
"""A CLI for proselint, a linter for prose."""
if time:
click.echo(timing_test())
return
# In debug or clean mode, delete cache & *.pyc files before running.
... | [
"def",
"proselint",
"(",
"paths",
"=",
"None",
",",
"version",
"=",
"None",
",",
"clean",
"=",
"None",
",",
"debug",
"=",
"None",
",",
"output_json",
"=",
"None",
",",
"time",
"=",
"None",
",",
"demo",
"=",
"None",
",",
"compact",
"=",
"None",
")",... | A CLI for proselint, a linter for prose. | [
"A",
"CLI",
"for",
"proselint",
"a",
"linter",
"for",
"prose",
"."
] | python | train |
awslabs/aws-sam-cli | samcli/local/lambda_service/lambda_error_responses.py | https://github.com/awslabs/aws-sam-cli/blob/c05af5e7378c6f05f7d82ad3f0bca17204177db6/samcli/local/lambda_service/lambda_error_responses.py#L158-L179 | def generic_path_not_found(*args):
"""
Creates a Lambda Service Generic PathNotFound Response
Parameters
----------
args list
List of arguments Flask passes to the method
Returns
-------
Flask.Response
A response object representi... | [
"def",
"generic_path_not_found",
"(",
"*",
"args",
")",
":",
"exception_tuple",
"=",
"LambdaErrorResponses",
".",
"PathNotFoundException",
"return",
"BaseLocalService",
".",
"service_response",
"(",
"LambdaErrorResponses",
".",
"_construct_error_response_body",
"(",
"Lambda... | Creates a Lambda Service Generic PathNotFound Response
Parameters
----------
args list
List of arguments Flask passes to the method
Returns
-------
Flask.Response
A response object representing the GenericPathNotFound Error | [
"Creates",
"a",
"Lambda",
"Service",
"Generic",
"PathNotFound",
"Response"
] | python | train |
jorgenschaefer/elpy | elpy/server.py | https://github.com/jorgenschaefer/elpy/blob/ffd982f829b11e53f2be187c7b770423341f29bc/elpy/server.py#L74-L79 | def rpc_get_oneline_docstring(self, filename, source, offset):
"""Get a oneline docstring for the symbol at the offset.
"""
return self._call_backend("rpc_get_oneline_docstring", None, filename,
get_source(source), offset) | [
"def",
"rpc_get_oneline_docstring",
"(",
"self",
",",
"filename",
",",
"source",
",",
"offset",
")",
":",
"return",
"self",
".",
"_call_backend",
"(",
"\"rpc_get_oneline_docstring\"",
",",
"None",
",",
"filename",
",",
"get_source",
"(",
"source",
")",
",",
"o... | Get a oneline docstring for the symbol at the offset. | [
"Get",
"a",
"oneline",
"docstring",
"for",
"the",
"symbol",
"at",
"the",
"offset",
"."
] | python | train |
rueckstiess/mtools | mtools/util/logevent.py | https://github.com/rueckstiess/mtools/blob/a6a22910c3569c0c8a3908660ca218a4557e4249/mtools/util/logevent.py#L626-L685 | def _extract_counters(self):
"""Extract counters like nscanned and nreturned from the logevent."""
# extract counters (if present)
counters = ['nscanned', 'nscannedObjects', 'ntoreturn', 'nreturned',
'ninserted', 'nupdated', 'ndeleted', 'r', 'w', 'numYields',
... | [
"def",
"_extract_counters",
"(",
"self",
")",
":",
"# extract counters (if present)",
"counters",
"=",
"[",
"'nscanned'",
",",
"'nscannedObjects'",
",",
"'ntoreturn'",
",",
"'nreturned'",
",",
"'ninserted'",
",",
"'nupdated'",
",",
"'ndeleted'",
",",
"'r'",
",",
"... | Extract counters like nscanned and nreturned from the logevent. | [
"Extract",
"counters",
"like",
"nscanned",
"and",
"nreturned",
"from",
"the",
"logevent",
"."
] | python | train |
tBaxter/tango-contact-manager | build/lib/contact_manager/models.py | https://github.com/tBaxter/tango-contact-manager/blob/7bd5be326a8db8f438cdefff0fbd14849d0474a5/build/lib/contact_manager/models.py#L239-L244 | def save(self, *args, **kwargs):
"""
Create formatted version of body text.
"""
self.body_formatted = sanetize_text(self.body)
super(Contact, self).save() | [
"def",
"save",
"(",
"self",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"self",
".",
"body_formatted",
"=",
"sanetize_text",
"(",
"self",
".",
"body",
")",
"super",
"(",
"Contact",
",",
"self",
")",
".",
"save",
"(",
")"
] | Create formatted version of body text. | [
"Create",
"formatted",
"version",
"of",
"body",
"text",
"."
] | python | train |
aiogram/aiogram | aiogram/bot/bot.py | https://github.com/aiogram/aiogram/blob/2af930149ce2482547721e2c8755c10307295e48/aiogram/bot/bot.py#L1916-L1948 | async def answer_shipping_query(self, shipping_query_id: base.String, ok: base.Boolean,
shipping_options: typing.Union[typing.List[types.ShippingOption], None] = None,
error_message: typing.Union[base.String, None] = None) -> base.Boolean:
... | [
"async",
"def",
"answer_shipping_query",
"(",
"self",
",",
"shipping_query_id",
":",
"base",
".",
"String",
",",
"ok",
":",
"base",
".",
"Boolean",
",",
"shipping_options",
":",
"typing",
".",
"Union",
"[",
"typing",
".",
"List",
"[",
"types",
".",
"Shippi... | If you sent an invoice requesting a shipping address and the parameter is_flexible was specified,
the Bot API will send an Update with a shipping_query field to the bot.
Source: https://core.telegram.org/bots/api#answershippingquery
:param shipping_query_id: Unique identifier for the query to ... | [
"If",
"you",
"sent",
"an",
"invoice",
"requesting",
"a",
"shipping",
"address",
"and",
"the",
"parameter",
"is_flexible",
"was",
"specified",
"the",
"Bot",
"API",
"will",
"send",
"an",
"Update",
"with",
"a",
"shipping_query",
"field",
"to",
"the",
"bot",
"."... | python | train |
ChargePoint/pydnp3 | examples/master_cmd.py | https://github.com/ChargePoint/pydnp3/blob/5bcd8240d1fc0aa1579e71f2efcab63b4c61c547/examples/master_cmd.py#L68-L71 | def do_chan_log_normal(self, line):
"""Set the channel log level to NORMAL. Command syntax is: chan_log_normal"""
self.application.channel.SetLogFilters(openpal.LogFilters(opendnp3.levels.NORMAL))
print('Channel log filtering level is now: {0}'.format(opendnp3.levels.NORMAL)) | [
"def",
"do_chan_log_normal",
"(",
"self",
",",
"line",
")",
":",
"self",
".",
"application",
".",
"channel",
".",
"SetLogFilters",
"(",
"openpal",
".",
"LogFilters",
"(",
"opendnp3",
".",
"levels",
".",
"NORMAL",
")",
")",
"print",
"(",
"'Channel log filteri... | Set the channel log level to NORMAL. Command syntax is: chan_log_normal | [
"Set",
"the",
"channel",
"log",
"level",
"to",
"NORMAL",
".",
"Command",
"syntax",
"is",
":",
"chan_log_normal"
] | python | valid |
3ll3d00d/vibe | backend/src/analyser/resources/measurement.py | https://github.com/3ll3d00d/vibe/blob/124b029f13ac746723e92cb47e9cb56edd2e54b5/backend/src/analyser/resources/measurement.py#L95-L102 | def _getAbsoluteTime(self, start, delay):
"""
Adds the delay in seconds to the start time.
:param start:
:param delay:
:return: a datetimem for the specified point in time.
"""
return start + datetime.timedelta(days=0, seconds=delay) | [
"def",
"_getAbsoluteTime",
"(",
"self",
",",
"start",
",",
"delay",
")",
":",
"return",
"start",
"+",
"datetime",
".",
"timedelta",
"(",
"days",
"=",
"0",
",",
"seconds",
"=",
"delay",
")"
] | Adds the delay in seconds to the start time.
:param start:
:param delay:
:return: a datetimem for the specified point in time. | [
"Adds",
"the",
"delay",
"in",
"seconds",
"to",
"the",
"start",
"time",
".",
":",
"param",
"start",
":",
":",
"param",
"delay",
":",
":",
"return",
":",
"a",
"datetimem",
"for",
"the",
"specified",
"point",
"in",
"time",
"."
] | python | train |
angr/angr | angr/state_plugins/inspect.py | https://github.com/angr/angr/blob/4e2f97d56af5419ee73bdb30482c8dd8ff5f3e40/angr/state_plugins/inspect.py#L186-L201 | def fire(self, state):
"""
Trigger the breakpoint.
:param state: The state.
"""
if self.action is None or self.action == BP_IPDB:
import ipdb; ipdb.set_trace() #pylint:disable=F0401
elif self.action == BP_IPYTHON:
import IPython
shel... | [
"def",
"fire",
"(",
"self",
",",
"state",
")",
":",
"if",
"self",
".",
"action",
"is",
"None",
"or",
"self",
".",
"action",
"==",
"BP_IPDB",
":",
"import",
"ipdb",
"ipdb",
".",
"set_trace",
"(",
")",
"#pylint:disable=F0401",
"elif",
"self",
".",
"actio... | Trigger the breakpoint.
:param state: The state. | [
"Trigger",
"the",
"breakpoint",
"."
] | python | train |
bwohlberg/sporco | sporco/admm/ccmodmd.py | https://github.com/bwohlberg/sporco/blob/8946a04331106f4e39904fbdf2dc7351900baa04/sporco/admm/ccmodmd.py#L524-L529 | def obfn_g1(self, Y1):
r"""Compute :math:`g_1(\mathbf{y_1})` component of ADMM objective
function.
"""
return np.linalg.norm((self.Pcn(Y1) - Y1)) | [
"def",
"obfn_g1",
"(",
"self",
",",
"Y1",
")",
":",
"return",
"np",
".",
"linalg",
".",
"norm",
"(",
"(",
"self",
".",
"Pcn",
"(",
"Y1",
")",
"-",
"Y1",
")",
")"
] | r"""Compute :math:`g_1(\mathbf{y_1})` component of ADMM objective
function. | [
"r",
"Compute",
":",
"math",
":",
"g_1",
"(",
"\\",
"mathbf",
"{",
"y_1",
"}",
")",
"component",
"of",
"ADMM",
"objective",
"function",
"."
] | python | train |
bwohlberg/sporco | sporco/dictlrn/prlcnscdl.py | https://github.com/bwohlberg/sporco/blob/8946a04331106f4e39904fbdf2dc7351900baa04/sporco/dictlrn/prlcnscdl.py#L727-L739 | def ccmodmd_xstep(k):
"""Do the X step of the ccmod stage. The only parameter is the slice
index `k` and there are no return values; all inputs and outputs are
from and to global variables.
"""
YU0 = mp_D_Y0 - mp_D_U0[k]
YU1 = mp_D_Y1[k] + mp_S[k] - mp_D_U1[k]
b = sl.rfftn(YU0, None, mp_cri... | [
"def",
"ccmodmd_xstep",
"(",
"k",
")",
":",
"YU0",
"=",
"mp_D_Y0",
"-",
"mp_D_U0",
"[",
"k",
"]",
"YU1",
"=",
"mp_D_Y1",
"[",
"k",
"]",
"+",
"mp_S",
"[",
"k",
"]",
"-",
"mp_D_U1",
"[",
"k",
"]",
"b",
"=",
"sl",
".",
"rfftn",
"(",
"YU0",
",",
... | Do the X step of the ccmod stage. The only parameter is the slice
index `k` and there are no return values; all inputs and outputs are
from and to global variables. | [
"Do",
"the",
"X",
"step",
"of",
"the",
"ccmod",
"stage",
".",
"The",
"only",
"parameter",
"is",
"the",
"slice",
"index",
"k",
"and",
"there",
"are",
"no",
"return",
"values",
";",
"all",
"inputs",
"and",
"outputs",
"are",
"from",
"and",
"to",
"global",... | python | train |
gboeing/osmnx | osmnx/utils.py | https://github.com/gboeing/osmnx/blob/be59fd313bcb68af8fc79242c56194f1247e26e2/osmnx/utils.py#L311-L357 | def get_largest_component(G, strongly=False):
"""
Return a subgraph of the largest weakly or strongly connected component
from a directed graph.
Parameters
----------
G : networkx multidigraph
strongly : bool
if True, return the largest strongly instead of weakly connected
c... | [
"def",
"get_largest_component",
"(",
"G",
",",
"strongly",
"=",
"False",
")",
":",
"start_time",
"=",
"time",
".",
"time",
"(",
")",
"original_len",
"=",
"len",
"(",
"list",
"(",
"G",
".",
"nodes",
"(",
")",
")",
")",
"if",
"strongly",
":",
"# if the... | Return a subgraph of the largest weakly or strongly connected component
from a directed graph.
Parameters
----------
G : networkx multidigraph
strongly : bool
if True, return the largest strongly instead of weakly connected
component
Returns
-------
G : networkx multidi... | [
"Return",
"a",
"subgraph",
"of",
"the",
"largest",
"weakly",
"or",
"strongly",
"connected",
"component",
"from",
"a",
"directed",
"graph",
"."
] | python | train |
BerkeleyAutomation/autolab_core | autolab_core/tensor_dataset.py | https://github.com/BerkeleyAutomation/autolab_core/blob/8f3813f6401972868cc5e3981ba1b4382d4418d5/autolab_core/tensor_dataset.py#L421-L425 | def tensor_index(self, datapoint_index):
""" Returns the index of the tensor containing the referenced datapoint. """
if datapoint_index >= self._num_datapoints:
raise ValueError('Datapoint index %d is greater than the number of datapoints (%d)' %(datapoint_index, self._num_datapoints))
... | [
"def",
"tensor_index",
"(",
"self",
",",
"datapoint_index",
")",
":",
"if",
"datapoint_index",
">=",
"self",
".",
"_num_datapoints",
":",
"raise",
"ValueError",
"(",
"'Datapoint index %d is greater than the number of datapoints (%d)'",
"%",
"(",
"datapoint_index",
",",
... | Returns the index of the tensor containing the referenced datapoint. | [
"Returns",
"the",
"index",
"of",
"the",
"tensor",
"containing",
"the",
"referenced",
"datapoint",
"."
] | python | train |
cohorte/cohorte-herald | python/snippets/herald_irc/client.py | https://github.com/cohorte/cohorte-herald/blob/bb3445d0031c8b3abad71e6219cc559b49faa3ee/python/snippets/herald_irc/client.py#L147-L156 | def on_welcome(self, connection, event):
"""
Server welcome: we're connected
"""
# Start the pool
self.__pool.start()
logging.info("! Connected to server '%s': %s",
event.source, event.arguments[0])
connection.join("#cohorte") | [
"def",
"on_welcome",
"(",
"self",
",",
"connection",
",",
"event",
")",
":",
"# Start the pool",
"self",
".",
"__pool",
".",
"start",
"(",
")",
"logging",
".",
"info",
"(",
"\"! Connected to server '%s': %s\"",
",",
"event",
".",
"source",
",",
"event",
".",... | Server welcome: we're connected | [
"Server",
"welcome",
":",
"we",
"re",
"connected"
] | python | train |
b3j0f/utils | b3j0f/utils/property.py | https://github.com/b3j0f/utils/blob/793871b98e90fd1c7ce9ef0dce839cc18fcbc6ff/b3j0f/utils/property.py#L255-L275 | def get_first_property(elt, key, default=None, ctx=None):
"""Get first property related to one input key.
:param elt: first property elt. Not None methods.
:param str key: property key to get.
:param default: default value to return if key does not exist in elt.
properties
:param ctx: elt c... | [
"def",
"get_first_property",
"(",
"elt",
",",
"key",
",",
"default",
"=",
"None",
",",
"ctx",
"=",
"None",
")",
":",
"result",
"=",
"default",
"properties",
"=",
"_get_properties",
"(",
"elt",
",",
"keys",
"=",
"(",
"key",
",",
")",
",",
"ctx",
"=",
... | Get first property related to one input key.
:param elt: first property elt. Not None methods.
:param str key: property key to get.
:param default: default value to return if key does not exist in elt.
properties
:param ctx: elt ctx from where get properties. Equals elt if None. It
allo... | [
"Get",
"first",
"property",
"related",
"to",
"one",
"input",
"key",
"."
] | python | train |
Neurita/boyle | boyle/utils/rcfile.py | https://github.com/Neurita/boyle/blob/2dae7199849395a209c887d5f30506e1de8a9ad9/boyle/utils/rcfile.py#L245-L270 | def get_rcfile_section(app_name, section_name):
""" Return the dictionary containing the rcfile section configuration
variables.
Parameters
----------
section_name: str
Name of the section in the rcfiles.
app_name: str
Name of the application to look for its rcfiles.
Retur... | [
"def",
"get_rcfile_section",
"(",
"app_name",
",",
"section_name",
")",
":",
"try",
":",
"settings",
"=",
"rcfile",
"(",
"app_name",
",",
"section_name",
")",
"except",
"IOError",
":",
"raise",
"except",
":",
"raise",
"KeyError",
"(",
"'Error looking for section... | Return the dictionary containing the rcfile section configuration
variables.
Parameters
----------
section_name: str
Name of the section in the rcfiles.
app_name: str
Name of the application to look for its rcfiles.
Returns
-------
settings: dict
Dict with vari... | [
"Return",
"the",
"dictionary",
"containing",
"the",
"rcfile",
"section",
"configuration",
"variables",
"."
] | python | valid |
sjwood/pydvdid | pydvdid/functions.py | https://github.com/sjwood/pydvdid/blob/03914fb7e24283c445e5af724f9d919b23caaf95/pydvdid/functions.py#L105-L112 | def _convert_timedelta_to_seconds(timedelta):
"""Returns the total seconds calculated from the supplied timedelta.
(Function provided to enable running on Python 2.6 which lacks timedelta.total_seconds()).
"""
days_in_seconds = timedelta.days * 24 * 3600
return int((timedelta.microseconds + (ti... | [
"def",
"_convert_timedelta_to_seconds",
"(",
"timedelta",
")",
":",
"days_in_seconds",
"=",
"timedelta",
".",
"days",
"*",
"24",
"*",
"3600",
"return",
"int",
"(",
"(",
"timedelta",
".",
"microseconds",
"+",
"(",
"timedelta",
".",
"seconds",
"+",
"days_in_seco... | Returns the total seconds calculated from the supplied timedelta.
(Function provided to enable running on Python 2.6 which lacks timedelta.total_seconds()). | [
"Returns",
"the",
"total",
"seconds",
"calculated",
"from",
"the",
"supplied",
"timedelta",
"."
] | python | train |
haizi-zh/scrapy-qiniu | scrapy_qiniu/impl.py | https://github.com/haizi-zh/scrapy-qiniu/blob/9a3dddacd2e665cb3c86308772040946c3b82415/scrapy_qiniu/impl.py#L146-L155 | def get_media_requests(self, item, info):
"""
根据item中的信息, 构造出需要下载的静态资源的Request对象
:param item:
:param info:
:return:
"""
key_generator = item.get(self.QINIU_KEY_GENERATOR_FIELD)
return [Request(x, meta={'qiniu_key_generator': key_generator}) for x in item.... | [
"def",
"get_media_requests",
"(",
"self",
",",
"item",
",",
"info",
")",
":",
"key_generator",
"=",
"item",
".",
"get",
"(",
"self",
".",
"QINIU_KEY_GENERATOR_FIELD",
")",
"return",
"[",
"Request",
"(",
"x",
",",
"meta",
"=",
"{",
"'qiniu_key_generator'",
... | 根据item中的信息, 构造出需要下载的静态资源的Request对象
:param item:
:param info:
:return: | [
"根据item中的信息",
"构造出需要下载的静态资源的Request对象"
] | python | train |
RudolfCardinal/pythonlib | cardinal_pythonlib/sqlalchemy/orm_inspect.py | https://github.com/RudolfCardinal/pythonlib/blob/0b84cb35f38bd7d8723958dae51b480a829b7227/cardinal_pythonlib/sqlalchemy/orm_inspect.py#L291-L382 | def rewrite_relationships(oldobj: object,
newobj: object,
objmap: Dict[object, object],
debug: bool = False,
skip_table_names: List[str] = None) -> None:
"""
A utility function only.
Used in copying objec... | [
"def",
"rewrite_relationships",
"(",
"oldobj",
":",
"object",
",",
"newobj",
":",
"object",
",",
"objmap",
":",
"Dict",
"[",
"object",
",",
"object",
"]",
",",
"debug",
":",
"bool",
"=",
"False",
",",
"skip_table_names",
":",
"List",
"[",
"str",
"]",
"... | A utility function only.
Used in copying objects between SQLAlchemy sessions.
Both ``oldobj`` and ``newobj`` are SQLAlchemy instances. The instance
``newobj`` is already a copy of ``oldobj`` but we wish to rewrite its
relationships, according to the map ``objmap``, which maps old to new
objects.
... | [
"A",
"utility",
"function",
"only",
".",
"Used",
"in",
"copying",
"objects",
"between",
"SQLAlchemy",
"sessions",
"."
] | python | train |
ionelmc/python-redis-lock | src/redis_lock/__init__.py | https://github.com/ionelmc/python-redis-lock/blob/5481cd88b64d86d318e389c79b0575a73464b1f5/src/redis_lock/__init__.py#L129-L140 | def _eval_script(redis, script_id, *keys, **kwargs):
"""Tries to call ``EVALSHA`` with the `hash` and then, if it fails, calls
regular ``EVAL`` with the `script`.
"""
args = kwargs.pop('args', ())
if kwargs:
raise TypeError("Unexpected keyword arguments %s" % kwargs.keys())
try:
... | [
"def",
"_eval_script",
"(",
"redis",
",",
"script_id",
",",
"*",
"keys",
",",
"*",
"*",
"kwargs",
")",
":",
"args",
"=",
"kwargs",
".",
"pop",
"(",
"'args'",
",",
"(",
")",
")",
"if",
"kwargs",
":",
"raise",
"TypeError",
"(",
"\"Unexpected keyword argu... | Tries to call ``EVALSHA`` with the `hash` and then, if it fails, calls
regular ``EVAL`` with the `script`. | [
"Tries",
"to",
"call",
"EVALSHA",
"with",
"the",
"hash",
"and",
"then",
"if",
"it",
"fails",
"calls",
"regular",
"EVAL",
"with",
"the",
"script",
"."
] | python | train |
djgagne/hagelslag | hagelslag/util/convert_mrms_grids.py | https://github.com/djgagne/hagelslag/blob/6fb6c3df90bf4867e13a97d3460b14471d107df1/hagelslag/util/convert_mrms_grids.py#L228-L276 | def interpolate_to_netcdf(self, in_lon, in_lat, out_path, date_unit="seconds since 1970-01-01T00:00",
interp_type="spline"):
"""
Calls the interpolation function and then saves the MRMS data to a netCDF file. It will also create
separate directories for each variab... | [
"def",
"interpolate_to_netcdf",
"(",
"self",
",",
"in_lon",
",",
"in_lat",
",",
"out_path",
",",
"date_unit",
"=",
"\"seconds since 1970-01-01T00:00\"",
",",
"interp_type",
"=",
"\"spline\"",
")",
":",
"if",
"interp_type",
"==",
"\"spline\"",
":",
"out_data",
"=",... | Calls the interpolation function and then saves the MRMS data to a netCDF file. It will also create
separate directories for each variable if they are not already available. | [
"Calls",
"the",
"interpolation",
"function",
"and",
"then",
"saves",
"the",
"MRMS",
"data",
"to",
"a",
"netCDF",
"file",
".",
"It",
"will",
"also",
"create",
"separate",
"directories",
"for",
"each",
"variable",
"if",
"they",
"are",
"not",
"already",
"availa... | python | train |
boundlessgeo/gsconfig | src/geoserver/catalog.py | https://github.com/boundlessgeo/gsconfig/blob/532f561f32b91ea8debea0573c503dd20988bf40/src/geoserver/catalog.py#L187-L192 | def get_short_version(self):
'''obtain the shory geoserver version
'''
gs_version = self.get_version()
match = re.compile(r'[^\d.]+')
return match.sub('', gs_version).strip('.') | [
"def",
"get_short_version",
"(",
"self",
")",
":",
"gs_version",
"=",
"self",
".",
"get_version",
"(",
")",
"match",
"=",
"re",
".",
"compile",
"(",
"r'[^\\d.]+'",
")",
"return",
"match",
".",
"sub",
"(",
"''",
",",
"gs_version",
")",
".",
"strip",
"("... | obtain the shory geoserver version | [
"obtain",
"the",
"shory",
"geoserver",
"version"
] | python | valid |
gtaylor/python-colormath | colormath/chromatic_adaptation.py | https://github.com/gtaylor/python-colormath/blob/1d168613718d2d7d31ec4230524e987ef66823c7/colormath/chromatic_adaptation.py#L101-L119 | def apply_chromatic_adaptation_on_color(color, targ_illum, adaptation='bradford'):
"""
Convenience function to apply an adaptation directly to a Color object.
"""
xyz_x = color.xyz_x
xyz_y = color.xyz_y
xyz_z = color.xyz_z
orig_illum = color.illuminant
targ_illum = targ_illum.lower()
... | [
"def",
"apply_chromatic_adaptation_on_color",
"(",
"color",
",",
"targ_illum",
",",
"adaptation",
"=",
"'bradford'",
")",
":",
"xyz_x",
"=",
"color",
".",
"xyz_x",
"xyz_y",
"=",
"color",
".",
"xyz_y",
"xyz_z",
"=",
"color",
".",
"xyz_z",
"orig_illum",
"=",
"... | Convenience function to apply an adaptation directly to a Color object. | [
"Convenience",
"function",
"to",
"apply",
"an",
"adaptation",
"directly",
"to",
"a",
"Color",
"object",
"."
] | python | train |
hydraplatform/hydra-base | hydra_base/lib/groups.py | https://github.com/hydraplatform/hydra-base/blob/9251ff7946505f7a272c87837390acd1c435bc6e/hydra_base/lib/groups.py#L43-L54 | def add_resourcegroup(group, network_id,**kwargs):
"""
Add a new group to a network.
"""
group_i = ResourceGroup()
group_i.name = group.name
group_i.description = group.description
group_i.status = group.status
group_i.network_id ... | [
"def",
"add_resourcegroup",
"(",
"group",
",",
"network_id",
",",
"*",
"*",
"kwargs",
")",
":",
"group_i",
"=",
"ResourceGroup",
"(",
")",
"group_i",
".",
"name",
"=",
"group",
".",
"name",
"group_i",
".",
"description",
"=",
"group",
".",
"description",
... | Add a new group to a network. | [
"Add",
"a",
"new",
"group",
"to",
"a",
"network",
"."
] | python | train |
CityOfZion/neo-python | neo/Core/Blockchain.py | https://github.com/CityOfZion/neo-python/blob/fe90f62e123d720d4281c79af0598d9df9e776fb/neo/Core/Blockchain.py#L99-L128 | def GenesisBlock() -> Block:
"""
Create the GenesisBlock.
Returns:
BLock:
"""
prev_hash = UInt256(data=bytearray(32))
timestamp = int(datetime(2016, 7, 15, 15, 8, 21, tzinfo=pytz.utc).timestamp())
index = 0
consensus_data = 2083236893 # Pay t... | [
"def",
"GenesisBlock",
"(",
")",
"->",
"Block",
":",
"prev_hash",
"=",
"UInt256",
"(",
"data",
"=",
"bytearray",
"(",
"32",
")",
")",
"timestamp",
"=",
"int",
"(",
"datetime",
"(",
"2016",
",",
"7",
",",
"15",
",",
"15",
",",
"8",
",",
"21",
",",... | Create the GenesisBlock.
Returns:
BLock: | [
"Create",
"the",
"GenesisBlock",
"."
] | python | train |
wummel/linkchecker | linkcheck/fileutil.py | https://github.com/wummel/linkchecker/blob/c2ce810c3fb00b895a841a7be6b2e78c64e7b042/linkcheck/fileutil.py#L211-L214 | def is_writable_by_others(filename):
"""Check if file or directory is world writable."""
mode = os.stat(filename)[stat.ST_MODE]
return mode & stat.S_IWOTH | [
"def",
"is_writable_by_others",
"(",
"filename",
")",
":",
"mode",
"=",
"os",
".",
"stat",
"(",
"filename",
")",
"[",
"stat",
".",
"ST_MODE",
"]",
"return",
"mode",
"&",
"stat",
".",
"S_IWOTH"
] | Check if file or directory is world writable. | [
"Check",
"if",
"file",
"or",
"directory",
"is",
"world",
"writable",
"."
] | python | train |
python/core-workflow | cherry_picker/cherry_picker/cherry_picker.py | https://github.com/python/core-workflow/blob/b93c76195f6db382cfcefee334380fb4c68d4e21/cherry_picker/cherry_picker/cherry_picker.py#L258-L278 | def amend_commit_message(self, cherry_pick_branch):
""" prefix the commit message with (X.Y) """
commit_prefix = ""
if self.prefix_commit:
commit_prefix = f"[{get_base_branch(cherry_pick_branch)}] "
updated_commit_message = f"""{commit_prefix}{self.get_commit_message(self.co... | [
"def",
"amend_commit_message",
"(",
"self",
",",
"cherry_pick_branch",
")",
":",
"commit_prefix",
"=",
"\"\"",
"if",
"self",
".",
"prefix_commit",
":",
"commit_prefix",
"=",
"f\"[{get_base_branch(cherry_pick_branch)}] \"",
"updated_commit_message",
"=",
"f\"\"\"{commit_pref... | prefix the commit message with (X.Y) | [
"prefix",
"the",
"commit",
"message",
"with",
"(",
"X",
".",
"Y",
")"
] | python | train |
mrallen1/pygett | pygett/request.py | https://github.com/mrallen1/pygett/blob/1e21f8674a3634a901af054226670174b5ce2d87/pygett/request.py#L45-L58 | def get(self, endpoint, *args, **kwargs):
"""
**get**
Make a GET call to a remote endpoint
Input:
* An endpoint relative to the ``base_url``
Output:
* A :py:mod:`pygett.request.GettResponse` object
"""
endpoint = self.base_url + endpoint... | [
"def",
"get",
"(",
"self",
",",
"endpoint",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"endpoint",
"=",
"self",
".",
"base_url",
"+",
"endpoint",
"return",
"self",
".",
"_make_request",
"(",
"endpoint",
",",
"type",
"=",
"'GET'",
")"
] | **get**
Make a GET call to a remote endpoint
Input:
* An endpoint relative to the ``base_url``
Output:
* A :py:mod:`pygett.request.GettResponse` object | [
"**",
"get",
"**"
] | python | train |
asweigart/pysimplevalidate | src/pysimplevalidate/__init__.py | https://github.com/asweigart/pysimplevalidate/blob/3ca27228abb7355d14bbf8abc225c63366379e44/src/pysimplevalidate/__init__.py#L611-L633 | def _validateParamsFor__validateToDateTimeFormat(formats, blank=False, strip=None, allowlistRegexes=None, blocklistRegexes=None, excMsg=None):
"""Raises PySimpleValidateException if the arguments are invalid. This is called by
the validateTime() function to check its arguments. This code was
refactored out ... | [
"def",
"_validateParamsFor__validateToDateTimeFormat",
"(",
"formats",
",",
"blank",
"=",
"False",
",",
"strip",
"=",
"None",
",",
"allowlistRegexes",
"=",
"None",
",",
"blocklistRegexes",
"=",
"None",
",",
"excMsg",
"=",
"None",
")",
":",
"_validateGenericParamet... | Raises PySimpleValidateException if the arguments are invalid. This is called by
the validateTime() function to check its arguments. This code was
refactored out to a separate function so that the PyInputPlus module (or
other modules) could check their parameters' arguments for inputTime(). | [
"Raises",
"PySimpleValidateException",
"if",
"the",
"arguments",
"are",
"invalid",
".",
"This",
"is",
"called",
"by",
"the",
"validateTime",
"()",
"function",
"to",
"check",
"its",
"arguments",
".",
"This",
"code",
"was",
"refactored",
"out",
"to",
"a",
"separ... | python | train |
dmlc/gluon-nlp | src/gluonnlp/model/train/embedding.py | https://github.com/dmlc/gluon-nlp/blob/4b83eb6bcc8881e5f1081a3675adaa19fac5c0ba/src/gluonnlp/model/train/embedding.py#L120-L131 | def hybrid_forward(self, F, words, weight):
"""Compute embedding of words in batch.
Parameters
----------
words : mx.nd.NDArray
Array of token indices.
"""
#pylint: disable=arguments-differ
embeddings = F.sparse.dot(words, weight)
return embe... | [
"def",
"hybrid_forward",
"(",
"self",
",",
"F",
",",
"words",
",",
"weight",
")",
":",
"#pylint: disable=arguments-differ",
"embeddings",
"=",
"F",
".",
"sparse",
".",
"dot",
"(",
"words",
",",
"weight",
")",
"return",
"embeddings"
] | Compute embedding of words in batch.
Parameters
----------
words : mx.nd.NDArray
Array of token indices. | [
"Compute",
"embedding",
"of",
"words",
"in",
"batch",
"."
] | python | train |
sashahart/vex | vex/config.py | https://github.com/sashahart/vex/blob/b7680c40897b8cbe6aae55ec9812b4fb11738192/vex/config.py#L61-L76 | def read(self, path, environ):
"""Read data from file into this vexrc instance.
"""
try:
inp = open(path, 'rb')
except FileNotFoundError as error:
if error.errno != 2:
raise
return None
parsing = parse_vexrc(inp, environ)
... | [
"def",
"read",
"(",
"self",
",",
"path",
",",
"environ",
")",
":",
"try",
":",
"inp",
"=",
"open",
"(",
"path",
",",
"'rb'",
")",
"except",
"FileNotFoundError",
"as",
"error",
":",
"if",
"error",
".",
"errno",
"!=",
"2",
":",
"raise",
"return",
"No... | Read data from file into this vexrc instance. | [
"Read",
"data",
"from",
"file",
"into",
"this",
"vexrc",
"instance",
"."
] | python | train |
NLeSC/scriptcwl | scriptcwl/workflow.py | https://github.com/NLeSC/scriptcwl/blob/33bb847a875379da3a5702c7a98dfa585306b960/scriptcwl/workflow.py#L342-L370 | def _get_step(self, name, make_copy=True):
"""Return step from steps library.
Optionally, the step returned is a deep copy from the step in the steps
library, so additional information (e.g., about whether the step was
scattered) can be stored in the copy.
Args:
nam... | [
"def",
"_get_step",
"(",
"self",
",",
"name",
",",
"make_copy",
"=",
"True",
")",
":",
"self",
".",
"_closed",
"(",
")",
"s",
"=",
"self",
".",
"steps_library",
".",
"get_step",
"(",
"name",
")",
"if",
"s",
"is",
"None",
":",
"msg",
"=",
"'\"{}\" n... | Return step from steps library.
Optionally, the step returned is a deep copy from the step in the steps
library, so additional information (e.g., about whether the step was
scattered) can be stored in the copy.
Args:
name (str): name of the step in the steps library.
... | [
"Return",
"step",
"from",
"steps",
"library",
"."
] | python | train |
DocNow/twarc | twarc/client.py | https://github.com/DocNow/twarc/blob/47dd87d0c00592a4d583412c9d660ba574fc6f26/twarc/client.py#L753-L774 | def validate_keys(self):
"""
Validate the keys provided are authentic credentials.
"""
url = 'https://api.twitter.com/1.1/account/verify_credentials.json'
keys_present = self.consumer_key and self.consumer_secret and \
self.access_token and self.access_tok... | [
"def",
"validate_keys",
"(",
"self",
")",
":",
"url",
"=",
"'https://api.twitter.com/1.1/account/verify_credentials.json'",
"keys_present",
"=",
"self",
".",
"consumer_key",
"and",
"self",
".",
"consumer_secret",
"and",
"self",
".",
"access_token",
"and",
"self",
".",... | Validate the keys provided are authentic credentials. | [
"Validate",
"the",
"keys",
"provided",
"are",
"authentic",
"credentials",
"."
] | python | train |
dlecocq/nsq-py | nsq/connection.py | https://github.com/dlecocq/nsq-py/blob/3ecacf6ab7719d38031179277113d875554a0c16/nsq/connection.py#L330-L371 | def _read(self, limit=1000):
'''Return all the responses read'''
# It's important to know that it may return no responses or multiple
# responses. It depends on how the buffering works out. First, read from
# the socket
for sock in self.socket():
if sock is None:
... | [
"def",
"_read",
"(",
"self",
",",
"limit",
"=",
"1000",
")",
":",
"# It's important to know that it may return no responses or multiple",
"# responses. It depends on how the buffering works out. First, read from",
"# the socket",
"for",
"sock",
"in",
"self",
".",
"socket",
"(",... | Return all the responses read | [
"Return",
"all",
"the",
"responses",
"read"
] | python | train |
litl/rauth | rauth/session.py | https://github.com/litl/rauth/blob/a6d887d7737cf21ec896a8104f25c2754c694011/rauth/session.py#L470-L515 | def sign(url, app_id, app_secret, hash_meth='sha1', **params):
'''
A signature method which generates the necessary Ofly parameters.
:param app_id: The oFlyAppId, i.e. "application ID".
:type app_id: str
:param app_secret: The oFlyAppSecret, i.e. "shared secret".
:type a... | [
"def",
"sign",
"(",
"url",
",",
"app_id",
",",
"app_secret",
",",
"hash_meth",
"=",
"'sha1'",
",",
"*",
"*",
"params",
")",
":",
"hash_meth_str",
"=",
"hash_meth",
"if",
"hash_meth",
"==",
"'sha1'",
":",
"hash_meth",
"=",
"sha1",
"elif",
"hash_meth",
"==... | A signature method which generates the necessary Ofly parameters.
:param app_id: The oFlyAppId, i.e. "application ID".
:type app_id: str
:param app_secret: The oFlyAppSecret, i.e. "shared secret".
:type app_secret: str
:param hash_meth: The hash method to use for signing, defaul... | [
"A",
"signature",
"method",
"which",
"generates",
"the",
"necessary",
"Ofly",
"parameters",
"."
] | python | train |
camptocamp/Studio | studio/lib/buildjs/jsmin.py | https://github.com/camptocamp/Studio/blob/43cb7298434fb606b15136801b79b03571a2f27e/studio/lib/buildjs/jsmin.py#L107-L130 | def _next(self):
"""get the next character, excluding comments. peek() is used to see
if a '/' is followed by a '/' or '*'.
"""
c = self._get()
if c == '/':
p = self._peek()
if p == '/':
c = self._get()
while c > '\n':
... | [
"def",
"_next",
"(",
"self",
")",
":",
"c",
"=",
"self",
".",
"_get",
"(",
")",
"if",
"c",
"==",
"'/'",
":",
"p",
"=",
"self",
".",
"_peek",
"(",
")",
"if",
"p",
"==",
"'/'",
":",
"c",
"=",
"self",
".",
"_get",
"(",
")",
"while",
"c",
">"... | get the next character, excluding comments. peek() is used to see
if a '/' is followed by a '/' or '*'. | [
"get",
"the",
"next",
"character",
"excluding",
"comments",
".",
"peek",
"()",
"is",
"used",
"to",
"see",
"if",
"a",
"/",
"is",
"followed",
"by",
"a",
"/",
"or",
"*",
"."
] | python | train |
PythonCharmers/python-future | src/libfuturize/fixer_util.py | https://github.com/PythonCharmers/python-future/blob/c423752879acc05eebc29b0bb9909327bd5c7308/src/libfuturize/fixer_util.py#L75-L94 | def indentation(node):
"""
Returns the indentation for this node
Iff a node is in a suite, then it has indentation.
"""
while node.parent is not None and node.parent.type != syms.suite:
node = node.parent
if node.parent is None:
return u""
# The first three children of a suit... | [
"def",
"indentation",
"(",
"node",
")",
":",
"while",
"node",
".",
"parent",
"is",
"not",
"None",
"and",
"node",
".",
"parent",
".",
"type",
"!=",
"syms",
".",
"suite",
":",
"node",
"=",
"node",
".",
"parent",
"if",
"node",
".",
"parent",
"is",
"No... | Returns the indentation for this node
Iff a node is in a suite, then it has indentation. | [
"Returns",
"the",
"indentation",
"for",
"this",
"node",
"Iff",
"a",
"node",
"is",
"in",
"a",
"suite",
"then",
"it",
"has",
"indentation",
"."
] | python | train |
Skype4Py/Skype4Py | Skype4Py/chat.py | https://github.com/Skype4Py/Skype4Py/blob/c48d83f7034109fe46315d45a066126002c6e0d4/Skype4Py/chat.py#L119-L130 | def SetPassword(self, Password, Hint=''):
"""Sets the chat password.
:Parameters:
Password : unicode
Password
Hint : unicode
Password hint
"""
if ' ' in Password:
raise ValueError('Password mut be one word')
self._Alter('SE... | [
"def",
"SetPassword",
"(",
"self",
",",
"Password",
",",
"Hint",
"=",
"''",
")",
":",
"if",
"' '",
"in",
"Password",
":",
"raise",
"ValueError",
"(",
"'Password mut be one word'",
")",
"self",
".",
"_Alter",
"(",
"'SETPASSWORD'",
",",
"'%s %s'",
"%",
"(",
... | Sets the chat password.
:Parameters:
Password : unicode
Password
Hint : unicode
Password hint | [
"Sets",
"the",
"chat",
"password",
"."
] | python | train |
arne-cl/discoursegraphs | src/discoursegraphs/readwrite/rst/rs3/rs3tree.py | https://github.com/arne-cl/discoursegraphs/blob/842f0068a3190be2c75905754521b176b25a54fb/src/discoursegraphs/readwrite/rst/rs3/rs3tree.py#L111-L134 | def dt(self, start_node=None):
"""main method to create an RSTTree from the output of get_rs3_data().
TODO: add proper documentation
"""
if start_node is None:
return self.root2tree(start_node=start_node)
elem_id = start_node
if elem_id not in self.elem_dict... | [
"def",
"dt",
"(",
"self",
",",
"start_node",
"=",
"None",
")",
":",
"if",
"start_node",
"is",
"None",
":",
"return",
"self",
".",
"root2tree",
"(",
"start_node",
"=",
"start_node",
")",
"elem_id",
"=",
"start_node",
"if",
"elem_id",
"not",
"in",
"self",
... | main method to create an RSTTree from the output of get_rs3_data().
TODO: add proper documentation | [
"main",
"method",
"to",
"create",
"an",
"RSTTree",
"from",
"the",
"output",
"of",
"get_rs3_data",
"()",
"."
] | python | train |
eventbrite/eventbrite-sdk-python | eventbrite/access_methods.py | https://github.com/eventbrite/eventbrite-sdk-python/blob/f2e5dc5aa1aa3e45766de13f16fd65722163d91a/eventbrite/access_methods.py#L373-L379 | def get_event_teams(self, id, **data):
"""
GET /events/:id/teams/
Returns a list of :format:`teams` for the event.
"""
return self.get("/events/{0}/teams/".format(id), data=data) | [
"def",
"get_event_teams",
"(",
"self",
",",
"id",
",",
"*",
"*",
"data",
")",
":",
"return",
"self",
".",
"get",
"(",
"\"/events/{0}/teams/\"",
".",
"format",
"(",
"id",
")",
",",
"data",
"=",
"data",
")"
] | GET /events/:id/teams/
Returns a list of :format:`teams` for the event. | [
"GET",
"/",
"events",
"/",
":",
"id",
"/",
"teams",
"/",
"Returns",
"a",
"list",
"of",
":",
"format",
":",
"teams",
"for",
"the",
"event",
"."
] | python | train |
huge-success/sanic | sanic/blueprints.py | https://github.com/huge-success/sanic/blob/6a4a3f617fdbe1d3ee8bdc9d1b12ad2d0b34acdd/sanic/blueprints.py#L166-L207 | def route(
self,
uri,
methods=frozenset({"GET"}),
host=None,
strict_slashes=None,
stream=False,
version=None,
name=None,
):
"""Create a blueprint route from a decorated function.
:param uri: endpoint at which the route will be accessib... | [
"def",
"route",
"(",
"self",
",",
"uri",
",",
"methods",
"=",
"frozenset",
"(",
"{",
"\"GET\"",
"}",
")",
",",
"host",
"=",
"None",
",",
"strict_slashes",
"=",
"None",
",",
"stream",
"=",
"False",
",",
"version",
"=",
"None",
",",
"name",
"=",
"Non... | Create a blueprint route from a decorated function.
:param uri: endpoint at which the route will be accessible.
:param methods: list of acceptable HTTP methods.
:param host: IP Address of FQDN for the sanic server to use.
:param strict_slashes: Enforce the API urls are requested with a
... | [
"Create",
"a",
"blueprint",
"route",
"from",
"a",
"decorated",
"function",
"."
] | python | train |
icometrix/dicom2nifti | dicom2nifti/convert_ge.py | https://github.com/icometrix/dicom2nifti/blob/1462ae5dd979fa3f276fe7a78ceb9b028121536f/dicom2nifti/convert_ge.py#L91-L136 | def _4d_to_nifti(grouped_dicoms, output_file):
"""
This function will convert ge 4d series to a nifti
"""
# Create mosaic block
logger.info('Creating data block')
full_block = _get_full_block(grouped_dicoms)
logger.info('Creating affine')
# Create the nifti header info
affine, slic... | [
"def",
"_4d_to_nifti",
"(",
"grouped_dicoms",
",",
"output_file",
")",
":",
"# Create mosaic block",
"logger",
".",
"info",
"(",
"'Creating data block'",
")",
"full_block",
"=",
"_get_full_block",
"(",
"grouped_dicoms",
")",
"logger",
".",
"info",
"(",
"'Creating af... | This function will convert ge 4d series to a nifti | [
"This",
"function",
"will",
"convert",
"ge",
"4d",
"series",
"to",
"a",
"nifti"
] | python | train |
juju/python-libjuju | juju/client/_client2.py | https://github.com/juju/python-libjuju/blob/58f0011f4c57cd68830258952fa952eaadca6b38/juju/client/_client2.py#L5174-L5187 | async def Save(self, metadata):
'''
metadata : typing.Sequence[~CloudImageMetadataList]
Returns -> typing.Sequence[~ErrorResult]
'''
# map input types to rpc msg
_params = dict()
msg = dict(type='ImageMetadata',
request='Save',
... | [
"async",
"def",
"Save",
"(",
"self",
",",
"metadata",
")",
":",
"# map input types to rpc msg",
"_params",
"=",
"dict",
"(",
")",
"msg",
"=",
"dict",
"(",
"type",
"=",
"'ImageMetadata'",
",",
"request",
"=",
"'Save'",
",",
"version",
"=",
"2",
",",
"para... | metadata : typing.Sequence[~CloudImageMetadataList]
Returns -> typing.Sequence[~ErrorResult] | [
"metadata",
":",
"typing",
".",
"Sequence",
"[",
"~CloudImageMetadataList",
"]",
"Returns",
"-",
">",
"typing",
".",
"Sequence",
"[",
"~ErrorResult",
"]"
] | python | train |
awslabs/sockeye | sockeye/utils.py | https://github.com/awslabs/sockeye/blob/5d64a1ee1ef3cbba17c6d1d94bc061020c43f6ab/sockeye/utils.py#L608-L701 | def acquire_gpus(requested_device_ids: List[int], lock_dir: str = "/tmp",
retry_wait_min: int = 10, retry_wait_rand: int = 60,
num_gpus_available: Optional[int] = None):
"""
Acquire a number of GPUs in a transactional way. This method should be used inside a `with` statement.
... | [
"def",
"acquire_gpus",
"(",
"requested_device_ids",
":",
"List",
"[",
"int",
"]",
",",
"lock_dir",
":",
"str",
"=",
"\"/tmp\"",
",",
"retry_wait_min",
":",
"int",
"=",
"10",
",",
"retry_wait_rand",
":",
"int",
"=",
"60",
",",
"num_gpus_available",
":",
"Op... | Acquire a number of GPUs in a transactional way. This method should be used inside a `with` statement.
Will try to acquire all the requested number of GPUs. If currently
not enough GPUs are available all locks will be released and we wait until we retry. Will retry until enough
GPUs become available.
:... | [
"Acquire",
"a",
"number",
"of",
"GPUs",
"in",
"a",
"transactional",
"way",
".",
"This",
"method",
"should",
"be",
"used",
"inside",
"a",
"with",
"statement",
".",
"Will",
"try",
"to",
"acquire",
"all",
"the",
"requested",
"number",
"of",
"GPUs",
".",
"If... | python | train |
IdentityPython/pyop | src/pyop/provider.py | https://github.com/IdentityPython/pyop/blob/7b1385964f079c39752fce5f2dbcf458b8a92e56/src/pyop/provider.py#L202-L216 | def _create_subject_identifier(self, user_id, client_id, redirect_uri):
# type (str, str, str) -> str
"""
Creates a subject identifier for the specified client and user
see <a href="http://openid.net/specs/openid-connect-core-1_0.html#Terminology">
"OpenID Connect Core 1.0", Sect... | [
"def",
"_create_subject_identifier",
"(",
"self",
",",
"user_id",
",",
"client_id",
",",
"redirect_uri",
")",
":",
"# type (str, str, str) -> str",
"supported_subject_types",
"=",
"self",
".",
"configuration_information",
"[",
"'subject_types_supported'",
"]",
"[",
"0",
... | Creates a subject identifier for the specified client and user
see <a href="http://openid.net/specs/openid-connect-core-1_0.html#Terminology">
"OpenID Connect Core 1.0", Section 1.2</a>.
:param user_id: local user identifier
:param client_id: which client to generate a subject identifier... | [
"Creates",
"a",
"subject",
"identifier",
"for",
"the",
"specified",
"client",
"and",
"user",
"see",
"<a",
"href",
"=",
"http",
":",
"//",
"openid",
".",
"net",
"/",
"specs",
"/",
"openid",
"-",
"connect",
"-",
"core",
"-",
"1_0",
".",
"html#Terminology",... | python | train |
PiotrDabkowski/Js2Py | js2py/base.py | https://github.com/PiotrDabkowski/Js2Py/blob/c0fa43f5679cf91ca8986c5747fcb07a433dc584/js2py/base.py#L1014-L1025 | def PyJsStrictEq(a, b):
'''a===b'''
tx, ty = Type(a), Type(b)
if tx != ty:
return false
if tx == 'Undefined' or tx == 'Null':
return true
if a.is_primitive(): #string bool and number case
return Js(a.value == b.value)
if a.Class == b.Class == 'PyObjectWrapper':
r... | [
"def",
"PyJsStrictEq",
"(",
"a",
",",
"b",
")",
":",
"tx",
",",
"ty",
"=",
"Type",
"(",
"a",
")",
",",
"Type",
"(",
"b",
")",
"if",
"tx",
"!=",
"ty",
":",
"return",
"false",
"if",
"tx",
"==",
"'Undefined'",
"or",
"tx",
"==",
"'Null'",
":",
"r... | a===b | [
"a",
"===",
"b"
] | python | valid |
globality-corp/microcosm-flask | microcosm_flask/paging.py | https://github.com/globality-corp/microcosm-flask/blob/c2eaf57f03e7d041eea343751a4a90fcc80df418/microcosm_flask/paging.py#L198-L211 | def parse_result(cls, result):
"""
Parse a simple items result.
May either be two item tuple containing items and a context dictionary (see: relation convention)
or a list of items.
"""
if isinstance(result, tuple) == 2:
items, context = result
else:... | [
"def",
"parse_result",
"(",
"cls",
",",
"result",
")",
":",
"if",
"isinstance",
"(",
"result",
",",
"tuple",
")",
"==",
"2",
":",
"items",
",",
"context",
"=",
"result",
"else",
":",
"context",
"=",
"{",
"}",
"items",
"=",
"result",
"return",
"items"... | Parse a simple items result.
May either be two item tuple containing items and a context dictionary (see: relation convention)
or a list of items. | [
"Parse",
"a",
"simple",
"items",
"result",
"."
] | python | train |
bitesofcode/projexui | projexui/widgets/xganttwidget/xganttwidgetitem.py | https://github.com/bitesofcode/projexui/blob/f18a73bec84df90b034ca69b9deea118dbedfc4d/projexui/widgets/xganttwidget/xganttwidgetitem.py#L503-L508 | def sync(self, recursive=False):
"""
Syncs the information from this item to the tree and view.
"""
self.syncTree(recursive=recursive)
self.syncView(recursive=recursive) | [
"def",
"sync",
"(",
"self",
",",
"recursive",
"=",
"False",
")",
":",
"self",
".",
"syncTree",
"(",
"recursive",
"=",
"recursive",
")",
"self",
".",
"syncView",
"(",
"recursive",
"=",
"recursive",
")"
] | Syncs the information from this item to the tree and view. | [
"Syncs",
"the",
"information",
"from",
"this",
"item",
"to",
"the",
"tree",
"and",
"view",
"."
] | python | train |
Genida/dependenpy | src/dependenpy/node.py | https://github.com/Genida/dependenpy/blob/df099c17cbe735c990eca9197e39cfc5eb8a4c8e/src/dependenpy/node.py#L251-L260 | def print_treemap(self, format=None, output=sys.stdout, **kwargs):
"""
Print the matrix for self's nodes.
Args:
format (str): output format (csv, json or text).
output (file): file descriptor on which to write.
"""
treemap = self.as_treemap()
tree... | [
"def",
"print_treemap",
"(",
"self",
",",
"format",
"=",
"None",
",",
"output",
"=",
"sys",
".",
"stdout",
",",
"*",
"*",
"kwargs",
")",
":",
"treemap",
"=",
"self",
".",
"as_treemap",
"(",
")",
"treemap",
".",
"print",
"(",
"format",
"=",
"format",
... | Print the matrix for self's nodes.
Args:
format (str): output format (csv, json or text).
output (file): file descriptor on which to write. | [
"Print",
"the",
"matrix",
"for",
"self",
"s",
"nodes",
"."
] | python | train |
ethereum/lahja | lahja/endpoint.py | https://github.com/ethereum/lahja/blob/e3993c5892232887a11800ed3e66332febcee96b/lahja/endpoint.py#L348-L357 | def stop(self) -> None:
"""
Stop the :class:`~lahja.endpoint.Endpoint` from receiving further events.
"""
if not self._running:
return
self._running = False
self._receiving_queue.put_nowait((TRANSPARENT_EVENT, None))
self._internal_queue.put_nowait((T... | [
"def",
"stop",
"(",
"self",
")",
"->",
"None",
":",
"if",
"not",
"self",
".",
"_running",
":",
"return",
"self",
".",
"_running",
"=",
"False",
"self",
".",
"_receiving_queue",
".",
"put_nowait",
"(",
"(",
"TRANSPARENT_EVENT",
",",
"None",
")",
")",
"s... | Stop the :class:`~lahja.endpoint.Endpoint` from receiving further events. | [
"Stop",
"the",
":",
"class",
":",
"~lahja",
".",
"endpoint",
".",
"Endpoint",
"from",
"receiving",
"further",
"events",
"."
] | python | train |
codelv/enaml-native | src/enamlnative/android/android_grid_layout.py | https://github.com/codelv/enaml-native/blob/c33986e9eda468c508806e0a3e73c771401e5718/src/enamlnative/android/android_grid_layout.py#L48-L53 | def create_widget(self):
""" Create the underlying widget.
"""
d = self.declaration
self.widget = GridLayout(self.get_context(), None, d.style) | [
"def",
"create_widget",
"(",
"self",
")",
":",
"d",
"=",
"self",
".",
"declaration",
"self",
".",
"widget",
"=",
"GridLayout",
"(",
"self",
".",
"get_context",
"(",
")",
",",
"None",
",",
"d",
".",
"style",
")"
] | Create the underlying widget. | [
"Create",
"the",
"underlying",
"widget",
"."
] | python | train |
kmpm/nodemcu-uploader | nodemcu_uploader/main.py | https://github.com/kmpm/nodemcu-uploader/blob/557a25f37b1fb4e31a745719e237e42fff192834/nodemcu_uploader/main.py#L20-L45 | def destination_from_source(sources, use_glob=True):
"""
Split each of the sources in the array on ':'
First part will be source, second will be destination.
Modifies the the original array to contain only sources
and returns an array of destinations.
"""
destinations = []
newsources = [... | [
"def",
"destination_from_source",
"(",
"sources",
",",
"use_glob",
"=",
"True",
")",
":",
"destinations",
"=",
"[",
"]",
"newsources",
"=",
"[",
"]",
"for",
"i",
"in",
"range",
"(",
"0",
",",
"len",
"(",
"sources",
")",
")",
":",
"srcdst",
"=",
"sour... | Split each of the sources in the array on ':'
First part will be source, second will be destination.
Modifies the the original array to contain only sources
and returns an array of destinations. | [
"Split",
"each",
"of",
"the",
"sources",
"in",
"the",
"array",
"on",
":",
"First",
"part",
"will",
"be",
"source",
"second",
"will",
"be",
"destination",
".",
"Modifies",
"the",
"the",
"original",
"array",
"to",
"contain",
"only",
"sources",
"and",
"return... | python | valid |
nwilming/ocupy | ocupy/datamat.py | https://github.com/nwilming/ocupy/blob/a0bd64f822576feaa502939d6bafd1183b237d16/ocupy/datamat.py#L560-L584 | def VectorFactory(fields, parameters, categories = None):
'''
Creates a datamat from a dictionary that contains lists/arrays as values.
Input:
fields: Dictionary
The values will be used as fields of the datamat and the keys
as field names.
parameters: Dictionary
... | [
"def",
"VectorFactory",
"(",
"fields",
",",
"parameters",
",",
"categories",
"=",
"None",
")",
":",
"fm",
"=",
"Datamat",
"(",
"categories",
"=",
"categories",
")",
"fm",
".",
"_fields",
"=",
"list",
"(",
"fields",
".",
"keys",
"(",
")",
")",
"for",
... | Creates a datamat from a dictionary that contains lists/arrays as values.
Input:
fields: Dictionary
The values will be used as fields of the datamat and the keys
as field names.
parameters: Dictionary
A dictionary whose values are added as parameters. Keys are us... | [
"Creates",
"a",
"datamat",
"from",
"a",
"dictionary",
"that",
"contains",
"lists",
"/",
"arrays",
"as",
"values",
"."
] | python | train |
Loudr/pale | pale/adapters/flask.py | https://github.com/Loudr/pale/blob/dc002ee6032c856551143af222ff8f71ed9853fe/pale/adapters/flask.py#L29-L58 | def bind_blueprint(pale_api_module, flask_blueprint):
"""Binds an implemented pale API module to a Flask Blueprint."""
if not isinstance(flask_blueprint, Blueprint):
raise TypeError(("pale.flask_adapter.bind_blueprint expected the "
"passed in flask_blueprint to be an instance ... | [
"def",
"bind_blueprint",
"(",
"pale_api_module",
",",
"flask_blueprint",
")",
":",
"if",
"not",
"isinstance",
"(",
"flask_blueprint",
",",
"Blueprint",
")",
":",
"raise",
"TypeError",
"(",
"(",
"\"pale.flask_adapter.bind_blueprint expected the \"",
"\"passed in flask_blue... | Binds an implemented pale API module to a Flask Blueprint. | [
"Binds",
"an",
"implemented",
"pale",
"API",
"module",
"to",
"a",
"Flask",
"Blueprint",
"."
] | python | train |
spacetelescope/stsci.tools | lib/stsci/tools/iterfile.py | https://github.com/spacetelescope/stsci.tools/blob/9a022503ad24ca54ce83331482dfa3ff6de9f403/lib/stsci/tools/iterfile.py#L35-L42 | def _shape(self):
""" Returns the shape of the data array associated with this file."""
hdu = self.open()
_shape = hdu.shape
if not self.inmemory:
self.close()
del hdu
return _shape | [
"def",
"_shape",
"(",
"self",
")",
":",
"hdu",
"=",
"self",
".",
"open",
"(",
")",
"_shape",
"=",
"hdu",
".",
"shape",
"if",
"not",
"self",
".",
"inmemory",
":",
"self",
".",
"close",
"(",
")",
"del",
"hdu",
"return",
"_shape"
] | Returns the shape of the data array associated with this file. | [
"Returns",
"the",
"shape",
"of",
"the",
"data",
"array",
"associated",
"with",
"this",
"file",
"."
] | python | train |
LuqueDaniel/pybooru | pybooru/api_danbooru.py | https://github.com/LuqueDaniel/pybooru/blob/60cd5254684d293b308f0b11b8f4ac2dce101479/pybooru/api_danbooru.py#L393-L402 | def comment_vote(self, comment_id, score):
"""Lets you vote for a comment (Requires login).
Parameters:
comment_id (int):
score (str): Can be: up, down.
"""
params = {'score': score}
return self._get('comments/{0}/votes.json'.format(comment_id), params,
... | [
"def",
"comment_vote",
"(",
"self",
",",
"comment_id",
",",
"score",
")",
":",
"params",
"=",
"{",
"'score'",
":",
"score",
"}",
"return",
"self",
".",
"_get",
"(",
"'comments/{0}/votes.json'",
".",
"format",
"(",
"comment_id",
")",
",",
"params",
",",
"... | Lets you vote for a comment (Requires login).
Parameters:
comment_id (int):
score (str): Can be: up, down. | [
"Lets",
"you",
"vote",
"for",
"a",
"comment",
"(",
"Requires",
"login",
")",
"."
] | python | train |
phodge/homely | homely/_utils.py | https://github.com/phodge/homely/blob/98ddcf3e4f29b0749645817b4866baaea8376085/homely/_utils.py#L615-L648 | def getstatus():
"""Get the status of the previous 'homely update', or any 'homely update'
that may be running in another process.
"""
if exists(RUNFILE):
mtime = os.stat(RUNFILE).st_mtime
with open(SECTIONFILE) as f:
section = f.read().strip()
# what section?
... | [
"def",
"getstatus",
"(",
")",
":",
"if",
"exists",
"(",
"RUNFILE",
")",
":",
"mtime",
"=",
"os",
".",
"stat",
"(",
"RUNFILE",
")",
".",
"st_mtime",
"with",
"open",
"(",
"SECTIONFILE",
")",
"as",
"f",
":",
"section",
"=",
"f",
".",
"read",
"(",
")... | Get the status of the previous 'homely update', or any 'homely update'
that may be running in another process. | [
"Get",
"the",
"status",
"of",
"the",
"previous",
"homely",
"update",
"or",
"any",
"homely",
"update",
"that",
"may",
"be",
"running",
"in",
"another",
"process",
"."
] | python | train |
Yubico/python-pyhsm | pyhsm/util.py | https://github.com/Yubico/python-pyhsm/blob/b6e2744d1ea15c352a0fc1d6ebc5950026b71311/pyhsm/util.py#L75-L86 | def input_validate_nonce(nonce, name='nonce', pad = False):
""" Input validation for nonces. """
if type(nonce) is not str:
raise pyhsm.exception.YHSM_WrongInputType( \
name, str, type(nonce))
if len(nonce) > pyhsm.defines.YSM_AEAD_NONCE_SIZE:
raise pyhsm.exception.YHSM_InputTooL... | [
"def",
"input_validate_nonce",
"(",
"nonce",
",",
"name",
"=",
"'nonce'",
",",
"pad",
"=",
"False",
")",
":",
"if",
"type",
"(",
"nonce",
")",
"is",
"not",
"str",
":",
"raise",
"pyhsm",
".",
"exception",
".",
"YHSM_WrongInputType",
"(",
"name",
",",
"s... | Input validation for nonces. | [
"Input",
"validation",
"for",
"nonces",
"."
] | python | train |
DarkEnergySurvey/ugali | ugali/scratch/position_angle.py | https://github.com/DarkEnergySurvey/ugali/blob/21e890b4117fc810afb6fb058e8055d564f03382/ugali/scratch/position_angle.py#L63-L76 | def plot_skyreg(header, data, **kwargs):
""" Plot sky region defined by header and data
header : FITS header
data : Data array
"""
kwargs.setdefault('cmap','binary')
fig = plt.figure()
ax = pywcsgrid2.subplot(111, header=header)
ax.set_ticklabel_type("dms")
im = ax.imshow(data, ori... | [
"def",
"plot_skyreg",
"(",
"header",
",",
"data",
",",
"*",
"*",
"kwargs",
")",
":",
"kwargs",
".",
"setdefault",
"(",
"'cmap'",
",",
"'binary'",
")",
"fig",
"=",
"plt",
".",
"figure",
"(",
")",
"ax",
"=",
"pywcsgrid2",
".",
"subplot",
"(",
"111",
... | Plot sky region defined by header and data
header : FITS header
data : Data array | [
"Plot",
"sky",
"region",
"defined",
"by",
"header",
"and",
"data",
"header",
":",
"FITS",
"header",
"data",
":",
"Data",
"array"
] | python | train |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.