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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
PyCollector.isnosetest | (self, obj) | Look for the __test__ attribute, which is applied by the
@nose.tools.istest decorator
| Look for the __test__ attribute, which is applied by the
| def isnosetest(self, obj):
""" Look for the __test__ attribute, which is applied by the
@nose.tools.istest decorator
"""
# We explicitly check for "is True" here to not mistakenly treat
# classes with a custom __getattr__ returning something truthy (like a
# function) as ... | [
"def",
"isnosetest",
"(",
"self",
",",
"obj",
")",
":",
"# We explicitly check for \"is True\" here to not mistakenly treat",
"# classes with a custom __getattr__ returning something truthy (like a",
"# function) as test classes.",
"return",
"safe_getattr",
"(",
"obj",
",",
"'__test_... | [
276,
4
] | [
283,
59
] | python | en | ['en', 'en', 'en'] | True |
PyCollector._matches_prefix_or_glob_option | (self, option_name, name) |
checks if the given name matches the prefix or glob-pattern defined
in ini configuration.
|
checks if the given name matches the prefix or glob-pattern defined
in ini configuration.
| def _matches_prefix_or_glob_option(self, option_name, name):
"""
checks if the given name matches the prefix or glob-pattern defined
in ini configuration.
"""
for option in self.config.getini(option_name):
if name.startswith(option):
return True
... | [
"def",
"_matches_prefix_or_glob_option",
"(",
"self",
",",
"option_name",
",",
"name",
")",
":",
"for",
"option",
"in",
"self",
".",
"config",
".",
"getini",
"(",
"option_name",
")",
":",
"if",
"name",
".",
"startswith",
"(",
"option",
")",
":",
"return",
... | [
309,
4
] | [
323,
20
] | python | en | ['en', 'error', 'th'] | False |
FunctionMixin.setup | (self) | perform setup for this test function. | perform setup for this test function. | def setup(self):
""" perform setup for this test function. """
if hasattr(self, '_preservedparent'):
obj = self._preservedparent
elif isinstance(self.parent, Instance):
obj = self.parent.newinstance()
self.obj = self._getobj()
else:
obj = s... | [
"def",
"setup",
"(",
"self",
")",
":",
"if",
"hasattr",
"(",
"self",
",",
"'_preservedparent'",
")",
":",
"obj",
"=",
"self",
".",
"_preservedparent",
"elif",
"isinstance",
"(",
"self",
".",
"parent",
",",
"Instance",
")",
":",
"obj",
"=",
"self",
".",... | [
542,
4
] | [
562,
54
] | python | en | ['en', 'en', 'en'] | True |
Metafunc.parametrize | (self, argnames, argvalues, indirect=False, ids=None,
scope=None) | Add new invocations to the underlying test function using the list
of argvalues for the given argnames. Parametrization is performed
during the collection phase. If you need to setup expensive resources
see about setting indirect to do it rather at test setup time.
:arg argnames: a c... | Add new invocations to the underlying test function using the list
of argvalues for the given argnames. Parametrization is performed
during the collection phase. If you need to setup expensive resources
see about setting indirect to do it rather at test setup time. | def parametrize(self, argnames, argvalues, indirect=False, ids=None,
scope=None):
""" Add new invocations to the underlying test function using the list
of argvalues for the given argnames. Parametrization is performed
during the collection phase. If you need to setup expen... | [
"def",
"parametrize",
"(",
"self",
",",
"argnames",
",",
"argvalues",
",",
"indirect",
"=",
"False",
",",
"ids",
"=",
"None",
",",
"scope",
"=",
"None",
")",
":",
"from",
"_pytest",
".",
"fixtures",
"import",
"scope2index",
"from",
"_pytest",
".",
"mark"... | [
745,
4
] | [
844,
30
] | python | en | ['en', 'en', 'en'] | True |
Metafunc.addcall | (self, funcargs=None, id=NOTSET, param=NOTSET) | Add a new call to the underlying test function during the collection phase of a test run.
.. deprecated:: 3.3
Use :meth:`parametrize` instead.
Note that request.addcall() is called during the test collection phase prior and
independently to actual test execution. You should only... | Add a new call to the underlying test function during the collection phase of a test run. | def addcall(self, funcargs=None, id=NOTSET, param=NOTSET):
""" Add a new call to the underlying test function during the collection phase of a test run.
.. deprecated:: 3.3
Use :meth:`parametrize` instead.
Note that request.addcall() is called during the test collection phase prio... | [
"def",
"addcall",
"(",
"self",
",",
"funcargs",
"=",
"None",
",",
"id",
"=",
"NOTSET",
",",
"param",
"=",
"NOTSET",
")",
":",
"if",
"self",
".",
"config",
":",
"self",
".",
"config",
".",
"warn",
"(",
"'C1'",
",",
"message",
"=",
"deprecated",
".",... | [
846,
4
] | [
886,
30
] | python | en | ['en', 'en', 'en'] | True |
Function.function | (self) | underlying python 'function' object | underlying python 'function' object | def function(self):
"underlying python 'function' object"
return getattr(self.obj, 'im_func', self.obj) | [
"def",
"function",
"(",
"self",
")",
":",
"return",
"getattr",
"(",
"self",
".",
"obj",
",",
"'im_func'",
",",
"self",
".",
"obj",
")"
] | [
1157,
4
] | [
1159,
53
] | python | en | ['en', 'en', 'en'] | True |
Function._pyfuncitem | (self) | (compatonly) for code expecting pytest-2.2 style request objects | (compatonly) for code expecting pytest-2.2 style request objects | def _pyfuncitem(self):
"(compatonly) for code expecting pytest-2.2 style request objects"
return self | [
"def",
"_pyfuncitem",
"(",
"self",
")",
":",
"return",
"self"
] | [
1169,
4
] | [
1171,
19
] | python | en | ['en', 'en', 'en'] | True |
Function.runtest | (self) | execute the underlying test function. | execute the underlying test function. | def runtest(self):
""" execute the underlying test function. """
self.ihook.pytest_pyfunc_call(pyfuncitem=self) | [
"def",
"runtest",
"(",
"self",
")",
":",
"self",
".",
"ihook",
".",
"pytest_pyfunc_call",
"(",
"pyfuncitem",
"=",
"self",
")"
] | [
1176,
4
] | [
1178,
54
] | python | en | ['en', 'en', 'en'] | True |
PianorollSequence.__init__ | (self, quantized_sequence=None, events_list=None,
steps_per_quarter=None, start_step=0, min_pitch=MIN_MIDI_PITCH,
max_pitch=MAX_MIDI_PITCH, split_repeats=True, shift_range=False) | Construct a PianorollSequence.
Exactly one of `quantized_sequence` or `steps_per_quarter` must be supplied.
At most one of `quantized_sequence` and `events_list` may be supplied.
Args:
quantized_sequence: an optional quantized NoteSequence proto to base
PianorollSequence on.
events_l... | Construct a PianorollSequence. | def __init__(self, quantized_sequence=None, events_list=None,
steps_per_quarter=None, start_step=0, min_pitch=MIN_MIDI_PITCH,
max_pitch=MAX_MIDI_PITCH, split_repeats=True, shift_range=False):
"""Construct a PianorollSequence.
Exactly one of `quantized_sequence` or `steps_per_quart... | [
"def",
"__init__",
"(",
"self",
",",
"quantized_sequence",
"=",
"None",
",",
"events_list",
"=",
"None",
",",
"steps_per_quarter",
"=",
"None",
",",
"start_step",
"=",
"0",
",",
"min_pitch",
"=",
"MIN_MIDI_PITCH",
",",
"max_pitch",
"=",
"MAX_MIDI_PITCH",
",",
... | [
37,
2
] | [
82,
33
] | python | it | ['it', 'en', 'it'] | True |
PianorollSequence.set_length | (self, steps, from_left=False) | Sets the length of the sequence to the specified number of steps.
If the event sequence is not long enough, pads with silence to make the
sequence the specified length. If it is too long, it will be truncated to
the requested length.
Note that this will append a STEP_END event to the end of the sequen... | Sets the length of the sequence to the specified number of steps. | def set_length(self, steps, from_left=False):
"""Sets the length of the sequence to the specified number of steps.
If the event sequence is not long enough, pads with silence to make the
sequence the specified length. If it is too long, it will be truncated to
the requested length.
Note that this ... | [
"def",
"set_length",
"(",
"self",
",",
"steps",
",",
"from_left",
"=",
"False",
")",
":",
"if",
"from_left",
":",
"raise",
"NotImplementedError",
"(",
"'from_left is not supported'",
")",
"# Then trim or pad as needed.",
"if",
"self",
".",
"num_steps",
"<",
"steps... | [
92,
2
] | [
114,
34
] | python | en | ['en', 'en', 'en'] | True |
PianorollSequence.append | (self, event, shift_range=False) | Appends the event to the end of the sequence.
Args:
event: The polyphonic event to append to the end.
shift_range: If True, assume that the given event is in the full MIDI
pitch range and needs to be shifted and filtered based on `min_pitch`
and `max_pitch`.
Raises:
ValueErr... | Appends the event to the end of the sequence. | def append(self, event, shift_range=False):
"""Appends the event to the end of the sequence.
Args:
event: The polyphonic event to append to the end.
shift_range: If True, assume that the given event is in the full MIDI
pitch range and needs to be shifted and filtered based on `min_pitch`
... | [
"def",
"append",
"(",
"self",
",",
"event",
",",
"shift_range",
"=",
"False",
")",
":",
"if",
"shift_range",
":",
"event",
"=",
"tuple",
"(",
"p",
"-",
"self",
".",
"_min_pitch",
"for",
"p",
"in",
"event",
"if",
"self",
".",
"_min_pitch",
"<=",
"p",
... | [
116,
2
] | [
130,
30
] | python | en | ['en', 'en', 'en'] | True |
PianorollSequence.__len__ | (self) | How many events are in this sequence.
Returns:
Number of events as an integer.
| How many events are in this sequence. | def __len__(self):
"""How many events are in this sequence.
Returns:
Number of events as an integer.
"""
return len(self._events) | [
"def",
"__len__",
"(",
"self",
")",
":",
"return",
"len",
"(",
"self",
".",
"_events",
")"
] | [
132,
2
] | [
138,
28
] | python | en | ['en', 'en', 'en'] | True |
PianorollSequence.__getitem__ | (self, i) | Returns the event at the given index. | Returns the event at the given index. | def __getitem__(self, i):
"""Returns the event at the given index."""
return self._events[i] | [
"def",
"__getitem__",
"(",
"self",
",",
"i",
")",
":",
"return",
"self",
".",
"_events",
"[",
"i",
"]"
] | [
140,
2
] | [
142,
26
] | python | en | ['en', 'en', 'en'] | True |
PianorollSequence.__iter__ | (self) | Return an iterator over the events in this sequence. | Return an iterator over the events in this sequence. | def __iter__(self):
"""Return an iterator over the events in this sequence."""
return iter(self._events) | [
"def",
"__iter__",
"(",
"self",
")",
":",
"return",
"iter",
"(",
"self",
".",
"_events",
")"
] | [
144,
2
] | [
146,
29
] | python | en | ['en', 'en', 'en'] | True |
PianorollSequence.num_steps | (self) | Returns how many steps long this sequence is.
Returns:
Length of the sequence in quantized steps.
| Returns how many steps long this sequence is. | def num_steps(self):
"""Returns how many steps long this sequence is.
Returns:
Length of the sequence in quantized steps.
"""
return len(self) | [
"def",
"num_steps",
"(",
"self",
")",
":",
"return",
"len",
"(",
"self",
")"
] | [
153,
2
] | [
159,
20
] | python | en | ['en', 'en', 'en'] | True |
PianorollSequence.steps | (self) | Returns a Python list of the time step at each event in this sequence. | Returns a Python list of the time step at each event in this sequence. | def steps(self):
"""Returns a Python list of the time step at each event in this sequence."""
return list(range(self.start_step, self.end_step)) | [
"def",
"steps",
"(",
"self",
")",
":",
"return",
"list",
"(",
"range",
"(",
"self",
".",
"start_step",
",",
"self",
".",
"end_step",
")",
")"
] | [
162,
2
] | [
164,
54
] | python | en | ['en', 'en', 'en'] | True |
PianorollSequence._from_quantized_sequence | (
quantized_sequence, start_step, min_pitch, max_pitch, split_repeats) | Populate self with events from the given quantized NoteSequence object.
Args:
quantized_sequence: A quantized NoteSequence instance.
start_step: Start converting the sequence at this time step.
Assumed to be the beginning of a bar.
min_pitch: The minimum valid pitch value, inclusive.
... | Populate self with events from the given quantized NoteSequence object. | def _from_quantized_sequence(
quantized_sequence, start_step, min_pitch, max_pitch, split_repeats):
"""Populate self with events from the given quantized NoteSequence object.
Args:
quantized_sequence: A quantized NoteSequence instance.
start_step: Start converting the sequence at this time st... | [
"def",
"_from_quantized_sequence",
"(",
"quantized_sequence",
",",
"start_step",
",",
"min_pitch",
",",
"max_pitch",
",",
"split_repeats",
")",
":",
"piano_roll",
"=",
"np",
".",
"zeros",
"(",
"(",
"quantized_sequence",
".",
"total_quantized_steps",
"-",
"start_step... | [
167,
2
] | [
202,
17
] | python | en | ['en', 'en', 'en'] | True |
PianorollSequence.to_sequence | (self,
velocity=100,
instrument=0,
program=0,
qpm=constants.DEFAULT_QUARTERS_PER_MINUTE,
base_note_sequence=None) | Converts the PianorollSequence to NoteSequence proto.
Args:
velocity: Midi velocity to give each note. Between 1 and 127 (inclusive).
instrument: Midi instrument to give each note.
program: Midi program to give each note.
qpm: Quarter notes per minute (float).
base_note_sequence: A No... | Converts the PianorollSequence to NoteSequence proto. | def to_sequence(self,
velocity=100,
instrument=0,
program=0,
qpm=constants.DEFAULT_QUARTERS_PER_MINUTE,
base_note_sequence=None):
"""Converts the PianorollSequence to NoteSequence proto.
Args:
velocity: Midi velocit... | [
"def",
"to_sequence",
"(",
"self",
",",
"velocity",
"=",
"100",
",",
"instrument",
"=",
"0",
",",
"program",
"=",
"0",
",",
"qpm",
"=",
"constants",
".",
"DEFAULT_QUARTERS_PER_MINUTE",
",",
"base_note_sequence",
"=",
"None",
")",
":",
"seconds_per_step",
"="... | [
204,
2
] | [
271,
19
] | python | en | ['en', 'en', 'en'] | True |
was_installed_by_pip | (pkg) | Checks whether pkg was installed by pip
This is used not to display the upgrade message when pip is in fact
installed by system package manager, such as dnf on Fedora.
| Checks whether pkg was installed by pip | def was_installed_by_pip(pkg):
# type: (str) -> bool
"""Checks whether pkg was installed by pip
This is used not to display the upgrade message when pip is in fact
installed by system package manager, such as dnf on Fedora.
"""
dist = get_distribution(pkg)
if not dist:
return False
... | [
"def",
"was_installed_by_pip",
"(",
"pkg",
")",
":",
"# type: (str) -> bool",
"dist",
"=",
"get_distribution",
"(",
"pkg",
")",
"if",
"not",
"dist",
":",
"return",
"False",
"return",
"\"pip\"",
"==",
"get_installer",
"(",
"dist",
")"
] | [
108,
0
] | [
118,
39
] | python | en | ['en', 'en', 'en'] | True |
pip_self_version_check | (session, options) | Check for an update for pip.
Limit the frequency of checks to once per week. State is stored either in
the active virtualenv or in the user's USER_CACHE_DIR keyed off the prefix
of the pip script path.
| Check for an update for pip. | def pip_self_version_check(session, options):
# type: (PipSession, optparse.Values) -> None
"""Check for an update for pip.
Limit the frequency of checks to once per week. State is stored either in
the active virtualenv or in the user's USER_CACHE_DIR keyed off the prefix
of the pip script path.
... | [
"def",
"pip_self_version_check",
"(",
"session",
",",
"options",
")",
":",
"# type: (PipSession, optparse.Values) -> None",
"installed_version",
"=",
"get_installed_version",
"(",
"\"pip\"",
")",
"if",
"not",
"installed_version",
":",
"return",
"pip_version",
"=",
"packag... | [
121,
0
] | [
204,
9
] | python | en | ['en', 'en', 'en'] | True |
capsys | (request) | Enable capturing of writes to sys.stdout/sys.stderr and make
captured output available via ``capsys.readouterr()`` method calls
which return a ``(out, err)`` tuple. ``out`` and ``err`` will be ``text``
objects.
| Enable capturing of writes to sys.stdout/sys.stderr and make
captured output available via ``capsys.readouterr()`` method calls
which return a ``(out, err)`` tuple. ``out`` and ``err`` will be ``text``
objects.
| def capsys(request):
"""Enable capturing of writes to sys.stdout/sys.stderr and make
captured output available via ``capsys.readouterr()`` method calls
which return a ``(out, err)`` tuple. ``out`` and ``err`` will be ``text``
objects.
"""
_ensure_only_one_capture_fixture(request, 'capsys')
... | [
"def",
"capsys",
"(",
"request",
")",
":",
"_ensure_only_one_capture_fixture",
"(",
"request",
",",
"'capsys'",
")",
"with",
"_install_capture_fixture_on_item",
"(",
"request",
",",
"SysCapture",
")",
"as",
"fixture",
":",
"yield",
"fixture"
] | [
198,
0
] | [
206,
21
] | python | en | ['en', 'en', 'en'] | True |
capsysbinary | (request) | Enable capturing of writes to sys.stdout/sys.stderr and make
captured output available via ``capsys.readouterr()`` method calls
which return a ``(out, err)`` tuple. ``out`` and ``err`` will be ``bytes``
objects.
| Enable capturing of writes to sys.stdout/sys.stderr and make
captured output available via ``capsys.readouterr()`` method calls
which return a ``(out, err)`` tuple. ``out`` and ``err`` will be ``bytes``
objects.
| def capsysbinary(request):
"""Enable capturing of writes to sys.stdout/sys.stderr and make
captured output available via ``capsys.readouterr()`` method calls
which return a ``(out, err)`` tuple. ``out`` and ``err`` will be ``bytes``
objects.
"""
_ensure_only_one_capture_fixture(request, 'capsys... | [
"def",
"capsysbinary",
"(",
"request",
")",
":",
"_ensure_only_one_capture_fixture",
"(",
"request",
",",
"'capsysbinary'",
")",
"# Currently, the implementation uses the python3 specific `.buffer`",
"# property of CaptureIO.",
"if",
"sys",
".",
"version_info",
"<",
"(",
"3",... | [
210,
0
] | [
222,
21
] | python | en | ['en', 'en', 'en'] | True |
capfd | (request) | Enable capturing of writes to file descriptors 1 and 2 and make
captured output available via ``capfd.readouterr()`` method calls
which return a ``(out, err)`` tuple. ``out`` and ``err`` will be ``text``
objects.
| Enable capturing of writes to file descriptors 1 and 2 and make
captured output available via ``capfd.readouterr()`` method calls
which return a ``(out, err)`` tuple. ``out`` and ``err`` will be ``text``
objects.
| def capfd(request):
"""Enable capturing of writes to file descriptors 1 and 2 and make
captured output available via ``capfd.readouterr()`` method calls
which return a ``(out, err)`` tuple. ``out`` and ``err`` will be ``text``
objects.
"""
_ensure_only_one_capture_fixture(request, 'capfd')
... | [
"def",
"capfd",
"(",
"request",
")",
":",
"_ensure_only_one_capture_fixture",
"(",
"request",
",",
"'capfd'",
")",
"if",
"not",
"hasattr",
"(",
"os",
",",
"'dup'",
")",
":",
"pytest",
".",
"skip",
"(",
"\"capfd fixture needs os.dup function which is not available in... | [
226,
0
] | [
236,
21
] | python | en | ['en', 'en', 'en'] | True |
capfdbinary | (request) | Enable capturing of write to file descriptors 1 and 2 and make
captured output available via ``capfdbinary.readouterr`` method calls
which return a ``(out, err)`` tuple. ``out`` and ``err`` will be
``bytes`` objects.
| Enable capturing of write to file descriptors 1 and 2 and make
captured output available via ``capfdbinary.readouterr`` method calls
which return a ``(out, err)`` tuple. ``out`` and ``err`` will be
``bytes`` objects.
| def capfdbinary(request):
"""Enable capturing of write to file descriptors 1 and 2 and make
captured output available via ``capfdbinary.readouterr`` method calls
which return a ``(out, err)`` tuple. ``out`` and ``err`` will be
``bytes`` objects.
"""
_ensure_only_one_capture_fixture(request, 'ca... | [
"def",
"capfdbinary",
"(",
"request",
")",
":",
"_ensure_only_one_capture_fixture",
"(",
"request",
",",
"'capfdbinary'",
")",
"if",
"not",
"hasattr",
"(",
"os",
",",
"'dup'",
")",
":",
"pytest",
".",
"skip",
"(",
"\"capfdbinary fixture needs os.dup function which i... | [
240,
0
] | [
250,
21
] | python | en | ['en', 'en', 'en'] | True |
_install_capture_fixture_on_item | (request, capture_class) |
Context manager which creates a ``CaptureFixture`` instance and "installs" it on
the item/node of the given request. Used by ``capsys`` and ``capfd``.
The CaptureFixture is added as attribute of the item because it needs to accessed
by ``CaptureManager`` during its ``pytest_runtest_*`` hooks.
|
Context manager which creates a ``CaptureFixture`` instance and "installs" it on
the item/node of the given request. Used by ``capsys`` and ``capfd``. | def _install_capture_fixture_on_item(request, capture_class):
"""
Context manager which creates a ``CaptureFixture`` instance and "installs" it on
the item/node of the given request. Used by ``capsys`` and ``capfd``.
The CaptureFixture is added as attribute of the item because it needs to accessed
... | [
"def",
"_install_capture_fixture_on_item",
"(",
"request",
",",
"capture_class",
")",
":",
"request",
".",
"node",
".",
"_capture_fixture",
"=",
"fixture",
"=",
"CaptureFixture",
"(",
"capture_class",
",",
"request",
")",
"capmanager",
"=",
"request",
".",
"config... | [
254,
0
] | [
270,
37
] | python | en | ['en', 'error', 'th'] | False |
safe_text_dupfile | (f, mode, default_encoding="UTF8") | return a open text file object that's a duplicate of f on the
FD-level if possible.
| return a open text file object that's a duplicate of f on the
FD-level if possible.
| def safe_text_dupfile(f, mode, default_encoding="UTF8"):
""" return a open text file object that's a duplicate of f on the
FD-level if possible.
"""
encoding = getattr(f, "encoding", None)
try:
fd = f.fileno()
except Exception:
if "b" not in getattr(f, "mode", "") and hasattr... | [
"def",
"safe_text_dupfile",
"(",
"f",
",",
"mode",
",",
"default_encoding",
"=",
"\"UTF8\"",
")",
":",
"encoding",
"=",
"getattr",
"(",
"f",
",",
"\"encoding\"",
",",
"None",
")",
"try",
":",
"fd",
"=",
"f",
".",
"fileno",
"(",
")",
"except",
"Exceptio... | [
307,
0
] | [
323,
55
] | python | en | ['en', 'en', 'en'] | True |
_colorama_workaround | () |
Ensure colorama is imported so that it attaches to the correct stdio
handles on Windows.
colorama uses the terminal on import time. So if something does the
first import of colorama while I/O capture is active, colorama will
fail in various ways.
|
Ensure colorama is imported so that it attaches to the correct stdio
handles on Windows. | def _colorama_workaround():
"""
Ensure colorama is imported so that it attaches to the correct stdio
handles on Windows.
colorama uses the terminal on import time. So if something does the
first import of colorama while I/O capture is active, colorama will
fail in various ways.
"""
if ... | [
"def",
"_colorama_workaround",
"(",
")",
":",
"if",
"not",
"sys",
".",
"platform",
".",
"startswith",
"(",
"'win32'",
")",
":",
"return",
"try",
":",
"import",
"colorama",
"# noqa",
"except",
"ImportError",
":",
"pass"
] | [
587,
0
] | [
602,
12
] | python | en | ['en', 'error', 'th'] | False |
_readline_workaround | () |
Ensure readline is imported so that it attaches to the correct stdio
handles on Windows.
Pdb uses readline support where available--when not running from the Python
prompt, the readline module is not imported until running the pdb REPL. If
running pytest with the --pdb option this means the readl... |
Ensure readline is imported so that it attaches to the correct stdio
handles on Windows. | def _readline_workaround():
"""
Ensure readline is imported so that it attaches to the correct stdio
handles on Windows.
Pdb uses readline support where available--when not running from the Python
prompt, the readline module is not imported until running the pdb REPL. If
running pytest with th... | [
"def",
"_readline_workaround",
"(",
")",
":",
"if",
"not",
"sys",
".",
"platform",
".",
"startswith",
"(",
"'win32'",
")",
":",
"return",
"try",
":",
"import",
"readline",
"# noqa",
"except",
"ImportError",
":",
"pass"
] | [
605,
0
] | [
629,
12
] | python | en | ['en', 'error', 'th'] | False |
_py36_windowsconsoleio_workaround | (stream) |
Python 3.6 implemented unicode console handling for Windows. This works
by reading/writing to the raw console handle using
``{Read,Write}ConsoleW``.
The problem is that we are going to ``dup2`` over the stdio file
descriptors when doing ``FDCapture`` and this will ``CloseHandle`` the
handles u... |
Python 3.6 implemented unicode console handling for Windows. This works
by reading/writing to the raw console handle using
``{Read,Write}ConsoleW``. | def _py36_windowsconsoleio_workaround(stream):
"""
Python 3.6 implemented unicode console handling for Windows. This works
by reading/writing to the raw console handle using
``{Read,Write}ConsoleW``.
The problem is that we are going to ``dup2`` over the stdio file
descriptors when doing ``FDCap... | [
"def",
"_py36_windowsconsoleio_workaround",
"(",
"stream",
")",
":",
"if",
"not",
"sys",
".",
"platform",
".",
"startswith",
"(",
"'win32'",
")",
"or",
"sys",
".",
"version_info",
"[",
":",
"2",
"]",
"<",
"(",
"3",
",",
"6",
")",
":",
"return",
"# bail... | [
632,
0
] | [
682,
65
] | python | en | ['en', 'error', 'th'] | False |
_attempt_to_close_capture_file | (f) | Suppress IOError when closing the temporary file used for capturing streams in py27 (#2370) | Suppress IOError when closing the temporary file used for capturing streams in py27 (#2370) | def _attempt_to_close_capture_file(f):
"""Suppress IOError when closing the temporary file used for capturing streams in py27 (#2370)"""
if six.PY2:
try:
f.close()
except IOError:
pass
else:
f.close() | [
"def",
"_attempt_to_close_capture_file",
"(",
"f",
")",
":",
"if",
"six",
".",
"PY2",
":",
"try",
":",
"f",
".",
"close",
"(",
")",
"except",
"IOError",
":",
"pass",
"else",
":",
"f",
".",
"close",
"(",
")"
] | [
685,
0
] | [
693,
17
] | python | en | ['en', 'en', 'en'] | True |
CaptureManager.activate_fixture | (self, item) | If the current item is using ``capsys`` or ``capfd``, activate them so they take precedence over
the global capture.
| If the current item is using ``capsys`` or ``capfd``, activate them so they take precedence over
the global capture.
| def activate_fixture(self, item):
"""If the current item is using ``capsys`` or ``capfd``, activate them so they take precedence over
the global capture.
"""
fixture = getattr(item, "_capture_fixture", None)
if fixture is not None:
fixture._start() | [
"def",
"activate_fixture",
"(",
"self",
",",
"item",
")",
":",
"fixture",
"=",
"getattr",
"(",
"item",
",",
"\"_capture_fixture\"",
",",
"None",
")",
"if",
"fixture",
"is",
"not",
"None",
":",
"fixture",
".",
"_start",
"(",
")"
] | [
115,
4
] | [
121,
28
] | python | en | ['en', 'en', 'en'] | True |
CaptureManager.deactivate_fixture | (self, item) | Deactivates the ``capsys`` or ``capfd`` fixture of this item, if any. | Deactivates the ``capsys`` or ``capfd`` fixture of this item, if any. | def deactivate_fixture(self, item):
"""Deactivates the ``capsys`` or ``capfd`` fixture of this item, if any."""
fixture = getattr(item, "_capture_fixture", None)
if fixture is not None:
fixture.close() | [
"def",
"deactivate_fixture",
"(",
"self",
",",
"item",
")",
":",
"fixture",
"=",
"getattr",
"(",
"item",
",",
"\"_capture_fixture\"",
",",
"None",
")",
"if",
"fixture",
"is",
"not",
"None",
":",
"fixture",
".",
"close",
"(",
")"
] | [
123,
4
] | [
127,
27
] | python | en | ['en', 'en', 'en'] | True |
EncodedFile.name | (self) | Ensure that file.name is a string. | Ensure that file.name is a string. | def name(self):
"""Ensure that file.name is a string."""
return repr(self.buffer) | [
"def",
"name",
"(",
"self",
")",
":",
"return",
"repr",
"(",
"self",
".",
"buffer",
")"
] | [
343,
4
] | [
345,
32
] | python | en | ['en', 'en', 'en'] | True |
MultiCapture.pop_outerr_to_orig | (self) | pop current snapshot out/err capture and flush to orig streams. | pop current snapshot out/err capture and flush to orig streams. | def pop_outerr_to_orig(self):
""" pop current snapshot out/err capture and flush to orig streams. """
out, err = self.readouterr()
if out:
self.out.writeorg(out)
if err:
self.err.writeorg(err)
return out, err | [
"def",
"pop_outerr_to_orig",
"(",
"self",
")",
":",
"out",
",",
"err",
"=",
"self",
".",
"readouterr",
"(",
")",
"if",
"out",
":",
"self",
".",
"out",
".",
"writeorg",
"(",
"out",
")",
"if",
"err",
":",
"self",
".",
"err",
".",
"writeorg",
"(",
"... | [
373,
4
] | [
380,
23
] | python | en | ['en', 'en', 'en'] | True |
MultiCapture.stop_capturing | (self) | stop capturing and reset capturing streams | stop capturing and reset capturing streams | def stop_capturing(self):
""" stop capturing and reset capturing streams """
if hasattr(self, '_reset'):
raise ValueError("was already stopped")
self._reset = True
if self.out:
self.out.done()
if self.err:
self.err.done()
if self.in_:
... | [
"def",
"stop_capturing",
"(",
"self",
")",
":",
"if",
"hasattr",
"(",
"self",
",",
"'_reset'",
")",
":",
"raise",
"ValueError",
"(",
"\"was already stopped\"",
")",
"self",
".",
"_reset",
"=",
"True",
"if",
"self",
".",
"out",
":",
"self",
".",
"out",
... | [
400,
4
] | [
410,
27
] | python | en | ['en', 'en', 'en'] | True |
MultiCapture.readouterr | (self) | return snapshot unicode value of stdout/stderr capturings. | return snapshot unicode value of stdout/stderr capturings. | def readouterr(self):
""" return snapshot unicode value of stdout/stderr capturings. """
return CaptureResult(self.out.snap() if self.out is not None else "",
self.err.snap() if self.err is not None else "") | [
"def",
"readouterr",
"(",
"self",
")",
":",
"return",
"CaptureResult",
"(",
"self",
".",
"out",
".",
"snap",
"(",
")",
"if",
"self",
".",
"out",
"is",
"not",
"None",
"else",
"\"\"",
",",
"self",
".",
"err",
".",
"snap",
"(",
")",
"if",
"self",
".... | [
412,
4
] | [
415,
77
] | python | en | ['en', 'no', 'en'] | True |
FDCaptureBinary.start | (self) | Start capturing on targetfd using memorized tmpfile. | Start capturing on targetfd using memorized tmpfile. | def start(self):
""" Start capturing on targetfd using memorized tmpfile. """
try:
os.fstat(self.targetfd_save)
except (AttributeError, OSError):
raise ValueError("saved filedescriptor not valid anymore")
os.dup2(self.tmpfile_fd, self.targetfd)
self.syscap... | [
"def",
"start",
"(",
"self",
")",
":",
"try",
":",
"os",
".",
"fstat",
"(",
"self",
".",
"targetfd_save",
")",
"except",
"(",
"AttributeError",
",",
"OSError",
")",
":",
"raise",
"ValueError",
"(",
"\"saved filedescriptor not valid anymore\"",
")",
"os",
"."... | [
455,
4
] | [
462,
31
] | python | en | ['en', 'jv', 'en'] | True |
FDCaptureBinary.done | (self) | stop capturing, restore streams, return original capture file,
seeked to position zero. | stop capturing, restore streams, return original capture file,
seeked to position zero. | def done(self):
""" stop capturing, restore streams, return original capture file,
seeked to position zero. """
targetfd_save = self.__dict__.pop("targetfd_save")
os.dup2(targetfd_save, self.targetfd)
os.close(targetfd_save)
self.syscapture.done()
_attempt_to_clos... | [
"def",
"done",
"(",
"self",
")",
":",
"targetfd_save",
"=",
"self",
".",
"__dict__",
".",
"pop",
"(",
"\"targetfd_save\"",
")",
"os",
".",
"dup2",
"(",
"targetfd_save",
",",
"self",
".",
"targetfd",
")",
"os",
".",
"close",
"(",
"targetfd_save",
")",
"... | [
471,
4
] | [
478,
52
] | python | en | ['en', 'ro', 'en'] | True |
FDCaptureBinary.writeorg | (self, data) | write to original file descriptor. | write to original file descriptor. | def writeorg(self, data):
""" write to original file descriptor. """
if isinstance(data, six.text_type):
data = data.encode("utf8") # XXX use encoding of original stream
os.write(self.targetfd_save, data) | [
"def",
"writeorg",
"(",
"self",
",",
"data",
")",
":",
"if",
"isinstance",
"(",
"data",
",",
"six",
".",
"text_type",
")",
":",
"data",
"=",
"data",
".",
"encode",
"(",
"\"utf8\"",
")",
"# XXX use encoding of original stream",
"os",
".",
"write",
"(",
"s... | [
488,
4
] | [
492,
42
] | python | en | ['en', 'pt', 'en'] | True |
spawn | (cmd, search_path=1, verbose=0, dry_run=0, env=None) | Run another program, specified as a command list 'cmd', in a new process.
'cmd' is just the argument list for the new process, ie.
cmd[0] is the program to run and cmd[1:] are the rest of its arguments.
There is no way to run a program with a name different from that of its
executable.
If 'search_... | Run another program, specified as a command list 'cmd', in a new process. | def spawn(cmd, search_path=1, verbose=0, dry_run=0, env=None):
"""Run another program, specified as a command list 'cmd', in a new process.
'cmd' is just the argument list for the new process, ie.
cmd[0] is the program to run and cmd[1:] are the rest of its arguments.
There is no way to run a program w... | [
"def",
"spawn",
"(",
"cmd",
",",
"search_path",
"=",
"1",
",",
"verbose",
"=",
"0",
",",
"dry_run",
"=",
"0",
",",
"env",
"=",
"None",
")",
":",
"# cmd is documented as a list, but just in case some code passes a tuple",
"# in, protect our %-formatting code against horr... | [
22,
0
] | [
87,
70
] | python | en | ['en', 'en', 'en'] | True |
find_executable | (executable, path=None) | Tries to find 'executable' in the directories listed in 'path'.
A string listing directories separated by 'os.pathsep'; defaults to
os.environ['PATH']. Returns the complete filename or None if not found.
| Tries to find 'executable' in the directories listed in 'path'. | def find_executable(executable, path=None):
"""Tries to find 'executable' in the directories listed in 'path'.
A string listing directories separated by 'os.pathsep'; defaults to
os.environ['PATH']. Returns the complete filename or None if not found.
"""
_, ext = os.path.splitext(executable)
i... | [
"def",
"find_executable",
"(",
"executable",
",",
"path",
"=",
"None",
")",
":",
"_",
",",
"ext",
"=",
"os",
".",
"path",
".",
"splitext",
"(",
"executable",
")",
"if",
"(",
"sys",
".",
"platform",
"==",
"'win32'",
")",
"and",
"(",
"ext",
"!=",
"'.... | [
90,
0
] | [
124,
15
] | python | en | ['en', 'en', 'en'] | True |
main | () | Script entry point. | Script entry point. | def main():
"""Script entry point."""
multi_process = True
if multi_process:
num_policies = 8
processes = []
for p_id in range(num_policies):
process = Process(target=multi_agent_match, args=[(p_id, 0)])
process.start()
processes.append(process)
... | [
"def",
"main",
"(",
")",
":",
"multi_process",
"=",
"True",
"if",
"multi_process",
":",
"num_policies",
"=",
"8",
"processes",
"=",
"[",
"]",
"for",
"p_id",
"in",
"range",
"(",
"num_policies",
")",
":",
"process",
"=",
"Process",
"(",
"target",
"=",
"m... | [
183,
0
] | [
200,
12
] | python | en | ['en', 'en', 'en'] | True |
test_setup_teardown_function_level_with_optional_argument | (testdir, monkeypatch, arg) | parameter to setup/teardown xunit-style functions parameter is now optional (#1728). | parameter to setup/teardown xunit-style functions parameter is now optional (#1728). | def test_setup_teardown_function_level_with_optional_argument(testdir, monkeypatch, arg):
"""parameter to setup/teardown xunit-style functions parameter is now optional (#1728)."""
import sys
trace_setups_teardowns = []
monkeypatch.setattr(sys, 'trace_setups_teardowns', trace_setups_teardowns, raising=F... | [
"def",
"test_setup_teardown_function_level_with_optional_argument",
"(",
"testdir",
",",
"monkeypatch",
",",
"arg",
")",
":",
"import",
"sys",
"trace_setups_teardowns",
"=",
"[",
"]",
"monkeypatch",
".",
"setattr",
"(",
"sys",
",",
"'trace_setups_teardowns'",
",",
"tr... | [
272,
0
] | [
318,
45
] | python | en | ['en', 'en', 'en'] | True |
Filter.__init__ | (self, source, require_matching_tags=True) | Creates a Filter
:arg source: the source token stream
:arg require_matching_tags: whether or not to require matching tags
| Creates a Filter | def __init__(self, source, require_matching_tags=True):
"""Creates a Filter
:arg source: the source token stream
:arg require_matching_tags: whether or not to require matching tags
"""
super(Filter, self).__init__(source)
self.require_matching_tags = require_matching_t... | [
"def",
"__init__",
"(",
"self",
",",
"source",
",",
"require_matching_tags",
"=",
"True",
")",
":",
"super",
"(",
"Filter",
",",
"self",
")",
".",
"__init__",
"(",
"source",
")",
"self",
".",
"require_matching_tags",
"=",
"require_matching_tags"
] | [
17,
4
] | [
26,
58
] | python | en | ['en', 'gl', 'en'] | True |
VizdoomEnv.step | (self, actions) |
Action is either a single value (discrete, one-hot), or a tuple with an action for each of the
discrete action subspaces.
|
Action is either a single value (discrete, one-hot), or a tuple with an action for each of the
discrete action subspaces.
| def step(self, actions):
"""
Action is either a single value (discrete, one-hot), or a tuple with an action for each of the
discrete action subspaces.
"""
action = actions.item()
obs, rew, done, info = self.env.step(action)
# print('Obs shape as returned by the en... | [
"def",
"step",
"(",
"self",
",",
"actions",
")",
":",
"action",
"=",
"actions",
".",
"item",
"(",
")",
"obs",
",",
"rew",
",",
"done",
",",
"info",
"=",
"self",
".",
"env",
".",
"step",
"(",
"action",
")",
"# print('Obs shape as returned by the env:', ob... | [
89,
4
] | [
98,
49
] | python | en | ['en', 'error', 'th'] | False |
DoomLstmModel.forward | (self, image, prev_action, prev_reward, init_rnn_state) | Feedforward layers process as [T*B,H], recurrent ones as [T,B,H].
Return same leading dims as input, can be [T,B], [B], or [].
(Same forward used for sampling and training.) | Feedforward layers process as [T*B,H], recurrent ones as [T,B,H].
Return same leading dims as input, can be [T,B], [B], or [].
(Same forward used for sampling and training.) | def forward(self, image, prev_action, prev_reward, init_rnn_state):
"""Feedforward layers process as [T*B,H], recurrent ones as [T,B,H].
Return same leading dims as input, can be [T,B], [B], or [].
(Same forward used for sampling and training.)"""
img = image.type(torch.float) # Expect... | [
"def",
"forward",
"(",
"self",
",",
"image",
",",
"prev_action",
",",
"prev_reward",
",",
"init_rnn_state",
")",
":",
"img",
"=",
"image",
".",
"type",
"(",
"torch",
".",
"float",
")",
"# Expect doom_torch.uint8 inputs",
"img",
"=",
"img",
".",
"mul_",
"("... | [
137,
4
] | [
165,
36
] | python | en | ['en', 'en', 'en'] | True |
Marker.evaluate | (self, environment=None) | Evaluate a marker.
Return the boolean from evaluating the given marker against the
environment. environment is an optional argument to override all or
part of the determined environment.
The environment is determined from the current Python process.
| Evaluate a marker. | def evaluate(self, environment=None):
# type: (Optional[Dict[str, str]]) -> bool
"""Evaluate a marker.
Return the boolean from evaluating the given marker against the
environment. environment is an optional argument to override all or
part of the determined environment.
... | [
"def",
"evaluate",
"(",
"self",
",",
"environment",
"=",
"None",
")",
":",
"# type: (Optional[Dict[str, str]]) -> bool",
"current_environment",
"=",
"default_environment",
"(",
")",
"if",
"environment",
"is",
"not",
"None",
":",
"current_environment",
".",
"update",
... | [
313,
4
] | [
327,
68
] | python | en | ['en', 'en', 'en'] | True |
fnmatch | (name, pat) | Test whether FILENAME matches PATTERN.
Patterns are Unix shell style:
* matches everything
? matches any single character
[seq] matches any character in seq
[!seq] matches any char not in seq
An initial period in FILENAME is not special.
Both FILENAME and PATTERN are first ... | Test whether FILENAME matches PATTERN. | def fnmatch(name, pat):
"""Test whether FILENAME matches PATTERN.
Patterns are Unix shell style:
* matches everything
? matches any single character
[seq] matches any character in seq
[!seq] matches any char not in seq
An initial period in FILENAME is not special.
Both ... | [
"def",
"fnmatch",
"(",
"name",
",",
"pat",
")",
":",
"name",
"=",
"os",
".",
"path",
".",
"normcase",
"(",
"name",
")",
"pat",
"=",
"os",
".",
"path",
".",
"normcase",
"(",
"pat",
")",
"return",
"fnmatchcase",
"(",
"name",
",",
"pat",
")"
] | [
18,
0
] | [
35,
33
] | python | en | ['en', 'en', 'en'] | True |
filter | (names, pat) | Return the subset of the list NAMES that match PAT. | Return the subset of the list NAMES that match PAT. | def filter(names, pat):
"""Return the subset of the list NAMES that match PAT."""
result = []
pat = os.path.normcase(pat)
match = _compile_pattern(pat)
if os.path is posixpath:
# normcase on posix is NOP. Optimize it away from the loop.
for name in names:
if match(name):
... | [
"def",
"filter",
"(",
"names",
",",
"pat",
")",
":",
"result",
"=",
"[",
"]",
"pat",
"=",
"os",
".",
"path",
".",
"normcase",
"(",
"pat",
")",
"match",
"=",
"_compile_pattern",
"(",
"pat",
")",
"if",
"os",
".",
"path",
"is",
"posixpath",
":",
"# ... | [
47,
0
] | [
61,
17
] | python | en | ['en', 'en', 'en'] | True |
fnmatchcase | (name, pat) | Test whether FILENAME matches PATTERN, including case.
This is a version of fnmatch() which doesn't case-normalize
its arguments.
| Test whether FILENAME matches PATTERN, including case. | def fnmatchcase(name, pat):
"""Test whether FILENAME matches PATTERN, including case.
This is a version of fnmatch() which doesn't case-normalize
its arguments.
"""
match = _compile_pattern(pat)
return match(name) is not None | [
"def",
"fnmatchcase",
"(",
"name",
",",
"pat",
")",
":",
"match",
"=",
"_compile_pattern",
"(",
"pat",
")",
"return",
"match",
"(",
"name",
")",
"is",
"not",
"None"
] | [
63,
0
] | [
70,
34
] | python | en | ['en', 'en', 'en'] | True |
translate | (pat) | Translate a shell PATTERN to a regular expression.
There is no way to quote meta-characters.
| Translate a shell PATTERN to a regular expression. | def translate(pat):
"""Translate a shell PATTERN to a regular expression.
There is no way to quote meta-characters.
"""
i, n = 0, len(pat)
res = ''
while i < n:
c = pat[i]
i = i+1
if c == '*':
res = res + '.*'
elif c == '?':
res = res + '... | [
"def",
"translate",
"(",
"pat",
")",
":",
"i",
",",
"n",
"=",
"0",
",",
"len",
"(",
"pat",
")",
"res",
"=",
"''",
"while",
"i",
"<",
"n",
":",
"c",
"=",
"pat",
"[",
"i",
"]",
"i",
"=",
"i",
"+",
"1",
"if",
"c",
"==",
"'*'",
":",
"res",
... | [
73,
0
] | [
108,
29
] | python | en | ['en', 'en', 'en'] | True |
open | (filename, mode='r', encoding=None, errors='strict', buffering=1) | Open an encoded file using the given mode and return
a wrapped version providing transparent encoding/decoding.
Note: The wrapped version will only accept the object format
defined by the codecs, i.e. Unicode objects for most builtin
codecs. Output is also codec dependent and will usua... | Open an encoded file using the given mode and return
a wrapped version providing transparent encoding/decoding. | def open(filename, mode='r', encoding=None, errors='strict', buffering=1):
""" Open an encoded file using the given mode and return
a wrapped version providing transparent encoding/decoding.
Note: The wrapped version will only accept the object format
defined by the codecs, i.e. Unicode ob... | [
"def",
"open",
"(",
"filename",
",",
"mode",
"=",
"'r'",
",",
"encoding",
"=",
"None",
",",
"errors",
"=",
"'strict'",
",",
"buffering",
"=",
"1",
")",
":",
"if",
"encoding",
"is",
"not",
"None",
"and",
"'b'",
"not",
"in",
"mode",
":",
"# Force openi... | [
863,
0
] | [
903,
14
] | python | en | ['en', 'en', 'en'] | True |
EncodedFile | (file, data_encoding, file_encoding=None, errors='strict') | Return a wrapped version of file which provides transparent
encoding translation.
Data written to the wrapped file is decoded according
to the given data_encoding and then encoded to the underlying
file using file_encoding. The intermediate data type
will usually be Unicode but... | Return a wrapped version of file which provides transparent
encoding translation. | def EncodedFile(file, data_encoding, file_encoding=None, errors='strict'):
""" Return a wrapped version of file which provides transparent
encoding translation.
Data written to the wrapped file is decoded according
to the given data_encoding and then encoded to the underlying
file ... | [
"def",
"EncodedFile",
"(",
"file",
",",
"data_encoding",
",",
"file_encoding",
"=",
"None",
",",
"errors",
"=",
"'strict'",
")",
":",
"if",
"file_encoding",
"is",
"None",
":",
"file_encoding",
"=",
"data_encoding",
"data_info",
"=",
"lookup",
"(",
"data_encodi... | [
905,
0
] | [
939,
13
] | python | en | ['en', 'en', 'en'] | True |
getencoder | (encoding) | Lookup up the codec for the given encoding and return
its encoder function.
Raises a LookupError in case the encoding cannot be found.
| Lookup up the codec for the given encoding and return
its encoder function. | def getencoder(encoding):
""" Lookup up the codec for the given encoding and return
its encoder function.
Raises a LookupError in case the encoding cannot be found.
"""
return lookup(encoding).encode | [
"def",
"getencoder",
"(",
"encoding",
")",
":",
"return",
"lookup",
"(",
"encoding",
")",
".",
"encode"
] | [
943,
0
] | [
951,
34
] | python | en | ['en', 'en', 'en'] | True |
getdecoder | (encoding) | Lookup up the codec for the given encoding and return
its decoder function.
Raises a LookupError in case the encoding cannot be found.
| Lookup up the codec for the given encoding and return
its decoder function. | def getdecoder(encoding):
""" Lookup up the codec for the given encoding and return
its decoder function.
Raises a LookupError in case the encoding cannot be found.
"""
return lookup(encoding).decode | [
"def",
"getdecoder",
"(",
"encoding",
")",
":",
"return",
"lookup",
"(",
"encoding",
")",
".",
"decode"
] | [
953,
0
] | [
961,
34
] | python | en | ['en', 'en', 'en'] | True |
getincrementalencoder | (encoding) | Lookup up the codec for the given encoding and return
its IncrementalEncoder class or factory function.
Raises a LookupError in case the encoding cannot be found
or the codecs doesn't provide an incremental encoder.
| Lookup up the codec for the given encoding and return
its IncrementalEncoder class or factory function. | def getincrementalencoder(encoding):
""" Lookup up the codec for the given encoding and return
its IncrementalEncoder class or factory function.
Raises a LookupError in case the encoding cannot be found
or the codecs doesn't provide an incremental encoder.
"""
encoder = lookup(enc... | [
"def",
"getincrementalencoder",
"(",
"encoding",
")",
":",
"encoder",
"=",
"lookup",
"(",
"encoding",
")",
".",
"incrementalencoder",
"if",
"encoder",
"is",
"None",
":",
"raise",
"LookupError",
"(",
"encoding",
")",
"return",
"encoder"
] | [
963,
0
] | [
975,
18
] | python | en | ['en', 'en', 'en'] | True |
getincrementaldecoder | (encoding) | Lookup up the codec for the given encoding and return
its IncrementalDecoder class or factory function.
Raises a LookupError in case the encoding cannot be found
or the codecs doesn't provide an incremental decoder.
| Lookup up the codec for the given encoding and return
its IncrementalDecoder class or factory function. | def getincrementaldecoder(encoding):
""" Lookup up the codec for the given encoding and return
its IncrementalDecoder class or factory function.
Raises a LookupError in case the encoding cannot be found
or the codecs doesn't provide an incremental decoder.
"""
decoder = lookup(enc... | [
"def",
"getincrementaldecoder",
"(",
"encoding",
")",
":",
"decoder",
"=",
"lookup",
"(",
"encoding",
")",
".",
"incrementaldecoder",
"if",
"decoder",
"is",
"None",
":",
"raise",
"LookupError",
"(",
"encoding",
")",
"return",
"decoder"
] | [
977,
0
] | [
989,
18
] | python | en | ['en', 'en', 'en'] | True |
getreader | (encoding) | Lookup up the codec for the given encoding and return
its StreamReader class or factory function.
Raises a LookupError in case the encoding cannot be found.
| Lookup up the codec for the given encoding and return
its StreamReader class or factory function. | def getreader(encoding):
""" Lookup up the codec for the given encoding and return
its StreamReader class or factory function.
Raises a LookupError in case the encoding cannot be found.
"""
return lookup(encoding).streamreader | [
"def",
"getreader",
"(",
"encoding",
")",
":",
"return",
"lookup",
"(",
"encoding",
")",
".",
"streamreader"
] | [
991,
0
] | [
999,
40
] | python | en | ['en', 'en', 'en'] | True |
getwriter | (encoding) | Lookup up the codec for the given encoding and return
its StreamWriter class or factory function.
Raises a LookupError in case the encoding cannot be found.
| Lookup up the codec for the given encoding and return
its StreamWriter class or factory function. | def getwriter(encoding):
""" Lookup up the codec for the given encoding and return
its StreamWriter class or factory function.
Raises a LookupError in case the encoding cannot be found.
"""
return lookup(encoding).streamwriter | [
"def",
"getwriter",
"(",
"encoding",
")",
":",
"return",
"lookup",
"(",
"encoding",
")",
".",
"streamwriter"
] | [
1001,
0
] | [
1009,
40
] | python | en | ['en', 'en', 'en'] | True |
iterencode | (iterator, encoding, errors='strict', **kwargs) |
Encoding iterator.
Encodes the input strings from the iterator using an IncrementalEncoder.
errors and kwargs are passed through to the IncrementalEncoder
constructor.
|
Encoding iterator. | def iterencode(iterator, encoding, errors='strict', **kwargs):
"""
Encoding iterator.
Encodes the input strings from the iterator using an IncrementalEncoder.
errors and kwargs are passed through to the IncrementalEncoder
constructor.
"""
encoder = getincrementalencoder(encoding)(errors, *... | [
"def",
"iterencode",
"(",
"iterator",
",",
"encoding",
",",
"errors",
"=",
"'strict'",
",",
"*",
"*",
"kwargs",
")",
":",
"encoder",
"=",
"getincrementalencoder",
"(",
"encoding",
")",
"(",
"errors",
",",
"*",
"*",
"kwargs",
")",
"for",
"input",
"in",
... | [
1011,
0
] | [
1027,
20
] | python | en | ['en', 'error', 'th'] | False |
iterdecode | (iterator, encoding, errors='strict', **kwargs) |
Decoding iterator.
Decodes the input strings from the iterator using an IncrementalDecoder.
errors and kwargs are passed through to the IncrementalDecoder
constructor.
|
Decoding iterator. | def iterdecode(iterator, encoding, errors='strict', **kwargs):
"""
Decoding iterator.
Decodes the input strings from the iterator using an IncrementalDecoder.
errors and kwargs are passed through to the IncrementalDecoder
constructor.
"""
decoder = getincrementaldecoder(encoding)(errors, *... | [
"def",
"iterdecode",
"(",
"iterator",
",",
"encoding",
",",
"errors",
"=",
"'strict'",
",",
"*",
"*",
"kwargs",
")",
":",
"decoder",
"=",
"getincrementaldecoder",
"(",
"encoding",
")",
"(",
"errors",
",",
"*",
"*",
"kwargs",
")",
"for",
"input",
"in",
... | [
1029,
0
] | [
1045,
20
] | python | en | ['en', 'error', 'th'] | False |
make_identity_dict | (rng) | make_identity_dict(rng) -> dict
Return a dictionary where elements of the rng sequence are
mapped to themselves.
| make_identity_dict(rng) -> dict | def make_identity_dict(rng):
""" make_identity_dict(rng) -> dict
Return a dictionary where elements of the rng sequence are
mapped to themselves.
"""
return {i:i for i in rng} | [
"def",
"make_identity_dict",
"(",
"rng",
")",
":",
"return",
"{",
"i",
":",
"i",
"for",
"i",
"in",
"rng",
"}"
] | [
1049,
0
] | [
1057,
29
] | python | en | ['es', 'en', 'en'] | True |
make_encoding_map | (decoding_map) | Creates an encoding map from a decoding map.
If a target mapping in the decoding map occurs multiple
times, then that target is mapped to None (undefined mapping),
causing an exception when encountered by the charmap codec
during translation.
One example where this happens is ... | Creates an encoding map from a decoding map. | def make_encoding_map(decoding_map):
""" Creates an encoding map from a decoding map.
If a target mapping in the decoding map occurs multiple
times, then that target is mapped to None (undefined mapping),
causing an exception when encountered by the charmap codec
during translation... | [
"def",
"make_encoding_map",
"(",
"decoding_map",
")",
":",
"m",
"=",
"{",
"}",
"for",
"k",
",",
"v",
"in",
"decoding_map",
".",
"items",
"(",
")",
":",
"if",
"not",
"v",
"in",
"m",
":",
"m",
"[",
"v",
"]",
"=",
"k",
"else",
":",
"m",
"[",
"v"... | [
1059,
0
] | [
1078,
12
] | python | en | ['en', 'en', 'en'] | True |
Codec.encode | (self, input, errors='strict') | Encodes the object input and returns a tuple (output
object, length consumed).
errors defines the error handling to apply. It defaults to
'strict' handling.
The method may not store state in the Codec instance. Use
StreamWriter for codecs which have to keep... | Encodes the object input and returns a tuple (output
object, length consumed). | def encode(self, input, errors='strict'):
""" Encodes the object input and returns a tuple (output
object, length consumed).
errors defines the error handling to apply. It defaults to
'strict' handling.
The method may not store state in the Codec instance. Use
... | [
"def",
"encode",
"(",
"self",
",",
"input",
",",
"errors",
"=",
"'strict'",
")",
":",
"raise",
"NotImplementedError"
] | [
136,
4
] | [
153,
33
] | python | en | ['en', 'en', 'en'] | True |
Codec.decode | (self, input, errors='strict') | Decodes the object input and returns a tuple (output
object, length consumed).
input must be an object which provides the bf_getreadbuf
buffer slot. Python strings, buffer objects and memory
mapped files are examples of objects providing this slot.
errors d... | Decodes the object input and returns a tuple (output
object, length consumed). | def decode(self, input, errors='strict'):
""" Decodes the object input and returns a tuple (output
object, length consumed).
input must be an object which provides the bf_getreadbuf
buffer slot. Python strings, buffer objects and memory
mapped files are examples... | [
"def",
"decode",
"(",
"self",
",",
"input",
",",
"errors",
"=",
"'strict'",
")",
":",
"raise",
"NotImplementedError"
] | [
155,
4
] | [
176,
33
] | python | en | ['en', 'en', 'en'] | True |
IncrementalEncoder.__init__ | (self, errors='strict') |
Creates an IncrementalEncoder instance.
The IncrementalEncoder may use different error handling schemes by
providing the errors keyword argument. See the module docstring
for a list of possible values.
|
Creates an IncrementalEncoder instance. | def __init__(self, errors='strict'):
"""
Creates an IncrementalEncoder instance.
The IncrementalEncoder may use different error handling schemes by
providing the errors keyword argument. See the module docstring
for a list of possible values.
"""
self.errors = er... | [
"def",
"__init__",
"(",
"self",
",",
"errors",
"=",
"'strict'",
")",
":",
"self",
".",
"errors",
"=",
"errors",
"self",
".",
"buffer",
"=",
"\"\""
] | [
184,
4
] | [
193,
24
] | python | en | ['en', 'error', 'th'] | False |
IncrementalEncoder.encode | (self, input, final=False) |
Encodes input and returns the resulting object.
|
Encodes input and returns the resulting object.
| def encode(self, input, final=False):
"""
Encodes input and returns the resulting object.
"""
raise NotImplementedError | [
"def",
"encode",
"(",
"self",
",",
"input",
",",
"final",
"=",
"False",
")",
":",
"raise",
"NotImplementedError"
] | [
195,
4
] | [
199,
33
] | python | en | ['en', 'error', 'th'] | False |
IncrementalEncoder.reset | (self) |
Resets the encoder to the initial state.
|
Resets the encoder to the initial state.
| def reset(self):
"""
Resets the encoder to the initial state.
""" | [
"def",
"reset",
"(",
"self",
")",
":"
] | [
201,
4
] | [
204,
11
] | python | en | ['en', 'error', 'th'] | False |
IncrementalEncoder.getstate | (self) |
Return the current state of the encoder.
|
Return the current state of the encoder.
| def getstate(self):
"""
Return the current state of the encoder.
"""
return 0 | [
"def",
"getstate",
"(",
"self",
")",
":",
"return",
"0"
] | [
206,
4
] | [
210,
16
] | python | en | ['en', 'error', 'th'] | False |
IncrementalEncoder.setstate | (self, state) |
Set the current state of the encoder. state must have been
returned by getstate().
|
Set the current state of the encoder. state must have been
returned by getstate().
| def setstate(self, state):
"""
Set the current state of the encoder. state must have been
returned by getstate().
""" | [
"def",
"setstate",
"(",
"self",
",",
"state",
")",
":"
] | [
212,
4
] | [
216,
11
] | python | en | ['en', 'error', 'th'] | False |
IncrementalDecoder.__init__ | (self, errors='strict') |
Create an IncrementalDecoder instance.
The IncrementalDecoder may use different error handling schemes by
providing the errors keyword argument. See the module docstring
for a list of possible values.
|
Create an IncrementalDecoder instance. | def __init__(self, errors='strict'):
"""
Create an IncrementalDecoder instance.
The IncrementalDecoder may use different error handling schemes by
providing the errors keyword argument. See the module docstring
for a list of possible values.
"""
self.errors = err... | [
"def",
"__init__",
"(",
"self",
",",
"errors",
"=",
"'strict'",
")",
":",
"self",
".",
"errors",
"=",
"errors"
] | [
258,
4
] | [
266,
28
] | python | en | ['en', 'error', 'th'] | False |
IncrementalDecoder.decode | (self, input, final=False) |
Decode input and returns the resulting object.
|
Decode input and returns the resulting object.
| def decode(self, input, final=False):
"""
Decode input and returns the resulting object.
"""
raise NotImplementedError | [
"def",
"decode",
"(",
"self",
",",
"input",
",",
"final",
"=",
"False",
")",
":",
"raise",
"NotImplementedError"
] | [
268,
4
] | [
272,
33
] | python | en | ['en', 'error', 'th'] | False |
IncrementalDecoder.reset | (self) |
Reset the decoder to the initial state.
|
Reset the decoder to the initial state.
| def reset(self):
"""
Reset the decoder to the initial state.
""" | [
"def",
"reset",
"(",
"self",
")",
":"
] | [
274,
4
] | [
277,
11
] | python | en | ['en', 'error', 'th'] | False |
IncrementalDecoder.getstate | (self) |
Return the current state of the decoder.
This must be a (buffered_input, additional_state_info) tuple.
buffered_input must be a bytes object containing bytes that
were passed to decode() that have not yet been converted.
additional_state_info must be a non-negative integer
... |
Return the current state of the decoder. | def getstate(self):
"""
Return the current state of the decoder.
This must be a (buffered_input, additional_state_info) tuple.
buffered_input must be a bytes object containing bytes that
were passed to decode() that have not yet been converted.
additional_state_info must... | [
"def",
"getstate",
"(",
"self",
")",
":",
"return",
"(",
"b\"\"",
",",
"0",
")"
] | [
279,
4
] | [
291,
23
] | python | en | ['en', 'error', 'th'] | False |
IncrementalDecoder.setstate | (self, state) |
Set the current state of the decoder.
state must have been returned by getstate(). The effect of
setstate((b"", 0)) must be equivalent to reset().
|
Set the current state of the decoder. | def setstate(self, state):
"""
Set the current state of the decoder.
state must have been returned by getstate(). The effect of
setstate((b"", 0)) must be equivalent to reset().
""" | [
"def",
"setstate",
"(",
"self",
",",
"state",
")",
":"
] | [
293,
4
] | [
299,
11
] | python | en | ['en', 'error', 'th'] | False |
StreamWriter.__init__ | (self, stream, errors='strict') | Creates a StreamWriter instance.
stream must be a file-like object open for writing.
The StreamWriter may use different error handling
schemes by providing the errors keyword argument. These
parameters are predefined:
'strict' - raise a ValueError (or a s... | Creates a StreamWriter instance. | def __init__(self, stream, errors='strict'):
""" Creates a StreamWriter instance.
stream must be a file-like object open for writing.
The StreamWriter may use different error handling
schemes by providing the errors keyword argument. These
parameters are predef... | [
"def",
"__init__",
"(",
"self",
",",
"stream",
",",
"errors",
"=",
"'strict'",
")",
":",
"self",
".",
"stream",
"=",
"stream",
"self",
".",
"errors",
"=",
"errors"
] | [
346,
4
] | [
369,
28
] | python | en | ['en', 'de', 'en'] | True |
StreamWriter.write | (self, object) | Writes the object's contents encoded to self.stream.
| Writes the object's contents encoded to self.stream.
| def write(self, object):
""" Writes the object's contents encoded to self.stream.
"""
data, consumed = self.encode(object, self.errors)
self.stream.write(data) | [
"def",
"write",
"(",
"self",
",",
"object",
")",
":",
"data",
",",
"consumed",
"=",
"self",
".",
"encode",
"(",
"object",
",",
"self",
".",
"errors",
")",
"self",
".",
"stream",
".",
"write",
"(",
"data",
")"
] | [
371,
4
] | [
376,
31
] | python | en | ['en', 'en', 'en'] | True |
StreamWriter.writelines | (self, list) | Writes the concatenated list of strings to the stream
using .write().
| Writes the concatenated list of strings to the stream
using .write().
| def writelines(self, list):
""" Writes the concatenated list of strings to the stream
using .write().
"""
self.write(''.join(list)) | [
"def",
"writelines",
"(",
"self",
",",
"list",
")",
":",
"self",
".",
"write",
"(",
"''",
".",
"join",
"(",
"list",
")",
")"
] | [
378,
4
] | [
383,
33
] | python | en | ['en', 'en', 'en'] | True |
StreamWriter.reset | (self) | Flushes and resets the codec buffers used for keeping state.
Calling this method should ensure that the data on the
output is put into a clean state, that allows appending
of new fresh data without having to rescan the whole
stream to recover state.
| Flushes and resets the codec buffers used for keeping state. | def reset(self):
""" Flushes and resets the codec buffers used for keeping state.
Calling this method should ensure that the data on the
output is put into a clean state, that allows appending
of new fresh data without having to rescan the whole
stream to recove... | [
"def",
"reset",
"(",
"self",
")",
":",
"pass"
] | [
385,
4
] | [
395,
12
] | python | en | ['en', 'en', 'en'] | True |
StreamWriter.__getattr__ | (self, name,
getattr=getattr) | Inherit all other methods from the underlying stream.
| Inherit all other methods from the underlying stream.
| def __getattr__(self, name,
getattr=getattr):
""" Inherit all other methods from the underlying stream.
"""
return getattr(self.stream, name) | [
"def",
"__getattr__",
"(",
"self",
",",
"name",
",",
"getattr",
"=",
"getattr",
")",
":",
"return",
"getattr",
"(",
"self",
".",
"stream",
",",
"name",
")"
] | [
402,
4
] | [
407,
41
] | python | en | ['en', 'en', 'en'] | True |
StreamReader.__init__ | (self, stream, errors='strict') | Creates a StreamReader instance.
stream must be a file-like object open for reading.
The StreamReader may use different error handling
schemes by providing the errors keyword argument. These
parameters are predefined:
'strict' - raise a ValueError (or a s... | Creates a StreamReader instance. | def __init__(self, stream, errors='strict'):
""" Creates a StreamReader instance.
stream must be a file-like object open for reading.
The StreamReader may use different error handling
schemes by providing the errors keyword argument. These
parameters are predef... | [
"def",
"__init__",
"(",
"self",
",",
"stream",
",",
"errors",
"=",
"'strict'",
")",
":",
"self",
".",
"stream",
"=",
"stream",
"self",
".",
"errors",
"=",
"errors",
"self",
".",
"bytebuffer",
"=",
"b\"\"",
"self",
".",
"_empty_charbuffer",
"=",
"self",
... | [
421,
4
] | [
444,
30
] | python | en | ['en', 'de', 'en'] | True |
StreamReader.read | (self, size=-1, chars=-1, firstline=False) | Decodes data from the stream self.stream and returns the
resulting object.
chars indicates the number of decoded code points or bytes to
return. read() will never return more data than requested,
but it might return less, if there is not enough available.
s... | Decodes data from the stream self.stream and returns the
resulting object. | def read(self, size=-1, chars=-1, firstline=False):
""" Decodes data from the stream self.stream and returns the
resulting object.
chars indicates the number of decoded code points or bytes to
return. read() will never return more data than requested,
but it mig... | [
"def",
"read",
"(",
"self",
",",
"size",
"=",
"-",
"1",
",",
"chars",
"=",
"-",
"1",
",",
"firstline",
"=",
"False",
")",
":",
"# If we have lines cached, first merge them back into characters",
"if",
"self",
".",
"linebuffer",
":",
"self",
".",
"charbuffer",
... | [
449,
4
] | [
527,
21
] | python | en | ['en', 'en', 'en'] | True |
StreamReader.readline | (self, size=None, keepends=True) | Read one line from the input stream and return the
decoded data.
size, if given, is passed as size argument to the
read() method.
| Read one line from the input stream and return the
decoded data. | def readline(self, size=None, keepends=True):
""" Read one line from the input stream and return the
decoded data.
size, if given, is passed as size argument to the
read() method.
"""
# If we have lines cached from an earlier read, return
# them unc... | [
"def",
"readline",
"(",
"self",
",",
"size",
"=",
"None",
",",
"keepends",
"=",
"True",
")",
":",
"# If we have lines cached from an earlier read, return",
"# them unconditionally",
"if",
"self",
".",
"linebuffer",
":",
"line",
"=",
"self",
".",
"linebuffer",
"[",... | [
529,
4
] | [
602,
19
] | python | en | ['en', 'en', 'en'] | True |
StreamReader.readlines | (self, sizehint=None, keepends=True) | Read all lines available on the input stream
and return them as a list.
Line breaks are implemented using the codec's decoder
method and are included in the list entries.
sizehint, if given, is ignored since there is no efficient
way to finding the true end... | Read all lines available on the input stream
and return them as a list. | def readlines(self, sizehint=None, keepends=True):
""" Read all lines available on the input stream
and return them as a list.
Line breaks are implemented using the codec's decoder
method and are included in the list entries.
sizehint, if given, is ignored sinc... | [
"def",
"readlines",
"(",
"self",
",",
"sizehint",
"=",
"None",
",",
"keepends",
"=",
"True",
")",
":",
"data",
"=",
"self",
".",
"read",
"(",
")",
"return",
"data",
".",
"splitlines",
"(",
"keepends",
")"
] | [
604,
4
] | [
617,
40
] | python | en | ['en', 'en', 'en'] | True |
StreamReader.reset | (self) | Resets the codec buffers used for keeping state.
Note that no stream repositioning should take place.
This method is primarily intended to be able to recover
from decoding errors.
| Resets the codec buffers used for keeping state. | def reset(self):
""" Resets the codec buffers used for keeping state.
Note that no stream repositioning should take place.
This method is primarily intended to be able to recover
from decoding errors.
"""
self.bytebuffer = b""
self.charbuffer = self... | [
"def",
"reset",
"(",
"self",
")",
":",
"self",
".",
"bytebuffer",
"=",
"b\"\"",
"self",
".",
"charbuffer",
"=",
"self",
".",
"_empty_charbuffer",
"self",
".",
"linebuffer",
"=",
"None"
] | [
619,
4
] | [
630,
30
] | python | en | ['en', 'en', 'en'] | True |
StreamReader.seek | (self, offset, whence=0) | Set the input stream's current position.
Resets the codec buffers used for keeping state.
| Set the input stream's current position. | def seek(self, offset, whence=0):
""" Set the input stream's current position.
Resets the codec buffers used for keeping state.
"""
self.stream.seek(offset, whence)
self.reset() | [
"def",
"seek",
"(",
"self",
",",
"offset",
",",
"whence",
"=",
"0",
")",
":",
"self",
".",
"stream",
".",
"seek",
"(",
"offset",
",",
"whence",
")",
"self",
".",
"reset",
"(",
")"
] | [
632,
4
] | [
638,
20
] | python | en | ['en', 'en', 'en'] | True |
StreamReader.__next__ | (self) | Return the next decoded line from the input stream. | Return the next decoded line from the input stream. | def __next__(self):
""" Return the next decoded line from the input stream."""
line = self.readline()
if line:
return line
raise StopIteration | [
"def",
"__next__",
"(",
"self",
")",
":",
"line",
"=",
"self",
".",
"readline",
"(",
")",
"if",
"line",
":",
"return",
"line",
"raise",
"StopIteration"
] | [
640,
4
] | [
646,
27
] | python | en | ['en', 'en', 'en'] | True |
StreamReader.__getattr__ | (self, name,
getattr=getattr) | Inherit all other methods from the underlying stream.
| Inherit all other methods from the underlying stream.
| def __getattr__(self, name,
getattr=getattr):
""" Inherit all other methods from the underlying stream.
"""
return getattr(self.stream, name) | [
"def",
"__getattr__",
"(",
"self",
",",
"name",
",",
"getattr",
"=",
"getattr",
")",
":",
"return",
"getattr",
"(",
"self",
".",
"stream",
",",
"name",
")"
] | [
651,
4
] | [
656,
41
] | python | en | ['en', 'en', 'en'] | True |
StreamReaderWriter.__init__ | (self, stream, Reader, Writer, errors='strict') | Creates a StreamReaderWriter instance.
stream must be a Stream-like object.
Reader, Writer must be factory functions or classes
providing the StreamReader, StreamWriter interface resp.
Error handling is done in the same way as defined for the
StreamWriter/... | Creates a StreamReaderWriter instance. | def __init__(self, stream, Reader, Writer, errors='strict'):
""" Creates a StreamReaderWriter instance.
stream must be a Stream-like object.
Reader, Writer must be factory functions or classes
providing the StreamReader, StreamWriter interface resp.
Error hand... | [
"def",
"__init__",
"(",
"self",
",",
"stream",
",",
"Reader",
",",
"Writer",
",",
"errors",
"=",
"'strict'",
")",
":",
"self",
".",
"stream",
"=",
"stream",
"self",
".",
"reader",
"=",
"Reader",
"(",
"stream",
",",
"errors",
")",
"self",
".",
"writer... | [
679,
4
] | [
695,
28
] | python | en | ['en', 'de', 'en'] | True |
StreamReaderWriter.__next__ | (self) | Return the next decoded line from the input stream. | Return the next decoded line from the input stream. | def __next__(self):
""" Return the next decoded line from the input stream."""
return next(self.reader) | [
"def",
"__next__",
"(",
"self",
")",
":",
"return",
"next",
"(",
"self",
".",
"reader",
")"
] | [
709,
4
] | [
712,
32
] | python | en | ['en', 'en', 'en'] | True |
StreamReaderWriter.__getattr__ | (self, name,
getattr=getattr) | Inherit all other methods from the underlying stream.
| Inherit all other methods from the underlying stream.
| def __getattr__(self, name,
getattr=getattr):
""" Inherit all other methods from the underlying stream.
"""
return getattr(self.stream, name) | [
"def",
"__getattr__",
"(",
"self",
",",
"name",
",",
"getattr",
"=",
"getattr",
")",
":",
"return",
"getattr",
"(",
"self",
".",
"stream",
",",
"name",
")"
] | [
736,
4
] | [
741,
41
] | python | en | ['en', 'en', 'en'] | True |
StreamRecoder.__init__ | (self, stream, encode, decode, Reader, Writer,
errors='strict') | Creates a StreamRecoder instance which implements a two-way
conversion: encode and decode work on the frontend (the
data visible to .read() and .write()) while Reader and Writer
work on the backend (the data in stream).
You can use these objects to do transparent
... | Creates a StreamRecoder instance which implements a two-way
conversion: encode and decode work on the frontend (the
data visible to .read() and .write()) while Reader and Writer
work on the backend (the data in stream). | def __init__(self, stream, encode, decode, Reader, Writer,
errors='strict'):
""" Creates a StreamRecoder instance which implements a two-way
conversion: encode and decode work on the frontend (the
data visible to .read() and .write()) while Reader and Writer
... | [
"def",
"__init__",
"(",
"self",
",",
"stream",
",",
"encode",
",",
"decode",
",",
"Reader",
",",
"Writer",
",",
"errors",
"=",
"'strict'",
")",
":",
"self",
".",
"stream",
"=",
"stream",
"self",
".",
"encode",
"=",
"encode",
"self",
".",
"decode",
"=... | [
773,
4
] | [
799,
28
] | python | en | ['en', 'en', 'en'] | True |
StreamRecoder.__next__ | (self) | Return the next decoded line from the input stream. | Return the next decoded line from the input stream. | def __next__(self):
""" Return the next decoded line from the input stream."""
data = next(self.reader)
data, bytesencoded = self.encode(data, self.errors)
return data | [
"def",
"__next__",
"(",
"self",
")",
":",
"data",
"=",
"next",
"(",
"self",
".",
"reader",
")",
"data",
",",
"bytesencoded",
"=",
"self",
".",
"encode",
"(",
"data",
",",
"self",
".",
"errors",
")",
"return",
"data"
] | [
822,
4
] | [
827,
19
] | python | en | ['en', 'en', 'en'] | True |
StreamRecoder.__getattr__ | (self, name,
getattr=getattr) | Inherit all other methods from the underlying stream.
| Inherit all other methods from the underlying stream.
| def __getattr__(self, name,
getattr=getattr):
""" Inherit all other methods from the underlying stream.
"""
return getattr(self.stream, name) | [
"def",
"__getattr__",
"(",
"self",
",",
"name",
",",
"getattr",
"=",
"getattr",
")",
":",
"return",
"getattr",
"(",
"self",
".",
"stream",
",",
"name",
")"
] | [
848,
4
] | [
853,
41
] | python | en | ['en', 'en', 'en'] | True |
upgrade_api | (request, client, version) | Ugrade the nova API to the specified version if possible. | Ugrade the nova API to the specified version if possible. | def upgrade_api(request, client, version):
"""Ugrade the nova API to the specified version if possible."""
min_ver, max_ver = api_versions._get_server_version_range(client)
if min_ver <= api_versions.APIVersion(version) <= max_ver:
client = _nova.novaclient(request, version)
return client | [
"def",
"upgrade_api",
"(",
"request",
",",
"client",
",",
"version",
")",
":",
"min_ver",
",",
"max_ver",
"=",
"api_versions",
".",
"_get_server_version_range",
"(",
"client",
")",
"if",
"min_ver",
"<=",
"api_versions",
".",
"APIVersion",
"(",
"version",
")",
... | [
191,
0
] | [
197,
17
] | python | en | ['en', 'en', 'en'] | True |
flavor_list | (request, is_public=True, get_extras=False) | Get the list of available instance sizes (flavors). | Get the list of available instance sizes (flavors). | def flavor_list(request, is_public=True, get_extras=False):
"""Get the list of available instance sizes (flavors)."""
flavors = _nova.novaclient(request).flavors.list(is_public=is_public)
if get_extras:
for flavor in flavors:
flavor.extras = flavor_get_extras(request, flavor.id, True, fl... | [
"def",
"flavor_list",
"(",
"request",
",",
"is_public",
"=",
"True",
",",
"get_extras",
"=",
"False",
")",
":",
"flavors",
"=",
"_nova",
".",
"novaclient",
"(",
"request",
")",
".",
"flavors",
".",
"list",
"(",
"is_public",
"=",
"is_public",
")",
"if",
... | [
266,
0
] | [
272,
18
] | python | en | ['en', 'en', 'en'] | True |
flavor_list_paged | (request, is_public=True, get_extras=False, marker=None,
paginate=False, sort_key="name", sort_dir="desc",
reversed_order=False) | Get the list of available instance sizes (flavors). | Get the list of available instance sizes (flavors). | def flavor_list_paged(request, is_public=True, get_extras=False, marker=None,
paginate=False, sort_key="name", sort_dir="desc",
reversed_order=False):
"""Get the list of available instance sizes (flavors)."""
has_more_data = False
has_prev_data = False
if pag... | [
"def",
"flavor_list_paged",
"(",
"request",
",",
"is_public",
"=",
"True",
",",
"get_extras",
"=",
"False",
",",
"marker",
"=",
"None",
",",
"paginate",
"=",
"False",
",",
"sort_key",
"=",
"\"name\"",
",",
"sort_dir",
"=",
"\"desc\"",
",",
"reversed_order",
... | [
299,
0
] | [
324,
50
] | python | en | ['en', 'en', 'en'] | True |
flavor_access_list | (request, flavor=None) | Get the list of access instance sizes (flavors). | Get the list of access instance sizes (flavors). | def flavor_access_list(request, flavor=None):
"""Get the list of access instance sizes (flavors)."""
return _nova.novaclient(request).flavor_access.list(flavor=flavor) | [
"def",
"flavor_access_list",
"(",
"request",
",",
"flavor",
"=",
"None",
")",
":",
"return",
"_nova",
".",
"novaclient",
"(",
"request",
")",
".",
"flavor_access",
".",
"list",
"(",
"flavor",
"=",
"flavor",
")"
] | [
329,
0
] | [
331,
70
] | python | en | ['en', 'en', 'en'] | True |
add_tenant_to_flavor | (request, flavor, tenant) | Add a tenant to the given flavor access list. | Add a tenant to the given flavor access list. | def add_tenant_to_flavor(request, flavor, tenant):
"""Add a tenant to the given flavor access list."""
return _nova.novaclient(request).flavor_access.add_tenant_access(
flavor=flavor, tenant=tenant) | [
"def",
"add_tenant_to_flavor",
"(",
"request",
",",
"flavor",
",",
"tenant",
")",
":",
"return",
"_nova",
".",
"novaclient",
"(",
"request",
")",
".",
"flavor_access",
".",
"add_tenant_access",
"(",
"flavor",
"=",
"flavor",
",",
"tenant",
"=",
"tenant",
")"
... | [
335,
0
] | [
338,
37
] | python | en | ['en', 'en', 'en'] | True |
remove_tenant_from_flavor | (request, flavor, tenant) | Remove a tenant from the given flavor access list. | Remove a tenant from the given flavor access list. | def remove_tenant_from_flavor(request, flavor, tenant):
"""Remove a tenant from the given flavor access list."""
return _nova.novaclient(request).flavor_access.remove_tenant_access(
flavor=flavor, tenant=tenant) | [
"def",
"remove_tenant_from_flavor",
"(",
"request",
",",
"flavor",
",",
"tenant",
")",
":",
"return",
"_nova",
".",
"novaclient",
"(",
"request",
")",
".",
"flavor_access",
".",
"remove_tenant_access",
"(",
"flavor",
"=",
"flavor",
",",
"tenant",
"=",
"tenant"... | [
342,
0
] | [
345,
37
] | 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.