Search is not available for this dataset
identifier stringlengths 1 155 | parameters stringlengths 2 6.09k | docstring stringlengths 11 63.4k | docstring_summary stringlengths 0 63.4k | function stringlengths 29 99.8k | function_tokens list | start_point list | end_point list | language stringclasses 1
value | docstring_language stringlengths 2 7 | docstring_language_predictions stringlengths 18 23 | is_langid_reliable stringclasses 2
values |
|---|---|---|---|---|---|---|---|---|---|---|---|
rename_for_jekyll | (nb_path: Path, warnings: Set[Tuple[str, str]]=None) |
Return a Path's filename string appended with its modified time in YYYY-MM-DD format.
|
Return a Path's filename string appended with its modified time in YYYY-MM-DD format.
| def rename_for_jekyll(nb_path: Path, warnings: Set[Tuple[str, str]]=None) -> str:
"""
Return a Path's filename string appended with its modified time in YYYY-MM-DD format.
"""
assert nb_path.exists(), f'{nb_path} could not be found.'
# Checks if filename is compliant with Jekyll blog posts
if _... | [
"def",
"rename_for_jekyll",
"(",
"nb_path",
":",
"Path",
",",
"warnings",
":",
"Set",
"[",
"Tuple",
"[",
"str",
",",
"str",
"]",
"]",
"=",
"None",
")",
"->",
"str",
":",
"assert",
"nb_path",
".",
"exists",
"(",
")",
",",
"f'{nb_path} could not be found.'... | [
10,
0
] | [
28,
19
] | python | en | ['en', 'error', 'th'] | False |
is_ascii_encoding | (encoding) | Checks if a given encoding is ascii. | Checks if a given encoding is ascii. | def is_ascii_encoding(encoding):
"""Checks if a given encoding is ascii."""
try:
return codecs.lookup(encoding).name == 'ascii'
except LookupError:
return False | [
"def",
"is_ascii_encoding",
"(",
"encoding",
")",
":",
"try",
":",
"return",
"codecs",
".",
"lookup",
"(",
"encoding",
")",
".",
"name",
"==",
"'ascii'",
"except",
"LookupError",
":",
"return",
"False"
] | [
36,
0
] | [
41,
20
] | python | en | ['en', 'en', 'en'] | True |
get_best_encoding | (stream) | Returns the default stream encoding if not found. | Returns the default stream encoding if not found. | def get_best_encoding(stream):
"""Returns the default stream encoding if not found."""
rv = getattr(stream, 'encoding', None) or sys.getdefaultencoding()
if is_ascii_encoding(rv):
return 'utf-8'
return rv | [
"def",
"get_best_encoding",
"(",
"stream",
")",
":",
"rv",
"=",
"getattr",
"(",
"stream",
",",
"'encoding'",
",",
"None",
")",
"or",
"sys",
".",
"getdefaultencoding",
"(",
")",
"if",
"is_ascii_encoding",
"(",
"rv",
")",
":",
"return",
"'utf-8'",
"return",
... | [
44,
0
] | [
49,
13
] | python | en | ['en', 'en', 'en'] | True |
build_iter_view | (matches) | Build an iterable view from the value returned by `find_matches()`. | Build an iterable view from the value returned by `find_matches()`. | def build_iter_view(matches):
"""Build an iterable view from the value returned by `find_matches()`."""
if callable(matches):
return _FactoryIterableView(matches)
if not isinstance(matches, collections_abc.Sequence):
matches = list(matches)
return _SequenceIterableView(matches) | [
"def",
"build_iter_view",
"(",
"matches",
")",
":",
"if",
"callable",
"(",
"matches",
")",
":",
"return",
"_FactoryIterableView",
"(",
"matches",
")",
"if",
"not",
"isinstance",
"(",
"matches",
",",
"collections_abc",
".",
"Sequence",
")",
":",
"matches",
"=... | [
158,
0
] | [
164,
41
] | python | en | ['en', 'en', 'en'] | True |
DirectedGraph.copy | (self) | Return a shallow copy of this graph. | Return a shallow copy of this graph. | def copy(self):
"""Return a shallow copy of this graph."""
other = DirectedGraph()
other._vertices = set(self._vertices)
other._forwards = {k: set(v) for k, v in self._forwards.items()}
other._backwards = {k: set(v) for k, v in self._backwards.items()}
return other | [
"def",
"copy",
"(",
"self",
")",
":",
"other",
"=",
"DirectedGraph",
"(",
")",
"other",
".",
"_vertices",
"=",
"set",
"(",
"self",
".",
"_vertices",
")",
"other",
".",
"_forwards",
"=",
"{",
"k",
":",
"set",
"(",
"v",
")",
"for",
"k",
",",
"v",
... | [
22,
4
] | [
28,
20
] | python | en | ['en', 'en', 'en'] | True |
DirectedGraph.add | (self, key) | Add a new vertex to the graph. | Add a new vertex to the graph. | def add(self, key):
"""Add a new vertex to the graph."""
if key in self._vertices:
raise ValueError("vertex exists")
self._vertices.add(key)
self._forwards[key] = set()
self._backwards[key] = set() | [
"def",
"add",
"(",
"self",
",",
"key",
")",
":",
"if",
"key",
"in",
"self",
".",
"_vertices",
":",
"raise",
"ValueError",
"(",
"\"vertex exists\"",
")",
"self",
".",
"_vertices",
".",
"add",
"(",
"key",
")",
"self",
".",
"_forwards",
"[",
"key",
"]",... | [
30,
4
] | [
36,
36
] | python | en | ['en', 'en', 'en'] | True |
DirectedGraph.remove | (self, key) | Remove a vertex from the graph, disconnecting all edges from/to it. | Remove a vertex from the graph, disconnecting all edges from/to it. | def remove(self, key):
"""Remove a vertex from the graph, disconnecting all edges from/to it."""
self._vertices.remove(key)
for f in self._forwards.pop(key):
self._backwards[f].remove(key)
for t in self._backwards.pop(key):
self._forwards[t].remove(key) | [
"def",
"remove",
"(",
"self",
",",
"key",
")",
":",
"self",
".",
"_vertices",
".",
"remove",
"(",
"key",
")",
"for",
"f",
"in",
"self",
".",
"_forwards",
".",
"pop",
"(",
"key",
")",
":",
"self",
".",
"_backwards",
"[",
"f",
"]",
".",
"remove",
... | [
38,
4
] | [
44,
41
] | python | en | ['en', 'en', 'en'] | True |
DirectedGraph.connect | (self, f, t) | Connect two existing vertices.
Nothing happens if the vertices are already connected.
| Connect two existing vertices. | def connect(self, f, t):
"""Connect two existing vertices.
Nothing happens if the vertices are already connected.
"""
if t not in self._vertices:
raise KeyError(t)
self._forwards[f].add(t)
self._backwards[t].add(f) | [
"def",
"connect",
"(",
"self",
",",
"f",
",",
"t",
")",
":",
"if",
"t",
"not",
"in",
"self",
".",
"_vertices",
":",
"raise",
"KeyError",
"(",
"t",
")",
"self",
".",
"_forwards",
"[",
"f",
"]",
".",
"add",
"(",
"t",
")",
"self",
".",
"_backwards... | [
49,
4
] | [
57,
33
] | python | en | ['nl', 'en', 'en'] | True |
flag_anomalies_by_thresholding | (
cur_batch_size, mahalanobis_dist, anom_thresh_var) | Flags anomalies by thresholding.
Given current batch size, mahalanobis distance, and anomaly threshold
variable, return predicted anomaly flags.
Args:
cur_batch_size: Current batch size, could be partially filled.
mahalanobis_dist: Mahalanobis distance.
anom_thresh_var: Anomaly threshold variable.
... | Flags anomalies by thresholding. | def flag_anomalies_by_thresholding(
cur_batch_size, mahalanobis_dist, anom_thresh_var):
"""Flags anomalies by thresholding.
Given current batch size, mahalanobis distance, and anomaly threshold
variable, return predicted anomaly flags.
Args:
cur_batch_size: Current batch size, could be partially fille... | [
"def",
"flag_anomalies_by_thresholding",
"(",
"cur_batch_size",
",",
"mahalanobis_dist",
",",
"anom_thresh_var",
")",
":",
"anom_flags",
"=",
"tf",
".",
"where",
"(",
"condition",
"=",
"tf",
".",
"reduce_any",
"(",
"input_tensor",
"=",
"tf",
".",
"greater",
"(",... | [
3,
0
] | [
28,
19
] | python | en | ['en', 'en', 'en'] | True |
anomaly_detection_predictions | (
cur_batch_size,
seq_len,
num_feat,
mahalanobis_dist_time,
mahalanobis_dist_feat,
time_anom_thresh_var,
feat_anom_thresh_var,
X_time_abs_recon_err,
X_feat_abs_recon_err) | Creates Estimator predictions and export outputs.
Given dimensions of inputs, mahalanobis distances and their respective
thresholds, and reconstructed inputs' absolute errors, returns Estimator's
predictions and export outputs.
Args:
cur_batch_size: Current batch size, could be partially filled.
seq_l... | Creates Estimator predictions and export outputs. | def anomaly_detection_predictions(
cur_batch_size,
seq_len,
num_feat,
mahalanobis_dist_time,
mahalanobis_dist_feat,
time_anom_thresh_var,
feat_anom_thresh_var,
X_time_abs_recon_err,
X_feat_abs_recon_err):
"""Creates Estimator predictions and export outputs.
Given dimensions of i... | [
"def",
"anomaly_detection_predictions",
"(",
"cur_batch_size",
",",
"seq_len",
",",
"num_feat",
",",
"mahalanobis_dist_time",
",",
"mahalanobis_dist_feat",
",",
"time_anom_thresh_var",
",",
"feat_anom_thresh_var",
",",
"X_time_abs_recon_err",
",",
"X_feat_abs_recon_err",
")",... | [
31,
0
] | [
98,
41
] | python | en | ['en', 'en', 'en'] | True |
register_json | (conn_or_curs=None, globally=False, loads=None,
oid=None, array_oid=None, name='json') | Create and register typecasters converting :sql:`json` type to Python objects.
:param conn_or_curs: a connection or cursor used to find the :sql:`json`
and :sql:`json[]` oids; the typecasters are registered in a scope
limited to this object, unless *globally* is set to `!True`. It can be
`!... | Create and register typecasters converting :sql:`json` type to Python objects. | def register_json(conn_or_curs=None, globally=False, loads=None,
oid=None, array_oid=None, name='json'):
"""Create and register typecasters converting :sql:`json` type to Python objects.
:param conn_or_curs: a connection or cursor used to find the :sql:`json`
and :sql:`json[]` oids; t... | [
"def",
"register_json",
"(",
"conn_or_curs",
"=",
"None",
",",
"globally",
"=",
"False",
",",
"loads",
"=",
"None",
",",
"oid",
"=",
"None",
",",
"array_oid",
"=",
"None",
",",
"name",
"=",
"'json'",
")",
":",
"if",
"oid",
"is",
"None",
":",
"oid",
... | [
88,
0
] | [
124,
26
] | python | en | ['en', 'en', 'en'] | True |
register_default_json | (conn_or_curs=None, globally=False, loads=None) |
Create and register :sql:`json` typecasters for PostgreSQL 9.2 and following.
Since PostgreSQL 9.2 :sql:`json` is a builtin type, hence its oid is known
and fixed. This function allows specifying a customized *loads* function
for the default :sql:`json` type without querying the database.
All the ... |
Create and register :sql:`json` typecasters for PostgreSQL 9.2 and following. | def register_default_json(conn_or_curs=None, globally=False, loads=None):
"""
Create and register :sql:`json` typecasters for PostgreSQL 9.2 and following.
Since PostgreSQL 9.2 :sql:`json` is a builtin type, hence its oid is known
and fixed. This function allows specifying a customized *loads* function... | [
"def",
"register_default_json",
"(",
"conn_or_curs",
"=",
"None",
",",
"globally",
"=",
"False",
",",
"loads",
"=",
"None",
")",
":",
"return",
"register_json",
"(",
"conn_or_curs",
"=",
"conn_or_curs",
",",
"globally",
"=",
"globally",
",",
"loads",
"=",
"l... | [
127,
0
] | [
137,
59
] | python | en | ['en', 'error', 'th'] | False |
register_default_jsonb | (conn_or_curs=None, globally=False, loads=None) |
Create and register :sql:`jsonb` typecasters for PostgreSQL 9.4 and following.
As in `register_default_json()`, the function allows to register a
customized *loads* function for the :sql:`jsonb` type at its known oid for
PostgreSQL 9.4 and following versions. All the parameters have the same
mean... |
Create and register :sql:`jsonb` typecasters for PostgreSQL 9.4 and following. | def register_default_jsonb(conn_or_curs=None, globally=False, loads=None):
"""
Create and register :sql:`jsonb` typecasters for PostgreSQL 9.4 and following.
As in `register_default_json()`, the function allows to register a
customized *loads* function for the :sql:`jsonb` type at its known oid for
... | [
"def",
"register_default_jsonb",
"(",
"conn_or_curs",
"=",
"None",
",",
"globally",
"=",
"False",
",",
"loads",
"=",
"None",
")",
":",
"return",
"register_json",
"(",
"conn_or_curs",
"=",
"conn_or_curs",
",",
"globally",
"=",
"globally",
",",
"loads",
"=",
"... | [
140,
0
] | [
150,
75
] | python | en | ['en', 'error', 'th'] | False |
_create_json_typecasters | (oid, array_oid, loads=None, name='JSON') | Create typecasters for json data type. | Create typecasters for json data type. | def _create_json_typecasters(oid, array_oid, loads=None, name='JSON'):
"""Create typecasters for json data type."""
if loads is None:
loads = json.loads
def typecast_json(s, cur):
if s is None:
return None
return loads(s)
JSON = new_type((oid, ), name, typecast_json... | [
"def",
"_create_json_typecasters",
"(",
"oid",
",",
"array_oid",
",",
"loads",
"=",
"None",
",",
"name",
"=",
"'JSON'",
")",
":",
"if",
"loads",
"is",
"None",
":",
"loads",
"=",
"json",
".",
"loads",
"def",
"typecast_json",
"(",
"s",
",",
"cur",
")",
... | [
153,
0
] | [
169,
26
] | python | en | ['en', 'en', 'en'] | True |
Json.dumps | (self, obj) | Serialize *obj* in JSON format.
The default is to call `!json.dumps()` or the *dumps* function
provided in the constructor. You can override this method to create a
customized JSON wrapper.
| Serialize *obj* in JSON format. | def dumps(self, obj):
"""Serialize *obj* in JSON format.
The default is to call `!json.dumps()` or the *dumps* function
provided in the constructor. You can override this method to create a
customized JSON wrapper.
"""
return self._dumps(obj) | [
"def",
"dumps",
"(",
"self",
",",
"obj",
")",
":",
"return",
"self",
".",
"_dumps",
"(",
"obj",
")"
] | [
64,
4
] | [
71,
31
] | python | en | ['en', 'fy', 'it'] | False |
develop._resolve_setup_path | (egg_base, install_dir, egg_path) |
Generate a path from egg_base back to '.' where the
setup script resides and ensure that path points to the
setup path from $install_dir/$egg_path.
|
Generate a path from egg_base back to '.' where the
setup script resides and ensure that path points to the
setup path from $install_dir/$egg_path.
| def _resolve_setup_path(egg_base, install_dir, egg_path):
"""
Generate a path from egg_base back to '.' where the
setup script resides and ensure that path points to the
setup path from $install_dir/$egg_path.
"""
path_to_setup = egg_base.replace(os.sep, '/').rstrip('/')
... | [
"def",
"_resolve_setup_path",
"(",
"egg_base",
",",
"install_dir",
",",
"egg_path",
")",
":",
"path_to_setup",
"=",
"egg_base",
".",
"replace",
"(",
"os",
".",
"sep",
",",
"'/'",
")",
".",
"rstrip",
"(",
"'/'",
")",
"if",
"path_to_setup",
"!=",
"os",
"."... | [
88,
4
] | [
104,
28
] | python | en | ['en', 'error', 'th'] | False |
_overload_dummy | (*args, **kwds) | Helper for @overload to raise when called. | Helper for | def _overload_dummy(*args, **kwds):
"""Helper for @overload to raise when called."""
raise NotImplementedError(
"You should not call an overloaded function. "
"A series of @overload-decorated functions "
"outside a stub module should always be followed "
"by an implementation tha... | [
"def",
"_overload_dummy",
"(",
"*",
"args",
",",
"*",
"*",
"kwds",
")",
":",
"raise",
"NotImplementedError",
"(",
"\"You should not call an overloaded function. \"",
"\"A series of @overload-decorated functions \"",
"\"outside a stub module should always be followed \"",
"\"by an i... | [
684,
0
] | [
690,
57
] | python | en | ['en', 'en', 'en'] | True |
overload | (func) | Decorator for overloaded functions/methods.
In a stub file, place two or more stub definitions for the same
function in a row, each decorated with @overload. For example:
@overload
def utf8(value: None) -> None: ...
@overload
def utf8(value: bytes) -> bytes: ...
@overload
... | Decorator for overloaded functions/methods. | def overload(func):
"""Decorator for overloaded functions/methods.
In a stub file, place two or more stub definitions for the same
function in a row, each decorated with @overload. For example:
@overload
def utf8(value: None) -> None: ...
@overload
def utf8(value: bytes) -> bytes:... | [
"def",
"overload",
"(",
"func",
")",
":",
"return",
"_overload_dummy"
] | [
693,
0
] | [
719,
26
] | python | en | ['en', 'en', 'en'] | True |
_define_guard | (type_name) |
Returns True if the given type isn't defined in typing but
is defined in collections_abc.
Adds the type to __all__ if the collection is found in either
typing or collection_abc.
|
Returns True if the given type isn't defined in typing but
is defined in collections_abc. | def _define_guard(type_name):
"""
Returns True if the given type isn't defined in typing but
is defined in collections_abc.
Adds the type to __all__ if the collection is found in either
typing or collection_abc.
"""
if hasattr(typing, type_name):
__all__.append(type_name)
gl... | [
"def",
"_define_guard",
"(",
"type_name",
")",
":",
"if",
"hasattr",
"(",
"typing",
",",
"type_name",
")",
":",
"__all__",
".",
"append",
"(",
"type_name",
")",
"globals",
"(",
")",
"[",
"type_name",
"]",
"=",
"getattr",
"(",
"typing",
",",
"type_name",
... | [
758,
0
] | [
774,
20
] | python | en | ['en', 'error', 'th'] | False |
_gorg | (cls) | This function exists for compatibility with old typing versions. | This function exists for compatibility with old typing versions. | def _gorg(cls):
"""This function exists for compatibility with old typing versions."""
assert isinstance(cls, GenericMeta)
if hasattr(cls, '_gorg'):
return cls._gorg
while cls.__origin__ is not None:
cls = cls.__origin__
return cls | [
"def",
"_gorg",
"(",
"cls",
")",
":",
"assert",
"isinstance",
"(",
"cls",
",",
"GenericMeta",
")",
"if",
"hasattr",
"(",
"cls",
",",
"'_gorg'",
")",
":",
"return",
"cls",
".",
"_gorg",
"while",
"cls",
".",
"__origin__",
"is",
"not",
"None",
":",
"cls... | [
1103,
0
] | [
1110,
14
] | python | en | ['en', 'en', 'en'] | True |
_ExtensionsGenericMeta.__subclasscheck__ | (self, subclass) | This mimics a more modern GenericMeta.__subclasscheck__() logic
(that does not have problems with recursion) to work around interactions
between collections, typing, and typing_extensions on older
versions of Python, see https://github.com/python/typing/issues/501.
| This mimics a more modern GenericMeta.__subclasscheck__() logic
(that does not have problems with recursion) to work around interactions
between collections, typing, and typing_extensions on older
versions of Python, see https://github.com/python/typing/issues/501.
| def __subclasscheck__(self, subclass):
"""This mimics a more modern GenericMeta.__subclasscheck__() logic
(that does not have problems with recursion) to work around interactions
between collections, typing, and typing_extensions on older
versions of Python, see https://github.com/python... | [
"def",
"__subclasscheck__",
"(",
"self",
",",
"subclass",
")",
":",
"if",
"sys",
".",
"version_info",
"[",
":",
"3",
"]",
">=",
"(",
"3",
",",
"5",
",",
"3",
")",
"or",
"sys",
".",
"version_info",
"[",
":",
"3",
"]",
"<",
"(",
"3",
",",
"5",
... | [
778,
4
] | [
802,
20
] | python | en | ['en', 'ca', 'en'] | True |
forbid_multi_line_headers | (name, val, encoding) | Forbid multi-line headers to prevent header injection. | Forbid multi-line headers to prevent header injection. | def forbid_multi_line_headers(name, val, encoding):
"""Forbid multi-line headers to prevent header injection."""
encoding = encoding or settings.DEFAULT_CHARSET
val = str(val) # val may be lazy
if '\n' in val or '\r' in val:
raise BadHeaderError("Header values can't contain newlines (got %r for... | [
"def",
"forbid_multi_line_headers",
"(",
"name",
",",
"val",
",",
"encoding",
")",
":",
"encoding",
"=",
"encoding",
"or",
"settings",
".",
"DEFAULT_CHARSET",
"val",
"=",
"str",
"(",
"val",
")",
"# val may be lazy",
"if",
"'\\n'",
"in",
"val",
"or",
"'\\r'",... | [
54,
0
] | [
70,
20
] | python | en | ['en', 'en', 'en'] | True |
sanitize_address | (addr, encoding) |
Format a pair of (name, address) or an email address string.
|
Format a pair of (name, address) or an email address string.
| def sanitize_address(addr, encoding):
"""
Format a pair of (name, address) or an email address string.
"""
address = None
if not isinstance(addr, tuple):
addr = force_str(addr)
try:
token, rest = parser.get_mailbox(addr)
except (HeaderParseError, ValueError, Index... | [
"def",
"sanitize_address",
"(",
"addr",
",",
"encoding",
")",
":",
"address",
"=",
"None",
"if",
"not",
"isinstance",
"(",
"addr",
",",
"tuple",
")",
":",
"addr",
"=",
"force_str",
"(",
"addr",
")",
"try",
":",
"token",
",",
"rest",
"=",
"parser",
".... | [
73,
0
] | [
115,
53
] | python | en | ['en', 'error', 'th'] | False |
MIMEMixin.as_string | (self, unixfrom=False, linesep='\n') | Return the entire formatted message as a string.
Optional `unixfrom' when True, means include the Unix From_ envelope
header.
This overrides the default as_string() implementation to not mangle
lines that begin with 'From '. See bug #13433 for details.
| Return the entire formatted message as a string.
Optional `unixfrom' when True, means include the Unix From_ envelope
header. | def as_string(self, unixfrom=False, linesep='\n'):
"""Return the entire formatted message as a string.
Optional `unixfrom' when True, means include the Unix From_ envelope
header.
This overrides the default as_string() implementation to not mangle
lines that begin with 'From '. ... | [
"def",
"as_string",
"(",
"self",
",",
"unixfrom",
"=",
"False",
",",
"linesep",
"=",
"'\\n'",
")",
":",
"fp",
"=",
"StringIO",
"(",
")",
"g",
"=",
"generator",
".",
"Generator",
"(",
"fp",
",",
"mangle_from_",
"=",
"False",
")",
"g",
".",
"flatten",
... | [
119,
4
] | [
130,
28
] | python | en | ['en', 'en', 'en'] | True |
MIMEMixin.as_bytes | (self, unixfrom=False, linesep='\n') | Return the entire formatted message as bytes.
Optional `unixfrom' when True, means include the Unix From_ envelope
header.
This overrides the default as_bytes() implementation to not mangle
lines that begin with 'From '. See bug #13433 for details.
| Return the entire formatted message as bytes.
Optional `unixfrom' when True, means include the Unix From_ envelope
header. | def as_bytes(self, unixfrom=False, linesep='\n'):
"""Return the entire formatted message as bytes.
Optional `unixfrom' when True, means include the Unix From_ envelope
header.
This overrides the default as_bytes() implementation to not mangle
lines that begin with 'From '. See b... | [
"def",
"as_bytes",
"(",
"self",
",",
"unixfrom",
"=",
"False",
",",
"linesep",
"=",
"'\\n'",
")",
":",
"fp",
"=",
"BytesIO",
"(",
")",
"g",
"=",
"generator",
".",
"BytesGenerator",
"(",
"fp",
",",
"mangle_from_",
"=",
"False",
")",
"g",
".",
"flatten... | [
132,
4
] | [
143,
28
] | python | en | ['en', 'en', 'en'] | True |
EmailMessage.__init__ | (self, subject='', body='', from_email=None, to=None, bcc=None,
connection=None, attachments=None, headers=None, cc=None,
reply_to=None) |
Initialize a single email message (which can be sent to multiple
recipients).
|
Initialize a single email message (which can be sent to multiple
recipients).
| def __init__(self, subject='', body='', from_email=None, to=None, bcc=None,
connection=None, attachments=None, headers=None, cc=None,
reply_to=None):
"""
Initialize a single email message (which can be sent to multiple
recipients).
"""
if to:
... | [
"def",
"__init__",
"(",
"self",
",",
"subject",
"=",
"''",
",",
"body",
"=",
"''",
",",
"from_email",
"=",
"None",
",",
"to",
"=",
"None",
",",
"bcc",
"=",
"None",
",",
"connection",
"=",
"None",
",",
"attachments",
"=",
"None",
",",
"headers",
"="... | [
193,
4
] | [
235,
36
] | python | en | ['en', 'error', 'th'] | False |
EmailMessage.recipients | (self) |
Return a list of all recipients of the email (includes direct
addressees as well as Cc and Bcc entries).
|
Return a list of all recipients of the email (includes direct
addressees as well as Cc and Bcc entries).
| def recipients(self):
"""
Return a list of all recipients of the email (includes direct
addressees as well as Cc and Bcc entries).
"""
return [email for email in (self.to + self.cc + self.bcc) if email] | [
"def",
"recipients",
"(",
"self",
")",
":",
"return",
"[",
"email",
"for",
"email",
"in",
"(",
"self",
".",
"to",
"+",
"self",
".",
"cc",
"+",
"self",
".",
"bcc",
")",
"if",
"email",
"]"
] | [
270,
4
] | [
275,
75
] | python | en | ['en', 'error', 'th'] | False |
EmailMessage.send | (self, fail_silently=False) | Send the email message. | Send the email message. | def send(self, fail_silently=False):
"""Send the email message."""
if not self.recipients():
# Don't bother creating the network connection if there's nobody to
# send to.
return 0
return self.get_connection(fail_silently).send_messages([self]) | [
"def",
"send",
"(",
"self",
",",
"fail_silently",
"=",
"False",
")",
":",
"if",
"not",
"self",
".",
"recipients",
"(",
")",
":",
"# Don't bother creating the network connection if there's nobody to",
"# send to.",
"return",
"0",
"return",
"self",
".",
"get_connectio... | [
277,
4
] | [
283,
71
] | python | en | ['en', 'en', 'en'] | True |
EmailMessage.attach | (self, filename=None, content=None, mimetype=None) |
Attach a file with the given filename and content. The filename can
be omitted and the mimetype is guessed, if not provided.
If the first parameter is a MIMEBase subclass, insert it directly
into the resulting message attachments.
For a text/* mimetype (guessed or specified), ... |
Attach a file with the given filename and content. The filename can
be omitted and the mimetype is guessed, if not provided. | def attach(self, filename=None, content=None, mimetype=None):
"""
Attach a file with the given filename and content. The filename can
be omitted and the mimetype is guessed, if not provided.
If the first parameter is a MIMEBase subclass, insert it directly
into the resulting mes... | [
"def",
"attach",
"(",
"self",
",",
"filename",
"=",
"None",
",",
"content",
"=",
"None",
",",
"mimetype",
"=",
"None",
")",
":",
"if",
"isinstance",
"(",
"filename",
",",
"MIMEBase",
")",
":",
"assert",
"content",
"is",
"None",
"assert",
"mimetype",
"i... | [
285,
4
] | [
315,
66
] | python | en | ['en', 'error', 'th'] | False |
EmailMessage.attach_file | (self, path, mimetype=None) |
Attach a file from the filesystem.
Set the mimetype to DEFAULT_ATTACHMENT_MIME_TYPE if it isn't specified
and cannot be guessed.
For a text/* mimetype (guessed or specified), decode the file's content
as UTF-8. If that fails, set the mimetype to
DEFAULT_ATTACHMENT_MIME... |
Attach a file from the filesystem. | def attach_file(self, path, mimetype=None):
"""
Attach a file from the filesystem.
Set the mimetype to DEFAULT_ATTACHMENT_MIME_TYPE if it isn't specified
and cannot be guessed.
For a text/* mimetype (guessed or specified), decode the file's content
as UTF-8. If that fai... | [
"def",
"attach_file",
"(",
"self",
",",
"path",
",",
"mimetype",
"=",
"None",
")",
":",
"path",
"=",
"Path",
"(",
"path",
")",
"with",
"path",
".",
"open",
"(",
"'rb'",
")",
"as",
"file",
":",
"content",
"=",
"file",
".",
"read",
"(",
")",
"self"... | [
317,
4
] | [
331,
53
] | python | en | ['en', 'error', 'th'] | False |
EmailMessage._create_mime_attachment | (self, content, mimetype) |
Convert the content, mimetype pair into a MIME attachment object.
If the mimetype is message/rfc822, content may be an
email.Message or EmailMessage object, as well as a str.
|
Convert the content, mimetype pair into a MIME attachment object. | def _create_mime_attachment(self, content, mimetype):
"""
Convert the content, mimetype pair into a MIME attachment object.
If the mimetype is message/rfc822, content may be an
email.Message or EmailMessage object, as well as a str.
"""
basetype, subtype = mimetype.split... | [
"def",
"_create_mime_attachment",
"(",
"self",
",",
"content",
",",
"mimetype",
")",
":",
"basetype",
",",
"subtype",
"=",
"mimetype",
".",
"split",
"(",
"'/'",
",",
"1",
")",
"if",
"basetype",
"==",
"'text'",
":",
"encoding",
"=",
"self",
".",
"encoding... | [
350,
4
] | [
378,
25
] | python | en | ['en', 'error', 'th'] | False |
EmailMessage._create_attachment | (self, filename, content, mimetype=None) |
Convert the filename, content, mimetype triple into a MIME attachment
object.
|
Convert the filename, content, mimetype triple into a MIME attachment
object.
| def _create_attachment(self, filename, content, mimetype=None):
"""
Convert the filename, content, mimetype triple into a MIME attachment
object.
"""
attachment = self._create_mime_attachment(content, mimetype)
if filename:
try:
filename.encode... | [
"def",
"_create_attachment",
"(",
"self",
",",
"filename",
",",
"content",
",",
"mimetype",
"=",
"None",
")",
":",
"attachment",
"=",
"self",
".",
"_create_mime_attachment",
"(",
"content",
",",
"mimetype",
")",
"if",
"filename",
":",
"try",
":",
"filename",... | [
380,
4
] | [
392,
25
] | python | en | ['en', 'error', 'th'] | False |
EmailMessage._set_list_header_if_not_empty | (self, msg, header, values) |
Set msg's header, either from self.extra_headers, if present, or from
the values argument.
|
Set msg's header, either from self.extra_headers, if present, or from
the values argument.
| def _set_list_header_if_not_empty(self, msg, header, values):
"""
Set msg's header, either from self.extra_headers, if present, or from
the values argument.
"""
if values:
try:
value = self.extra_headers[header]
except KeyError:
... | [
"def",
"_set_list_header_if_not_empty",
"(",
"self",
",",
"msg",
",",
"header",
",",
"values",
")",
":",
"if",
"values",
":",
"try",
":",
"value",
"=",
"self",
".",
"extra_headers",
"[",
"header",
"]",
"except",
"KeyError",
":",
"value",
"=",
"', '",
"."... | [
394,
4
] | [
404,
31
] | python | en | ['en', 'error', 'th'] | False |
EmailMultiAlternatives.__init__ | (self, subject='', body='', from_email=None, to=None, bcc=None,
connection=None, attachments=None, headers=None, alternatives=None,
cc=None, reply_to=None) |
Initialize a single email message (which can be sent to multiple
recipients).
|
Initialize a single email message (which can be sent to multiple
recipients).
| def __init__(self, subject='', body='', from_email=None, to=None, bcc=None,
connection=None, attachments=None, headers=None, alternatives=None,
cc=None, reply_to=None):
"""
Initialize a single email message (which can be sent to multiple
recipients).
"""... | [
"def",
"__init__",
"(",
"self",
",",
"subject",
"=",
"''",
",",
"body",
"=",
"''",
",",
"from_email",
"=",
"None",
",",
"to",
"=",
"None",
",",
"bcc",
"=",
"None",
",",
"connection",
"=",
"None",
",",
"attachments",
"=",
"None",
",",
"headers",
"="... | [
415,
4
] | [
426,
46
] | python | en | ['en', 'error', 'th'] | False |
EmailMultiAlternatives.attach_alternative | (self, content, mimetype) | Attach an alternative content representation. | Attach an alternative content representation. | def attach_alternative(self, content, mimetype):
"""Attach an alternative content representation."""
assert content is not None
assert mimetype is not None
self.alternatives.append((content, mimetype)) | [
"def",
"attach_alternative",
"(",
"self",
",",
"content",
",",
"mimetype",
")",
":",
"assert",
"content",
"is",
"not",
"None",
"assert",
"mimetype",
"is",
"not",
"None",
"self",
".",
"alternatives",
".",
"append",
"(",
"(",
"content",
",",
"mimetype",
")",... | [
428,
4
] | [
432,
53
] | python | en | ['en', 'lb', 'en'] | True |
Subversion.get_revision | (cls, location) |
Return the maximum revision for all files under a given location
|
Return the maximum revision for all files under a given location
| def get_revision(cls, location):
# type: (str) -> str
"""
Return the maximum revision for all files under a given location
"""
# Note: taken from setuptools.command.egg_info
revision = 0
for base, dirs, _ in os.walk(location):
if cls.dirname not in di... | [
"def",
"get_revision",
"(",
"cls",
",",
"location",
")",
":",
"# type: (str) -> str",
"# Note: taken from setuptools.command.egg_info",
"revision",
"=",
"0",
"for",
"base",
",",
"dirs",
",",
"_",
"in",
"os",
".",
"walk",
"(",
"location",
")",
":",
"if",
"cls",... | [
48,
4
] | [
75,
28
] | python | en | ['en', 'error', 'th'] | False |
Subversion.get_netloc_and_auth | (cls, netloc, scheme) |
This override allows the auth information to be passed to svn via the
--username and --password options instead of via the URL.
|
This override allows the auth information to be passed to svn via the
--username and --password options instead of via the URL.
| def get_netloc_and_auth(cls, netloc, scheme):
# type: (str, str) -> Tuple[str, Tuple[Optional[str], Optional[str]]]
"""
This override allows the auth information to be passed to svn via the
--username and --password options instead of via the URL.
"""
if scheme == 'ssh':
... | [
"def",
"get_netloc_and_auth",
"(",
"cls",
",",
"netloc",
",",
"scheme",
")",
":",
"# type: (str, str) -> Tuple[str, Tuple[Optional[str], Optional[str]]]",
"if",
"scheme",
"==",
"'ssh'",
":",
"# The --username and --password options can't be used for",
"# svn+ssh URLs, so keep the a... | [
78,
4
] | [
89,
45
] | python | en | ['en', 'error', 'th'] | False |
Subversion.is_commit_id_equal | (cls, dest, name) | Always assume the versions don't match | Always assume the versions don't match | def is_commit_id_equal(cls, dest, name):
# type: (str, Optional[str]) -> bool
"""Always assume the versions don't match"""
return False | [
"def",
"is_commit_id_equal",
"(",
"cls",
",",
"dest",
",",
"name",
")",
":",
"# type: (str, Optional[str]) -> bool",
"return",
"False"
] | [
192,
4
] | [
195,
20
] | python | en | ['en', 'en', 'en'] | True |
Subversion.call_vcs_version | (self) | Query the version of the currently installed Subversion client.
:return: A tuple containing the parts of the version information or
``()`` if the version returned from ``svn`` could not be parsed.
:raises: BadCommand: If ``svn`` is not installed.
| Query the version of the currently installed Subversion client. | def call_vcs_version(self):
# type: () -> Tuple[int, ...]
"""Query the version of the currently installed Subversion client.
:return: A tuple containing the parts of the version information or
``()`` if the version returned from ``svn`` could not be parsed.
:raises: BadComma... | [
"def",
"call_vcs_version",
"(",
"self",
")",
":",
"# type: () -> Tuple[int, ...]",
"# Example versions:",
"# svn, version 1.10.3 (r1842928)",
"# compiled Feb 25 2019, 14:20:39 on x86_64-apple-darwin17.0.0",
"# svn, version 1.7.14 (r1542130)",
"# compiled Mar 28 2018, 08:49:13 on ... | [
212,
4
] | [
241,
29
] | python | en | ['en', 'en', 'en'] | True |
Subversion.get_vcs_version | (self) | Return the version of the currently installed Subversion client.
If the version of the Subversion client has already been queried,
a cached value will be used.
:return: A tuple containing the parts of the version information or
``()`` if the version returned from ``svn`` could not ... | Return the version of the currently installed Subversion client. | def get_vcs_version(self):
# type: () -> Tuple[int, ...]
"""Return the version of the currently installed Subversion client.
If the version of the Subversion client has already been queried,
a cached value will be used.
:return: A tuple containing the parts of the version infor... | [
"def",
"get_vcs_version",
"(",
"self",
")",
":",
"# type: () -> Tuple[int, ...]",
"if",
"self",
".",
"_vcs_version",
"is",
"not",
"None",
":",
"# Use cached version, if available.",
"# If parsing the version failed previously (empty tuple),",
"# do not attempt to parse it again.",
... | [
243,
4
] | [
262,
26
] | python | en | ['en', 'en', 'en'] | True |
Subversion.get_remote_call_options | (self) | Return options to be used on calls to Subversion that contact the server.
These options are applicable for the following ``svn`` subcommands used
in this class.
- checkout
- switch
- update
:return: A list of command line arguments to pass to ``svn``.
... | Return options to be used on calls to Subversion that contact the server. | def get_remote_call_options(self):
# type: () -> CommandArgs
"""Return options to be used on calls to Subversion that contact the server.
These options are applicable for the following ``svn`` subcommands used
in this class.
- checkout
- switch
- upd... | [
"def",
"get_remote_call_options",
"(",
"self",
")",
":",
"# type: () -> CommandArgs",
"if",
"not",
"self",
".",
"use_interactive",
":",
"# --non-interactive switch is available since Subversion 0.14.4.",
"# Subversion < 1.8 runs in interactive mode by default.",
"return",
"[",
"'--... | [
264,
4
] | [
294,
17
] | python | en | ['en', 'en', 'en'] | True |
Node.__init__ | (self, name) | Creates a Node
:arg name: The tag name associated with the node
| Creates a Node | def __init__(self, name):
"""Creates a Node
:arg name: The tag name associated with the node
"""
# The tag name associated with the node
self.name = name
# The parent of the current node (or None for the document node)
self.parent = None
# The value of t... | [
"def",
"__init__",
"(",
"self",
",",
"name",
")",
":",
"# The tag name associated with the node",
"self",
".",
"name",
"=",
"name",
"# The parent of the current node (or None for the document node)",
"self",
".",
"parent",
"=",
"None",
"# The value of the current node (applie... | [
24,
4
] | [
42,
24
] | python | en | ['en', 'gl', 'en'] | True |
Node.appendChild | (self, node) | Insert node as a child of the current node
:arg node: the node to insert
| Insert node as a child of the current node | def appendChild(self, node):
"""Insert node as a child of the current node
:arg node: the node to insert
"""
raise NotImplementedError | [
"def",
"appendChild",
"(",
"self",
",",
"node",
")",
":",
"raise",
"NotImplementedError"
] | [
56,
4
] | [
62,
33
] | python | en | ['en', 'en', 'en'] | True |
Node.insertText | (self, data, insertBefore=None) | Insert data as text in the current node, positioned before the
start of node insertBefore or to the end of the node's text.
:arg data: the data to insert
:arg insertBefore: True if you want to insert the text before the node
and False if you want to insert it after the node
... | Insert data as text in the current node, positioned before the
start of node insertBefore or to the end of the node's text. | def insertText(self, data, insertBefore=None):
"""Insert data as text in the current node, positioned before the
start of node insertBefore or to the end of the node's text.
:arg data: the data to insert
:arg insertBefore: True if you want to insert the text before the node
... | [
"def",
"insertText",
"(",
"self",
",",
"data",
",",
"insertBefore",
"=",
"None",
")",
":",
"raise",
"NotImplementedError"
] | [
64,
4
] | [
74,
33
] | python | en | ['en', 'en', 'en'] | True |
Node.insertBefore | (self, node, refNode) | Insert node as a child of the current node, before refNode in the
list of child nodes. Raises ValueError if refNode is not a child of
the current node
:arg node: the node to insert
:arg refNode: the child node to insert the node before
| Insert node as a child of the current node, before refNode in the
list of child nodes. Raises ValueError if refNode is not a child of
the current node | def insertBefore(self, node, refNode):
"""Insert node as a child of the current node, before refNode in the
list of child nodes. Raises ValueError if refNode is not a child of
the current node
:arg node: the node to insert
:arg refNode: the child node to insert the node before
... | [
"def",
"insertBefore",
"(",
"self",
",",
"node",
",",
"refNode",
")",
":",
"raise",
"NotImplementedError"
] | [
76,
4
] | [
86,
33
] | python | en | ['en', 'en', 'en'] | True |
Node.removeChild | (self, node) | Remove node from the children of the current node
:arg node: the child node to remove
| Remove node from the children of the current node | def removeChild(self, node):
"""Remove node from the children of the current node
:arg node: the child node to remove
"""
raise NotImplementedError | [
"def",
"removeChild",
"(",
"self",
",",
"node",
")",
":",
"raise",
"NotImplementedError"
] | [
88,
4
] | [
94,
33
] | python | en | ['en', 'en', 'en'] | True |
Node.reparentChildren | (self, newParent) | Move all the children of the current node to newParent.
This is needed so that trees that don't store text as nodes move the
text in the correct way
:arg newParent: the node to move all this node's children to
| Move all the children of the current node to newParent.
This is needed so that trees that don't store text as nodes move the
text in the correct way | def reparentChildren(self, newParent):
"""Move all the children of the current node to newParent.
This is needed so that trees that don't store text as nodes move the
text in the correct way
:arg newParent: the node to move all this node's children to
"""
# XXX - should... | [
"def",
"reparentChildren",
"(",
"self",
",",
"newParent",
")",
":",
"# XXX - should this method be made more general?",
"for",
"child",
"in",
"self",
".",
"childNodes",
":",
"newParent",
".",
"appendChild",
"(",
"child",
")",
"self",
".",
"childNodes",
"=",
"[",
... | [
96,
4
] | [
107,
28
] | python | en | ['en', 'en', 'en'] | True |
Node.cloneNode | (self) | Return a shallow copy of the current node i.e. a node with the same
name and attributes but with no parent or child nodes
| Return a shallow copy of the current node i.e. a node with the same
name and attributes but with no parent or child nodes
| def cloneNode(self):
"""Return a shallow copy of the current node i.e. a node with the same
name and attributes but with no parent or child nodes
"""
raise NotImplementedError | [
"def",
"cloneNode",
"(",
"self",
")",
":",
"raise",
"NotImplementedError"
] | [
109,
4
] | [
113,
33
] | python | en | ['en', 'pt', 'en'] | True |
Node.hasContent | (self) | Return true if the node has children or text, false otherwise
| Return true if the node has children or text, false otherwise
| def hasContent(self):
"""Return true if the node has children or text, false otherwise
"""
raise NotImplementedError | [
"def",
"hasContent",
"(",
"self",
")",
":",
"raise",
"NotImplementedError"
] | [
115,
4
] | [
118,
33
] | python | en | ['en', 'en', 'en'] | True |
TreeBuilder.__init__ | (self, namespaceHTMLElements) | Create a TreeBuilder
:arg namespaceHTMLElements: whether or not to namespace HTML elements
| Create a TreeBuilder | def __init__(self, namespaceHTMLElements):
"""Create a TreeBuilder
:arg namespaceHTMLElements: whether or not to namespace HTML elements
"""
if namespaceHTMLElements:
self.defaultNamespace = "http://www.w3.org/1999/xhtml"
else:
self.defaultNamespace = No... | [
"def",
"__init__",
"(",
"self",
",",
"namespaceHTMLElements",
")",
":",
"if",
"namespaceHTMLElements",
":",
"self",
".",
"defaultNamespace",
"=",
"\"http://www.w3.org/1999/xhtml\"",
"else",
":",
"self",
".",
"defaultNamespace",
"=",
"None",
"self",
".",
"reset",
"... | [
171,
4
] | [
181,
20
] | python | en | ['en', 'ro', 'en'] | True |
TreeBuilder.elementInActiveFormattingElements | (self, name) | Check if an element exists between the end of the active
formatting elements and the last marker. If it does, return it, else
return false | Check if an element exists between the end of the active
formatting elements and the last marker. If it does, return it, else
return false | def elementInActiveFormattingElements(self, name):
"""Check if an element exists between the end of the active
formatting elements and the last marker. If it does, return it, else
return false"""
for item in self.activeFormattingElements[::-1]:
# Check for Marker first becau... | [
"def",
"elementInActiveFormattingElements",
"(",
"self",
",",
"name",
")",
":",
"for",
"item",
"in",
"self",
".",
"activeFormattingElements",
"[",
":",
":",
"-",
"1",
"]",
":",
"# Check for Marker first because if it's a Marker it doesn't have a",
"# name attribute.",
"... | [
268,
4
] | [
280,
20
] | python | en | ['en', 'en', 'en'] | True |
TreeBuilder.createElement | (self, token) | Create an element but don't insert it anywhere | Create an element but don't insert it anywhere | def createElement(self, token):
"""Create an element but don't insert it anywhere"""
name = token["name"]
namespace = token.get("namespace", self.defaultNamespace)
element = self.elementClass(name, namespace)
element.attributes = token["data"]
return element | [
"def",
"createElement",
"(",
"self",
",",
"token",
")",
":",
"name",
"=",
"token",
"[",
"\"name\"",
"]",
"namespace",
"=",
"token",
".",
"get",
"(",
"\"namespace\"",
",",
"self",
".",
"defaultNamespace",
")",
"element",
"=",
"self",
".",
"elementClass",
... | [
300,
4
] | [
306,
22
] | python | en | ['en', 'en', 'en'] | True |
TreeBuilder._setInsertFromTable | (self, value) | Switch the function used to insert an element from the
normal one to the misnested table one and back again | Switch the function used to insert an element from the
normal one to the misnested table one and back again | def _setInsertFromTable(self, value):
"""Switch the function used to insert an element from the
normal one to the misnested table one and back again"""
self._insertFromTable = value
if value:
self.insertElement = self.insertElementTable
else:
self.insertEl... | [
"def",
"_setInsertFromTable",
"(",
"self",
",",
"value",
")",
":",
"self",
".",
"_insertFromTable",
"=",
"value",
"if",
"value",
":",
"self",
".",
"insertElement",
"=",
"self",
".",
"insertElementTable",
"else",
":",
"self",
".",
"insertElement",
"=",
"self"... | [
311,
4
] | [
318,
57
] | python | en | ['en', 'en', 'en'] | True |
TreeBuilder.insertElementTable | (self, token) | Create an element and insert it into the tree | Create an element and insert it into the tree | def insertElementTable(self, token):
"""Create an element and insert it into the tree"""
element = self.createElement(token)
if self.openElements[-1].name not in tableInsertModeElements:
return self.insertElementNormal(token)
else:
# We should be in the InTable mo... | [
"def",
"insertElementTable",
"(",
"self",
",",
"token",
")",
":",
"element",
"=",
"self",
".",
"createElement",
"(",
"token",
")",
"if",
"self",
".",
"openElements",
"[",
"-",
"1",
"]",
".",
"name",
"not",
"in",
"tableInsertModeElements",
":",
"return",
... | [
332,
4
] | [
346,
22
] | python | en | ['en', 'en', 'en'] | True |
TreeBuilder.insertText | (self, data, parent=None) | Insert text data. | Insert text data. | def insertText(self, data, parent=None):
"""Insert text data."""
if parent is None:
parent = self.openElements[-1]
if (not self.insertFromTable or (self.insertFromTable and
self.openElements[-1].name
n... | [
"def",
"insertText",
"(",
"self",
",",
"data",
",",
"parent",
"=",
"None",
")",
":",
"if",
"parent",
"is",
"None",
":",
"parent",
"=",
"self",
".",
"openElements",
"[",
"-",
"1",
"]",
"if",
"(",
"not",
"self",
".",
"insertFromTable",
"or",
"(",
"se... | [
348,
4
] | [
361,
49
] | python | en | ['fr', 'lb', 'en'] | False |
TreeBuilder.getTableMisnestedNodePosition | (self) | Get the foster parent element, and sibling to insert before
(or None) when inserting a misnested table node | Get the foster parent element, and sibling to insert before
(or None) when inserting a misnested table node | def getTableMisnestedNodePosition(self):
"""Get the foster parent element, and sibling to insert before
(or None) when inserting a misnested table node"""
# The foster parent element is the one which comes before the most
# recently opened table element
# XXX - this is really ine... | [
"def",
"getTableMisnestedNodePosition",
"(",
"self",
")",
":",
"# The foster parent element is the one which comes before the most",
"# recently opened table element",
"# XXX - this is really inelegant",
"lastTable",
"=",
"None",
"fosterParent",
"=",
"None",
"insertBefore",
"=",
"N... | [
363,
4
] | [
387,
41
] | python | en | ['en', 'en', 'en'] | True |
TreeBuilder.getDocument | (self) | Return the final tree | Return the final tree | def getDocument(self):
"""Return the final tree"""
return self.document | [
"def",
"getDocument",
"(",
"self",
")",
":",
"return",
"self",
".",
"document"
] | [
399,
4
] | [
401,
28
] | python | en | ['en', 'mt', 'en'] | True |
TreeBuilder.getFragment | (self) | Return the final fragment | Return the final fragment | def getFragment(self):
"""Return the final fragment"""
# assert self.innerHTML
fragment = self.fragmentClass()
self.openElements[0].reparentChildren(fragment)
return fragment | [
"def",
"getFragment",
"(",
"self",
")",
":",
"# assert self.innerHTML",
"fragment",
"=",
"self",
".",
"fragmentClass",
"(",
")",
"self",
".",
"openElements",
"[",
"0",
"]",
".",
"reparentChildren",
"(",
"fragment",
")",
"return",
"fragment"
] | [
403,
4
] | [
408,
23
] | python | en | ['en', 'no', 'en'] | True |
TreeBuilder.testSerializer | (self, node) | Serialize the subtree of node in the format required by unit tests
:arg node: the node from which to start serializing
| Serialize the subtree of node in the format required by unit tests | def testSerializer(self, node):
"""Serialize the subtree of node in the format required by unit tests
:arg node: the node from which to start serializing
"""
raise NotImplementedError | [
"def",
"testSerializer",
"(",
"self",
",",
"node",
")",
":",
"raise",
"NotImplementedError"
] | [
410,
4
] | [
416,
33
] | python | en | ['en', 'en', 'en'] | True |
command_date | (bot, user, channel, args) | Shows date information. Usage: date [now|epoch] | Shows date information. Usage: date [now|epoch] | def command_date(bot, user, channel, args):
"Shows date information. Usage: date [now|epoch]"
days = ["Monday", "Tuesday", "Wednesday", "Thursday", "Friday",
"Saturday", "Sunday"]
d = datetime.datetime.now(tzlocal())
tomorrow = days[d.weekday() + 1]
n = d.strftime("%Z/UTC%z: %H:%M:%S, %... | [
"def",
"command_date",
"(",
"bot",
",",
"user",
",",
"channel",
",",
"args",
")",
":",
"days",
"=",
"[",
"\"Monday\"",
",",
"\"Tuesday\"",
",",
"\"Wednesday\"",
",",
"\"Thursday\"",
",",
"\"Friday\"",
",",
"\"Saturday\"",
",",
"\"Sunday\"",
"]",
"d",
"=",
... | [
13,
0
] | [
27,
60
] | python | en | ['fr', 'en', 'en'] | True |
infix | (bp, func) |
Create an infix operator, given a binding power and a function that
evaluates the node.
|
Create an infix operator, given a binding power and a function that
evaluates the node.
| def infix(bp, func):
"""
Create an infix operator, given a binding power and a function that
evaluates the node.
"""
class Operator(TokenBase):
lbp = bp
def led(self, left, parser):
self.first = left
self.second = parser.expression(bp)
return self... | [
"def",
"infix",
"(",
"bp",
",",
"func",
")",
":",
"class",
"Operator",
"(",
"TokenBase",
")",
":",
"lbp",
"=",
"bp",
"def",
"led",
"(",
"self",
",",
"left",
",",
"parser",
")",
":",
"self",
".",
"first",
"=",
"left",
"self",
".",
"second",
"=",
... | [
42,
0
] | [
64,
19
] | python | en | ['en', 'error', 'th'] | False |
prefix | (bp, func) |
Create a prefix operator, given a binding power and a function that
evaluates the node.
|
Create a prefix operator, given a binding power and a function that
evaluates the node.
| def prefix(bp, func):
"""
Create a prefix operator, given a binding power and a function that
evaluates the node.
"""
class Operator(TokenBase):
lbp = bp
def nud(self, parser):
self.first = parser.expression(bp)
self.second = None
return self
... | [
"def",
"prefix",
"(",
"bp",
",",
"func",
")",
":",
"class",
"Operator",
"(",
"TokenBase",
")",
":",
"lbp",
"=",
"bp",
"def",
"nud",
"(",
"self",
",",
"parser",
")",
":",
"self",
".",
"first",
"=",
"parser",
".",
"expression",
"(",
"bp",
")",
"sel... | [
67,
0
] | [
86,
19
] | python | en | ['en', 'error', 'th'] | False |
TokenBase.display | (self) |
Return what to display in error messages for this node
|
Return what to display in error messages for this node
| def display(self):
"""
Return what to display in error messages for this node
"""
return self.id | [
"def",
"display",
"(",
"self",
")",
":",
"return",
"self",
".",
"id"
] | [
31,
4
] | [
35,
22
] | python | en | ['en', 'error', 'th'] | False |
COP_fn_mdot | (L, transmissivity, mdot,dT) |
Calculates COP as a function of mass flow rate.
L is the well spacing [m]
transmissivity is the transmissivity [m^3]
mdot is the mass flow rate [kg/s]
dT is the difference in temperature between T_CV and T_DH, which depends
on depth
|
Calculates COP as a function of mass flow rate. | def COP_fn_mdot(L, transmissivity, mdot,dT):
"""
Calculates COP as a function of mass flow rate.
L is the well spacing [m]
transmissivity is the transmissivity [m^3]
mdot is the mass flow rate [kg/s]
dT is the difference in temperature between T_CV and T_DH, which depends
on depth
"... | [
"def",
"COP_fn_mdot",
"(",
"L",
",",
"transmissivity",
",",
"mdot",
",",
"dT",
")",
":",
"import",
"global_vars",
"as",
"GV",
"import",
"numpy",
"as",
"np",
"# import pudb; pudb.set_trace()",
"COP",
"=",
"(",
"GV",
".",
"rho_w",
"**",
"2",
"*",
"GV",
"."... | [
4,
0
] | [
20,
14
] | python | en | ['en', 'error', 'th'] | False |
m_max_ResVol | (L, b) |
Defines the maximum mass flow rate [kg/s] based on the amount of heat the
reservoir volume can hold. The reservoir volume is approximated as L^2*b.
This is Constraint I in Birdsell paper.
L is the well spacing [m].
b is the aquifer thickness [m].
|
Defines the maximum mass flow rate [kg/s] based on the amount of heat the
reservoir volume can hold. The reservoir volume is approximated as L^2*b.
This is Constraint I in Birdsell paper. | def m_max_ResVol(L, b):
"""
Defines the maximum mass flow rate [kg/s] based on the amount of heat the
reservoir volume can hold. The reservoir volume is approximated as L^2*b.
This is Constraint I in Birdsell paper.
L is the well spacing [m].
b is the aquifer thickness [m].
"""
import g... | [
"def",
"m_max_ResVol",
"(",
"L",
",",
"b",
")",
":",
"import",
"global_vars",
"as",
"GV",
"mdot",
"=",
"(",
"GV",
".",
"rho_w",
"*",
"GV",
".",
"Cpw",
"*",
"GV",
".",
"porosity",
"+",
"GV",
".",
"rho_r",
"*",
"GV",
".",
"Cpr",
"*",
"(",
"1.0",
... | [
22,
0
] | [
35,
15
] | python | en | ['en', 'error', 'th'] | False |
COP_HF | (L, dT, reservoir_depth = None) |
Defines the maximum mass flow rate [kg/s] to avoid hydraulic fracuting. This
is Constraint II in Birdsell paper.
L is the distance between the wells [m].
reservoir_depth is the depth of the reservoir [m]. Note - if it is changing
within the script, it should be provided a value. Otherwise it w... |
Defines the maximum mass flow rate [kg/s] to avoid hydraulic fracuting. This
is Constraint II in Birdsell paper. | def COP_HF(L, dT, reservoir_depth = None):
"""
Defines the maximum mass flow rate [kg/s] to avoid hydraulic fracuting. This
is Constraint II in Birdsell paper.
L is the distance between the wells [m].
reservoir_depth is the depth of the reservoir [m]. Note - if it is changing
within the scr... | [
"def",
"COP_HF",
"(",
"L",
",",
"dT",
",",
"reservoir_depth",
"=",
"None",
")",
":",
"import",
"global_vars",
"as",
"GV",
"if",
"reservoir_depth",
"is",
"None",
":",
"print",
"(",
"'Warning - you are using the default reservoir_depth'",
")",
"reservoir_depth",
"="... | [
37,
0
] | [
57,
17
] | python | en | ['en', 'error', 'th'] | False |
mdot_minLCOH | (well_cost, transmissivity, Lstar) |
Calculates the flow rate that gives the minimum LCOH, from d(LCOH)/d(mdot)
well_cost is the construction cost of one well [$]. The capital cost are 4
times the cost of a single well because there are two wells and the
capital cost is assumed to double.
transmissivity is the reservoir trans... |
Calculates the flow rate that gives the minimum LCOH, from d(LCOH)/d(mdot) | def mdot_minLCOH(well_cost, transmissivity, Lstar):
"""
Calculates the flow rate that gives the minimum LCOH, from d(LCOH)/d(mdot)
well_cost is the construction cost of one well [$]. The capital cost are 4
times the cost of a single well because there are two wells and the
capital cost is a... | [
"def",
"mdot_minLCOH",
"(",
"well_cost",
",",
"transmissivity",
",",
"Lstar",
")",
":",
"import",
"global_vars",
"as",
"GV",
"import",
"numpy",
"as",
"np",
"capital_cost",
"=",
"4.0",
"*",
"well_cost",
"cap_cost",
"=",
"capital_cost",
"CRF",
"=",
"(",
"GV",
... | [
59,
0
] | [
78,
23
] | python | en | ['en', 'error', 'th'] | False |
m_max_COP | (L, b, k, dT) |
Defines the maximum mass flow rate (kg/s) based on the COP>1 constraint.
This is not
L is the distance between the wells.
b is the aquifer thickness
k is the permeability
dT is the difference in temperature between T_CV and T_DH, which depends
on depth
|
Defines the maximum mass flow rate (kg/s) based on the COP>1 constraint.
This is not | def m_max_COP(L, b, k, dT):
"""
Defines the maximum mass flow rate (kg/s) based on the COP>1 constraint.
This is not
L is the distance between the wells.
b is the aquifer thickness
k is the permeability
dT is the difference in temperature between T_CV and T_DH, which depends
on dept... | [
"def",
"m_max_COP",
"(",
"L",
",",
"b",
",",
"k",
",",
"dT",
")",
":",
"import",
"global_vars",
"as",
"GV",
"import",
"numpy",
"as",
"np",
"# import pudb; pudb.set_trace()",
"mdot",
"=",
"(",
"GV",
".",
"rho_w",
"*",
"GV",
".",
"Cpw",
"*",
"dT",
")",... | [
80,
0
] | [
97,
15
] | python | en | ['en', 'error', 'th'] | False |
m_max_HF | (L , b , k, reservoir_depth = None) |
defines the maximum mass flow rate (kg/s) to avoid hydraulic fracuting. this
assumes that pore pressure should be less than 80% of lithostatic stress.
L is half the distance between the wells.
b is the aquifer thickness
k is the permeability
|
defines the maximum mass flow rate (kg/s) to avoid hydraulic fracuting. this
assumes that pore pressure should be less than 80% of lithostatic stress. | def m_max_HF(L , b , k, reservoir_depth = None):
"""
defines the maximum mass flow rate (kg/s) to avoid hydraulic fracuting. this
assumes that pore pressure should be less than 80% of lithostatic stress.
L is half the distance between the wells.
b is the aquifer thickness
k is the permeability
... | [
"def",
"m_max_HF",
"(",
"L",
",",
"b",
",",
"k",
",",
"reservoir_depth",
"=",
"None",
")",
":",
"import",
"global_vars",
"as",
"GV",
"import",
"numpy",
"as",
"np",
"if",
"reservoir_depth",
"is",
"None",
":",
"reservoir_depth",
"=",
"GV",
".",
"reservoir_... | [
99,
0
] | [
119,
15
] | python | en | ['en', 'error', 'th'] | False |
thermal_radius | (mdot , b, t_inj = None ) |
Calculates the thermal radius
mdot is the flow rate [kg/s]
t_inj is the duration of the injection [s]
b is the reservoir thickness
|
Calculates the thermal radius | def thermal_radius(mdot , b, t_inj = None ):
"""
Calculates the thermal radius
mdot is the flow rate [kg/s]
t_inj is the duration of the injection [s]
b is the reservoir thickness
"""
import global_vars as GV
import numpy as np
if t_inj is None:
t_inj = GV.t_inj
pri... | [
"def",
"thermal_radius",
"(",
"mdot",
",",
"b",
",",
"t_inj",
"=",
"None",
")",
":",
"import",
"global_vars",
"as",
"GV",
"import",
"numpy",
"as",
"np",
"if",
"t_inj",
"is",
"None",
":",
"t_inj",
"=",
"GV",
".",
"t_inj",
"print",
"(",
"\"Warning t_inj ... | [
121,
0
] | [
137,
15
] | python | en | ['en', 'error', 'th'] | False |
dP_inj_fn | (mdot, transmissivity , L ) |
Calculates the change in pressure for a single well from Darcy's equation.
See Schaetlze (1980).
mdot is flow rate [kg/s]
transmissivity is reservoir transmissivity [m3]
L is the well spacing [m]
|
Calculates the change in pressure for a single well from Darcy's equation.
See Schaetlze (1980). | def dP_inj_fn(mdot, transmissivity , L ):
"""
Calculates the change in pressure for a single well from Darcy's equation.
See Schaetlze (1980).
mdot is flow rate [kg/s]
transmissivity is reservoir transmissivity [m3]
L is the well spacing [m]
"""
import global_vars as GV
import numpy... | [
"def",
"dP_inj_fn",
"(",
"mdot",
",",
"transmissivity",
",",
"L",
")",
":",
"import",
"global_vars",
"as",
"GV",
"import",
"numpy",
"as",
"np",
"dP_inj",
"=",
"mdot",
"*",
"GV",
".",
"viscosity",
"*",
"np",
".",
"log",
"(",
"L",
"/",
"GV",
".",
"D"... | [
139,
0
] | [
152,
17
] | python | en | ['en', 'error', 'th'] | False |
heat_loss_fn | (depth, Rth, b, T_WH = None, T_DH = None, T_surf = None,
geothermal_gradient = None,Lstar = None) |
depth = reservoir depth [m]
Rth = thermal radius [m]
b = reservoir thickness [m]
T_WH is the waste heat temperature
T_DH is the district heating rejection temperature
T_surf is the average surface temperature
geothermal_gradient [C/m] is the geothermal gradient
Lstar is well spacing (on... |
depth = reservoir depth [m]
Rth = thermal radius [m]
b = reservoir thickness [m]
T_WH is the waste heat temperature
T_DH is the district heating rejection temperature
T_surf is the average surface temperature
geothermal_gradient [C/m] is the geothermal gradient
Lstar is well spacing (on... | def heat_loss_fn(depth, Rth, b, T_WH = None, T_DH = None, T_surf = None,
geothermal_gradient = None,Lstar = None):
"""
depth = reservoir depth [m]
Rth = thermal radius [m]
b = reservoir thickness [m]
T_WH is the waste heat temperature
T_DH is the district heating rejection tempera... | [
"def",
"heat_loss_fn",
"(",
"depth",
",",
"Rth",
",",
"b",
",",
"T_WH",
"=",
"None",
",",
"T_DH",
"=",
"None",
",",
"T_surf",
"=",
"None",
",",
"geothermal_gradient",
"=",
"None",
",",
"Lstar",
"=",
"None",
")",
":",
"import",
"global_vars",
"as",
"G... | [
155,
0
] | [
194,
60
] | python | en | ['en', 'error', 'th'] | False |
Deserializer | (stream_or_string, **options) | Deserialize a stream or string of YAML data. | Deserialize a stream or string of YAML data. | def Deserializer(stream_or_string, **options):
"""Deserialize a stream or string of YAML data."""
if isinstance(stream_or_string, bytes):
stream_or_string = stream_or_string.decode()
if isinstance(stream_or_string, str):
stream = StringIO(stream_or_string)
else:
stream = stream_o... | [
"def",
"Deserializer",
"(",
"stream_or_string",
",",
"*",
"*",
"options",
")",
":",
"if",
"isinstance",
"(",
"stream_or_string",
",",
"bytes",
")",
":",
"stream_or_string",
"=",
"stream_or_string",
".",
"decode",
"(",
")",
"if",
"isinstance",
"(",
"stream_or_s... | [
66,
0
] | [
79,
45
] | python | en | ['en', 'en', 'en'] | True |
SeleniumTestCaseBase.__new__ | (cls, name, bases, attrs) |
Dynamically create new classes and add them to the test module when
multiple browsers specs are provided (e.g. --selenium=firefox,chrome).
|
Dynamically create new classes and add them to the test module when
multiple browsers specs are provided (e.g. --selenium=firefox,chrome).
| def __new__(cls, name, bases, attrs):
"""
Dynamically create new classes and add them to the test module when
multiple browsers specs are provided (e.g. --selenium=firefox,chrome).
"""
test_class = super().__new__(cls, name, bases, attrs)
# If the test class is either bro... | [
"def",
"__new__",
"(",
"cls",
",",
"name",
",",
"bases",
",",
"attrs",
")",
":",
"test_class",
"=",
"super",
"(",
")",
".",
"__new__",
"(",
"cls",
",",
"name",
",",
"bases",
",",
"attrs",
")",
"# If the test class is either browser-specific or a test base, ret... | [
22,
4
] | [
60,
66
] | python | en | ['en', 'error', 'th'] | False |
UpdateCacheMiddleware.process_response | (self, request, response) | Set the cache, if needed. | Set the cache, if needed. | def process_response(self, request, response):
"""Set the cache, if needed."""
if not self._should_update_cache(request, response):
# We don't need to update the cache, just return.
return response
if response.streaming or response.status_code not in (200, 304):
... | [
"def",
"process_response",
"(",
"self",
",",
"request",
",",
"response",
")",
":",
"if",
"not",
"self",
".",
"_should_update_cache",
"(",
"request",
",",
"response",
")",
":",
"# We don't need to update the cache, just return.",
"return",
"response",
"if",
"response... | [
76,
4
] | [
115,
23
] | python | en | ['en', 'en', 'en'] | True |
FetchFromCacheMiddleware.process_request | (self, request) |
Check whether the page is already cached and return the cached
version if available.
|
Check whether the page is already cached and return the cached
version if available.
| def process_request(self, request):
"""
Check whether the page is already cached and return the cached
version if available.
"""
if request.method not in ('GET', 'HEAD'):
request._cache_update_cache = False
return None # Don't bother checking the cache.
... | [
"def",
"process_request",
"(",
"self",
",",
"request",
")",
":",
"if",
"request",
".",
"method",
"not",
"in",
"(",
"'GET'",
",",
"'HEAD'",
")",
":",
"request",
".",
"_cache_update_cache",
"=",
"False",
"return",
"None",
"# Don't bother checking the cache.",
"#... | [
134,
4
] | [
160,
23
] | python | en | ['en', 'error', 'th'] | False |
HTTPResponse__getheaders | (self) | Return list of (header, value) tuples. | Return list of (header, value) tuples. | def HTTPResponse__getheaders(self):
"""Return list of (header, value) tuples."""
if self.msg is None:
raise httplib.ResponseNotReady()
return self.msg.items() | [
"def",
"HTTPResponse__getheaders",
"(",
"self",
")",
":",
"if",
"self",
".",
"msg",
"is",
"None",
":",
"raise",
"httplib",
".",
"ResponseNotReady",
"(",
")",
"return",
"self",
".",
"msg",
".",
"items",
"(",
")"
] | [
166,
0
] | [
170,
27
] | python | en | ['en', 'et', 'en'] | True |
parse_uri | (uri) | Parses a URI using the regex given in Appendix B of RFC 3986.
(scheme, authority, path, query, fragment) = parse_uri(uri)
| Parses a URI using the regex given in Appendix B of RFC 3986. | def parse_uri(uri):
"""Parses a URI using the regex given in Appendix B of RFC 3986.
(scheme, authority, path, query, fragment) = parse_uri(uri)
"""
groups = URI.match(uri).groups()
return (groups[1], groups[3], groups[4], groups[6], groups[8]) | [
"def",
"parse_uri",
"(",
"uri",
")",
":",
"groups",
"=",
"URI",
".",
"match",
"(",
"uri",
")",
".",
"groups",
"(",
")",
"return",
"(",
"groups",
"[",
"1",
"]",
",",
"groups",
"[",
"3",
"]",
",",
"groups",
"[",
"4",
"]",
",",
"groups",
"[",
"6... | [
296,
0
] | [
302,
66
] | python | en | ['en', 'en', 'en'] | True |
safename | (filename) | Return a filename suitable for the cache.
Strips dangerous and common characters to create a filename we
can use to store the cache in.
| Return a filename suitable for the cache.
Strips dangerous and common characters to create a filename we
can use to store the cache in.
| def safename(filename):
"""Return a filename suitable for the cache.
Strips dangerous and common characters to create a filename we
can use to store the cache in.
"""
if isinstance(filename, str):
filename_bytes = filename
filename = filename.decode("utf-8")
else:
filenam... | [
"def",
"safename",
"(",
"filename",
")",
":",
"if",
"isinstance",
"(",
"filename",
",",
"str",
")",
":",
"filename_bytes",
"=",
"filename",
"filename",
"=",
"filename",
".",
"decode",
"(",
"\"utf-8\"",
")",
"else",
":",
"filename_bytes",
"=",
"filename",
"... | [
326,
0
] | [
347,
40
] | python | en | ['en', 'en', 'en'] | True |
_parse_www_authenticate | (headers, headername="www-authenticate") | Returns a dictionary of dictionaries, one dict
per auth_scheme. | Returns a dictionary of dictionaries, one dict
per auth_scheme. | def _parse_www_authenticate(headers, headername="www-authenticate"):
"""Returns a dictionary of dictionaries, one dict
per auth_scheme."""
retval = {}
if headername in headers:
try:
authenticate = headers[headername].strip()
www_auth = (
USE_WWW_AUTH_STRI... | [
"def",
"_parse_www_authenticate",
"(",
"headers",
",",
"headername",
"=",
"\"www-authenticate\"",
")",
":",
"retval",
"=",
"{",
"}",
"if",
"headername",
"in",
"headers",
":",
"try",
":",
"authenticate",
"=",
"headers",
"[",
"headername",
"]",
".",
"strip",
"... | [
398,
0
] | [
431,
17
] | python | en | ['en', 'en', 'en'] | True |
_entry_disposition | (response_headers, request_headers) | Determine freshness from the Date, Expires and Cache-Control headers.
We don't handle the following:
1. Cache-Control: max-stale
2. Age: headers are not used in the calculations.
Not that this algorithm is simpler than you might think
because we are operating as a private (non-shared) cache.
... | Determine freshness from the Date, Expires and Cache-Control headers. | def _entry_disposition(response_headers, request_headers):
"""Determine freshness from the Date, Expires and Cache-Control headers.
We don't handle the following:
1. Cache-Control: max-stale
2. Age: headers are not used in the calculations.
Not that this algorithm is simpler than you might think
... | [
"def",
"_entry_disposition",
"(",
"response_headers",
",",
"request_headers",
")",
":",
"retval",
"=",
"\"STALE\"",
"cc",
"=",
"_parse_cache_control",
"(",
"request_headers",
")",
"cc_response",
"=",
"_parse_cache_control",
"(",
"response_headers",
")",
"if",
"(",
"... | [
435,
0
] | [
510,
17
] | python | en | ['en', 'en', 'en'] | True |
proxy_info_from_environment | (method="http") | Read proxy info from the environment variables.
| Read proxy info from the environment variables.
| def proxy_info_from_environment(method="http"):
"""Read proxy info from the environment variables.
"""
if method not in ["http", "https"]:
return
env_var = method + "_proxy"
url = os.environ.get(env_var, os.environ.get(env_var.upper()))
if not url:
return
return proxy_info_f... | [
"def",
"proxy_info_from_environment",
"(",
"method",
"=",
"\"http\"",
")",
":",
"if",
"method",
"not",
"in",
"[",
"\"http\"",
",",
"\"https\"",
"]",
":",
"return",
"env_var",
"=",
"method",
"+",
"\"_proxy\"",
"url",
"=",
"os",
".",
"environ",
".",
"get",
... | [
1068,
0
] | [
1078,
49
] | python | en | ['en', 'en', 'en'] | True |
proxy_info_from_url | (url, method="http", noproxy=None) | Construct a ProxyInfo from a URL (such as http_proxy env var)
| Construct a ProxyInfo from a URL (such as http_proxy env var)
| def proxy_info_from_url(url, method="http", noproxy=None):
"""Construct a ProxyInfo from a URL (such as http_proxy env var)
"""
url = urlparse.urlparse(url)
username = None
password = None
port = None
if "@" in url[1]:
ident, host_port = url[1].split("@", 1)
if ":" in ident:
... | [
"def",
"proxy_info_from_url",
"(",
"url",
",",
"method",
"=",
"\"http\"",
",",
"noproxy",
"=",
"None",
")",
":",
"url",
"=",
"urlparse",
".",
"urlparse",
"(",
"url",
")",
"username",
"=",
"None",
"password",
"=",
"None",
"port",
"=",
"None",
"if",
"\"@... | [
1081,
0
] | [
1128,
13
] | python | en | ['en', 'en', 'en'] | True |
Authentication.request | (self, method, request_uri, headers, content) | Modify the request headers to add the appropriate
Authorization header. Over-ride this in sub-classes. | Modify the request headers to add the appropriate
Authorization header. Over-ride this in sub-classes. | def request(self, method, request_uri, headers, content):
"""Modify the request headers to add the appropriate
Authorization header. Over-ride this in sub-classes."""
pass | [
"def",
"request",
"(",
"self",
",",
"method",
",",
"request_uri",
",",
"headers",
",",
"content",
")",
":",
"pass"
] | [
617,
4
] | [
620,
12
] | python | en | ['en', 'en', 'en'] | True |
Authentication.response | (self, response, content) | Gives us a chance to update with new nonces
or such returned from the last authorized response.
Over-rise this in sub-classes if necessary.
Return TRUE is the request is to be retried, for
example Digest may return stale=true.
| Gives us a chance to update with new nonces
or such returned from the last authorized response.
Over-rise this in sub-classes if necessary. | def response(self, response, content):
"""Gives us a chance to update with new nonces
or such returned from the last authorized response.
Over-rise this in sub-classes if necessary.
Return TRUE is the request is to be retried, for
example Digest may return stale=true.
""... | [
"def",
"response",
"(",
"self",
",",
"response",
",",
"content",
")",
":",
"return",
"False"
] | [
622,
4
] | [
630,
20
] | python | en | ['en', 'en', 'en'] | True |
BasicAuthentication.request | (self, method, request_uri, headers, content) | Modify the request headers to add the appropriate
Authorization header. | Modify the request headers to add the appropriate
Authorization header. | def request(self, method, request_uri, headers, content):
"""Modify the request headers to add the appropriate
Authorization header."""
headers["authorization"] = (
"Basic " + base64.b64encode("%s:%s" % self.credentials).strip()
) | [
"def",
"request",
"(",
"self",
",",
"method",
",",
"request_uri",
",",
"headers",
",",
"content",
")",
":",
"headers",
"[",
"\"authorization\"",
"]",
"=",
"(",
"\"Basic \"",
"+",
"base64",
".",
"b64encode",
"(",
"\"%s:%s\"",
"%",
"self",
".",
"credentials"... | [
641,
4
] | [
646,
9
] | python | en | ['en', 'en', 'en'] | True |
DigestAuthentication.request | (self, method, request_uri, headers, content, cnonce=None) | Modify the request headers | Modify the request headers | def request(self, method, request_uri, headers, content, cnonce=None):
"""Modify the request headers"""
H = lambda x: _md5(x).hexdigest()
KD = lambda s, d: H("%s:%s" % (s, d))
A2 = "".join([method, ":", request_uri])
self.challenge["cnonce"] = cnonce or _cnonce()
request_... | [
"def",
"request",
"(",
"self",
",",
"method",
",",
"request_uri",
",",
"headers",
",",
"content",
",",
"cnonce",
"=",
"None",
")",
":",
"H",
"=",
"lambda",
"x",
":",
"_md5",
"(",
"x",
")",
".",
"hexdigest",
"(",
")",
"KD",
"=",
"lambda",
"s",
","... | [
685,
4
] | [
719,
33
] | python | en | ['en', 'en', 'en'] | True |
HmacDigestAuthentication.request | (self, method, request_uri, headers, content) | Modify the request headers | Modify the request headers | def request(self, method, request_uri, headers, content):
"""Modify the request headers"""
keys = _get_end2end_headers(headers)
keylist = "".join(["%s " % k for k in keys])
headers_val = "".join([headers[k] for k in keys])
created = time.strftime("%Y-%m-%dT%H:%M:%SZ", time.gmtime... | [
"def",
"request",
"(",
"self",
",",
"method",
",",
"request_uri",
",",
"headers",
",",
"content",
")",
":",
"keys",
"=",
"_get_end2end_headers",
"(",
"headers",
")",
"keylist",
"=",
"\"\"",
".",
"join",
"(",
"[",
"\"%s \"",
"%",
"k",
"for",
"k",
"in",
... | [
799,
4
] | [
829,
9
] | python | en | ['en', 'en', 'en'] | True |
WsseAuthentication.request | (self, method, request_uri, headers, content) | Modify the request headers to add the appropriate
Authorization header. | Modify the request headers to add the appropriate
Authorization header. | def request(self, method, request_uri, headers, content):
"""Modify the request headers to add the appropriate
Authorization header."""
headers["authorization"] = 'WSSE profile="UsernameToken"'
iso_now = time.strftime("%Y-%m-%dT%H:%M:%SZ", time.gmtime())
cnonce = _cnonce()
... | [
"def",
"request",
"(",
"self",
",",
"method",
",",
"request_uri",
",",
"headers",
",",
"content",
")",
":",
"headers",
"[",
"\"authorization\"",
"]",
"=",
"'WSSE profile=\"UsernameToken\"'",
"iso_now",
"=",
"time",
".",
"strftime",
"(",
"\"%Y-%m-%dT%H:%M:%SZ\"",
... | [
856,
4
] | [
866,
67
] | python | en | ['en', 'en', 'en'] | True |
GoogleLoginAuthentication.request | (self, method, request_uri, headers, content) | Modify the request headers to add the appropriate
Authorization header. | Modify the request headers to add the appropriate
Authorization header. | def request(self, method, request_uri, headers, content):
"""Modify the request headers to add the appropriate
Authorization header."""
headers["authorization"] = "GoogleLogin Auth=" + self.Auth | [
"def",
"request",
"(",
"self",
",",
"method",
",",
"request_uri",
",",
"headers",
",",
"content",
")",
":",
"headers",
"[",
"\"authorization\"",
"]",
"=",
"\"GoogleLogin Auth=\"",
"+",
"self",
".",
"Auth"
] | [
907,
4
] | [
910,
66
] | python | en | ['en', 'en', 'en'] | True |
ProxyInfo.__init__ | (
self,
proxy_type,
proxy_host,
proxy_port,
proxy_rdns=True,
proxy_user=None,
proxy_pass=None,
proxy_headers=None,
) | Args:
proxy_type: The type of proxy server. This must be set to one of
socks.PROXY_TYPE_XXX constants. For example: p =
ProxyInfo(proxy_type=socks.PROXY_TYPE_HTTP, proxy_host='localhost',
proxy_port=8000)
proxy_host: The hostname or IP address of the proxy server.
... | Args: | def __init__(
self,
proxy_type,
proxy_host,
proxy_port,
proxy_rdns=True,
proxy_user=None,
proxy_pass=None,
proxy_headers=None,
):
"""Args:
proxy_type: The type of proxy server. This must be set to one of
socks.PROXY_TYPE_X... | [
"def",
"__init__",
"(",
"self",
",",
"proxy_type",
",",
"proxy_host",
",",
"proxy_port",
",",
"proxy_rdns",
"=",
"True",
",",
"proxy_user",
"=",
"None",
",",
"proxy_pass",
"=",
"None",
",",
"proxy_headers",
"=",
"None",
",",
")",
":",
"self",
".",
"proxy... | [
993,
4
] | [
1026,
42
] | python | en | ['en', 'gl', 'ur'] | False |
ProxyInfo.bypass_host | (self, hostname) | Has this host been excluded from the proxy config | Has this host been excluded from the proxy config | def bypass_host(self, hostname):
"""Has this host been excluded from the proxy config"""
if self.bypass_hosts is AllHosts:
return True
hostname = "." + hostname.lstrip(".")
for skip_name in self.bypass_hosts:
# *.suffix
if skip_name.startswith(".") an... | [
"def",
"bypass_host",
"(",
"self",
",",
"hostname",
")",
":",
"if",
"self",
".",
"bypass_hosts",
"is",
"AllHosts",
":",
"return",
"True",
"hostname",
"=",
"\".\"",
"+",
"hostname",
".",
"lstrip",
"(",
"\".\"",
")",
"for",
"skip_name",
"in",
"self",
".",
... | [
1045,
4
] | [
1058,
20
] | python | en | ['en', 'en', 'en'] | True |
HTTPConnectionWithTimeout.connect | (self) | Connect to the host and port specified in __init__. | Connect to the host and port specified in __init__. | def connect(self):
"""Connect to the host and port specified in __init__."""
# Mostly verbatim from httplib.py.
if self.proxy_info and socks is None:
raise ProxiesUnavailableError(
"Proxy support missing but proxy use was requested!"
)
msg = "getad... | [
"def",
"connect",
"(",
"self",
")",
":",
"# Mostly verbatim from httplib.py.",
"if",
"self",
".",
"proxy_info",
"and",
"socks",
"is",
"None",
":",
"raise",
"ProxiesUnavailableError",
"(",
"\"Proxy support missing but proxy use was requested!\"",
")",
"msg",
"=",
"\"geta... | [
1145,
4
] | [
1231,
35
] | python | en | ['en', 'en', 'en'] | True |
HTTPSConnectionWithTimeout._GetValidHostsForCert | (self, cert) | Returns a list of valid host globs for an SSL certificate.
Args:
cert: A dictionary representing an SSL certificate.
Returns:
list: A list of valid host globs.
| Returns a list of valid host globs for an SSL certificate. | def _GetValidHostsForCert(self, cert):
"""Returns a list of valid host globs for an SSL certificate.
Args:
cert: A dictionary representing an SSL certificate.
Returns:
list: A list of valid host globs.
"""
if "subjectAltName" in cert:
return [x[1]... | [
"def",
"_GetValidHostsForCert",
"(",
"self",
",",
"cert",
")",
":",
"if",
"\"subjectAltName\"",
"in",
"cert",
":",
"return",
"[",
"x",
"[",
"1",
"]",
"for",
"x",
"in",
"cert",
"[",
"\"subjectAltName\"",
"]",
"if",
"x",
"[",
"0",
"]",
".",
"lower",
"(... | [
1287,
4
] | [
1298,
88
] | python | en | ['en', 'lb', 'en'] | True |
HTTPSConnectionWithTimeout._ValidateCertificateHostname | (self, cert, hostname) | Validates that a given hostname is valid for an SSL certificate.
Args:
cert: A dictionary representing an SSL certificate.
hostname: The hostname to test.
Returns:
bool: Whether or not the hostname is valid for this certificate.
| Validates that a given hostname is valid for an SSL certificate. | def _ValidateCertificateHostname(self, cert, hostname):
"""Validates that a given hostname is valid for an SSL certificate.
Args:
cert: A dictionary representing an SSL certificate.
hostname: The hostname to test.
Returns:
bool: Whether or not the hostname is valid... | [
"def",
"_ValidateCertificateHostname",
"(",
"self",
",",
"cert",
",",
"hostname",
")",
":",
"hosts",
"=",
"self",
".",
"_GetValidHostsForCert",
"(",
"cert",
")",
"for",
"host",
"in",
"hosts",
":",
"host_re",
"=",
"host",
".",
"replace",
"(",
"\".\"",
",",
... | [
1300,
4
] | [
1314,
20
] | python | en | ['en', 'en', 'en'] | True |
HTTPSConnectionWithTimeout.connect | (self) | Connect to a host on a given (SSL) port. | Connect to a host on a given (SSL) port. | def connect(self):
"Connect to a host on a given (SSL) port."
msg = "getaddrinfo returns an empty list"
if self.proxy_info and self.proxy_info.isgood():
use_proxy = True
proxy_type, proxy_host, proxy_port, proxy_rdns, proxy_user, proxy_pass, proxy_headers = (
... | [
"def",
"connect",
"(",
"self",
")",
":",
"msg",
"=",
"\"getaddrinfo returns an empty list\"",
"if",
"self",
".",
"proxy_info",
"and",
"self",
".",
"proxy_info",
".",
"isgood",
"(",
")",
":",
"use_proxy",
"=",
"True",
"proxy_type",
",",
"proxy_host",
",",
"pr... | [
1316,
4
] | [
1438,
35
] | python | en | ['en', 'en', 'en'] | True |
Http.__init__ | (
self,
cache=None,
timeout=None,
proxy_info=proxy_info_from_environment,
ca_certs=None,
disable_ssl_certificate_validation=False,
ssl_version=None,
) | If 'cache' is a string then it is used as a directory name for
a disk cache. Otherwise it must be an object that supports the
same interface as FileCache.
All timeouts are in seconds. If None is passed for timeout
then Python's default timeout for sockets will be used. See
for e... | If 'cache' is a string then it is used as a directory name for
a disk cache. Otherwise it must be an object that supports the
same interface as FileCache. | def __init__(
self,
cache=None,
timeout=None,
proxy_info=proxy_info_from_environment,
ca_certs=None,
disable_ssl_certificate_validation=False,
ssl_version=None,
):
"""If 'cache' is a string then it is used as a directory name for
a disk cache. ... | [
"def",
"__init__",
"(",
"self",
",",
"cache",
"=",
"None",
",",
"timeout",
"=",
"None",
",",
"proxy_info",
"=",
"proxy_info_from_environment",
",",
"ca_certs",
"=",
"None",
",",
"disable_ssl_certificate_validation",
"=",
"False",
",",
"ssl_version",
"=",
"None",... | [
1574,
4
] | [
1649,
50
] | python | en | ['en', 'en', 'en'] | True |
Http._auth_from_challenge | (self, host, request_uri, headers, response, content) | A generator that creates Authorization objects
that can be applied to requests.
| A generator that creates Authorization objects
that can be applied to requests.
| def _auth_from_challenge(self, host, request_uri, headers, response, content):
"""A generator that creates Authorization objects
that can be applied to requests.
"""
challenges = _parse_www_authenticate(response, "www-authenticate")
for cred in self.credentials.iter(host):
... | [
"def",
"_auth_from_challenge",
"(",
"self",
",",
"host",
",",
"request_uri",
",",
"headers",
",",
"response",
",",
"content",
")",
":",
"challenges",
"=",
"_parse_www_authenticate",
"(",
"response",
",",
"\"www-authenticate\"",
")",
"for",
"cred",
"in",
"self",
... | [
1665,
4
] | [
1675,
21
] | python | en | ['en', 'en', 'en'] | True |
Http.add_credentials | (self, name, password, domain="") | Add a name and password that will be used
any time a request requires authentication. | Add a name and password that will be used
any time a request requires authentication. | def add_credentials(self, name, password, domain=""):
"""Add a name and password that will be used
any time a request requires authentication."""
self.credentials.add(name, password, domain) | [
"def",
"add_credentials",
"(",
"self",
",",
"name",
",",
"password",
",",
"domain",
"=",
"\"\"",
")",
":",
"self",
".",
"credentials",
".",
"add",
"(",
"name",
",",
"password",
",",
"domain",
")"
] | [
1677,
4
] | [
1680,
52
] | python | en | ['en', 'en', 'en'] | True |
Http.add_certificate | (self, key, cert, domain) | Add a key and cert that will be used
any time a request requires authentication. | Add a key and cert that will be used
any time a request requires authentication. | def add_certificate(self, key, cert, domain):
"""Add a key and cert that will be used
any time a request requires authentication."""
self.certificates.add(key, cert, domain) | [
"def",
"add_certificate",
"(",
"self",
",",
"key",
",",
"cert",
",",
"domain",
")",
":",
"self",
".",
"certificates",
".",
"add",
"(",
"key",
",",
"cert",
",",
"domain",
")"
] | [
1682,
4
] | [
1685,
48
] | python | en | ['en', 'en', 'en'] | True |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.