Instruction
stringlengths
362
7.83k
output_code
stringlengths
1
945
Using the snippet: <|code_start|>""" tests.test_yaspin ~~~~~~~~~~~~~~~~~ Basic unittests. """ @pytest.mark.parametrize( "spinner, expected", [ # None <|code_end|> , determine the next line of code. You have imports: from collections import namedtuple from yaspin import Spinner, yaspin from yaspin...
(None, default_spinner),
Given the code snippet: <|code_start|>""" examples.spinner_properties ~~~~~~~~~~~~~~~~~~~~~~~~~~~ Updating spinner on the fly. """ def manual_setup(): <|code_end|> , generate the next line using the imports in this file: import time from yaspin import yaspin from yaspin.spinners import Spinners and context (func...
sp = yaspin(text="Default spinner")
Given snippet: <|code_start|>""" examples.spinner_properties ~~~~~~~~~~~~~~~~~~~~~~~~~~~ Updating spinner on the fly. """ def manual_setup(): sp = yaspin(text="Default spinner") sp.start() time.sleep(2) <|code_end|> , continue by predicting the next line. Consider current file imports: import time f...
sp.spinner = Spinners.arc
Next line prediction: <|code_start|>""" tests.test_spinners ~~~~~~~~~~~~~~~~~~~ Tests for spinners collection. """ <|code_end|> . Use current file imports: (import json import pytest from collections import OrderedDict from yaspin.spinners import SPINNERS_DATA, Spinners) and context including class names, funct...
spinners_dict = OrderedDict(json.loads(SPINNERS_DATA))
Predict the next line after this snippet: <|code_start|>""" tests.test_spinners ~~~~~~~~~~~~~~~~~~~ Tests for spinners collection. """ spinners_dict = OrderedDict(json.loads(SPINNERS_DATA)) test_cases = [(name, v["frames"], v["interval"]) for name, v in spinners_dict.items()] def test_len(): <|code_end|> using...
assert len(Spinners) == len(spinners_dict)
Here is a snippet: <|code_start|>""" examples.reverse_spinner ~~~~~~~~~~~~~~~~~~~~~~~~ Reverse spinner rotation. """ def main(): <|code_end|> . Write the next line using the current file imports: import time from yaspin import yaspin from yaspin.spinners import Spinners and context from other files: # Path: yas...
with yaspin(Spinners.clock, text="Clockwise") as sp:
Based on the snippet: <|code_start|>""" examples.reverse_spinner ~~~~~~~~~~~~~~~~~~~~~~~~ Reverse spinner rotation. """ def main(): <|code_end|> , predict the immediate next line with the help of imports: import time from yaspin import yaspin from yaspin.spinners import Spinners and context (classes, functions, ...
with yaspin(Spinners.clock, text="Clockwise") as sp:
Here is a snippet: <|code_start|>""" examples.advanced_colors ~~~~~~~~~~~~~~~~~~~~~~~~ Use familiar API of the `termcolor.colored` function to apply any color, highlight, attribute or their mix to your yaspin spinner. """ def white_shark(): # Set with attributes <|code_end|> . Write the next line using the cur...
with yaspin().white.bold.shark.on_blue as sp:
Given the following code snippet before the placeholder: <|code_start|>""" examples.colors ~~~~~~~~~~~~~~~ Basic usage of the 'color', 'on_color' and 'attrs' arguments. """ def all_colors(): <|code_end|> , predict the next line using imports from the current file: import time from yaspin import yaspin and contex...
with yaspin(text="Colors!").bouncingBar as sp:
Here is a snippet: <|code_start|>""" examples.basic_usage ~~~~~~~~~~~~~~~~~~~~ Common usage patterns for the yaspin spinner. """ def context_manager_default(): <|code_end|> . Write the next line using the current file imports: import signal import time from yaspin import Spinner, yaspin from yaspin.signal_handler...
with yaspin(text="Braille"):
Predict the next line after this snippet: <|code_start|>""" examples.basic_usage ~~~~~~~~~~~~~~~~~~~~ Common usage patterns for the yaspin spinner. """ def context_manager_default(): with yaspin(text="Braille"): time.sleep(3) def context_manager_line(): <|code_end|> using the current file's imports:...
line_spinner = Spinner("-\\|/", 150)
Given snippet: <|code_start|>~~~~~~~~~~~~~~~~~~~~ Common usage patterns for the yaspin spinner. """ def context_manager_default(): with yaspin(text="Braille"): time.sleep(3) def context_manager_line(): line_spinner = Spinner("-\\|/", 150) with yaspin(line_spinner, "line"): time.sleep(...
sigmap={signal.SIGINT: fancy_handler},
Given the code snippet: <|code_start|>""" examples.basic_usage ~~~~~~~~~~~~~~~~~~~~ Common usage patterns for the yaspin spinner. """ def context_manager_default(): with yaspin(text="Braille"): time.sleep(3) def context_manager_line(): line_spinner = Spinner("-\\|/", 150) with yaspin(line_spi...
spinner=Spinners.simpleDotsScrolling,
Predict the next line for this snippet: <|code_start|> Handling signals. Reference --------- - Signals in a nutshell: https://twitter.com/b0rk/status/981678748763414529 - More detailed overview: https://jvns.ca/blog/2016/06/13/should-you-be-scared-of-signals/ - Python signal module examples: https://pym...
with kbi_safe_yaspin(text=DEFAULT_TEXT):
Based on the snippet: <|code_start|> - More detailed overview: https://jvns.ca/blog/2016/06/13/should-you-be-scared-of-signals/ - Python signal module examples: https://pymotw.com/3/signal/index.html - Linux signals reference: https://www.computerhope.com/unix/signals.htm#linux """ DEFAULT_TEXT = "Pr...
with yaspin(sigmap={signal.SIGINT: fancy_handler}, text=DEFAULT_TEXT):
Based on the snippet: <|code_start|> - More detailed overview: https://jvns.ca/blog/2016/06/13/should-you-be-scared-of-signals/ - Python signal module examples: https://pymotw.com/3/signal/index.html - Linux signals reference: https://www.computerhope.com/unix/signals.htm#linux """ DEFAULT_TEXT = "Pr...
with yaspin(sigmap={signal.SIGINT: fancy_handler}, text=DEFAULT_TEXT):
Given the code snippet: <|code_start|> sp.write("E.g. $ kill -USR1 {0}".format(os.getpid())) time.sleep(60) sp.write("No signal received") def ignore_signal(): with yaspin(sigmap={signal.SIGINT: signal.SIG_IGN}, text="You can't interrupt me!"): time.sleep(5) def default_os_handler...
spinner=Spinners.simpleDotsScrolling,
Predict the next line after this snippet: <|code_start|>""" tests.test_properties ~~~~~~~~~~~~~~~~~~~~~ Test getters and setters. """ # # Yaspin.spinner # def test_spinner_getter(frames, interval): <|code_end|> using the current file's imports: import pytest from yaspin import Spinner, yaspin from yaspin.base_sp...
sp = yaspin()
Predict the next line for this snippet: <|code_start|>""" tests.test_properties ~~~~~~~~~~~~~~~~~~~~~ Test getters and setters. """ # # Yaspin.spinner # def test_spinner_getter(frames, interval): sp = yaspin() assert sp.spinner == default_spinner <|code_end|> with the help of current file imports: impor...
new_spinner = Spinner(frames, interval)
Using the snippet: <|code_start|>""" tests.test_properties ~~~~~~~~~~~~~~~~~~~~~ Test getters and setters. """ # # Yaspin.spinner # def test_spinner_getter(frames, interval): sp = yaspin() <|code_end|> , determine the next line of code. You have imports: import pytest from yaspin import Spinner, yaspin from y...
assert sp.spinner == default_spinner
Next line prediction: <|code_start|> new_spinner = Spinner(frames, interval) sp.spinner = new_spinner assert sp.spinner == sp._set_spinner(new_spinner) def test_spinner_setter(frames, interval): sp = yaspin() assert sp._spinner == default_spinner assert isinstance(sp._frames, str) assert sp...
assert sp.text == to_unicode(text)
Given the following code snippet before the placeholder: <|code_start|>""" tests.test_timer ~~~~~~~~~~~~~~~~ Test timer feature. """ def test_no_timer(): <|code_end|> , predict the next line using imports from the current file: import re import time import pytest from yaspin import yaspin and context including ...
sp = yaspin(timer=False)
Continue the code snippet: <|code_start|>""" tests.test_pipes ~~~~~~~~~~~~~~~~ Checks that scripts with yaspin are safe for pipes and redirects: $ python script_that_uses_yaspin.py > script.log $ python script_that_uses_yaspin.py | grep ERROR """ TEST_CODE = """\ import time from yaspin import yaspin, Spinn...
def to_bytes(str_or_bytes, encoding=ENCODING):
Predict the next line after this snippet: <|code_start|>""" tests.test_in_out ~~~~~~~~~~~~~~~~~ Checks that all input data is converted to unicode. And all output data is converted to builtin str type. """ def test_input_converted_to_unicode(text, frames, interval, reversal, side): sp = Spinner(frames, interv...
sp = yaspin(sp, text, side=side, reversal=reversal)
Here is a snippet: <|code_start|>""" tests.test_in_out ~~~~~~~~~~~~~~~~~ Checks that all input data is converted to unicode. And all output data is converted to builtin str type. """ def test_input_converted_to_unicode(text, frames, interval, reversal, side): <|code_end|> . Write the next line using the current f...
sp = Spinner(frames, interval)
Continue the code snippet: <|code_start|>""" examples.timer_spinner ~~~~~~~~~~~~~~~~~~~~~~ Show elapsed time at the end of the line. """ def main(): <|code_end|> . Use current file imports: import time from yaspin import yaspin and context (classes, functions, or code) from other files: # Path: yaspin/api.py # ...
with yaspin(text="elapsed time", timer=True) as sp:
Given the code snippet: <|code_start|>Starting from yaspin v1.1.0 handled by ``hidden`` context manager. Requires python-prompt-tooklit >= 2.0.1 https://github.com/jonathanslenders/python-prompt-toolkit/ .. code:: bash pip install "prompt_toolkit>=2.0.1" """ try: except ImportError: print( "This e...
with yaspin(text="Downloading images") as sp:
Given the following code snippet before the placeholder: <|code_start|>""" examples.hide_show ~~~~~~~~~~~~~~~~~~ Basic usage of the ``hide`` and ``show`` methods. Starting from yaspin v1.1.0 handled by ``hidden`` context manager. """ def main(): <|code_end|> , predict the next line using imports from the current f...
with yaspin(text="Downloading images") as sp:
Predict the next line for this snippet: <|code_start|> available_values = [k for k, v in COLOR_MAP.items() if v == "attrs"] for attr in attrs: if attr not in available_values: raise ValueError( "'{0}': unsupported attribute value. " "Use...
def _set_frames(spinner: Spinner, reversal: bool) -> Union[str, List]:
Given snippet: <|code_start|> value, ", ".join(available_values) ) ) return value @staticmethod def _set_on_color(value: str) -> str: available_values = [k for k, v in COLOR_MAP.items() if v == "on_color"] if value not in available_values: ...
sp = default_spinner
Here is a snippet: <|code_start|> # Dunders # def __repr__(self): return "<Yaspin frames={0!s}>".format(self._frames) def __enter__(self): self.start() return self def __exit__(self, exc_type, exc_val, traceback): # Avoid stop() execution for the 2nd time if ...
elif name in COLOR_ATTRS:
Given the following code snippet before the placeholder: <|code_start|> # def __repr__(self): return "<Yaspin frames={0!s}>".format(self._frames) def __enter__(self): self.start() return self def __exit__(self, exc_type, exc_val, traceback): # Avoid stop() execution for ...
attr_type = COLOR_MAP[name]
Continue the code snippet: <|code_start|> # Maps signals to their default handlers in order to reset # custom handlers set by ``sigmap`` at the cleanup phase. self._dfl_sigmap = {} # Dict[Signal, SigHandler] # # Dunders # def __repr__(self): return "<Yaspin frames={0!s}>...
if name in SPINNER_ATTRS:
Based on the snippet: <|code_start|> try: yield finally: self._hidden_level -= 1 if self._hidden_level == 0: self.show() def show(self): """Show the hidden spinner.""" thr_is_alive = self._spin_thread and self._spin_thread.is_alive...
_text = to_unicode(text)
Given snippet: <|code_start|>""" tests.test_finalizers ~~~~~~~~~~~~~~~~~~~~~ """ def test_freeze(final_text): <|code_end|> , continue by predicting the next line. Consider current file imports: from yaspin import yaspin and context: # Path: yaspin/api.py # def yaspin(*args, **kwargs): # """Display spinner in...
sp = yaspin()
Based on the snippet: <|code_start|>""" tests.test_attrs ~~~~~~~~~~~~~~~~ Test Yaspin attributes magic hidden in __getattr__. """ @pytest.mark.parametrize("attr_name", SPINNER_ATTRS) def test_set_spinner_by_name(attr_name): <|code_end|> , predict the immediate next line with the help of imports: import pytest fro...
sp = getattr(yaspin(), attr_name)
Continue the code snippet: <|code_start|> with pytest.raises(AttributeError): getattr(sp, color) else: getattr(sp, color) assert sp.color == expected assert sp._color_func.keywords["color"] == expected # pylint: disable=no-member # Values for ``on_color`` argument def t...
"attr", sorted([k for k, v in COLOR_MAP.items() if v == "attrs"])
Based on the snippet: <|code_start|>""" tests.test_attrs ~~~~~~~~~~~~~~~~ Test Yaspin attributes magic hidden in __getattr__. """ <|code_end|> , predict the immediate next line with the help of imports: import pytest from yaspin import yaspin from yaspin.constants import COLOR_MAP, SPINNER_ATTRS from yaspin.spinn...
@pytest.mark.parametrize("attr_name", SPINNER_ATTRS)
Using the snippet: <|code_start|>""" tests.test_attrs ~~~~~~~~~~~~~~~~ Test Yaspin attributes magic hidden in __getattr__. """ @pytest.mark.parametrize("attr_name", SPINNER_ATTRS) def test_set_spinner_by_name(attr_name): sp = getattr(yaspin(), attr_name) <|code_end|> , determine the next line of code. You have...
assert sp.spinner == getattr(Spinners, attr_name)
Given the following code snippet before the placeholder: <|code_start|># :copyright: (c) 2021 by Pavlo Dmytrenko. # :license: MIT, see LICENSE for more details. """ yaspin.helpers ~~~~~~~~~~~~~~ Helper functions. """ <|code_end|> , predict the next line using imports from the current file: from .constants import ...
def to_unicode(text_type, encoding=ENCODING):
Predict the next line after this snippet: <|code_start|>""" examples.write_method ~~~~~~~~~~~~~~~~~~~~~ Basic usage of ``write`` method. """ def main(): <|code_end|> using the current file's imports: import time from yaspin import yaspin and any relevant context from other files: # Path: yaspin/api.py # def ya...
with yaspin(text="Downloading images") as sp:
Using the snippet: <|code_start|>""" examples.finalizers ~~~~~~~~~~~~~~~~~~~ Success and Failure finalizers. """ def default_finalizers(): <|code_end|> , determine the next line of code. You have imports: import time from yaspin import yaspin and context (class names, function names, or code) available: # Path:...
with yaspin(text="Downloading...") as sp:
Given snippet: <|code_start|>""" examples.dynamic_text ~~~~~~~~~~~~~~~~~~~~~ Evaluates text on every spinner frame. """ class TimedText: def __init__(self, text): self.text = text self._start = datetime.now() def __str__(self): now = datetime.now() delta = now - self._start...
with yaspin(text=TimedText("time passed:")):
Predict the next line after this snippet: <|code_start|>""" examples.right_spinner ~~~~~~~~~~~~~~~~~~~~~~ Left and Right spinner position. """ def main(): <|code_end|> using the current file's imports: import time from yaspin import yaspin and any relevant context from other files: # Path: yaspin/api.py # def ...
with yaspin(text="Right spinner", side="right", color="cyan") as sp:
Continue the code snippet: <|code_start|> ("simpleDots", 1), ("star", 0.5), ("balloon", 0.7), ("noise", 0.5), ("arc", 0.5), ("arrow2", 0.5), ("bouncingBar", 1), ("bouncingBall", 1), ("smiley", 0.7), ("hearts", 0.5), ("clock", 0.7), ...
with yaspin(spinner, text=text, color="cyan"):
Predict the next line after this snippet: <|code_start|>""" examples.demo ~~~~~~~~~~~~~ Yaspin features demonstration. """ <|code_end|> using the current file's imports: import random import time from yaspin import yaspin from yaspin.constants import COLOR_MAP from yaspin.spinners import Spinners and any releva...
COLORS = (k for k, v in COLOR_MAP.items() if v == "color")
Here is a snippet: <|code_start|>def any_spinner_you_like(): params = [ ("line", 0.8), ("dots10", 0.8), ("dots11", 0.8), ("simpleDots", 1), ("star", 0.5), ("balloon", 0.7), ("noise", 0.5), ("arc", 0.5), ("arrow2", 0.5), ("bouncingBar", ...
spinner = getattr(Spinners, name)
Based on the snippet: <|code_start|>""" examples.cli_spinners ~~~~~~~~~~~~~~~~~~~~~ Run all spinners from cli-spinners library: https://github.com/sindresorhus/cli-spinners Spinners are sorted alphabetically. """ def main(): for name in SPINNER_ATTRS: spinner = getattr(Spinners, name) <|code_end|> , p...
with yaspin(spinner, text=name):
Predict the next line for this snippet: <|code_start|>""" examples.cli_spinners ~~~~~~~~~~~~~~~~~~~~~ Run all spinners from cli-spinners library: https://github.com/sindresorhus/cli-spinners Spinners are sorted alphabetically. """ def main(): <|code_end|> with the help of current file imports: import time from ...
for name in SPINNER_ATTRS:
Given snippet: <|code_start|>""" examples.cli_spinners ~~~~~~~~~~~~~~~~~~~~~ Run all spinners from cli-spinners library: https://github.com/sindresorhus/cli-spinners Spinners are sorted alphabetically. """ def main(): for name in SPINNER_ATTRS: <|code_end|> , continue by predicting the next line. Consider cur...
spinner = getattr(Spinners, name)
Given snippet: <|code_start|> # SIG_DFL and SIG_IGN cases assert sig_handler == handler finally: sp.stop() def test_raise_exception_for_sigkill(): sp = yaspin(sigmap={signal.SIGKILL: signal.SIG_IGN}) try: with pytest.raises(ValueError): sp.start()...
sp = kbi_safe_yaspin()
Here is a snippet: <|code_start|>""" tests.test_signals ~~~~~~~~~~~~~~~~~~ Test Yaspin signals handling. """ def test_sigmap_setting(sigmap_test_cases): sigmap = sigmap_test_cases <|code_end|> . Write the next line using the current file imports: import functools import signal import pytest from yaspin impor...
sp = yaspin(sigmap=sigmap)
Given the following code snippet before the placeholder: <|code_start|> assert req.meta['depth'] == 1 and copy_req.meta['depth'] == 0 def test_replace_http_request(): req = HttpRequest('http://example.com/', 'POST', body=b'body1') new_req = req.replace(url='https://example.com/', body=b'body2') assert ...
resp = HttpResponse('http://example.com/', 200, body=b'body')
Given the following code snippet before the placeholder: <|code_start|># coding=utf-8 def test_copy_http_request(): req = HttpRequest('http://example.com/', params={'key': 'value'}, meta={'depth': 0}) copy_req = req.copy() assert copy_req.url == req.url params = get_params_in_url(copy_req.url) as...
headers = HttpHeaders()
Next line prediction: <|code_start|># coding=utf-8 def test_copy_http_request(): req = HttpRequest('http://example.com/', params={'key': 'value'}, meta={'depth': 0}) copy_req = req.copy() assert copy_req.url == req.url <|code_end|> . Use current file imports: (from xpaw.http import HttpRequest, HttpResp...
params = get_params_in_url(copy_req.url)
Next line prediction: <|code_start|># coding=utf-8 log = logging.getLogger(__name__) __all__ = ['DefaultHeadersMiddleware'] class DefaultHeadersMiddleware: def __init__(self, default_headers=None): self._headers = default_headers or {} def __repr__(self): cls_name = self.__class__.__name_...
raise NotEnabled
Predict the next line after this snippet: <|code_start|> """ method """ @staticmethod def staticmethod(): """ static method """ def method1(self): self.count1 += 1 @pytest.mark.asyncio async def method2(self): self.count2 += 1 de...
eventbus = EventBus()
Continue the code snippet: <|code_start|># coding=utf-8 class TestXPathSelector: def test_selector_list(self): html = """<li>a</li><div><ul><li>b</li><li>c</li></ul></div><ul><li>d</li></ul>""" <|code_end|> . Use current file imports: import pytest from xpaw.selector import Selector from lxml.e...
s = Selector(html)
Continue the code snippet: <|code_start|> @classmethod def from_dict(cls, d): return cls(**d) class HttpResponse: def __init__(self, url, status, body=None, headers=None, request=None, encoding=None): """ Construct an HTTP response. """ self.url = u...
encoding = get_encoding_from_content(self.body)
Given the following code snippet before the placeholder: <|code_start|> } return d @classmethod def from_dict(cls, d): return cls(**d) class HttpResponse: def __init__(self, url, status, body=None, headers=None, request=None, encoding=None): """ Con...
encoding = get_encoding_from_content_type(self.headers.get("Content-Type"))
Given the code snippet: <|code_start|># coding=utf-8 HttpHeaders = _HttpHeaders class HttpRequest: def __init__(self, url, method="GET", body=None, params=None, headers=None, proxy=None, timeout=20, verify_ssl=False, allow_redirects=True, auth=None, proxy_auth=None, priority=...
self.url = make_url(url, params)
Predict the next line for this snippet: <|code_start|># coding=utf-8 log = logging.getLogger(__name__) __all__ = ['SpeedLimitMiddleware'] class SpeedLimitMiddleware: def __init__(self, rate=1, burst=1): self._rate = rate self._burst = burst if self._rate <= 0: raise ValueEr...
raise NotEnabled
Predict the next line for this snippet: <|code_start|># coding=utf-8 log = logging.getLogger(__name__) __all__ = ['ProxyMiddleware'] class ProxyMiddleware: def __init__(self, proxy): self._proxies = {'http': None, 'https': None} self._set_proxy(proxy) def __repr__(self): cls_name ...
raise NotEnabled
Continue the code snippet: <|code_start|># coding=utf-8 class TestConfig: def test_get(self): d = {'key': 'value'} <|code_end|> . Use current file imports: from xpaw.config import Config and context (classes, functions, or code) from other files: # Path: xpaw/config.py # class Config(MutableMapping): ...
config = Config(d)
Predict the next line for this snippet: <|code_start|># coding=utf-8 log = logging.getLogger(__name__) class HashDupeFilter: def __init__(self): self._hash = set() def is_duplicated(self, request): if request.dont_filter: return False <|code_end|> with the help of current file...
h = request_fingerprint(request)
Continue the code snippet: <|code_start|># coding=utf-8 class Crawler: def __init__(self, **kwargs): self.event_bus = EventBus() <|code_end|> . Use current file imports: from xpaw.eventbus import EventBus from xpaw.config import Config, DEFAULT_CONFIG and context (classes, functions, or code) from othe...
self.config = Config(DEFAULT_CONFIG, **kwargs)
Given the following code snippet before the placeholder: <|code_start|># coding=utf-8 class Crawler: def __init__(self, **kwargs): self.event_bus = EventBus() <|code_end|> , predict the next line using imports from the current file: from xpaw.eventbus import EventBus from xpaw.config import Config, DEFA...
self.config = Config(DEFAULT_CONFIG, **kwargs)
Predict the next line for this snippet: <|code_start|> assert stats.get('key2') == 1 stats.inc('key3', start=1) assert stats.get('key3') == 2 stats.inc('key4', 2, start=3) assert stats.get('key4') == 5 def test_clear_stats(self): stats = StatsCollector() stats...
stats = DummyStatsCollector()
Using the snippet: <|code_start|># coding=utf-8 log = logging.getLogger(__name__) __all__ = ['DepthMiddleware'] class DepthMiddleware: def __init__(self, max_depth=None): self._max_depth = max_depth def __repr__(self): cls_name = self.__class__.__name__ return '{}(max_depth={})'.f...
if isinstance(r, HttpRequest):
Using the snippet: <|code_start|># coding=utf-8 class FooSpider(Spider): def __init__(self, *args, **kwargs): super().__init__(*args, **kwargs) self.data = self.config['data'] def open(self): super().open() self.data['open'] = '' def close(self): super().close(...
await crawler.event_bus.send(events.crawler_start)
Continue the code snippet: <|code_start|># coding=utf-8 class FooSpider(Spider): def __init__(self, *args, **kwargs): super().__init__(*args, **kwargs) self.data = self.config['data'] def open(self): super().open() self.data['open'] = '' def close(self): super(...
crawler = Crawler(data=data)
Using the snippet: <|code_start|> default_arguments = ['--headless', '--incognito', '--ignore-certificate-errors', '--ignore-ssl-errors', '--disable-gpu', '--no-sandbox'] default_prefs = {'profile.managed_default_content_settings.images': 2} def __init__(self, options=None): ...
response = HttpResponse(driver.current_url, 200, body=driver.page_source.encode('utf-8'),
Predict the next line after this snippet: <|code_start|> '--disable-gpu', '--no-sandbox'] default_prefs = {'profile.managed_default_content_settings.images': 2} def __init__(self, options=None): self.options = {'default': self.make_chrome_options()} if options: ...
headers=HttpHeaders(), request=request)
Here is a snippet: <|code_start|> chrome_options.add_argument('--ignore-certificate-errors') chrome_options.add_argument('--ignore-ssl-errors') chrome_options.add_argument('--disable-gpu') chrome_options.add_argument('--no-sandbox') prefs = {'profile.managed_default_content_settings.images': 2} c...
@log_time('reopen chrome')
Predict the next line for this snippet: <|code_start|># coding=utf-8 @pytest.mark.asyncio async def test_fifo_queue(): q = FifoQueue() with pytest.raises(asyncio.TimeoutError): with async_timeout.timeout(0.1): await q.pop() obj_list = [HttpRequest('1'), HttpRequest('2'), HttpRequest...
q = LifoQueue()
Continue the code snippet: <|code_start|> assert await q.pop() == obj_list[i] with pytest.raises(asyncio.TimeoutError): with async_timeout.timeout(0.1): await q.pop() @pytest.mark.asyncio async def test_lifo_queue(): q = LifoQueue() with pytest.raises(asyncio.TimeoutError): ...
q = PriorityQueue()
Given the following code snippet before the placeholder: <|code_start|># coding=utf-8 @pytest.mark.asyncio async def test_fifo_queue(): q = FifoQueue() with pytest.raises(asyncio.TimeoutError): with async_timeout.timeout(0.1): await q.pop() <|code_end|> , predict the next line using imp...
obj_list = [HttpRequest('1'), HttpRequest('2'), HttpRequest('3')]
Next line prediction: <|code_start|> async def pop(self): await self._semaphore.acquire() return self._queue.pop() class PriorityQueue: def __init__(self): self._queue = [] self._semaphore = Semaphore(0) def __len__(self): return len(self._queue) async def push...
return cmp((-self.priority, self.now), (-other.priority, other.now))
Continue the code snippet: <|code_start|> r_get_dont_filter = HttpRequest("http://example.com", dont_filter=True) r_get_dir = HttpRequest("http://example.com/") r_get_post = HttpRequest("http://example.com/post") r_post = HttpRequest("http://example.com/post", "POST") r_post_dir = HttpRequest("http:/...
run_any_dupe_filter(HashDupeFilter())
Using the snippet: <|code_start|># coding=utf-8 def run_any_dupe_filter(f): r_get = HttpRequest("http://example.com") r_get_port_80 = HttpRequest("http://example.com:80") r_get_port_81 = HttpRequest("http://example.com:81") r_get_dont_filter = HttpRequest("http://example.com", dont_filter=True) r...
r_get_param = HttpRequest(make_url("http://example.com/get", params={'k1': 'v1'}))
Next line prediction: <|code_start|># coding=utf-8 log = logging.getLogger(__name__) __all__ = ['RetryMiddleware'] class RetryMiddleware: <|code_end|> . Use current file imports: (import logging from xpaw.errors import ClientError, NotEnabled, HttpError from xpaw.utils import with_not_none_params) and context i...
RETRY_ERRORS = (ClientError,)
Predict the next line after this snippet: <|code_start|># coding=utf-8 log = logging.getLogger(__name__) __all__ = ['RetryMiddleware'] class RetryMiddleware: RETRY_ERRORS = (ClientError,) RETRY_HTTP_STATUS = (500, 502, 503, 504, 408, 429) def __init__(self, max_retry_times=3, retry_http_status=None):...
raise NotEnabled
Given the following code snippet before the placeholder: <|code_start|> def handle_response(self, request, response): for p in self._retry_http_status: if self.match_status(p, response.status): return self.retry(request, "HTTP status={}".format(response.status)) @staticmethod...
if isinstance(error, HttpError):
Here is a snippet: <|code_start|># coding=utf-8 log = logging.getLogger(__name__) __all__ = ['RetryMiddleware'] class RetryMiddleware: RETRY_ERRORS = (ClientError,) RETRY_HTTP_STATUS = (500, 502, 503, 504, 408, 429) def __init__(self, max_retry_times=3, retry_http_status=None): self._max_retr...
return cls(**with_not_none_params(max_retry_times=config.getint('max_retry_times'),
Next line prediction: <|code_start|># coding=utf-8 class ListHeapPriorityQueue: def __init__(self): self.q = [] def push(self, item): heappush(self.q, item) def pop(self): return heappop(self.q) <|code_end|> . Use current file imports: (import random from queue import Priori...
@log_time('prepare benchmark data')
Using the snippet: <|code_start|> 'values', 'cpt' *V* : a dict Notes ----- """ if file is not None: bn = ior.read_bn(file) self.V = bn.V self.E = bn.E self.F = ...
return are_class_equivalent(self, y)
Using the snippet: <|code_start|> skeleton after structure learning algorithms. See "structure_learn" folder & algorithms Arguments --------- *edge_dict* : a dictionary, where key = rv, value = list of rv's children NOTE: THIS MUST BE...
self.V = topsort(edge_dict)
Predict the next line after this snippet: <|code_start|>""" ****************************** Conditional Independence Tests for Constraint-based Learning ****************************** Implemented Constraint-based Tests ---------------------------------- - mutual information - Pearson's X^2 I may consider putting this...
bins = unique_bins(data)
Continue the code snippet: <|code_start|>""" ******** UnitTest Misc ******** """ __author__ = """Nicholas Cullen <ncullen.th@dartmouth.edu>""" class RandomSampleTestCase(unittest.TestCase): def setUp(self): self.dpath = os.path.join(dirname(dirname(dirname(dirname(__file__)))),'data') self.bn = read_bn(os.p...
sample = random_sample(self.bn,5)
Given the code snippet: <|code_start|> _T = range(n_rv) else: assert (not isinstance(feature_selection, list)), 'feature_selection must be only one value' _T = [feature_selection] # LEARN MARKOV BLANKET for T in _T: V = set(range(n_rv)) - {T} Mb_change=True # GROWING PHASE while Mb_change: Mb_chan...
if are_independent(data[:,cols]):
Based on the snippet: <|code_start|> Returns ------- *bn* : a BayesNet object Effects ------- None Notes ----- """ n_rv = data.shape[1] Mb = dict([(rv,{}) for rv in range(n_rv)]) if feature_selection is None: _T = range(n_rv) else: assert (not isinstance(feature_selection, list)), 'feature_selection ...
H_tmb = entropy(data[:,cols])
Continue the code snippet: <|code_start|>#!/usr/bin/env python3 '''ARM multisample discarding extension for EGL. This extension allows the multisample buffer of pixmap surface to be marked as discardable. This is aimed at GPU hardware that does all multisampled rendering internally and only writes downsampled data to...
SurfaceAttribs.extend('DISCARD_SAMPLES', 0x3286, bool, False)
Given the code snippet: <|code_start|>multisampled rendering internally and only writes downsampled data to external memory, thus making the EGL multisample buffer redundant. ''' # Copyright © 2014 Tim Pederick. # # This file is part of Pegl. # # Pegl is free software: you can redistribute it and/or modify it # under ...
PixmapSurface.samples_discardable = property(samples_discardable)
Given snippet: <|code_start|> # Subclass SyncAttribs to generate wider native values, and add the new sync # attribute. class WideSyncAttribs(SyncAttribs): '''The set of attributes relevant to sync objects. Unlike the superclass, SyncAttribs, this class uses a native type that can fit any pointer, avoiding...
class OpenCLSync(FenceSync):
Given the code snippet: <|code_start|># Pegl is free software: you can redistribute it and/or modify it # under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # Pegl is distributed in the hope that i...
class WideSyncAttribs(SyncAttribs):
Given the following code snippet before the placeholder: <|code_start|># # Pegl is free software: you can redistribute it and/or modify it # under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # Peg...
(c_display, c_sync), fail_on=NO_NATIVE_FENCE_FD)
Given the following code snippet before the placeholder: <|code_start|># Pegl is distributed in the hope that it will be useful, but WITHOUT # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY # or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public # License for more details. # # You should h...
class NativeFenceSync(Sync):
Given the code snippet: <|code_start|># the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # Pegl is distributed in the hope that it will be useful, but WITHOUT # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY # or FITNESS FOR A PARTICULAR PURPO...
SyncAttribs.extend('NATIVE_FENCE_FD', 0x3145, c_int, NO_NATIVE_FENCE_FD)
Continue the code snippet: <|code_start|># # Pegl is free software: you can redistribute it and/or modify it # under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # Pegl is distributed in the hope t...
(c_display, c_sync), fail_on=NO_NATIVE_FENCE_FD)
Predict the next line for this snippet: <|code_start|>#!/usr/bin/env python3 '''Cross-vendor Wayland platform support extension for EGL. This extension adds the Wayland display server as an explicitly supportable native platform. http://www.khronos.org/registry/egl/extensions/EXT/EGL_EXT_platform_wayland.txt ''' # ...
class WaylandDisplay(PlatformDisplay):