nwo stringlengths 5 106 | sha stringlengths 40 40 | path stringlengths 4 174 | language stringclasses 1
value | identifier stringlengths 1 140 | parameters stringlengths 0 87.7k | argument_list stringclasses 1
value | return_statement stringlengths 0 426k | docstring stringlengths 0 64.3k | docstring_summary stringlengths 0 26.3k | docstring_tokens list | function stringlengths 18 4.83M | function_tokens list | url stringlengths 83 304 |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
andresriancho/w3af | cd22e5252243a87aaa6d0ddea47cf58dacfe00a9 | w3af/core/data/parsers/doc/sgml.py | python | SGMLParser.get_references | (self) | return self.references | [] | def get_references(self):
return self.references | [
"def",
"get_references",
"(",
"self",
")",
":",
"return",
"self",
".",
"references"
] | https://github.com/andresriancho/w3af/blob/cd22e5252243a87aaa6d0ddea47cf58dacfe00a9/w3af/core/data/parsers/doc/sgml.py#L473-L474 | |||
robinhood/faust | 01b4c0ad8390221db71751d80001b0fd879291e2 | faust/types/settings/settings.py | python | Settings.stream_ack_cancelled_tasks | (self) | Deprecated setting has no effect. | Deprecated setting has no effect. | [
"Deprecated",
"setting",
"has",
"no",
"effect",
"."
] | def stream_ack_cancelled_tasks(self) -> bool:
"""Deprecated setting has no effect.""" | [
"def",
"stream_ack_cancelled_tasks",
"(",
"self",
")",
"->",
"bool",
":"
] | https://github.com/robinhood/faust/blob/01b4c0ad8390221db71751d80001b0fd879291e2/faust/types/settings/settings.py#L2315-L2316 | ||
AppScale/gts | 46f909cf5dc5ba81faf9d81dc9af598dcf8a82a9 | AppServer/google/appengine/ext/ndb/key.py | python | Key.get_async | (self, **ctx_options) | return fut | Return a Future whose result is the entity for this Key.
If no such entity exists, a Future is still returned, and the
Future's eventual return result be None. | Return a Future whose result is the entity for this Key. | [
"Return",
"a",
"Future",
"whose",
"result",
"is",
"the",
"entity",
"for",
"this",
"Key",
"."
] | def get_async(self, **ctx_options):
"""Return a Future whose result is the entity for this Key.
If no such entity exists, a Future is still returned, and the
Future's eventual return result be None.
"""
from . import model, tasklets
ctx = tasklets.get_context()
cls = model.Model._kind_map.g... | [
"def",
"get_async",
"(",
"self",
",",
"*",
"*",
"ctx_options",
")",
":",
"from",
".",
"import",
"model",
",",
"tasklets",
"ctx",
"=",
"tasklets",
".",
"get_context",
"(",
")",
"cls",
"=",
"model",
".",
"Model",
".",
"_kind_map",
".",
"get",
"(",
"sel... | https://github.com/AppScale/gts/blob/46f909cf5dc5ba81faf9d81dc9af598dcf8a82a9/AppServer/google/appengine/ext/ndb/key.py#L534-L551 | |
dhconnelly/paip-python | e6784004bea1d16c90a4ca75c798ae31e6ab698a | paip/examples/search/pathfinding.py | python | print_map | (map) | Pretty-prints the given map to standard output. | Pretty-prints the given map to standard output. | [
"Pretty",
"-",
"prints",
"the",
"given",
"map",
"to",
"standard",
"output",
"."
] | def print_map(map):
"""Pretty-prints the given map to standard output."""
print '-' * (2 * len(map) + 3)
for row in map:
print '|',
for col in row:
print '%s' % (col if col == 1 or col == 'X' else ' '),
print '|'
print '-' * (2 * len(map) + 3) | [
"def",
"print_map",
"(",
"map",
")",
":",
"print",
"'-'",
"*",
"(",
"2",
"*",
"len",
"(",
"map",
")",
"+",
"3",
")",
"for",
"row",
"in",
"map",
":",
"print",
"'|'",
",",
"for",
"col",
"in",
"row",
":",
"print",
"'%s'",
"%",
"(",
"col",
"if",
... | https://github.com/dhconnelly/paip-python/blob/e6784004bea1d16c90a4ca75c798ae31e6ab698a/paip/examples/search/pathfinding.py#L35-L43 | ||
MeanEYE/Sunflower | 1024bbdde3b8e202ddad3553b321a7b6230bffc9 | sunflower/gui/input_dialog.py | python | CreateToolbarWidgetDialog.set_transient_for | (self, window) | Set dialog window transistency | Set dialog window transistency | [
"Set",
"dialog",
"window",
"transistency"
] | def set_transient_for(self, window):
"""Set dialog window transistency"""
self._dialog.set_transient_for(window) | [
"def",
"set_transient_for",
"(",
"self",
",",
"window",
")",
":",
"self",
".",
"_dialog",
".",
"set_transient_for",
"(",
"window",
")"
] | https://github.com/MeanEYE/Sunflower/blob/1024bbdde3b8e202ddad3553b321a7b6230bffc9/sunflower/gui/input_dialog.py#L1589-L1591 | ||
janpipek/physt | e7bce911532fac5f96e4e2d54881152e7e668a41 | physt/histogram_base.py | python | HistogramBase._apply_bin_map | (
self,
old_frequencies: np.ndarray,
new_frequencies: np.ndarray,
old_errors2: np.ndarray,
new_errors2: np.ndarray,
bin_map: Union[Iterable[Tuple[int, int]], int],
axis: int,
) | Fill new data arrays using a map.
Parameters
----------
old_frequencies : Source of frequencies data
new_frequencies : Target of frequencies data
old_errors2 : Source of errors data
new_errors2 : Target of errors data
bin_map: Iterable[(old, new)] or int or None
... | Fill new data arrays using a map. | [
"Fill",
"new",
"data",
"arrays",
"using",
"a",
"map",
"."
] | def _apply_bin_map(
self,
old_frequencies: np.ndarray,
new_frequencies: np.ndarray,
old_errors2: np.ndarray,
new_errors2: np.ndarray,
bin_map: Union[Iterable[Tuple[int, int]], int],
axis: int,
):
"""Fill new data arrays using a map.
Parameters... | [
"def",
"_apply_bin_map",
"(",
"self",
",",
"old_frequencies",
":",
"np",
".",
"ndarray",
",",
"new_frequencies",
":",
"np",
".",
"ndarray",
",",
"old_errors2",
":",
"np",
".",
"ndarray",
",",
"new_errors2",
":",
"np",
".",
"ndarray",
",",
"bin_map",
":",
... | https://github.com/janpipek/physt/blob/e7bce911532fac5f96e4e2d54881152e7e668a41/physt/histogram_base.py#L584-L622 | ||
krintoxi/NoobSec-Toolkit | 38738541cbc03cedb9a3b3ed13b629f781ad64f6 | NoobSecToolkit /tools/sqli/plugins/dbms/firebird/syntax.py | python | Syntax.__init__ | (self) | [] | def __init__(self):
GenericSyntax.__init__(self) | [
"def",
"__init__",
"(",
"self",
")",
":",
"GenericSyntax",
".",
"__init__",
"(",
"self",
")"
] | https://github.com/krintoxi/NoobSec-Toolkit/blob/38738541cbc03cedb9a3b3ed13b629f781ad64f6/NoobSecToolkit /tools/sqli/plugins/dbms/firebird/syntax.py#L13-L14 | ||||
Kozea/WeasyPrint | 6cce2978165134e37683cb5b3d156cac6a11a7f9 | weasyprint/css/validation/properties.py | python | footnote_display | (keyword) | return keyword in ('block', 'inline', 'compact') | Validation for ``footnote-display``. | Validation for ``footnote-display``. | [
"Validation",
"for",
"footnote",
"-",
"display",
"."
] | def footnote_display(keyword):
"""Validation for ``footnote-display``."""
return keyword in ('block', 'inline', 'compact') | [
"def",
"footnote_display",
"(",
"keyword",
")",
":",
"return",
"keyword",
"in",
"(",
"'block'",
",",
"'inline'",
",",
"'compact'",
")"
] | https://github.com/Kozea/WeasyPrint/blob/6cce2978165134e37683cb5b3d156cac6a11a7f9/weasyprint/css/validation/properties.py#L1469-L1471 | |
pandaproject/panda | 133baa47882a289773a30c9656e2ea4efe569387 | panda/models/task_status.py | python | TaskStatus.complete | (self, message) | Mark that task has completed. | Mark that task has completed. | [
"Mark",
"that",
"task",
"has",
"completed",
"."
] | def complete(self, message):
"""
Mark that task has completed.
"""
self.status = 'SUCCESS'
self.end = now()
self.message = message
self.save() | [
"def",
"complete",
"(",
"self",
",",
"message",
")",
":",
"self",
".",
"status",
"=",
"'SUCCESS'",
"self",
".",
"end",
"=",
"now",
"(",
")",
"self",
".",
"message",
"=",
"message",
"self",
".",
"save",
"(",
")"
] | https://github.com/pandaproject/panda/blob/133baa47882a289773a30c9656e2ea4efe569387/panda/models/task_status.py#L85-L92 | ||
mozillazg/pypy | 2ff5cd960c075c991389f842c6d59e71cf0cb7d0 | lib-python/2.7/urllib.py | python | toBytes | (url) | return url | toBytes(u"URL") --> 'URL'. | toBytes(u"URL") --> 'URL'. | [
"toBytes",
"(",
"u",
"URL",
")",
"--",
">",
"URL",
"."
] | def toBytes(url):
"""toBytes(u"URL") --> 'URL'."""
# Most URL schemes require ASCII. If that changes, the conversion
# can be relaxed
if _is_unicode(url):
try:
url = url.encode("ASCII")
except UnicodeError:
raise UnicodeError("URL " + repr(url) +
... | [
"def",
"toBytes",
"(",
"url",
")",
":",
"# Most URL schemes require ASCII. If that changes, the conversion",
"# can be relaxed",
"if",
"_is_unicode",
"(",
"url",
")",
":",
"try",
":",
"url",
"=",
"url",
".",
"encode",
"(",
"\"ASCII\"",
")",
"except",
"UnicodeError",... | https://github.com/mozillazg/pypy/blob/2ff5cd960c075c991389f842c6d59e71cf0cb7d0/lib-python/2.7/urllib.py#L1065-L1075 | |
HymanLiuTS/flaskTs | 286648286976e85d9b9a5873632331efcafe0b21 | flasky/lib/python2.7/site-packages/sqlalchemy/sql/elements.py | python | outparam | (key, type_=None) | return BindParameter(
key, None, type_=type_, unique=False, isoutparam=True) | Create an 'OUT' parameter for usage in functions (stored procedures),
for databases which support them.
The ``outparam`` can be used like a regular function parameter.
The "output" value will be available from the
:class:`~sqlalchemy.engine.ResultProxy` object via its ``out_parameters``
attribute, ... | Create an 'OUT' parameter for usage in functions (stored procedures),
for databases which support them. | [
"Create",
"an",
"OUT",
"parameter",
"for",
"usage",
"in",
"functions",
"(",
"stored",
"procedures",
")",
"for",
"databases",
"which",
"support",
"them",
"."
] | def outparam(key, type_=None):
"""Create an 'OUT' parameter for usage in functions (stored procedures),
for databases which support them.
The ``outparam`` can be used like a regular function parameter.
The "output" value will be available from the
:class:`~sqlalchemy.engine.ResultProxy` object via ... | [
"def",
"outparam",
"(",
"key",
",",
"type_",
"=",
"None",
")",
":",
"return",
"BindParameter",
"(",
"key",
",",
"None",
",",
"type_",
"=",
"type_",
",",
"unique",
"=",
"False",
",",
"isoutparam",
"=",
"True",
")"
] | https://github.com/HymanLiuTS/flaskTs/blob/286648286976e85d9b9a5873632331efcafe0b21/flasky/lib/python2.7/site-packages/sqlalchemy/sql/elements.py#L129-L140 | |
FSecureLABS/Jandroid | e31d0dab58a2bfd6ed8e0a387172b8bd7c893436 | libs/platform-tools/platform-tools_windows/systrace/catapult/devil/devil/base_error.py | python | BaseError.is_infra_error | (self) | return self._is_infra_error | Property to indicate if error was caused by an infrastructure issue. | Property to indicate if error was caused by an infrastructure issue. | [
"Property",
"to",
"indicate",
"if",
"error",
"was",
"caused",
"by",
"an",
"infrastructure",
"issue",
"."
] | def is_infra_error(self):
"""Property to indicate if error was caused by an infrastructure issue."""
return self._is_infra_error | [
"def",
"is_infra_error",
"(",
"self",
")",
":",
"return",
"self",
".",
"_is_infra_error"
] | https://github.com/FSecureLABS/Jandroid/blob/e31d0dab58a2bfd6ed8e0a387172b8bd7c893436/libs/platform-tools/platform-tools_windows/systrace/catapult/devil/devil/base_error.py#L21-L23 | |
jotyGill/openpyn-nordvpn | 74a2c4d8529f0a2ca138bbb0b338da02f3233d8c | openpyn/converter.py | python | Converter.set_certs_folder | (self, certs_output) | Sets the destination folder for the certificates | Sets the destination folder for the certificates | [
"Sets",
"the",
"destination",
"folder",
"for",
"the",
"certificates"
] | def set_certs_folder(self, certs_output):
"""Sets the destination folder for the certificates"""
if not certs_output or not os.path.isdir(certs_output):
raise RuntimeError("Please specify a valid path for the certificates.")
self._certs_folder = certs_output | [
"def",
"set_certs_folder",
"(",
"self",
",",
"certs_output",
")",
":",
"if",
"not",
"certs_output",
"or",
"not",
"os",
".",
"path",
".",
"isdir",
"(",
"certs_output",
")",
":",
"raise",
"RuntimeError",
"(",
"\"Please specify a valid path for the certificates.\"",
... | https://github.com/jotyGill/openpyn-nordvpn/blob/74a2c4d8529f0a2ca138bbb0b338da02f3233d8c/openpyn/converter.py#L125-L130 | ||
heynemann/pyccuracy | 0bbe3bcff4d13a6501bf77d5af9457f6a1491ab6 | pyccuracy/airspeed.py | python | CachingFileLoader.load_template | (self, name) | return template | [] | def load_template(self, name):
if self.debugging: print "Loading template...", name,
mtime = os.path.getmtime(self.filename_of(name))
if self.known_templates.has_key(name):
template, prev_mtime = self.known_templates[name]
if mtime <= prev_mtime:
if self.d... | [
"def",
"load_template",
"(",
"self",
",",
"name",
")",
":",
"if",
"self",
".",
"debugging",
":",
"print",
"\"Loading template...\"",
",",
"name",
",",
"mtime",
"=",
"os",
".",
"path",
".",
"getmtime",
"(",
"self",
".",
"filename_of",
"(",
"name",
")",
... | https://github.com/heynemann/pyccuracy/blob/0bbe3bcff4d13a6501bf77d5af9457f6a1491ab6/pyccuracy/airspeed.py#L120-L132 | |||
jimgoo/zipline-tensorboard | 2c1aa45569dfa9506ff9689c2decb56e9da21403 | olmar_tensorboard.py | python | simplex_projection | (v, b=1) | return w | Projection vectors to the simplex domain
Implemented according to the paper: Efficient projections onto the
l1-ball for learning in high dimensions, John Duchi, et al. ICML 2008.
Implementation Time: 2011 June 17 by Bin@libin AT pmail.ntu.edu.sg
Optimization Problem: min_{w}\| w - v \|_{2}^{2}
s.t.... | Projection vectors to the simplex domain | [
"Projection",
"vectors",
"to",
"the",
"simplex",
"domain"
] | def simplex_projection(v, b=1):
"""Projection vectors to the simplex domain
Implemented according to the paper: Efficient projections onto the
l1-ball for learning in high dimensions, John Duchi, et al. ICML 2008.
Implementation Time: 2011 June 17 by Bin@libin AT pmail.ntu.edu.sg
Optimization Probl... | [
"def",
"simplex_projection",
"(",
"v",
",",
"b",
"=",
"1",
")",
":",
"v",
"=",
"np",
".",
"asarray",
"(",
"v",
")",
"p",
"=",
"len",
"(",
"v",
")",
"# Sort v into u in descending order",
"v",
"=",
"(",
"v",
">",
"0",
")",
"*",
"v",
"u",
"=",
"n... | https://github.com/jimgoo/zipline-tensorboard/blob/2c1aa45569dfa9506ff9689c2decb56e9da21403/olmar_tensorboard.py#L133-L168 | |
analysiscenter/batchflow | 294747da0bca309785f925be891441fdd824e9fa | batchflow/research/distributor.py | python | DynamicQueue.stop_workers | (self, n_workers) | Stop all workers by putting `None` task into queue. | Stop all workers by putting `None` task into queue. | [
"Stop",
"all",
"workers",
"by",
"putting",
"None",
"task",
"into",
"queue",
"."
] | def stop_workers(self, n_workers):
""" Stop all workers by putting `None` task into queue. """
for _ in range(n_workers):
self.put(None) | [
"def",
"stop_workers",
"(",
"self",
",",
"n_workers",
")",
":",
"for",
"_",
"in",
"range",
"(",
"n_workers",
")",
":",
"self",
".",
"put",
"(",
"None",
")"
] | https://github.com/analysiscenter/batchflow/blob/294747da0bca309785f925be891441fdd824e9fa/batchflow/research/distributor.py#L81-L84 | ||
openshift/openshift-tools | 1188778e728a6e4781acf728123e5b356380fe6f | openshift/installer/vendored/openshift-ansible-3.9.40/roles/lib_vendored_deps/filter_plugins/openshift_master.py | python | FilterModule.translate_idps | (idps, api_version) | return u(yaml.dump([idp.to_dict() for idp in idp_list],
allow_unicode=True,
default_flow_style=False,
width=float("inf"),
Dumper=AnsibleDumper)) | Translates a list of dictionaries into a valid identityProviders config | Translates a list of dictionaries into a valid identityProviders config | [
"Translates",
"a",
"list",
"of",
"dictionaries",
"into",
"a",
"valid",
"identityProviders",
"config"
] | def translate_idps(idps, api_version):
''' Translates a list of dictionaries into a valid identityProviders config '''
idp_list = []
if not isinstance(idps, list):
raise errors.AnsibleFilterError("|failed expects to filter on a list of identity providers")
for idp in idps:
... | [
"def",
"translate_idps",
"(",
"idps",
",",
"api_version",
")",
":",
"idp_list",
"=",
"[",
"]",
"if",
"not",
"isinstance",
"(",
"idps",
",",
"list",
")",
":",
"raise",
"errors",
".",
"AnsibleFilterError",
"(",
"\"|failed expects to filter on a list of identity prov... | https://github.com/openshift/openshift-tools/blob/1188778e728a6e4781acf728123e5b356380fe6f/openshift/installer/vendored/openshift-ansible-3.9.40/roles/lib_vendored_deps/filter_plugins/openshift_master.py#L461-L482 | |
pyparallel/pyparallel | 11e8c6072d48c8f13641925d17b147bf36ee0ba3 | Lib/email/utils.py | python | unquote | (str) | return str | Remove quotes from a string. | Remove quotes from a string. | [
"Remove",
"quotes",
"from",
"a",
"string",
"."
] | def unquote(str):
"""Remove quotes from a string."""
if len(str) > 1:
if str.startswith('"') and str.endswith('"'):
return str[1:-1].replace('\\\\', '\\').replace('\\"', '"')
if str.startswith('<') and str.endswith('>'):
return str[1:-1]
return str | [
"def",
"unquote",
"(",
"str",
")",
":",
"if",
"len",
"(",
"str",
")",
">",
"1",
":",
"if",
"str",
".",
"startswith",
"(",
"'\"'",
")",
"and",
"str",
".",
"endswith",
"(",
"'\"'",
")",
":",
"return",
"str",
"[",
"1",
":",
"-",
"1",
"]",
".",
... | https://github.com/pyparallel/pyparallel/blob/11e8c6072d48c8f13641925d17b147bf36ee0ba3/Lib/email/utils.py#L238-L245 | |
apple/coremltools | 141a83af482fcbdd5179807c9eaff9a7999c2c49 | coremltools/models/neural_network/builder.py | python | NeuralNetworkBuilder.add_mvn | (
self,
name,
input_name,
output_name,
across_channels=True,
normalize_variance=True,
epsilon=1e-5,
) | return spec_layer | Add an MVN (mean variance normalization) layer. Computes mean, variance and normalizes the input.
Refer to the ``MeanVarianceNormalizeLayerParams`` message in the specification (NeuralNetwork.proto) for more details.
Parameters
----------
name: str
The name of this layer.
... | Add an MVN (mean variance normalization) layer. Computes mean, variance and normalizes the input.
Refer to the ``MeanVarianceNormalizeLayerParams`` message in the specification (NeuralNetwork.proto) for more details. | [
"Add",
"an",
"MVN",
"(",
"mean",
"variance",
"normalization",
")",
"layer",
".",
"Computes",
"mean",
"variance",
"and",
"normalizes",
"the",
"input",
".",
"Refer",
"to",
"the",
"MeanVarianceNormalizeLayerParams",
"message",
"in",
"the",
"specification",
"(",
"Ne... | def add_mvn(
self,
name,
input_name,
output_name,
across_channels=True,
normalize_variance=True,
epsilon=1e-5,
):
"""
Add an MVN (mean variance normalization) layer. Computes mean, variance and normalizes the input.
Refer to the ``MeanV... | [
"def",
"add_mvn",
"(",
"self",
",",
"name",
",",
"input_name",
",",
"output_name",
",",
"across_channels",
"=",
"True",
",",
"normalize_variance",
"=",
"True",
",",
"epsilon",
"=",
"1e-5",
",",
")",
":",
"spec_layer",
"=",
"self",
".",
"_add_generic_layer",
... | https://github.com/apple/coremltools/blob/141a83af482fcbdd5179807c9eaff9a7999c2c49/coremltools/models/neural_network/builder.py#L4237-L4281 | |
pyecharts/pyecharts | 727339e6c21fab6197983acbd2ea04783bd647a3 | pyecharts/datasets/__init__.py | python | FuzzyDict._search | (self, lookfor: typing.Any, stop_on_first: bool = False) | return best_ratio >= self.cutoff, best_key, best_match, best_ratio | Returns the value whose key best matches lookfor
if stop_on_first is True then the method returns as soon
as it finds the first item | Returns the value whose key best matches lookfor | [
"Returns",
"the",
"value",
"whose",
"key",
"best",
"matches",
"lookfor"
] | def _search(self, lookfor: typing.Any, stop_on_first: bool = False):
"""Returns the value whose key best matches lookfor
if stop_on_first is True then the method returns as soon
as it finds the first item
"""
# if the item is in the dictionary then just return it
if sel... | [
"def",
"_search",
"(",
"self",
",",
"lookfor",
":",
"typing",
".",
"Any",
",",
"stop_on_first",
":",
"bool",
"=",
"False",
")",
":",
"# if the item is in the dictionary then just return it",
"if",
"self",
".",
"_dict_contains",
"(",
"lookfor",
")",
":",
"return"... | https://github.com/pyecharts/pyecharts/blob/727339e6c21fab6197983acbd2ea04783bd647a3/pyecharts/datasets/__init__.py#L26-L72 | |
pypa/pipenv | b21baade71a86ab3ee1429f71fbc14d4f95fb75d | pipenv/patched/notpip/_internal/metadata/base.py | python | BaseDistribution.metadata_version | (self) | return self.metadata.get("Metadata-Version") | Value of "Metadata-Version:" in distribution metadata, if available. | Value of "Metadata-Version:" in distribution metadata, if available. | [
"Value",
"of",
"Metadata",
"-",
"Version",
":",
"in",
"distribution",
"metadata",
"if",
"available",
"."
] | def metadata_version(self) -> Optional[str]:
"""Value of "Metadata-Version:" in distribution metadata, if available."""
return self.metadata.get("Metadata-Version") | [
"def",
"metadata_version",
"(",
"self",
")",
"->",
"Optional",
"[",
"str",
"]",
":",
"return",
"self",
".",
"metadata",
".",
"get",
"(",
"\"Metadata-Version\"",
")"
] | https://github.com/pypa/pipenv/blob/b21baade71a86ab3ee1429f71fbc14d4f95fb75d/pipenv/patched/notpip/_internal/metadata/base.py#L154-L156 | |
wangzheng0822/algo | b2c1228ff915287ad7ebeae4355fa26854ea1557 | python/39_back_track/01_bag.py | python | get_value | (items_info: List, pick_items: List) | return sum([a*b for a, b in zip(values, pick_items)]) | [] | def get_value(items_info: List, pick_items: List):
values = [_[1] for _ in items_info]
return sum([a*b for a, b in zip(values, pick_items)]) | [
"def",
"get_value",
"(",
"items_info",
":",
"List",
",",
"pick_items",
":",
"List",
")",
":",
"values",
"=",
"[",
"_",
"[",
"1",
"]",
"for",
"_",
"in",
"items_info",
"]",
"return",
"sum",
"(",
"[",
"a",
"*",
"b",
"for",
"a",
",",
"b",
"in",
"zi... | https://github.com/wangzheng0822/algo/blob/b2c1228ff915287ad7ebeae4355fa26854ea1557/python/39_back_track/01_bag.py#L36-L38 | |||
yinhm/datafeed | 62193278212c2441d8e49b45d71b8d9d79aab31c | datafeed/dividend.py | python | Dividend.ex_date | (self) | return datetime.date.fromtimestamp(self._npd['time']) | [] | def ex_date(self):
return datetime.date.fromtimestamp(self._npd['time']) | [
"def",
"ex_date",
"(",
"self",
")",
":",
"return",
"datetime",
".",
"date",
".",
"fromtimestamp",
"(",
"self",
".",
"_npd",
"[",
"'time'",
"]",
")"
] | https://github.com/yinhm/datafeed/blob/62193278212c2441d8e49b45d71b8d9d79aab31c/datafeed/dividend.py#L81-L82 | |||
TencentCloud/tencentcloud-sdk-python | 3677fd1cdc8c5fd626ce001c13fd3b59d1f279d2 | tencentcloud/live/v20180801/models.py | python | BillDataInfo.__init__ | (self) | r"""
:param Time: 时间点,格式: yyyy-mm-dd HH:MM:SS。
:type Time: str
:param Bandwidth: 带宽,单位是 Mbps。
:type Bandwidth: float
:param Flux: 流量,单位是 MB。
:type Flux: float
:param PeakTime: 峰值时间点,格式: yyyy-mm-dd HH:MM:SS,原始数据为5分钟粒度,如果查询小时和天粒度数据,则返回对应粒度内的带宽峰值时间点。
:type Pe... | r"""
:param Time: 时间点,格式: yyyy-mm-dd HH:MM:SS。
:type Time: str
:param Bandwidth: 带宽,单位是 Mbps。
:type Bandwidth: float
:param Flux: 流量,单位是 MB。
:type Flux: float
:param PeakTime: 峰值时间点,格式: yyyy-mm-dd HH:MM:SS,原始数据为5分钟粒度,如果查询小时和天粒度数据,则返回对应粒度内的带宽峰值时间点。
:type Pe... | [
"r",
":",
"param",
"Time",
":",
"时间点,格式",
":",
"yyyy",
"-",
"mm",
"-",
"dd",
"HH",
":",
"MM",
":",
"SS。",
":",
"type",
"Time",
":",
"str",
":",
"param",
"Bandwidth",
":",
"带宽,单位是",
"Mbps。",
":",
"type",
"Bandwidth",
":",
"float",
":",
"param",
"F... | def __init__(self):
r"""
:param Time: 时间点,格式: yyyy-mm-dd HH:MM:SS。
:type Time: str
:param Bandwidth: 带宽,单位是 Mbps。
:type Bandwidth: float
:param Flux: 流量,单位是 MB。
:type Flux: float
:param PeakTime: 峰值时间点,格式: yyyy-mm-dd HH:MM:SS,原始数据为5分钟粒度,如果查询小时和天粒度数据,则返回对应粒... | [
"def",
"__init__",
"(",
"self",
")",
":",
"self",
".",
"Time",
"=",
"None",
"self",
".",
"Bandwidth",
"=",
"None",
"self",
".",
"Flux",
"=",
"None",
"self",
".",
"PeakTime",
"=",
"None"
] | https://github.com/TencentCloud/tencentcloud-sdk-python/blob/3677fd1cdc8c5fd626ce001c13fd3b59d1f279d2/tencentcloud/live/v20180801/models.py#L319-L333 | ||
bruderstein/PythonScript | df9f7071ddf3a079e3a301b9b53a6dc78cf1208f | PythonLib/min/optparse.py | python | Option._check_callback | (self) | [] | def _check_callback(self):
if self.action == "callback":
if not callable(self.callback):
raise OptionError(
"callback not callable: %r" % self.callback, self)
if (self.callback_args is not None and
not isinstance(self.callback_args, tup... | [
"def",
"_check_callback",
"(",
"self",
")",
":",
"if",
"self",
".",
"action",
"==",
"\"callback\"",
":",
"if",
"not",
"callable",
"(",
"self",
".",
"callback",
")",
":",
"raise",
"OptionError",
"(",
"\"callback not callable: %r\"",
"%",
"self",
".",
"callbac... | https://github.com/bruderstein/PythonScript/blob/df9f7071ddf3a079e3a301b9b53a6dc78cf1208f/PythonLib/min/optparse.py#L705-L730 | ||||
selfboot/LeetCode | 473c0c5451651140d75cbd143309c51cd8fe1cf1 | ToBeOptimized/18_4Sum.py | python | Solution.fourSum | (self, nums, target) | :type nums: List[int]
:type target: int
:rtype: List[List[int]] | :type nums: List[int]
:type target: int
:rtype: List[List[int]] | [
":",
"type",
"nums",
":",
"List",
"[",
"int",
"]",
":",
"type",
"target",
":",
"int",
":",
"rtype",
":",
"List",
"[",
"List",
"[",
"int",
"]]"
] | def fourSum(self, nums, target):
"""
:type nums: List[int]
:type target: int
:rtype: List[List[int]]
"""
nums.sort()
length = len(nums)
# Get all the two sums and their two addend's index.
two_sums_dict = {}
for i in range(length):
... | [
"def",
"fourSum",
"(",
"self",
",",
"nums",
",",
"target",
")",
":",
"nums",
".",
"sort",
"(",
")",
"length",
"=",
"len",
"(",
"nums",
")",
"# Get all the two sums and their two addend's index.",
"two_sums_dict",
"=",
"{",
"}",
"for",
"i",
"in",
"range",
"... | https://github.com/selfboot/LeetCode/blob/473c0c5451651140d75cbd143309c51cd8fe1cf1/ToBeOptimized/18_4Sum.py#L6-L26 | ||
asweigart/PythonStdioGames | 8bdabf93e6b1bb6af3e26fea24da93f85e8314b6 | src/gamesbyexample/ninetyninebottles2.py | python | slowPrint | (text, pauseAmount=0.1) | Slowly print out the characters in text one at a time. | Slowly print out the characters in text one at a time. | [
"Slowly",
"print",
"out",
"the",
"characters",
"in",
"text",
"one",
"at",
"a",
"time",
"."
] | def slowPrint(text, pauseAmount=0.1):
"""Slowly print out the characters in text one at a time."""
for character in text:
# Set flush=True here so the text is immediately printed:
print(character, flush=True, end='') # end='' means no newline.
time.sleep(pauseAmount) # Pause in between... | [
"def",
"slowPrint",
"(",
"text",
",",
"pauseAmount",
"=",
"0.1",
")",
":",
"for",
"character",
"in",
"text",
":",
"# Set flush=True here so the text is immediately printed:",
"print",
"(",
"character",
",",
"flush",
"=",
"True",
",",
"end",
"=",
"''",
")",
"# ... | https://github.com/asweigart/PythonStdioGames/blob/8bdabf93e6b1bb6af3e26fea24da93f85e8314b6/src/gamesbyexample/ninetyninebottles2.py#L16-L22 | ||
twilio/twilio-python | 6e1e811ea57a1edfadd5161ace87397c563f6915 | twilio/rest/flex_api/v1/__init__.py | python | V1.web_channel | (self) | return self._web_channel | :rtype: twilio.rest.flex_api.v1.web_channel.WebChannelList | :rtype: twilio.rest.flex_api.v1.web_channel.WebChannelList | [
":",
"rtype",
":",
"twilio",
".",
"rest",
".",
"flex_api",
".",
"v1",
".",
"web_channel",
".",
"WebChannelList"
] | def web_channel(self):
"""
:rtype: twilio.rest.flex_api.v1.web_channel.WebChannelList
"""
if self._web_channel is None:
self._web_channel = WebChannelList(self)
return self._web_channel | [
"def",
"web_channel",
"(",
"self",
")",
":",
"if",
"self",
".",
"_web_channel",
"is",
"None",
":",
"self",
".",
"_web_channel",
"=",
"WebChannelList",
"(",
"self",
")",
"return",
"self",
".",
"_web_channel"
] | https://github.com/twilio/twilio-python/blob/6e1e811ea57a1edfadd5161ace87397c563f6915/twilio/rest/flex_api/v1/__init__.py#L60-L66 | |
OpenCobolIDE/OpenCobolIDE | c78d0d335378e5fe0a5e74f53c19b68b55e85388 | open_cobol_ide/extlibs/future/backports/email/headerregistry.py | python | BaseHeader.defects | (self) | return tuple(self._defects) | [] | def defects(self):
return tuple(self._defects) | [
"def",
"defects",
"(",
"self",
")",
":",
"return",
"tuple",
"(",
"self",
".",
"_defects",
")"
] | https://github.com/OpenCobolIDE/OpenCobolIDE/blob/c78d0d335378e5fe0a5e74f53c19b68b55e85388/open_cobol_ide/extlibs/future/backports/email/headerregistry.py#L220-L221 | |||
HariSekhon/Nagios-Plugins | a436fc63e10ab8a64d623df109777dea2eda5758 | older/lib_nagios.py | python | NagiosTester.sighandler | (self, _discarded, _discarded2) | Function to be called by signal.alarm to kill the plugin | Function to be called by signal.alarm to kill the plugin | [
"Function",
"to",
"be",
"called",
"by",
"signal",
".",
"alarm",
"to",
"kill",
"the",
"plugin"
] | def sighandler(self, _discarded, _discarded2):
"""Function to be called by signal.alarm to kill the plugin"""
if self.timeout == 1:
timeout = "(1 second)"
else:
timeout = "(%s seconds)" % self.timeout
if not CHECK_NAME:
check_name = ""
else:
... | [
"def",
"sighandler",
"(",
"self",
",",
"_discarded",
",",
"_discarded2",
")",
":",
"if",
"self",
".",
"timeout",
"==",
"1",
":",
"timeout",
"=",
"\"(1 second)\"",
"else",
":",
"timeout",
"=",
"\"(%s seconds)\"",
"%",
"self",
".",
"timeout",
"if",
"not",
... | https://github.com/HariSekhon/Nagios-Plugins/blob/a436fc63e10ab8a64d623df109777dea2eda5758/older/lib_nagios.py#L210-L224 | ||
holzschu/Carnets | 44effb10ddfc6aa5c8b0687582a724ba82c6b547 | Library/lib/python3.7/site-packages/pip/_vendor/urllib3/connectionpool.py | python | HTTPSConnectionPool._prepare_proxy | (self, conn) | Establish tunnel connection early, because otherwise httplib
would improperly set Host: header to proxy's IP:port. | Establish tunnel connection early, because otherwise httplib
would improperly set Host: header to proxy's IP:port. | [
"Establish",
"tunnel",
"connection",
"early",
"because",
"otherwise",
"httplib",
"would",
"improperly",
"set",
"Host",
":",
"header",
"to",
"proxy",
"s",
"IP",
":",
"port",
"."
] | def _prepare_proxy(self, conn):
"""
Establish tunnel connection early, because otherwise httplib
would improperly set Host: header to proxy's IP:port.
"""
conn.set_tunnel(self._proxy_host, self.port, self.proxy_headers)
conn.connect() | [
"def",
"_prepare_proxy",
"(",
"self",
",",
"conn",
")",
":",
"conn",
".",
"set_tunnel",
"(",
"self",
".",
"_proxy_host",
",",
"self",
".",
"port",
",",
"self",
".",
"proxy_headers",
")",
"conn",
".",
"connect",
"(",
")"
] | https://github.com/holzschu/Carnets/blob/44effb10ddfc6aa5c8b0687582a724ba82c6b547/Library/lib/python3.7/site-packages/pip/_vendor/urllib3/connectionpool.py#L799-L805 | ||
StyraHem/ShellyForHASS | 902c04ab25b0a7667718eeef53bb6ad43614fe2f | custom_components/shelly/__init__.py | python | ShellyInstance.stop | (self, _=None) | Stop Shelly. | Stop Shelly. | [
"Stop",
"Shelly",
"."
] | async def stop(self, _=None):
"""Stop Shelly."""
_LOGGER.info("Shutting down Shelly")
entity_reg = \
await self.hass.helpers.entity_registry.async_get_registry()
#entities_to_remove = []
#for entity in entity_reg.entities.values():
# if entity.platform == "... | [
"async",
"def",
"stop",
"(",
"self",
",",
"_",
"=",
"None",
")",
":",
"_LOGGER",
".",
"info",
"(",
"\"Shutting down Shelly\"",
")",
"entity_reg",
"=",
"await",
"self",
".",
"hass",
".",
"helpers",
".",
"entity_registry",
".",
"async_get_registry",
"(",
")"... | https://github.com/StyraHem/ShellyForHASS/blob/902c04ab25b0a7667718eeef53bb6ad43614fe2f/custom_components/shelly/__init__.py#L407-L421 | ||
samuelcolvin/arq | 5f6162c94816d4b4302e9c8666da1f4a46cac228 | arq/worker.py | python | FailedJobs.__str__ | (self) | [] | def __str__(self) -> str:
if self.count == 1 and self.job_results:
exc = self.job_results[0].result
return f'1 job failed {exc!r}'
else:
return f'{self.count} jobs failed:\n' + '\n'.join(repr(r.result) for r in self.job_results) | [
"def",
"__str__",
"(",
"self",
")",
"->",
"str",
":",
"if",
"self",
".",
"count",
"==",
"1",
"and",
"self",
".",
"job_results",
":",
"exc",
"=",
"self",
".",
"job_results",
"[",
"0",
"]",
".",
"result",
"return",
"f'1 job failed {exc!r}'",
"else",
":",... | https://github.com/samuelcolvin/arq/blob/5f6162c94816d4b4302e9c8666da1f4a46cac228/arq/worker.py#L113-L118 | ||||
richrd/suplemon | 8bb67d6758e5bc5ca200fdce7a0fb6635abb66f4 | suplemon/modules/battery.py | python | Battery.readf | (self, path) | return data | Read and return file contents at path. | Read and return file contents at path. | [
"Read",
"and",
"return",
"file",
"contents",
"at",
"path",
"."
] | def readf(self, path):
"""Read and return file contents at path."""
f = open(path)
data = f.read()
f.close()
return data | [
"def",
"readf",
"(",
"self",
",",
"path",
")",
":",
"f",
"=",
"open",
"(",
"path",
")",
"data",
"=",
"f",
".",
"read",
"(",
")",
"f",
".",
"close",
"(",
")",
"return",
"data"
] | https://github.com/richrd/suplemon/blob/8bb67d6758e5bc5ca200fdce7a0fb6635abb66f4/suplemon/modules/battery.py#L106-L111 | |
linxid/Machine_Learning_Study_Path | 558e82d13237114bbb8152483977806fc0c222af | Machine Learning In Action/Chapter5-LogisticRegression/venv/Lib/_weakrefset.py | python | WeakSet.discard | (self, item) | [] | def discard(self, item):
if self._pending_removals:
self._commit_removals()
self.data.discard(ref(item)) | [
"def",
"discard",
"(",
"self",
",",
"item",
")",
":",
"if",
"self",
".",
"_pending_removals",
":",
"self",
".",
"_commit_removals",
"(",
")",
"self",
".",
"data",
".",
"discard",
"(",
"ref",
"(",
"item",
")",
")"
] | https://github.com/linxid/Machine_Learning_Study_Path/blob/558e82d13237114bbb8152483977806fc0c222af/Machine Learning In Action/Chapter5-LogisticRegression/venv/Lib/_weakrefset.py#L111-L114 | ||||
ilastik/ilastik | 6acd2c554bc517e9c8ddad3623a7aaa2e6970c28 | ilastik/shell/gui/startShellGui.py | python | _applyStyleSheet | (app) | Apply application-wide style-sheet rules. | Apply application-wide style-sheet rules. | [
"Apply",
"application",
"-",
"wide",
"style",
"-",
"sheet",
"rules",
"."
] | def _applyStyleSheet(app):
"""
Apply application-wide style-sheet rules.
"""
styleSheetPath = os.path.join(os.path.split(__file__)[0], "ilastik-style.qss")
with open(styleSheetPath, "r") as f:
styleSheetText = f.read()
app.setStyleSheet(styleSheetText) | [
"def",
"_applyStyleSheet",
"(",
"app",
")",
":",
"styleSheetPath",
"=",
"os",
".",
"path",
".",
"join",
"(",
"os",
".",
"path",
".",
"split",
"(",
"__file__",
")",
"[",
"0",
"]",
",",
"\"ilastik-style.qss\"",
")",
"with",
"open",
"(",
"styleSheetPath",
... | https://github.com/ilastik/ilastik/blob/6acd2c554bc517e9c8ddad3623a7aaa2e6970c28/ilastik/shell/gui/startShellGui.py#L73-L80 | ||
TurboWay/spiderman | 168f18552e0abb06187388b542d6a0df057ba852 | SP/pipelines/pipelines_hdfs.py | python | HdfsPipeline.process_item | (self, item, spider) | return item | :param item:
:param spider:
:return: 数据分表入库 | :param item:
:param spider:
:return: 数据分表入库 | [
":",
"param",
"item",
":",
":",
"param",
"spider",
":",
":",
"return",
":",
"数据分表入库"
] | def process_item(self, item, spider):
"""
:param item:
:param spider:
:return: 数据分表入库
"""
if item.tablename in self.buckets_map:
self.buckets_map[item.tablename].append(item)
else:
cols, col_default = [], {}
for field, value in ... | [
"def",
"process_item",
"(",
"self",
",",
"item",
",",
"spider",
")",
":",
"if",
"item",
".",
"tablename",
"in",
"self",
".",
"buckets_map",
":",
"self",
".",
"buckets_map",
"[",
"item",
".",
"tablename",
"]",
".",
"append",
"(",
"item",
")",
"else",
... | https://github.com/TurboWay/spiderman/blob/168f18552e0abb06187388b542d6a0df057ba852/SP/pipelines/pipelines_hdfs.py#L41-L60 | |
p-christ/nn_builder | a79b45d15176b4d333dbed094e78bb3b216ed037 | nn_builder/pytorch/CNN.py | python | CNN.check_CNN_layers_valid | (self) | Checks that the user inputs for cnn_hidden_layers were valid. cnn_hidden_layers must be a list of layers where
each layer must be of one of these forms:
- ["conv", channels, kernel_size, stride, padding]
- ["maxpool", kernel_size, stride, padding]
- ["avgpool", kernel_size, stride, paddi... | Checks that the user inputs for cnn_hidden_layers were valid. cnn_hidden_layers must be a list of layers where
each layer must be of one of these forms:
- ["conv", channels, kernel_size, stride, padding]
- ["maxpool", kernel_size, stride, padding]
- ["avgpool", kernel_size, stride, paddi... | [
"Checks",
"that",
"the",
"user",
"inputs",
"for",
"cnn_hidden_layers",
"were",
"valid",
".",
"cnn_hidden_layers",
"must",
"be",
"a",
"list",
"of",
"layers",
"where",
"each",
"layer",
"must",
"be",
"of",
"one",
"of",
"these",
"forms",
":",
"-",
"[",
"conv",... | def check_CNN_layers_valid(self):
"""Checks that the user inputs for cnn_hidden_layers were valid. cnn_hidden_layers must be a list of layers where
each layer must be of one of these forms:
- ["conv", channels, kernel_size, stride, padding]
- ["maxpool", kernel_size, stride, padding]
... | [
"def",
"check_CNN_layers_valid",
"(",
"self",
")",
":",
"error_msg_layer_type",
"=",
"\"First element in a layer specification must be one of {}\"",
".",
"format",
"(",
"self",
".",
"valid_cnn_hidden_layer_types",
")",
"error_msg_conv_layer",
"=",
"\"\"\"Conv layer must be of for... | https://github.com/p-christ/nn_builder/blob/a79b45d15176b4d333dbed094e78bb3b216ed037/nn_builder/pytorch/CNN.py#L65-L137 | ||
thusiyuan/holistic_scene_parsing | b4a73b2cfe218e1374a8a6e63f1df52ae57431d0 | utils/plyfile.py | python | PlyProperty.dtype | (self, byte_order='=') | return byte_order + self.val_dtype | Return the numpy dtype description for this property (as a tuple
of strings). | Return the numpy dtype description for this property (as a tuple
of strings). | [
"Return",
"the",
"numpy",
"dtype",
"description",
"for",
"this",
"property",
"(",
"as",
"a",
"tuple",
"of",
"strings",
")",
"."
] | def dtype(self, byte_order='='):
'''
Return the numpy dtype description for this property (as a tuple
of strings).
'''
return byte_order + self.val_dtype | [
"def",
"dtype",
"(",
"self",
",",
"byte_order",
"=",
"'='",
")",
":",
"return",
"byte_order",
"+",
"self",
".",
"val_dtype"
] | https://github.com/thusiyuan/holistic_scene_parsing/blob/b4a73b2cfe218e1374a8a6e63f1df52ae57431d0/utils/plyfile.py#L770-L776 | |
microsoft/hummingbird | 2705c42585ac1d3ee69e65a93e5f59d7d42f44d5 | hummingbird/ml/operator_converters/sparkml/discretizer.py | python | convert_sparkml_bucketizer | (operator, device, extra_config) | return KBinsDiscretizer(operator, None, None, np.array(bin_edges), labels, device) | Converter for `pyspark.ml.feature.Bucketizer`
Args:
operator: An operator wrapping a `pyspark.ml.feature.QuantileDiscretizer` model
device: String defining the type of device the converted operator should be run on
extra_config: Extra configuration used to select the best conversion strateg... | Converter for `pyspark.ml.feature.Bucketizer` | [
"Converter",
"for",
"pyspark",
".",
"ml",
".",
"feature",
".",
"Bucketizer"
] | def convert_sparkml_bucketizer(operator, device, extra_config):
"""
Converter for `pyspark.ml.feature.Bucketizer`
Args:
operator: An operator wrapping a `pyspark.ml.feature.QuantileDiscretizer` model
device: String defining the type of device the converted operator should be run on
... | [
"def",
"convert_sparkml_bucketizer",
"(",
"operator",
",",
"device",
",",
"extra_config",
")",
":",
"bin_edges",
"=",
"[",
"operator",
".",
"raw_operator",
".",
"getSplits",
"(",
")",
"]",
"max_bin_edges",
"=",
"max",
"(",
"[",
"len",
"(",
"bins",
")",
"fo... | https://github.com/microsoft/hummingbird/blob/2705c42585ac1d3ee69e65a93e5f59d7d42f44d5/hummingbird/ml/operator_converters/sparkml/discretizer.py#L19-L40 | |
KalleHallden/AutoTimer | 2d954216700c4930baa154e28dbddc34609af7ce | env/lib/python2.7/site-packages/setuptools/_vendor/pyparsing.py | python | FollowedBy.parseImpl | ( self, instring, loc, doActions=True ) | return loc, [] | [] | def parseImpl( self, instring, loc, doActions=True ):
self.expr.tryParse( instring, loc )
return loc, [] | [
"def",
"parseImpl",
"(",
"self",
",",
"instring",
",",
"loc",
",",
"doActions",
"=",
"True",
")",
":",
"self",
".",
"expr",
".",
"tryParse",
"(",
"instring",
",",
"loc",
")",
"return",
"loc",
",",
"[",
"]"
] | https://github.com/KalleHallden/AutoTimer/blob/2d954216700c4930baa154e28dbddc34609af7ce/env/lib/python2.7/site-packages/setuptools/_vendor/pyparsing.py#L3813-L3815 | |||
cool-RR/python_toolbox | cb9ef64b48f1d03275484d707dc5079b6701ad0c | python_toolbox/nifty_collections/lazy_tuple.py | python | _with_lock | (method, *args, **kwargs) | Decorator for using the `LazyTuple`'s lock. | Decorator for using the `LazyTuple`'s lock. | [
"Decorator",
"for",
"using",
"the",
"LazyTuple",
"s",
"lock",
"."
] | def _with_lock(method, *args, **kwargs):
'''Decorator for using the `LazyTuple`'s lock.'''
self = args[0]
with self.lock:
return method(*args, **kwargs) | [
"def",
"_with_lock",
"(",
"method",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"self",
"=",
"args",
"[",
"0",
"]",
"with",
"self",
".",
"lock",
":",
"return",
"method",
"(",
"*",
"args",
",",
"*",
"*",
"kwargs",
")"
] | https://github.com/cool-RR/python_toolbox/blob/cb9ef64b48f1d03275484d707dc5079b6701ad0c/python_toolbox/nifty_collections/lazy_tuple.py#L41-L45 | ||
SUSE/DeepSea | 9c7fad93915ba1250c40d50c855011e9fe41ed21 | cli/deepsea.py | python | cli | (log_level, log_file) | DeepSea CLI tool.
Use this tool to visualize the execution progress of DeepSea, either by
running the stages directly through "stage run" command, or by monitoring
the salt-run execution using the "monitor" command. | DeepSea CLI tool. | [
"DeepSea",
"CLI",
"tool",
"."
] | def cli(log_level, log_file):
"""
DeepSea CLI tool.
Use this tool to visualize the execution progress of DeepSea, either by
running the stages directly through "stage run" command, or by monitoring
the salt-run execution using the "monitor" command.
"""
Config.LOG_LEVEL = log_level
Conf... | [
"def",
"cli",
"(",
"log_level",
",",
"log_file",
")",
":",
"Config",
".",
"LOG_LEVEL",
"=",
"log_level",
"Config",
".",
"LOG_FILE_PATH",
"=",
"log_file"
] | https://github.com/SUSE/DeepSea/blob/9c7fad93915ba1250c40d50c855011e9fe41ed21/cli/deepsea.py#L256-L265 | ||
kovidgoyal/calibre | 2b41671370f2a9eb1109b9ae901ccf915f1bd0c8 | src/calibre/library/catalogs/epub_mobi_builder.py | python | CatalogBuilder.generate_html_description_header | (self, book) | return soup | Generate the HTML Description header from template.
Create HTML Description from book metadata and template.
Called by generate_html_descriptions()
Args:
book (dict): book metadata
Return:
soup (BeautifulSoup): HTML Description for book | Generate the HTML Description header from template. | [
"Generate",
"the",
"HTML",
"Description",
"header",
"from",
"template",
"."
] | def generate_html_description_header(self, book):
""" Generate the HTML Description header from template.
Create HTML Description from book metadata and template.
Called by generate_html_descriptions()
Args:
book (dict): book metadata
Return:
soup (BeautifulS... | [
"def",
"generate_html_description_header",
"(",
"self",
",",
"book",
")",
":",
"from",
"calibre",
".",
"ebooks",
".",
"oeb",
".",
"base",
"import",
"XHTML_NS",
"def",
"_generate_html",
"(",
")",
":",
"args",
"=",
"dict",
"(",
"author",
"=",
"escape",
"(",
... | https://github.com/kovidgoyal/calibre/blob/2b41671370f2a9eb1109b9ae901ccf915f1bd0c8/src/calibre/library/catalogs/epub_mobi_builder.py#L2651-L2844 | |
oracle/graalpython | 577e02da9755d916056184ec441c26e00b70145c | graalpython/lib-python/3/ssl.py | python | _ASN1Object.fromnid | (cls, nid) | return super().__new__(cls, *_nid2obj(nid)) | Create _ASN1Object from OpenSSL numeric ID | Create _ASN1Object from OpenSSL numeric ID | [
"Create",
"_ASN1Object",
"from",
"OpenSSL",
"numeric",
"ID"
] | def fromnid(cls, nid):
"""Create _ASN1Object from OpenSSL numeric ID
"""
return super().__new__(cls, *_nid2obj(nid)) | [
"def",
"fromnid",
"(",
"cls",
",",
"nid",
")",
":",
"return",
"super",
"(",
")",
".",
"__new__",
"(",
"cls",
",",
"*",
"_nid2obj",
"(",
"nid",
")",
")"
] | https://github.com/oracle/graalpython/blob/577e02da9755d916056184ec441c26e00b70145c/graalpython/lib-python/3/ssl.py#L456-L459 | |
fortharris/Pcode | 147962d160a834c219e12cb456abc130826468e4 | venv/__init__.py | python | EnvBuilder.create | (self, env_dir) | Create a virtual environment in a directory.
:param env_dir: The target directory to create an environment in. | Create a virtual environment in a directory. | [
"Create",
"a",
"virtual",
"environment",
"in",
"a",
"directory",
"."
] | def create(self, env_dir):
"""
Create a virtual environment in a directory.
:param env_dir: The target directory to create an environment in.
"""
env_dir = os.path.abspath(env_dir)
context = self.ensure_directories(env_dir)
self.create_configuration(context)
... | [
"def",
"create",
"(",
"self",
",",
"env_dir",
")",
":",
"env_dir",
"=",
"os",
".",
"path",
".",
"abspath",
"(",
"env_dir",
")",
"context",
"=",
"self",
".",
"ensure_directories",
"(",
"env_dir",
")",
"self",
".",
"create_configuration",
"(",
"context",
"... | https://github.com/fortharris/Pcode/blob/147962d160a834c219e12cb456abc130826468e4/venv/__init__.py#L81-L94 | ||
zhl2008/awd-platform | 0416b31abea29743387b10b3914581fbe8e7da5e | web_flaskbb/Python-2.7.9/Lib/distutils/msvc9compiler.py | python | normalize_and_reduce_paths | (paths) | return reduced_paths | Return a list of normalized paths with duplicates removed.
The current order of paths is maintained. | Return a list of normalized paths with duplicates removed. | [
"Return",
"a",
"list",
"of",
"normalized",
"paths",
"with",
"duplicates",
"removed",
"."
] | def normalize_and_reduce_paths(paths):
"""Return a list of normalized paths with duplicates removed.
The current order of paths is maintained.
"""
# Paths are normalized so things like: /a and /a/ aren't both preserved.
reduced_paths = []
for p in paths:
np = os.path.normpath(p)
... | [
"def",
"normalize_and_reduce_paths",
"(",
"paths",
")",
":",
"# Paths are normalized so things like: /a and /a/ aren't both preserved.",
"reduced_paths",
"=",
"[",
"]",
"for",
"p",
"in",
"paths",
":",
"np",
"=",
"os",
".",
"path",
".",
"normpath",
"(",
"p",
")",
... | https://github.com/zhl2008/awd-platform/blob/0416b31abea29743387b10b3914581fbe8e7da5e/web_flaskbb/Python-2.7.9/Lib/distutils/msvc9compiler.py#L194-L206 | |
IJDykeman/wangTiles | 7c1ee2095ebdf7f72bce07d94c6484915d5cae8b | experimental_code/tiles_3d/venv_mac/lib/python2.7/site-packages/setuptools/command/easy_install.py | python | get_exe_prefixes | (exe_filename) | return prefixes | Get exe->egg path translations for a given .exe file | Get exe->egg path translations for a given .exe file | [
"Get",
"exe",
"-",
">",
"egg",
"path",
"translations",
"for",
"a",
"given",
".",
"exe",
"file"
] | def get_exe_prefixes(exe_filename):
"""Get exe->egg path translations for a given .exe file"""
prefixes = [
('PURELIB/', ''),
('PLATLIB/pywin32_system32', ''),
('PLATLIB/', ''),
('SCRIPTS/', 'EGG-INFO/scripts/'),
('DATA/lib/site-packages', ''),
]
z = zipfile.ZipF... | [
"def",
"get_exe_prefixes",
"(",
"exe_filename",
")",
":",
"prefixes",
"=",
"[",
"(",
"'PURELIB/'",
",",
"''",
")",
",",
"(",
"'PLATLIB/pywin32_system32'",
",",
"''",
")",
",",
"(",
"'PLATLIB/'",
",",
"''",
")",
",",
"(",
"'SCRIPTS/'",
",",
"'EGG-INFO/scrip... | https://github.com/IJDykeman/wangTiles/blob/7c1ee2095ebdf7f72bce07d94c6484915d5cae8b/experimental_code/tiles_3d/venv_mac/lib/python2.7/site-packages/setuptools/command/easy_install.py#L1534-L1570 | |
Pyomo/pyomo | dbd4faee151084f343b893cc2b0c04cf2b76fd92 | pyomo/dae/plugins/finitedifference.py | python | _central_transform_order2 | (v, s) | return _ctr_fun2 | Applies the Central Difference formula of order O(h^2) for second
derivatives | Applies the Central Difference formula of order O(h^2) for second
derivatives | [
"Applies",
"the",
"Central",
"Difference",
"formula",
"of",
"order",
"O",
"(",
"h^2",
")",
"for",
"second",
"derivatives"
] | def _central_transform_order2(v, s):
"""
Applies the Central Difference formula of order O(h^2) for second
derivatives
"""
def _ctr_fun2(i):
tmp = list(s)
idx = s.ord(i)-1
if idx == 0: # Needed since '-1' is considered a valid index in Python
raise IndexError("li... | [
"def",
"_central_transform_order2",
"(",
"v",
",",
"s",
")",
":",
"def",
"_ctr_fun2",
"(",
"i",
")",
":",
"tmp",
"=",
"list",
"(",
"s",
")",
"idx",
"=",
"s",
".",
"ord",
"(",
"i",
")",
"-",
"1",
"if",
"idx",
"==",
"0",
":",
"# Needed since '-1' i... | https://github.com/Pyomo/pyomo/blob/dbd4faee151084f343b893cc2b0c04cf2b76fd92/pyomo/dae/plugins/finitedifference.py#L45-L57 | |
karlicoss/HPI | be21606075cbc15018d1f36c2581ab138e4a44cc | my/core/__main__.py | python | module_cmd | (list_all: bool) | List available modules | List available modules | [
"List",
"available",
"modules"
] | def module_cmd(list_all: bool) -> None:
'''List available modules'''
list_modules(list_all=list_all) | [
"def",
"module_cmd",
"(",
"list_all",
":",
"bool",
")",
"->",
"None",
":",
"list_modules",
"(",
"list_all",
"=",
"list_all",
")"
] | https://github.com/karlicoss/HPI/blob/be21606075cbc15018d1f36c2581ab138e4a44cc/my/core/__main__.py#L548-L550 | ||
DxCx/plugin.video.9anime | 34358c2f701e5ddf19d3276926374a16f63f7b6a | resources/lib/ui/js2py/translators/friendly_nodes.py | python | compose_regex | (val) | return u'/%s/%s' % (reg, flags) | [] | def compose_regex(val):
reg, flags = val
#reg = REGEXP_CONVERTER._unescape_string(reg)
return u'/%s/%s' % (reg, flags) | [
"def",
"compose_regex",
"(",
"val",
")",
":",
"reg",
",",
"flags",
"=",
"val",
"#reg = REGEXP_CONVERTER._unescape_string(reg)",
"return",
"u'/%s/%s'",
"%",
"(",
"reg",
",",
"flags",
")"
] | https://github.com/DxCx/plugin.video.9anime/blob/34358c2f701e5ddf19d3276926374a16f63f7b6a/resources/lib/ui/js2py/translators/friendly_nodes.py#L55-L58 | |||
IronLanguages/ironpython3 | 7a7bb2a872eeab0d1009fc8a6e24dca43f65b693 | Src/StdLib/Lib/xml/etree/ElementTree.py | python | ElementTree.getiterator | (self, tag=None) | return list(self.iter(tag)) | [] | def getiterator(self, tag=None):
# Change for a DeprecationWarning in 1.4
warnings.warn(
"This method will be removed in future versions. "
"Use 'tree.iter()' or 'list(tree.iter())' instead.",
PendingDeprecationWarning, stacklevel=2
)
return list(self... | [
"def",
"getiterator",
"(",
"self",
",",
"tag",
"=",
"None",
")",
":",
"# Change for a DeprecationWarning in 1.4",
"warnings",
".",
"warn",
"(",
"\"This method will be removed in future versions. \"",
"\"Use 'tree.iter()' or 'list(tree.iter())' instead.\"",
",",
"PendingDeprecati... | https://github.com/IronLanguages/ironpython3/blob/7a7bb2a872eeab0d1009fc8a6e24dca43f65b693/Src/StdLib/Lib/xml/etree/ElementTree.py#L624-L631 | |||
tenpy/tenpy | bbdd3dbbdb511948eb0e6ba7ff619ac6ca657fff | tenpy/linalg/np_conserved.py | python | grid_concat | (grid, axes, copy=True) | return _grid_concat_recursion(grid, axes, copy) | Given an np.array of npc.Arrays, performs a multi-dimensional concatentation along 'axes'.
Similar to :func:`numpy.block`, but only for uniform blocking.
Stacks the qind of the array, *without* sorting/blocking.
Parameters
----------
grid : array_like of :class:`Array`
The grid of arrays.... | Given an np.array of npc.Arrays, performs a multi-dimensional concatentation along 'axes'. | [
"Given",
"an",
"np",
".",
"array",
"of",
"npc",
".",
"Arrays",
"performs",
"a",
"multi",
"-",
"dimensional",
"concatentation",
"along",
"axes",
"."
] | def grid_concat(grid, axes, copy=True):
"""Given an np.array of npc.Arrays, performs a multi-dimensional concatentation along 'axes'.
Similar to :func:`numpy.block`, but only for uniform blocking.
Stacks the qind of the array, *without* sorting/blocking.
Parameters
----------
grid : array_lik... | [
"def",
"grid_concat",
"(",
"grid",
",",
"axes",
",",
"copy",
"=",
"True",
")",
":",
"grid",
"=",
"np",
".",
"asarray",
"(",
"grid",
",",
"dtype",
"=",
"object",
")",
"if",
"grid",
".",
"ndim",
"<",
"1",
"or",
"grid",
".",
"ndim",
"!=",
"len",
"... | https://github.com/tenpy/tenpy/blob/bbdd3dbbdb511948eb0e6ba7ff619ac6ca657fff/tenpy/linalg/np_conserved.py#L2958-L3062 | |
rembo10/headphones | b3199605be1ebc83a7a8feab6b1e99b64014187c | lib/oauth2/__init__.py | python | Client.__init__ | (self, consumer, token=None, cache=None, timeout=None,
proxy_info=None) | [] | def __init__(self, consumer, token=None, cache=None, timeout=None,
proxy_info=None):
if consumer is not None and not isinstance(consumer, Consumer):
raise ValueError("Invalid consumer.")
if token is not None and not isinstance(token, Token):
raise ValueError("Invalid to... | [
"def",
"__init__",
"(",
"self",
",",
"consumer",
",",
"token",
"=",
"None",
",",
"cache",
"=",
"None",
",",
"timeout",
"=",
"None",
",",
"proxy_info",
"=",
"None",
")",
":",
"if",
"consumer",
"is",
"not",
"None",
"and",
"not",
"isinstance",
"(",
"con... | https://github.com/rembo10/headphones/blob/b3199605be1ebc83a7a8feab6b1e99b64014187c/lib/oauth2/__init__.py#L557-L571 | ||||
holzschu/Carnets | 44effb10ddfc6aa5c8b0687582a724ba82c6b547 | Library/lib/python3.7/site-packages/astropy-4.0-py3.7-macosx-10.9-x86_64.egg/astropy/io/ascii/core.py | python | BaseHeader.get_cols | (self, lines) | Initialize the header Column objects from the table ``lines``.
Based on the previously set Header attributes find or create the column names.
Sets ``self.cols`` with the list of Columns.
Parameters
----------
lines : list
List of table lines | Initialize the header Column objects from the table ``lines``. | [
"Initialize",
"the",
"header",
"Column",
"objects",
"from",
"the",
"table",
"lines",
"."
] | def get_cols(self, lines):
"""Initialize the header Column objects from the table ``lines``.
Based on the previously set Header attributes find or create the column names.
Sets ``self.cols`` with the list of Columns.
Parameters
----------
lines : list
List o... | [
"def",
"get_cols",
"(",
"self",
",",
"lines",
")",
":",
"start_line",
"=",
"_get_line_index",
"(",
"self",
".",
"start_line",
",",
"self",
".",
"process_lines",
"(",
"lines",
")",
")",
"if",
"start_line",
"is",
"None",
":",
"# No header line so auto-generate n... | https://github.com/holzschu/Carnets/blob/44effb10ddfc6aa5c8b0687582a724ba82c6b547/Library/lib/python3.7/site-packages/astropy-4.0-py3.7-macosx-10.9-x86_64.egg/astropy/io/ascii/core.py#L557-L592 | ||
learningequality/ka-lite | 571918ea668013dcf022286ea85eff1c5333fb8b | kalite/packages/bundled/django/contrib/gis/db/models/fields.py | python | GeometryField.get_srid | (self, geom) | Returns the default SRID for the given geometry, taking into account
the SRID set for the field. For example, if the input geometry
has no SRID, then that of the field will be returned. | Returns the default SRID for the given geometry, taking into account
the SRID set for the field. For example, if the input geometry
has no SRID, then that of the field will be returned. | [
"Returns",
"the",
"default",
"SRID",
"for",
"the",
"given",
"geometry",
"taking",
"into",
"account",
"the",
"SRID",
"set",
"for",
"the",
"field",
".",
"For",
"example",
"if",
"the",
"input",
"geometry",
"has",
"no",
"SRID",
"then",
"that",
"of",
"the",
"... | def get_srid(self, geom):
"""
Returns the default SRID for the given geometry, taking into account
the SRID set for the field. For example, if the input geometry
has no SRID, then that of the field will be returned.
"""
gsrid = geom.srid # SRID of given geometry.
... | [
"def",
"get_srid",
"(",
"self",
",",
"geom",
")",
":",
"gsrid",
"=",
"geom",
".",
"srid",
"# SRID of given geometry.",
"if",
"gsrid",
"is",
"None",
"or",
"self",
".",
"srid",
"==",
"-",
"1",
"or",
"(",
"gsrid",
"==",
"-",
"1",
"and",
"self",
".",
"... | https://github.com/learningequality/ka-lite/blob/571918ea668013dcf022286ea85eff1c5333fb8b/kalite/packages/bundled/django/contrib/gis/db/models/fields.py#L181-L191 | ||
open-mmlab/OpenPCDet | 0f4d3f1f5c1fbe551c35917220e75eb90e28035f | pcdet/models/dense_heads/target_assigner/atss_target_assigner.py | python | ATSSTargetAssigner.assign_targets | (self, anchors_list, gt_boxes_with_classes, use_multihead=False) | return ret_dict | Args:
anchors: [(N, 7), ...]
gt_boxes: (B, M, 8)
Returns: | Args:
anchors: [(N, 7), ...]
gt_boxes: (B, M, 8)
Returns: | [
"Args",
":",
"anchors",
":",
"[",
"(",
"N",
"7",
")",
"...",
"]",
"gt_boxes",
":",
"(",
"B",
"M",
"8",
")",
"Returns",
":"
] | def assign_targets(self, anchors_list, gt_boxes_with_classes, use_multihead=False):
"""
Args:
anchors: [(N, 7), ...]
gt_boxes: (B, M, 8)
Returns:
"""
if not isinstance(anchors_list, list):
anchors_list = [anchors_list]
single_set_o... | [
"def",
"assign_targets",
"(",
"self",
",",
"anchors_list",
",",
"gt_boxes_with_classes",
",",
"use_multihead",
"=",
"False",
")",
":",
"if",
"not",
"isinstance",
"(",
"anchors_list",
",",
"list",
")",
":",
"anchors_list",
"=",
"[",
"anchors_list",
"]",
"single... | https://github.com/open-mmlab/OpenPCDet/blob/0f4d3f1f5c1fbe551c35917220e75eb90e28035f/pcdet/models/dense_heads/target_assigner/atss_target_assigner.py#L16-L73 | |
jgagneastro/coffeegrindsize | 22661ebd21831dba4cf32bfc6ba59fe3d49f879c | App/dist/coffeegrindsize.app/Contents/Resources/lib/python3.7/scipy/integrate/_ode.py | python | IntegratorBase.reset | (self, n, has_jac) | Prepare integrator for call: allocate memory, set flags, etc.
n - number of equations.
has_jac - if user has supplied function for evaluating Jacobian. | Prepare integrator for call: allocate memory, set flags, etc.
n - number of equations.
has_jac - if user has supplied function for evaluating Jacobian. | [
"Prepare",
"integrator",
"for",
"call",
":",
"allocate",
"memory",
"set",
"flags",
"etc",
".",
"n",
"-",
"number",
"of",
"equations",
".",
"has_jac",
"-",
"if",
"user",
"has",
"supplied",
"function",
"for",
"evaluating",
"Jacobian",
"."
] | def reset(self, n, has_jac):
"""Prepare integrator for call: allocate memory, set flags, etc.
n - number of equations.
has_jac - if user has supplied function for evaluating Jacobian.
""" | [
"def",
"reset",
"(",
"self",
",",
"n",
",",
"has_jac",
")",
":"
] | https://github.com/jgagneastro/coffeegrindsize/blob/22661ebd21831dba4cf32bfc6ba59fe3d49f879c/App/dist/coffeegrindsize.app/Contents/Resources/lib/python3.7/scipy/integrate/_ode.py#L793-L797 | ||
n1nj4sec/pupy | a5d766ea81fdfe3bc2c38c9bdaf10e9b75af3b39 | pupy/network/lib/picocmd/picocmd.py | python | PortQuizPort.__init__ | (self, ports) | [] | def __init__(self, ports):
self.ports = [int(x) for x in ports] | [
"def",
"__init__",
"(",
"self",
",",
"ports",
")",
":",
"self",
".",
"ports",
"=",
"[",
"int",
"(",
"x",
")",
"for",
"x",
"in",
"ports",
"]"
] | https://github.com/n1nj4sec/pupy/blob/a5d766ea81fdfe3bc2c38c9bdaf10e9b75af3b39/pupy/network/lib/picocmd/picocmd.py#L1027-L1028 | ||||
tdamdouni/Pythonista | 3e082d53b6b9b501a3c8cf3251a8ad4c8be9c2ad | markdown/markdown2pdf/PyPDF2/generic.py | python | PdfObject.getObject | (self) | return self | Resolves indirect references. | Resolves indirect references. | [
"Resolves",
"indirect",
"references",
"."
] | def getObject(self):
"""Resolves indirect references."""
return self | [
"def",
"getObject",
"(",
"self",
")",
":",
"return",
"self"
] | https://github.com/tdamdouni/Pythonista/blob/3e082d53b6b9b501a3c8cf3251a8ad4c8be9c2ad/markdown/markdown2pdf/PyPDF2/generic.py#L94-L96 | |
zhanlaoban/Transformers_for_Text_Classification | 5e12b21616b29e445e11fe307948e5c55084bb0e | transformers/modeling_ctrl.py | python | CTRLPreTrainedModel._init_weights | (self, module) | Initialize the weights. | Initialize the weights. | [
"Initialize",
"the",
"weights",
"."
] | def _init_weights(self, module):
""" Initialize the weights.
"""
if isinstance(module, (nn.Linear, nn.Embedding, Conv1D)):
# Slightly different from the TF version which uses truncated_normal for initialization
# cf https://github.com/pytorch/pytorch/pull/5617
... | [
"def",
"_init_weights",
"(",
"self",
",",
"module",
")",
":",
"if",
"isinstance",
"(",
"module",
",",
"(",
"nn",
".",
"Linear",
",",
"nn",
".",
"Embedding",
",",
"Conv1D",
")",
")",
":",
"# Slightly different from the TF version which uses truncated_normal for ini... | https://github.com/zhanlaoban/Transformers_for_Text_Classification/blob/5e12b21616b29e445e11fe307948e5c55084bb0e/transformers/modeling_ctrl.py#L178-L189 | ||
zhou13/lcnn | e07e48b98d9c5b067a63d48445e757c2460ba4b6 | lcnn/utils.py | python | np_softmax | (x, axis=0) | return e_x / e_x.sum(axis=axis, keepdims=True) | Compute softmax values for each sets of scores in x. | Compute softmax values for each sets of scores in x. | [
"Compute",
"softmax",
"values",
"for",
"each",
"sets",
"of",
"scores",
"in",
"x",
"."
] | def np_softmax(x, axis=0):
"""Compute softmax values for each sets of scores in x."""
e_x = np.exp(x - np.max(x))
return e_x / e_x.sum(axis=axis, keepdims=True) | [
"def",
"np_softmax",
"(",
"x",
",",
"axis",
"=",
"0",
")",
":",
"e_x",
"=",
"np",
".",
"exp",
"(",
"x",
"-",
"np",
".",
"max",
"(",
"x",
")",
")",
"return",
"e_x",
"/",
"e_x",
".",
"sum",
"(",
"axis",
"=",
"axis",
",",
"keepdims",
"=",
"Tru... | https://github.com/zhou13/lcnn/blob/e07e48b98d9c5b067a63d48445e757c2460ba4b6/lcnn/utils.py#L60-L63 | |
standardebooks/tools | f57af3c5938a9aeed9e97e82b2c130424f6033e5 | se/commands/create_draft.py | python | _generate_contributor_string | (contributors: List[Dict], include_xhtml: bool) | return output | Given a list of contributors, generate a contributor string like `Bob Smith, Jane Doe, and Sam Johnson`.
With include_xhtml, the string looks like: `<b epub:type="z3998:personal-name">Bob Smith</b>, <a href="https://en.wikipedia.org/wiki/Jane_Doe">Jane Doe</a>, and <b epub:type="z3998:personal-name">Sam Johnson</b>`
... | Given a list of contributors, generate a contributor string like `Bob Smith, Jane Doe, and Sam Johnson`.
With include_xhtml, the string looks like: `<b epub:type="z3998:personal-name">Bob Smith</b>, <a href="https://en.wikipedia.org/wiki/Jane_Doe">Jane Doe</a>, and <b epub:type="z3998:personal-name">Sam Johnson</b>` | [
"Given",
"a",
"list",
"of",
"contributors",
"generate",
"a",
"contributor",
"string",
"like",
"Bob",
"Smith",
"Jane",
"Doe",
"and",
"Sam",
"Johnson",
".",
"With",
"include_xhtml",
"the",
"string",
"looks",
"like",
":",
"<b",
"epub",
":",
"type",
"=",
"z399... | def _generate_contributor_string(contributors: List[Dict], include_xhtml: bool) -> str:
"""
Given a list of contributors, generate a contributor string like `Bob Smith, Jane Doe, and Sam Johnson`.
With include_xhtml, the string looks like: `<b epub:type="z3998:personal-name">Bob Smith</b>, <a href="https://en.wikipe... | [
"def",
"_generate_contributor_string",
"(",
"contributors",
":",
"List",
"[",
"Dict",
"]",
",",
"include_xhtml",
":",
"bool",
")",
"->",
"str",
":",
"output",
"=",
"\"\"",
"# Don't include \"anonymous\" contributors",
"contributors",
"=",
"[",
"contributor",
"for",
... | https://github.com/standardebooks/tools/blob/f57af3c5938a9aeed9e97e82b2c130424f6033e5/se/commands/create_draft.py#L416-L475 | |
openshift/openshift-tools | 1188778e728a6e4781acf728123e5b356380fe6f | ansible/roles/lib_oa_openshift/library/oc_objectvalidator.py | python | locate_oc_binary | () | return oc_binary | Find and return oc binary file | Find and return oc binary file | [
"Find",
"and",
"return",
"oc",
"binary",
"file"
] | def locate_oc_binary():
''' Find and return oc binary file '''
# https://github.com/openshift/openshift-ansible/issues/3410
# oc can be in /usr/local/bin in some cases, but that may not
# be in $PATH due to ansible/sudo
paths = os.environ.get("PATH", os.defpath).split(os.pathsep) + ADDITIONAL_PATH_L... | [
"def",
"locate_oc_binary",
"(",
")",
":",
"# https://github.com/openshift/openshift-ansible/issues/3410",
"# oc can be in /usr/local/bin in some cases, but that may not",
"# be in $PATH due to ansible/sudo",
"paths",
"=",
"os",
".",
"environ",
".",
"get",
"(",
"\"PATH\"",
",",
"o... | https://github.com/openshift/openshift-tools/blob/1188778e728a6e4781acf728123e5b356380fe6f/ansible/roles/lib_oa_openshift/library/oc_objectvalidator.py#L803-L823 | |
nicolas-chaulet/torch-points3d | 8e4c19ecb81926626231bf185e9eca77d92a0606 | torch_points3d/models/base_architectures/unet.py | python | UnwrappedUnetBasedModel._fetch_arguments | (self, conv_opt, index, flow) | return args | Fetches arguments for building a convolution (up or down)
Arguments:
conv_opt
index in sequential order (as they come in the config)
flow "UP" or "DOWN" | Fetches arguments for building a convolution (up or down) | [
"Fetches",
"arguments",
"for",
"building",
"a",
"convolution",
"(",
"up",
"or",
"down",
")"
] | def _fetch_arguments(self, conv_opt, index, flow):
"""Fetches arguments for building a convolution (up or down)
Arguments:
conv_opt
index in sequential order (as they come in the config)
flow "UP" or "DOWN"
"""
args = self._fetch_arguments_from_list(c... | [
"def",
"_fetch_arguments",
"(",
"self",
",",
"conv_opt",
",",
"index",
",",
"flow",
")",
":",
"args",
"=",
"self",
".",
"_fetch_arguments_from_list",
"(",
"conv_opt",
",",
"index",
")",
"args",
"[",
"\"conv_cls\"",
"]",
"=",
"self",
".",
"_factory_module",
... | https://github.com/nicolas-chaulet/torch-points3d/blob/8e4c19ecb81926626231bf185e9eca77d92a0606/torch_points3d/models/base_architectures/unet.py#L476-L487 | |
mrkipling/maraschino | c6be9286937783ae01df2d6d8cebfc8b2734a7d7 | lib/werkzeug/wrappers.py | python | ETagResponseMixin.add_etag | (self, overwrite=False, weak=False) | Add an etag for the current response if there is none yet. | Add an etag for the current response if there is none yet. | [
"Add",
"an",
"etag",
"for",
"the",
"current",
"response",
"if",
"there",
"is",
"none",
"yet",
"."
] | def add_etag(self, overwrite=False, weak=False):
"""Add an etag for the current response if there is none yet."""
if overwrite or 'etag' not in self.headers:
self.set_etag(generate_etag(self.data), weak) | [
"def",
"add_etag",
"(",
"self",
",",
"overwrite",
"=",
"False",
",",
"weak",
"=",
"False",
")",
":",
"if",
"overwrite",
"or",
"'etag'",
"not",
"in",
"self",
".",
"headers",
":",
"self",
".",
"set_etag",
"(",
"generate_etag",
"(",
"self",
".",
"data",
... | https://github.com/mrkipling/maraschino/blob/c6be9286937783ae01df2d6d8cebfc8b2734a7d7/lib/werkzeug/wrappers.py#L1278-L1281 | ||
AppScale/gts | 46f909cf5dc5ba81faf9d81dc9af598dcf8a82a9 | AppServer/google/appengine/datastore/datastore_v4_pb.py | python | DatastoreV4Service.BeginTransaction | (self, rpc, request, response) | Handles a BeginTransaction RPC call. You should override this.
Args:
rpc: a Stubby RPC object
request: a BeginTransactionRequest that contains the client request
response: a BeginTransactionResponse that should be modified to send the response | Handles a BeginTransaction RPC call. You should override this. | [
"Handles",
"a",
"BeginTransaction",
"RPC",
"call",
".",
"You",
"should",
"override",
"this",
"."
] | def BeginTransaction(self, rpc, request, response):
"""Handles a BeginTransaction RPC call. You should override this.
Args:
rpc: a Stubby RPC object
request: a BeginTransactionRequest that contains the client request
response: a BeginTransactionResponse that should be modified to send the res... | [
"def",
"BeginTransaction",
"(",
"self",
",",
"rpc",
",",
"request",
",",
"response",
")",
":",
"raise",
"NotImplementedError"
] | https://github.com/AppScale/gts/blob/46f909cf5dc5ba81faf9d81dc9af598dcf8a82a9/AppServer/google/appengine/datastore/datastore_v4_pb.py#L6630-L6638 | ||
timkpaine/paperboy | 6c0854b2c0dad139c25153e520ca79ffed820fa4 | paperboy/config/user.py | python | UserConfig.store | (self) | return ret | Generate response modal for client when saving a User object | Generate response modal for client when saving a User object | [
"Generate",
"response",
"modal",
"for",
"client",
"when",
"saving",
"a",
"User",
"object"
] | def store(self):
'''Generate response modal for client when saving a User object'''
ret = Response()
ret.entries = [
DOMEntry(type='p', value='Success!'),
DOMEntry(type='p', value='Successfully stored user {}'.format(self.name)),
]
return ret | [
"def",
"store",
"(",
"self",
")",
":",
"ret",
"=",
"Response",
"(",
")",
"ret",
".",
"entries",
"=",
"[",
"DOMEntry",
"(",
"type",
"=",
"'p'",
",",
"value",
"=",
"'Success!'",
")",
",",
"DOMEntry",
"(",
"type",
"=",
"'p'",
",",
"value",
"=",
"'Su... | https://github.com/timkpaine/paperboy/blob/6c0854b2c0dad139c25153e520ca79ffed820fa4/paperboy/config/user.py#L45-L52 | |
ratschlab/RGAN | f41731b965348259dcd94b0dcb1374d3e1c4ca7d | data_utils.py | python | get_data | (data_type, data_options=None) | return samples, pdf, labels | Helper/wrapper function to get the requested data. | Helper/wrapper function to get the requested data. | [
"Helper",
"/",
"wrapper",
"function",
"to",
"get",
"the",
"requested",
"data",
"."
] | def get_data(data_type, data_options=None):
"""
Helper/wrapper function to get the requested data.
"""
labels = None
pdf = None
if data_type == 'load':
data_dict = np.load(data_options).item()
samples = data_dict['samples']
pdf = data_dict['pdf']
labels = data_dic... | [
"def",
"get_data",
"(",
"data_type",
",",
"data_options",
"=",
"None",
")",
":",
"labels",
"=",
"None",
"pdf",
"=",
"None",
"if",
"data_type",
"==",
"'load'",
":",
"data_dict",
"=",
"np",
".",
"load",
"(",
"data_options",
")",
".",
"item",
"(",
")",
... | https://github.com/ratschlab/RGAN/blob/f41731b965348259dcd94b0dcb1374d3e1c4ca7d/data_utils.py#L110-L141 | |
google/budou | d45791a244e00d84f87da2a4678da2b63a9c232f | budou/chunk.py | python | Chunk.is_space | (self) | return self.pos == self._SPACE_POS | Whether the chunk is a space.
Returns:
bool: True if it is a space. | Whether the chunk is a space. | [
"Whether",
"the",
"chunk",
"is",
"a",
"space",
"."
] | def is_space(self):
"""Whether the chunk is a space.
Returns:
bool: True if it is a space.
"""
return self.pos == self._SPACE_POS | [
"def",
"is_space",
"(",
"self",
")",
":",
"return",
"self",
".",
"pos",
"==",
"self",
".",
"_SPACE_POS"
] | https://github.com/google/budou/blob/d45791a244e00d84f87da2a4678da2b63a9c232f/budou/chunk.py#L93-L99 | |
urwid/urwid | e2423b5069f51d318ea1ac0f355a0efe5448f7eb | urwid/lcd_display.py | python | KeyRepeatSimulator.release | (self, key) | [] | def release(self, key):
if key not in self.pressed:
return # ignore extra release events
del self.pressed[key]
if not self.pressed:
self.multiple_pressed = False | [
"def",
"release",
"(",
"self",
",",
"key",
")",
":",
"if",
"key",
"not",
"in",
"self",
".",
"pressed",
":",
"return",
"# ignore extra release events",
"del",
"self",
".",
"pressed",
"[",
"key",
"]",
"if",
"not",
"self",
".",
"pressed",
":",
"self",
"."... | https://github.com/urwid/urwid/blob/e2423b5069f51d318ea1ac0f355a0efe5448f7eb/urwid/lcd_display.py#L222-L227 | ||||
rm-hull/luma.examples | 3a5110ab27a2d4f10cd62dc0156f439f4decd1e7 | examples/maze.py | python | Maze.coords | (self, offset) | return (offset % self.width, offset // self.width) | Converts offset to [x,y] co-ords | Converts offset to [x,y] co-ords | [
"Converts",
"offset",
"to",
"[",
"x",
"y",
"]",
"co",
"-",
"ords"
] | def coords(self, offset):
""" Converts offset to [x,y] co-ords """
return (offset % self.width, offset // self.width) | [
"def",
"coords",
"(",
"self",
",",
"offset",
")",
":",
"return",
"(",
"offset",
"%",
"self",
".",
"width",
",",
"offset",
"//",
"self",
".",
"width",
")"
] | https://github.com/rm-hull/luma.examples/blob/3a5110ab27a2d4f10cd62dc0156f439f4decd1e7/examples/maze.py#L35-L37 | |
bloomberg/phabricator-tools | 09bd1587fe8945d93a891162fd4c89640c6fada7 | py/abd/abdt_naming.py | python | isStatusBad | (working_branch) | return working_branch.status.startswith(WB_STATUS_PREFIX_BAD) | Return True if the status of 'working_branch' is bad.
:working_branch: a WorkingBranch
:returns: True if the branch is bad | Return True if the status of 'working_branch' is bad. | [
"Return",
"True",
"if",
"the",
"status",
"of",
"working_branch",
"is",
"bad",
"."
] | def isStatusBad(working_branch):
"""Return True if the status of 'working_branch' is bad.
:working_branch: a WorkingBranch
:returns: True if the branch is bad
"""
return working_branch.status.startswith(WB_STATUS_PREFIX_BAD) | [
"def",
"isStatusBad",
"(",
"working_branch",
")",
":",
"return",
"working_branch",
".",
"status",
".",
"startswith",
"(",
"WB_STATUS_PREFIX_BAD",
")"
] | https://github.com/bloomberg/phabricator-tools/blob/09bd1587fe8945d93a891162fd4c89640c6fada7/py/abd/abdt_naming.py#L93-L100 | |
w3h/isf | 6faf0a3df185465ec17369c90ccc16e2a03a1870 | lib/thirdparty/DateTime/interfaces.py | python | IDateTime.__int__ | () | Convert to an integer number of seconds since the epoch (gmt) | Convert to an integer number of seconds since the epoch (gmt) | [
"Convert",
"to",
"an",
"integer",
"number",
"of",
"seconds",
"since",
"the",
"epoch",
"(",
"gmt",
")"
] | def __int__():
"""Convert to an integer number of seconds since the epoch (gmt)""" | [
"def",
"__int__",
"(",
")",
":"
] | https://github.com/w3h/isf/blob/6faf0a3df185465ec17369c90ccc16e2a03a1870/lib/thirdparty/DateTime/interfaces.py#L368-L369 | ||
calico/basenji | 2dae9b54744bd0495041c4259c22593054eef50b | basenji/archive/seqnn_util.py | python | SeqNNModel.test_h5 | (self, sess, batcher, test_batches=None) | return acc | Compute model accuracy on a test set.
Args:
sess: TensorFlow session
batcher: Batcher object to provide data
test_batches: Number of test batches
Returns:
acc: Accuracy object | Compute model accuracy on a test set. | [
"Compute",
"model",
"accuracy",
"on",
"a",
"test",
"set",
"."
] | def test_h5(self, sess, batcher, test_batches=None):
""" Compute model accuracy on a test set.
Args:
sess: TensorFlow session
batcher: Batcher object to provide data
test_batches: Number of test batches
Returns:
acc: Accuracy object
... | [
"def",
"test_h5",
"(",
"self",
",",
"sess",
",",
"batcher",
",",
"test_batches",
"=",
"None",
")",
":",
"# setup feed dict",
"fd",
"=",
"self",
".",
"set_mode",
"(",
"'test'",
")",
"# initialize prediction and target arrays",
"preds",
"=",
"[",
"]",
"targets",... | https://github.com/calico/basenji/blob/2dae9b54744bd0495041c4259c22593054eef50b/basenji/archive/seqnn_util.py#L1096-L1167 | |
pyg-team/pytorch_geometric | b920e9a3a64e22c8356be55301c88444ff051cae | benchmark/citation/arma.py | python | Net.reset_parameters | (self) | [] | def reset_parameters(self):
self.conv1.reset_parameters()
self.conv2.reset_parameters() | [
"def",
"reset_parameters",
"(",
"self",
")",
":",
"self",
".",
"conv1",
".",
"reset_parameters",
"(",
")",
"self",
".",
"conv2",
".",
"reset_parameters",
"(",
")"
] | https://github.com/pyg-team/pytorch_geometric/blob/b920e9a3a64e22c8356be55301c88444ff051cae/benchmark/citation/arma.py#L36-L38 | ||||
luispedro/jug | e967c6388ca69c78698e1522b9535d647a2c5b22 | jug/backends/base.py | python | base_store.getlock | (self, name) | lock = store.getlock(name)
Retrieve a lock object associated with ``name``.
Parameters
----------
name : str
Key
Returns
-------
lock : Lock object
This should obey the Lock Interface
See Also
--------
base_lock ... | lock = store.getlock(name) | [
"lock",
"=",
"store",
".",
"getlock",
"(",
"name",
")"
] | def getlock(self, name):
'''
lock = store.getlock(name)
Retrieve a lock object associated with ``name``.
Parameters
----------
name : str
Key
Returns
-------
lock : Lock object
This should obey the Lock Interface
... | [
"def",
"getlock",
"(",
"self",
",",
"name",
")",
":"
] | https://github.com/luispedro/jug/blob/e967c6388ca69c78698e1522b9535d647a2c5b22/jug/backends/base.py#L166-L185 | ||
oracle/oci-python-sdk | 3c1604e4e212008fb6718e2f68cdb5ef71fd5793 | src/oci/database_management/db_management_client.py | python | DbManagementClient.get_work_request | (self, work_request_id, **kwargs) | Gets the status of the work request with the given Work Request ID
:param str work_request_id: (required)
The `OCID`__ of the asynchronous work request.
__ https://docs.cloud.oracle.com/Content/General/Concepts/identifiers.htm
:param str opc_request_id: (optional)
... | Gets the status of the work request with the given Work Request ID | [
"Gets",
"the",
"status",
"of",
"the",
"work",
"request",
"with",
"the",
"given",
"Work",
"Request",
"ID"
] | def get_work_request(self, work_request_id, **kwargs):
"""
Gets the status of the work request with the given Work Request ID
:param str work_request_id: (required)
The `OCID`__ of the asynchronous work request.
__ https://docs.cloud.oracle.com/Content/General/Concepts... | [
"def",
"get_work_request",
"(",
"self",
",",
"work_request_id",
",",
"*",
"*",
"kwargs",
")",
":",
"resource_path",
"=",
"\"/workRequests/{workRequestId}\"",
"method",
"=",
"\"GET\"",
"# Don't accept unknown kwargs",
"expected_kwargs",
"=",
"[",
"\"retry_strategy\"",
",... | https://github.com/oracle/oci-python-sdk/blob/3c1604e4e212008fb6718e2f68cdb5ef71fd5793/src/oci/database_management/db_management_client.py#L2447-L2526 | ||
home-assistant/core | 265ebd17a3f17ed8dc1e9bdede03ac8e323f1ab1 | homeassistant/components/yeelight/light.py | python | YeelightGenericLight.async_set_rgb | (self, rgb, duration) | Set bulb's color. | Set bulb's color. | [
"Set",
"bulb",
"s",
"color",
"."
] | async def async_set_rgb(self, rgb, duration) -> None:
"""Set bulb's color."""
if not rgb or COLOR_MODE_RGB not in self.supported_color_modes:
return
if (
not self.device.is_color_flow_enabled
and self.color_mode == COLOR_MODE_RGB
and self.rgb_color... | [
"async",
"def",
"async_set_rgb",
"(",
"self",
",",
"rgb",
",",
"duration",
")",
"->",
"None",
":",
"if",
"not",
"rgb",
"or",
"COLOR_MODE_RGB",
"not",
"in",
"self",
".",
"supported_color_modes",
":",
"return",
"if",
"(",
"not",
"self",
".",
"device",
".",... | https://github.com/home-assistant/core/blob/265ebd17a3f17ed8dc1e9bdede03ac8e323f1ab1/homeassistant/components/yeelight/light.py#L656-L674 | ||
huggingface/transformers | 623b4f7c63f60cce917677ee704d6c93ee960b4b | src/transformers/pipelines/conversational.py | python | Conversation.__eq__ | (self, other) | return (
self.new_user_input == other.new_user_input
and self.past_user_inputs == other.past_user_inputs
and self.generated_responses == other.generated_responses
) | [] | def __eq__(self, other):
if not isinstance(other, Conversation):
return False
if self.uuid == other.uuid:
return True
return (
self.new_user_input == other.new_user_input
and self.past_user_inputs == other.past_user_inputs
and self.gene... | [
"def",
"__eq__",
"(",
"self",
",",
"other",
")",
":",
"if",
"not",
"isinstance",
"(",
"other",
",",
"Conversation",
")",
":",
"return",
"False",
"if",
"self",
".",
"uuid",
"==",
"other",
".",
"uuid",
":",
"return",
"True",
"return",
"(",
"self",
".",... | https://github.com/huggingface/transformers/blob/623b4f7c63f60cce917677ee704d6c93ee960b4b/src/transformers/pipelines/conversational.py#L72-L81 | |||
spesmilo/electrum | bdbd59300fbd35b01605e66145458e5f396108e8 | electrum/daemon.py | python | Daemon._run | (self, jobs: Iterable = None) | [] | async def _run(self, jobs: Iterable = None):
if jobs is None:
jobs = []
self.logger.info("starting taskgroup.")
try:
async with self.taskgroup as group:
[await group.spawn(job) for job in jobs]
await group.spawn(asyncio.Event().wait) # run... | [
"async",
"def",
"_run",
"(",
"self",
",",
"jobs",
":",
"Iterable",
"=",
"None",
")",
":",
"if",
"jobs",
"is",
"None",
":",
"jobs",
"=",
"[",
"]",
"self",
".",
"logger",
".",
"info",
"(",
"\"starting taskgroup.\"",
")",
"try",
":",
"async",
"with",
... | https://github.com/spesmilo/electrum/blob/bdbd59300fbd35b01605e66145458e5f396108e8/electrum/daemon.py#L500-L517 | ||||
tensorflow/mesh | 57ed4018e6a173952501b074daabad32b6449f3d | mesh_tensorflow/ops.py | python | random_uniform | (mesh, shape, **kwargs) | return RandomOperation(mesh, shape, tf.random.uniform, **kwargs).outputs[0] | Random uniform.
Args:
mesh: a Mesh
shape: a Shape
**kwargs: keyword args for tf.random.uniform, except seed
Returns:
a Tensor | Random uniform. | [
"Random",
"uniform",
"."
] | def random_uniform(mesh, shape, **kwargs):
"""Random uniform.
Args:
mesh: a Mesh
shape: a Shape
**kwargs: keyword args for tf.random.uniform, except seed
Returns:
a Tensor
"""
shape = convert_to_shape(shape)
return RandomOperation(mesh, shape, tf.random.uniform, **kwargs).outputs[0] | [
"def",
"random_uniform",
"(",
"mesh",
",",
"shape",
",",
"*",
"*",
"kwargs",
")",
":",
"shape",
"=",
"convert_to_shape",
"(",
"shape",
")",
"return",
"RandomOperation",
"(",
"mesh",
",",
"shape",
",",
"tf",
".",
"random",
".",
"uniform",
",",
"*",
"*",... | https://github.com/tensorflow/mesh/blob/57ed4018e6a173952501b074daabad32b6449f3d/mesh_tensorflow/ops.py#L5850-L5862 | |
openstack/cinder | 23494a6d6c51451688191e1847a458f1d3cdcaa5 | cinder/volume/drivers/dell_emc/powermax/masking.py | python | PowerMaxMasking._check_adding_volume_to_storage_group | (
self, serial_number, device_id, storagegroup_name,
volume_name, extra_specs) | return msg | Check if a volume is part of an sg and add it if not.
:param serial_number: the array serial number
:param device_id: the device id
:param storagegroup_name: the storage group name
:param volume_name: volume name
:param extra_specs: extra specifications
:returns: msg | Check if a volume is part of an sg and add it if not. | [
"Check",
"if",
"a",
"volume",
"is",
"part",
"of",
"an",
"sg",
"and",
"add",
"it",
"if",
"not",
"."
] | def _check_adding_volume_to_storage_group(
self, serial_number, device_id, storagegroup_name,
volume_name, extra_specs):
"""Check if a volume is part of an sg and add it if not.
:param serial_number: the array serial number
:param device_id: the device id
:param ... | [
"def",
"_check_adding_volume_to_storage_group",
"(",
"self",
",",
"serial_number",
",",
"device_id",
",",
"storagegroup_name",
",",
"volume_name",
",",
"extra_specs",
")",
":",
"msg",
"=",
"None",
"if",
"self",
".",
"rest",
".",
"is_volume_in_storagegroup",
"(",
"... | https://github.com/openstack/cinder/blob/23494a6d6c51451688191e1847a458f1d3cdcaa5/cinder/volume/drivers/dell_emc/powermax/masking.py#L708-L739 | |
tp4a/teleport | 1fafd34f1f775d2cf80ea4af6e44468d8e0b24ad | server/www/packages/packages-linux/x64/psutil/__init__.py | python | Process.name | (self) | return name | The process name. The return value is cached after first call. | The process name. The return value is cached after first call. | [
"The",
"process",
"name",
".",
"The",
"return",
"value",
"is",
"cached",
"after",
"first",
"call",
"."
] | def name(self):
"""The process name. The return value is cached after first call."""
# Process name is only cached on Windows as on POSIX it may
# change, see:
# https://github.com/giampaolo/psutil/issues/692
if WINDOWS and self._name is not None:
return self._name
... | [
"def",
"name",
"(",
"self",
")",
":",
"# Process name is only cached on Windows as on POSIX it may",
"# change, see:",
"# https://github.com/giampaolo/psutil/issues/692",
"if",
"WINDOWS",
"and",
"self",
".",
"_name",
"is",
"not",
"None",
":",
"return",
"self",
".",
"_name... | https://github.com/tp4a/teleport/blob/1fafd34f1f775d2cf80ea4af6e44468d8e0b24ad/server/www/packages/packages-linux/x64/psutil/__init__.py#L623-L647 | |
buke/GreenOdoo | 3d8c55d426fb41fdb3f2f5a1533cfe05983ba1df | runtime/python/lib/python2.7/os2emxpath.py | python | splitunc | (p) | return '', p | Split a pathname into UNC mount point and relative path specifiers.
Return a 2-tuple (unc, rest); either part may be empty.
If unc is not empty, it has the form '//host/mount' (or similar
using backslashes). unc+rest is always the input path.
Paths containing drive letters never have an UNC part. | Split a pathname into UNC mount point and relative path specifiers. | [
"Split",
"a",
"pathname",
"into",
"UNC",
"mount",
"point",
"and",
"relative",
"path",
"specifiers",
"."
] | def splitunc(p):
"""Split a pathname into UNC mount point and relative path specifiers.
Return a 2-tuple (unc, rest); either part may be empty.
If unc is not empty, it has the form '//host/mount' (or similar
using backslashes). unc+rest is always the input path.
Paths containing drive letters neve... | [
"def",
"splitunc",
"(",
"p",
")",
":",
"if",
"p",
"[",
"1",
":",
"2",
"]",
"==",
"':'",
":",
"return",
"''",
",",
"p",
"# Drive letter present",
"firstTwo",
"=",
"p",
"[",
"0",
":",
"2",
"]",
"if",
"firstTwo",
"==",
"'/'",
"*",
"2",
"or",
"firs... | https://github.com/buke/GreenOdoo/blob/3d8c55d426fb41fdb3f2f5a1533cfe05983ba1df/runtime/python/lib/python2.7/os2emxpath.py#L58-L83 | |
PrefectHQ/prefect | 67bdc94e2211726d99561f6f52614bec8970e981 | src/prefect/engine/results/local_result.py | python | LocalResult.read | (self, location: str) | return new | Reads a result from the local file system and returns the corresponding `Result` instance.
Args:
- location (str): the location to read from
Returns:
- Result: a new result instance with the data represented by the location | Reads a result from the local file system and returns the corresponding `Result` instance. | [
"Reads",
"a",
"result",
"from",
"the",
"local",
"file",
"system",
"and",
"returns",
"the",
"corresponding",
"Result",
"instance",
"."
] | def read(self, location: str) -> Result:
"""
Reads a result from the local file system and returns the corresponding `Result` instance.
Args:
- location (str): the location to read from
Returns:
- Result: a new result instance with the data represented by the lo... | [
"def",
"read",
"(",
"self",
",",
"location",
":",
"str",
")",
"->",
"Result",
":",
"new",
"=",
"self",
".",
"copy",
"(",
")",
"new",
".",
"location",
"=",
"location",
"self",
".",
"logger",
".",
"debug",
"(",
"\"Starting to read result from {}...\"",
"."... | https://github.com/PrefectHQ/prefect/blob/67bdc94e2211726d99561f6f52614bec8970e981/src/prefect/engine/results/local_result.py#L68-L90 | |
google/grr | 8ad8a4d2c5a93c92729206b7771af19d92d4f915 | grr/server/grr_response_server/databases/mysql_flows.py | python | MySQLDBFlowMixin._FlowObjectFromRow | (self, row) | return flow_obj | Generates a flow object from a database row. | Generates a flow object from a database row. | [
"Generates",
"a",
"flow",
"object",
"from",
"a",
"database",
"row",
"."
] | def _FlowObjectFromRow(self, row):
"""Generates a flow object from a database row."""
datetime = mysql_utils.TimestampToRDFDatetime
cpu_time = db_utils.MicrosToSeconds
# pyformat: disable
(client_id, flow_id, long_flow_id, parent_flow_id, parent_hunt_id,
name, creator,
flow, flow_state,
... | [
"def",
"_FlowObjectFromRow",
"(",
"self",
",",
"row",
")",
":",
"datetime",
"=",
"mysql_utils",
".",
"TimestampToRDFDatetime",
"cpu_time",
"=",
"db_utils",
".",
"MicrosToSeconds",
"# pyformat: disable",
"(",
"client_id",
",",
"flow_id",
",",
"long_flow_id",
",",
"... | https://github.com/google/grr/blob/8ad8a4d2c5a93c92729206b7771af19d92d4f915/grr/server/grr_response_server/databases/mysql_flows.py#L347-L408 | |
wandb/client | 3963364d8112b7dedb928fa423b6878ea1b467d9 | wandb/sdk/interface/artifacts.py | python | Artifact.__setitem__ | (self, name: str, item: WBValue) | Adds `item` to the artifact at path `name`
Arguments:
name: (str) The path within the artifact to add the object.
item: (wandb.WBValue) The object to add.
Returns:
ArtifactManifestEntry: the added manifest entry
Examples:
Basic usage
... | Adds `item` to the artifact at path `name` | [
"Adds",
"item",
"to",
"the",
"artifact",
"at",
"path",
"name"
] | def __setitem__(self, name: str, item: WBValue):
"""
Adds `item` to the artifact at path `name`
Arguments:
name: (str) The path within the artifact to add the object.
item: (wandb.WBValue) The object to add.
Returns:
ArtifactManifestEntry: the added ... | [
"def",
"__setitem__",
"(",
"self",
",",
"name",
":",
"str",
",",
"item",
":",
"WBValue",
")",
":",
"raise",
"NotImplementedError"
] | https://github.com/wandb/client/blob/3963364d8112b7dedb928fa423b6878ea1b467d9/wandb/sdk/interface/artifacts.py#L700-L727 | ||
FSecureLABS/Jandroid | e31d0dab58a2bfd6ed8e0a387172b8bd7c893436 | libs/platform-tools/platform-tools_windows/systrace/catapult/devil/devil/utils/geometry.py | python | Point.__add__ | (self, other) | Sum of two points, e.g. p + q. | Sum of two points, e.g. p + q. | [
"Sum",
"of",
"two",
"points",
"e",
".",
"g",
".",
"p",
"+",
"q",
"."
] | def __add__(self, other):
"""Sum of two points, e.g. p + q."""
if isinstance(other, Point):
return Point(self.x + other.x, self.y + other.y)
else:
return NotImplemented | [
"def",
"__add__",
"(",
"self",
",",
"other",
")",
":",
"if",
"isinstance",
"(",
"other",
",",
"Point",
")",
":",
"return",
"Point",
"(",
"self",
".",
"x",
"+",
"other",
".",
"x",
",",
"self",
".",
"y",
"+",
"other",
".",
"y",
")",
"else",
":",
... | https://github.com/FSecureLABS/Jandroid/blob/e31d0dab58a2bfd6ed8e0a387172b8bd7c893436/libs/platform-tools/platform-tools_windows/systrace/catapult/devil/devil/utils/geometry.py#L22-L27 | ||
scrapy/scrapy | b04cfa48328d5d5749dca6f50fa34e0cfc664c89 | scrapy/utils/python.py | python | MutableChain.extend | (self, *iterables: Iterable) | [] | def extend(self, *iterables: Iterable):
self.data = chain(self.data, chain.from_iterable(iterables)) | [
"def",
"extend",
"(",
"self",
",",
"*",
"iterables",
":",
"Iterable",
")",
":",
"self",
".",
"data",
"=",
"chain",
"(",
"self",
".",
"data",
",",
"chain",
".",
"from_iterable",
"(",
"iterables",
")",
")"
] | https://github.com/scrapy/scrapy/blob/b04cfa48328d5d5749dca6f50fa34e0cfc664c89/scrapy/utils/python.py#L347-L348 | ||||
alteryx/featuretools | d59e11082962f163540fd6e185901f65c506326a | featuretools/synthesis/deep_feature_synthesis.py | python | _match_contains_numeric_foreign_key | (match) | return any(is_valid_input(f.column_schema, match_schema) for f in match) | [] | def _match_contains_numeric_foreign_key(match):
match_schema = ColumnSchema(semantic_tags={'foreign_key', 'numeric'})
return any(is_valid_input(f.column_schema, match_schema) for f in match) | [
"def",
"_match_contains_numeric_foreign_key",
"(",
"match",
")",
":",
"match_schema",
"=",
"ColumnSchema",
"(",
"semantic_tags",
"=",
"{",
"'foreign_key'",
",",
"'numeric'",
"}",
")",
"return",
"any",
"(",
"is_valid_input",
"(",
"f",
".",
"column_schema",
",",
"... | https://github.com/alteryx/featuretools/blob/d59e11082962f163540fd6e185901f65c506326a/featuretools/synthesis/deep_feature_synthesis.py#L842-L844 | |||
bitcraze/crazyflie-lib-python | 876f0dc003b91ba5e4de05daae9d0b79cf600f81 | cflib/crtp/udpdriver.py | python | UdpDriver.get_name | (self) | return 'udp' | [] | def get_name(self):
return 'udp' | [
"def",
"get_name",
"(",
"self",
")",
":",
"return",
"'udp'"
] | https://github.com/bitcraze/crazyflie-lib-python/blob/876f0dc003b91ba5e4de05daae9d0b79cf600f81/cflib/crtp/udpdriver.py#L100-L101 | |||
cloudera/hue | 23f02102d4547c17c32bd5ea0eb24e9eadd657a4 | desktop/core/ext-py/Babel-2.5.1/babel/messages/frontend.py | python | CommandLineInterface._configure_command | (self, cmdname, argv) | return cmdinst | :type cmdname: str
:type argv: list[str] | :type cmdname: str
:type argv: list[str] | [
":",
"type",
"cmdname",
":",
"str",
":",
"type",
"argv",
":",
"list",
"[",
"str",
"]"
] | def _configure_command(self, cmdname, argv):
"""
:type cmdname: str
:type argv: list[str]
"""
cmdclass = self.command_classes[cmdname]
cmdinst = cmdclass()
if self.log:
cmdinst.log = self.log # Use our logger, not distutils'.
assert isinstance... | [
"def",
"_configure_command",
"(",
"self",
",",
"cmdname",
",",
"argv",
")",
":",
"cmdclass",
"=",
"self",
".",
"command_classes",
"[",
"cmdname",
"]",
"cmdinst",
"=",
"cmdclass",
"(",
")",
"if",
"self",
".",
"log",
":",
"cmdinst",
".",
"log",
"=",
"sel... | https://github.com/cloudera/hue/blob/23f02102d4547c17c32bd5ea0eb24e9eadd657a4/desktop/core/ext-py/Babel-2.5.1/babel/messages/frontend.py#L858-L904 | |
pawamoy/aria2p | 2855c6a9a38e36278671258439f6caf59c39cfc3 | src/aria2p/downloads.py | python | Download.move_up | (self, pos: int = 1) | return self.api.move_up(self, pos) | Move the download up in the queue.
Arguments:
pos: Number of times to move up.
Returns:
The new position of the download. | Move the download up in the queue. | [
"Move",
"the",
"download",
"up",
"in",
"the",
"queue",
"."
] | def move_up(self, pos: int = 1) -> int:
"""
Move the download up in the queue.
Arguments:
pos: Number of times to move up.
Returns:
The new position of the download.
"""
return self.api.move_up(self, pos) | [
"def",
"move_up",
"(",
"self",
",",
"pos",
":",
"int",
"=",
"1",
")",
"->",
"int",
":",
"return",
"self",
".",
"api",
".",
"move_up",
"(",
"self",
",",
"pos",
")"
] | https://github.com/pawamoy/aria2p/blob/2855c6a9a38e36278671258439f6caf59c39cfc3/src/aria2p/downloads.py#L969-L979 | |
pyansys/pymapdl | c07291fc062b359abf0e92b95a92d753a95ef3d7 | ansys/mapdl/core/logging.py | python | PymapdlCustomAdapter.log_to_stdout | (self, level=LOG_LEVEL) | Add standard output handler to the logger.
Parameters
----------
level : str, optional
Level of logging record. By default LOG_LEVEL | Add standard output handler to the logger. | [
"Add",
"standard",
"output",
"handler",
"to",
"the",
"logger",
"."
] | def log_to_stdout(self, level=LOG_LEVEL):
"""Add standard output handler to the logger.
Parameters
----------
level : str, optional
Level of logging record. By default LOG_LEVEL
"""
if self.std_out_handler:
raise Exception('Stdout logger already d... | [
"def",
"log_to_stdout",
"(",
"self",
",",
"level",
"=",
"LOG_LEVEL",
")",
":",
"if",
"self",
".",
"std_out_handler",
":",
"raise",
"Exception",
"(",
"'Stdout logger already defined.'",
")",
"self",
".",
"logger",
"=",
"add_stdout_handler",
"(",
"self",
".",
"l... | https://github.com/pyansys/pymapdl/blob/c07291fc062b359abf0e92b95a92d753a95ef3d7/ansys/mapdl/core/logging.py#L198-L210 | ||
vially/googlemusic-xbmc | ecdc7748356307008bfc18297da5ffb943665685 | resources/Lib/gmusicapi/protocol/metadata.py | python | detail_line | (e) | return line | Given an expectation, return a readable one-line explanation of it. | Given an expectation, return a readable one-line explanation of it. | [
"Given",
"an",
"expectation",
"return",
"a",
"readable",
"one",
"-",
"line",
"explanation",
"of",
"it",
"."
] | def detail_line(e):
"""Given an expectation, return a readable one-line explanation of it."""
fields = [fname for fname in ('mutable', 'optional', 'volatile')
if getattr(e, fname, None)]
if e.depends_on:
fields.append("depends_on=%s" % e.depends_on)
line = ', '.join(fields)
i... | [
"def",
"detail_line",
"(",
"e",
")",
":",
"fields",
"=",
"[",
"fname",
"for",
"fname",
"in",
"(",
"'mutable'",
",",
"'optional'",
",",
"'volatile'",
")",
"if",
"getattr",
"(",
"e",
",",
"fname",
",",
"None",
")",
"]",
"if",
"e",
".",
"depends_on",
... | https://github.com/vially/googlemusic-xbmc/blob/ecdc7748356307008bfc18297da5ffb943665685/resources/Lib/gmusicapi/protocol/metadata.py#L204-L216 | |
biolab/orange3 | 41685e1c7b1d1babe680113685a2d44bcc9fec0b | Orange/widgets/visualize/owscatterplot.py | python | OWScatterPlot.attr_changed | (self) | [] | def attr_changed(self):
self.cb_reg_line.setEnabled(self.can_draw_regresssion_line())
self.setup_plot()
self.commit.deferred() | [
"def",
"attr_changed",
"(",
"self",
")",
":",
"self",
".",
"cb_reg_line",
".",
"setEnabled",
"(",
"self",
".",
"can_draw_regresssion_line",
"(",
")",
")",
"self",
".",
"setup_plot",
"(",
")",
"self",
".",
"commit",
".",
"deferred",
"(",
")"
] | https://github.com/biolab/orange3/blob/41685e1c7b1d1babe680113685a2d44bcc9fec0b/Orange/widgets/visualize/owscatterplot.py#L607-L610 | ||||
rdiff-backup/rdiff-backup | 321e0cd6e5e47d4c158a0172e47ab38240a8b653 | src/rdiff_backup/Main.py | python | main_run_and_exit | (arglist) | Main function to be called with arguments list without the name of the
program, aka $0 resp. sys.argv[0].
The function simply calls the internal function '_main_run' and exits
with the code returned. | Main function to be called with arguments list without the name of the
program, aka $0 resp. sys.argv[0]. | [
"Main",
"function",
"to",
"be",
"called",
"with",
"arguments",
"list",
"without",
"the",
"name",
"of",
"the",
"program",
"aka",
"$0",
"resp",
".",
"sys",
".",
"argv",
"[",
"0",
"]",
"."
] | def main_run_and_exit(arglist):
"""
Main function to be called with arguments list without the name of the
program, aka $0 resp. sys.argv[0].
The function simply calls the internal function '_main_run' and exits
with the code returned.
"""
sys.exit(_main_run(arglist)) | [
"def",
"main_run_and_exit",
"(",
"arglist",
")",
":",
"sys",
".",
"exit",
"(",
"_main_run",
"(",
"arglist",
")",
")"
] | https://github.com/rdiff-backup/rdiff-backup/blob/321e0cd6e5e47d4c158a0172e47ab38240a8b653/src/rdiff_backup/Main.py#L29-L37 | ||
rowliny/DiffHelper | ab3a96f58f9579d0023aed9ebd785f4edf26f8af | Tool/SitePackages/nltk/draw/util.py | python | CanvasWidget._manage | (self) | Arrange the child widgets of this canvas widget. This method
is called when the canvas widget is initially created. It is
also called if the user calls the ``manage`` method on this
canvas widget or any of its ancestors.
:rtype: None | Arrange the child widgets of this canvas widget. This method
is called when the canvas widget is initially created. It is
also called if the user calls the ``manage`` method on this
canvas widget or any of its ancestors. | [
"Arrange",
"the",
"child",
"widgets",
"of",
"this",
"canvas",
"widget",
".",
"This",
"method",
"is",
"called",
"when",
"the",
"canvas",
"widget",
"is",
"initially",
"created",
".",
"It",
"is",
"also",
"called",
"if",
"the",
"user",
"calls",
"the",
"manage"... | def _manage(self):
"""
Arrange the child widgets of this canvas widget. This method
is called when the canvas widget is initially created. It is
also called if the user calls the ``manage`` method on this
canvas widget or any of its ancestors.
:rtype: None
""" | [
"def",
"_manage",
"(",
"self",
")",
":"
] | https://github.com/rowliny/DiffHelper/blob/ab3a96f58f9579d0023aed9ebd785f4edf26f8af/Tool/SitePackages/nltk/draw/util.py#L716-L724 | ||
chribsen/simple-machine-learning-examples | dc94e52a4cebdc8bb959ff88b81ff8cfeca25022 | venv/lib/python2.7/site-packages/pandas/indexes/base.py | python | Index.get_slice_bound | (self, label, side, kind) | Calculate slice bound that corresponds to given label.
Returns leftmost (one-past-the-rightmost if ``side=='right'``) position
of given label.
Parameters
----------
label : object
side : {'left', 'right'}
kind : {'ix', 'loc', 'getitem'} | Calculate slice bound that corresponds to given label. | [
"Calculate",
"slice",
"bound",
"that",
"corresponds",
"to",
"given",
"label",
"."
] | def get_slice_bound(self, label, side, kind):
"""
Calculate slice bound that corresponds to given label.
Returns leftmost (one-past-the-rightmost if ``side=='right'``) position
of given label.
Parameters
----------
label : object
side : {'left', 'right'}... | [
"def",
"get_slice_bound",
"(",
"self",
",",
"label",
",",
"side",
",",
"kind",
")",
":",
"assert",
"kind",
"in",
"[",
"'ix'",
",",
"'loc'",
",",
"'getitem'",
",",
"None",
"]",
"if",
"side",
"not",
"in",
"(",
"'left'",
",",
"'right'",
")",
":",
"rai... | https://github.com/chribsen/simple-machine-learning-examples/blob/dc94e52a4cebdc8bb959ff88b81ff8cfeca25022/venv/lib/python2.7/site-packages/pandas/indexes/base.py#L3090-L3147 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.