Instruction
stringlengths
362
7.83k
output_code
stringlengths
1
945
Based on the snippet: <|code_start|> admin.autodiscover() app_name = "test_accounts" urlpatterns = [ path( "register/", include( ModelInvitation(org_model=Account, namespace="invitations").urls, namespace="account_invitations", <|code_end|> , predict the immediate next lin...
),
Based on the snippet: <|code_start|># -*- coding: utf-8 -*- @override_settings(USE_TZ=True) class ActiveManagerTests(TestCase): fixtures = ["users.json", "orgs.json"] def test_active(self): self.assertEqual(3, Organization.objects.all().count()) <|code_end|> , predict the immediate next line with ...
self.assertEqual(2, Organization.active.all().count())
Predict the next line for this snippet: <|code_start|># -*- coding: utf-8 -*- @override_settings(USE_TZ=True) class ActiveManagerTests(TestCase): fixtures = ["users.json", "orgs.json"] def test_active(self): self.assertEqual(3, Organization.objects.all().count()) self.assertEqual(2, Organi...
class OrgModelTests(TestCase):
Predict the next line for this snippet: <|code_start|># -*- coding: utf-8 -*- @override_settings(USE_TZ=True) class ActiveManagerTests(TestCase): fixtures = ["users.json", "orgs.json"] def test_active(self): <|code_end|> with the help of current file imports: from functools import partial from django.co...
self.assertEqual(3, Organization.objects.all().count())
Predict the next line for this snippet: <|code_start|> @fixture def tmpfile(tmpdir): tmpfile = tmpdir.join('tmpfile') assert not tmpfile.exists() yield tmpfile.strpath def assert_locked(tmpfile): with ShouldRaise(flock.Locked(tmpfile)): with flock(tmpfile): raise AssertionError('...
assert_locked(tmpfile)
Given the code snippet: <|code_start|> pytestmark = pytest.mark.usefixtures('in_example_dir') SLOW_STARTUP_TIME = 6 @pytest.fixture def service_name(): yield 'poll-ready-quick-shutdown' def it_stops_quickly(): """Tests a regression in pgctl where services using pgctl-poll-ready fail to stop because th...
assert poststop_time - prestop_time < 2
Given snippet: <|code_start|> if error.errno == 3: # no such process pass else: raise limit -= 1 class DirtyTest: @pytest.fixture(autouse=True) def cleanup(self, in_example_dir): try: yield in_...
def it_starts_up_fine(self):
Given snippet: <|code_start|> def clean_service(service_path): # we use SIGTERM; SIGKILL is cheating. limit = 100 while limit > 0: # pragma: no branch: we don't expect to ever hit the limit assert os.path.isdir(service_path), service_path try: show_runaway_processes(service_p...
os.kill(pid, signal.SIGTERM)
Given snippet: <|code_start|> def clean_service(service_path): # we use SIGTERM; SIGKILL is cheating. limit = 100 while limit > 0: # pragma: no branch: we don't expect to ever hit the limit assert os.path.isdir(service_path), service_path <|code_end|> , continue by predicting the next line. Cons...
try:
Using the snippet: <|code_start|> if error.errno == 3: # no such process pass else: raise limit -= 1 class DirtyTest: @pytest.fixture(autouse=True) def cleanup(self, in_example_dir): try: yield...
def it_starts_up_fine(self):
Given the following code snippet before the placeholder: <|code_start|> def clean_service(service_path): # we use SIGTERM; SIGKILL is cheating. limit = 100 while limit > 0: # pragma: no branch: we don't expect to ever hit the limit assert os.path.isdir(service_path), service_path try: ...
try:
Predict the next line after this snippet: <|code_start|> class DescribeRetry: def it_can_succeed(self): assert wait_for(lambda: True) is True def it_can_fail(self): <|code_end|> using the current file's imports: from testfixtures import ShouldRaise from .assertions import wait_for and any relevan...
with ShouldRaise(AssertionError('assert (False is None or False)')):
Predict the next line after this snippet: <|code_start|> @pytest.fixture(autouse=True) def sleep_short_background_long_foreground(): with set_slow_shutdown_sleeptime(0.75, 2.25): yield @pytest.mark.parametrize('service_name', ['slow-shutdown']) <|code_end|> using the current file's imports: from time...
@pytest.mark.usefixtures('in_example_dir')
Given the code snippet: <|code_start|> @pytest.fixture(autouse=True) def sleep_short_background_long_foreground(): with set_slow_shutdown_sleeptime(0.75, 2.25): yield @pytest.mark.parametrize('service_name', ['slow-shutdown']) @pytest.mark.usefixtures('in_example_dir') def it_is_disallowed(): <|code_en...
assert_command(
Given the following code snippet before the placeholder: <|code_start|> class ANY_INTEGER: def __eq__(self, other): return isinstance(other, int) class DescribePgctlLog: @pytest.fixture def service_name(self): yield 'output' def it_is_empty_before_anything_starts(self, in_example...
('pgctl', 'log'),
Here is a snippet: <|code_start|> class ANY_INTEGER: def __eq__(self, other): return isinstance(other, int) class DescribePgctlLog: @pytest.fixture def service_name(self): yield 'output' def it_is_empty_before_anything_starts(self, in_example_dir): <|code_end|> . Write the next l...
assert_command(
Given snippet: <|code_start|> class ANY_INTEGER: def __eq__(self, other): return isinstance(other, int) class DescribePgctlLog: @pytest.fixture def service_name(self): yield 'output' def it_is_empty_before_anything_starts(self, in_example_dir): assert_command( <|code_end|...
('pgctl', 'log'),
Continue the code snippet: <|code_start|> @contextmanager def setup(tmpdir): etc = tmpdir.ensure_dir('etc') home = tmpdir.ensure_dir('home') app = tmpdir.ensure_dir('app') a = app.ensure_dir('a') b = a.ensure_dir('b') c = b.ensure_dir('c') etc.join('my.conf').write('[my]\netc = etc') ...
app = app
Next line prediction: <|code_start|> assert read_line(read) == 'What is your name?\n' proc.stdin.write(b'Buck\n') proc.stdin.flush() assert read_line(read) == 'Hello, Buck.\n' finally: ctrl_c(proc) proc.wait() @greeter_service def it_works_with_nothing_running(): ...
assert_works_interactively()
Predict the next line for this snippet: <|code_start|> pytestmark = pytest.mark.usefixtures('in_example_dir') greeter_service = pytest.mark.parametrize('service_name', ['greeter']) unreliable_service = pytest.mark.parametrize('service_name', ['unreliable']) def read_line(fd): # read one-byte-at-a-time to avoid ...
byte = read(fd, 1).decode('utf-8')
Using the snippet: <|code_start|> pytestmark = pytest.mark.usefixtures('in_example_dir') greeter_service = pytest.mark.parametrize('service_name', ['greeter']) unreliable_service = pytest.mark.parametrize('service_name', ['unreliable']) def read_line(fd): # read one-byte-at-a-time to avoid deadlocking by readin...
read, write = os.openpty()
Given snippet: <|code_start|> pytestmark = pytest.mark.usefixtures('in_example_dir') greeter_service = pytest.mark.parametrize('service_name', ['greeter']) unreliable_service = pytest.mark.parametrize('service_name', ['unreliable']) def read_line(fd): # read one-byte-at-a-time to avoid deadlocking by reading to...
line = ''
Given the code snippet: <|code_start|> class DescribeUnique: def it_does_not_have_duplicates(self): data = ['b', 'b', 'b'] assert list(unique(data)) == ['b'] def it_removes_duplicates_with_first_one_wins_mentality(self): data = ['a', 'b', 'c', 'b', 'd', 'a'] assert list(uniq...
'aliases': frozendict({
Predict the next line for this snippet: <|code_start|> @pytest.fixture(autouse=True) def in_tmpdir(tmpdir): with tmpdir.as_cwd(): yield class DescribeFloatFile: def it_loads_files(self): filename = 'notification-fd' with open(filename, 'w') as f: f.write('5') re...
assert result == 5.0
Predict the next line for this snippet: <|code_start|>def svstat_parse(svstat_string): r''' >>> svstat_parse('up (pid 3714560) 13 seconds, normally down, ready 7 seconds\n') ready (pid 3714560) 7 seconds >>> svstat_parse('up (pid 1202562) 100 seconds, ready 10 seconds\n') ready (pid 1202562) 10 sec...
could not get status, supervisor is down
Using the snippet: <|code_start|> ready (pid 3714560) 7 seconds >>> svstat_parse('up (pid 1202562) 100 seconds, ready 10 seconds\n') ready (pid 1202562) 10 seconds >>> svstat_parse('up (pid 1202562) 100 seconds\n') up (pid 1202562) 100 seconds >>> svstat_parse('down 4334 seconds, normally up, ...
no such service
Using the snippet: <|code_start|>def svstat_parse(svstat_string): r''' >>> svstat_parse('up (pid 3714560) 13 seconds, normally down, ready 7 seconds\n') ready (pid 3714560) 7 seconds >>> svstat_parse('up (pid 1202562) 100 seconds, ready 10 seconds\n') ready (pid 1202562) 10 seconds >>> svstat_...
could not get status, supervisor is down
Continue the code snippet: <|code_start|> up (pid 1202562) 100 seconds >>> svstat_parse('down 4334 seconds, normally up, want up') down 4334 seconds, starting >>> svstat_parse('down (exitcode 0) 0 seconds, normally up, want up, ready 0 seconds') down (exitcode 0) 0 seconds, starting >>> svstat...
Traceback (most recent call last):
Given the following code snippet before the placeholder: <|code_start|> string = string[len(start):] try: result, string = string.split(divider, 1) except ValueError: # if there's no separator found and we found the `start` token, the whole input is the result ...
>>> svstat_parse('down 0 seconds, normally up')
Based on the snippet: <|code_start|> status = status.decode('UTF-8') #status is listed per line for each argument return status def parse(string, start, divider, type=str): """general purpose tokenizer, used below""" if string.startswith(start): string = string[len(start):] try: ...
>>> svstat_parse('up (pid 1202562) 100 seconds\n')
Next line prediction: <|code_start|> def test_tailer(tmp_path): file_a = (tmp_path / 'a').open('a+') file_b = (tmp_path / 'b').open('a+') # At the start there should be no lines. tailer = Tailer((file_a.name, file_b.name)) assert tailer.new_lines_available() is False assert tailer.get_logs()...
file_b.flush()
Next line prediction: <|code_start|> def test_tailer(tmp_path): file_a = (tmp_path / 'a').open('a+') file_b = (tmp_path / 'b').open('a+') # At the start there should be no lines. tailer = Tailer((file_a.name, file_b.name)) assert tailer.new_lines_available() is False assert tailer.get_logs() =...
]
Given snippet: <|code_start|> def startElement(self, name, attrs): """map element stream to ET elements as they occur""" # first level, stream starts if self.depth == 0: if name != "stream:stream": raise BadFormatError self.streamhandler(attrs) ...
retdict = OrderedDict(attrs.items())
Next line prediction: <|code_start|> if self.depth == 0: if name != "stream:stream": raise BadFormatError self.streamhandler(attrs) self.depth = 1 # second level creates element tree else: self.treebuilder.start(name, self.makedictfr...
return retdict
Continue the code snippet: <|code_start|> """map element stream to ET elements as they occur""" # first level, stream starts if self.depth == 0: if name != "stream:stream": raise BadFormatError self.streamhandler(attrs) self.depth = 1 # ...
for k, v in attrs.items():
Next line prediction: <|code_start|> class UserTests(TestCase): def setUp(self): self.m_session = mock.Mock() self.m_session.get.return_value = get_fake_response(data={'id': 'foo'}) self.user = user.User(self.m_session) def test_id_is_foo(self): self.assertEqual(self.user.me['...
self.m_session.post.return_value = mock.Mock(ok=True)
Based on the snippet: <|code_start|>class UserTests(TestCase): def setUp(self): self.m_session = mock.Mock() self.m_session.get.return_value = get_fake_response(data={'id': 'foo'}) self.user = user.User(self.m_session) def test_id_is_foo(self): self.assertEqual(self.user.me['id'...
def setUp(self):
Based on the snippet: <|code_start|> class UserTests(TestCase): def setUp(self): self.m_session = mock.Mock() self.m_session.get.return_value = get_fake_response(data={'id': 'foo'}) self.user = user.User(self.m_session) def test_id_is_foo(self): self.assertEqual(self.user.me['...
(__, id_), __ = m_blocks.Blocks.call_args
Using the snippet: <|code_start|> class ChatsTests(unittest.TestCase): def setUp(self): self.m_session = mock.Mock() self.chats = chats.Chats(self.m_session) class ListChatsTests(ChatsTests): def setUp(self): super().setUp() m_chat = { 'other_user': {'id': 42}, ...
'created_at': 123457890,
Here is a snippet: <|code_start|> class ChatsTests(unittest.TestCase): def setUp(self): self.m_session = mock.Mock() self.chats = chats.Chats(self.m_session) class ListChatsTests(ChatsTests): def setUp(self): super().setUp() m_chat = { <|code_end|> . Write the next line using...
'other_user': {'id': 42},
Given the code snippet: <|code_start|> class GroupPostTests(GroupTests): def setUp(self): super().setUp() self.group.messages = mock.Mock() self.result = self.group.post(text='foo') def test_messages_used(self): self.assertTrue(self.group.messages.create.called) class GroupUpd...
def setUp(self):
Given the code snippet: <|code_start|> self.assertEqual(self.group, group) def test_different_group_id(self): group = groups.Group(mock.Mock(), **get_fake_group_data()) group.group_id = 2 * self.group.group_id self.assertNotEqual(self.group, group) class GroupReprTests(GroupTests):...
self.assertTrue(self.group.manager.update.called)
Based on the snippet: <|code_start|> class GroupTests(TestCase): def setUp(self): self.group = groups.Group(mock.Mock(), **get_fake_group_data()) class GroupEqualityTests(GroupTests): def test_same_group_id(self): group = groups.Group(mock.Mock(), **get_fake_group_data()) self.assertEq...
self.assertTrue(self.group.messages.create.called)
Next line prediction: <|code_start|> def setUp(self): super().setUp() self.group.rejoin() def test_manager_used(self): self.assertTrue(self.group.manager.rejoin.called) class GroupRefreshFromServerTests(GroupTests): def setUp(self): super().setUp() self.members = [g...
for code in self.known_codes:
Predict the next line for this snippet: <|code_start|> self.assertTrue(all(isinstance(g, groups.Group) for g in self.results)) def test_results_is_a_list(self): self.assertTrue(isinstance(self.results, list)) class ListCurrentGroupsTests(GroupsTests): def setUp(self): super().setUp() ...
class CreateGroupTests(GroupsTests):
Next line prediction: <|code_start|> self.group.messages = mock.Mock() self.result = self.group.post(text='foo') def test_messages_used(self): self.assertTrue(self.group.messages.create.called) class GroupUpdateTests(GroupTests): def setUp(self): super().setUp() self.gr...
def test_manager_used(self):
Given snippet: <|code_start|> __, kwargs = self.m_session.post.call_args message = kwargs['json']['message'] self.assertEqual(message['text'], 'qux') def test_payload_lacks_attachments(self): __, kwargs = self.m_session.post.call_args message = kwargs['json']['message'] ...
message = kwargs['json']['message']
Given the code snippet: <|code_start|> class AttachmentTests(base.TestCase): def setUp(self): self.m_manager = mock.Mock() class AttachmentToJsonTests(AttachmentTests): def test_json_is_correct(self): a = messages.Attachment(type='foo', text='bar') self.assertEqual(a.to_json(), {'type'...
self.m_session = mock.Mock()
Continue the code snippet: <|code_start|> class LikeGenericMessageTests(GenericMessageTests): def setUp(self): super().setUp() self.message._likes = mock.Mock() def test_like_uses_likes(self): self.message.like() self.assertTrue(self.message._likes.like.called) def test_un...
self.assertEqual(self.message.conversation_id, self.message.group_id)
Given snippet: <|code_start|> def __init__(self, session): super().__init__(session, 'users') self._me = None self._blocks = None self.sms_mode = SmsMode(self.session) @property def blocks(self): if self._blocks is None: self._blocks = blocks.Blocks(self.s...
def __init__(self, session):
Using the snippet: <|code_start|> class TestAttachmentsFromData(unittest.TestCase): def test_known_attachment_type(self): data = {'type': 'split', 'token': 'foo'} attachment = attachments.Attachment.from_data(**data) self.assertIsInstance(attachment, attachments.Split) def test_unknow...
def test_known_attachment_type_with_unknown_field(self):
Given the code snippet: <|code_start|> class SessionTests(unittest.TestCase): def setUp(self): self.token = 'abc123' self.session = session.Session(self.token) self.url = 'https://example.com/foo' @responses.activate <|code_end|> , generate the next line using the imports in this fil...
def test_token_is_present_in_headers(self):
Given the following code snippet before the placeholder: <|code_start|> self.url = 'https://example.com/foo' @responses.activate def test_token_is_present_in_headers(self): responses.add(responses.GET, self.url) self.session.get(self.url) self.assertEqual(responses.calls[0].reque...
@responses.activate
Continue the code snippet: <|code_start|> def test_token_is_present_in_headers(self): responses.add(responses.GET, self.url) self.session.get(self.url) self.assertEqual(responses.calls[0].request.headers['x-access-token'], self.token) def test_content_type_is_jso...
self.url = 'https://example.com/foo'
Next line prediction: <|code_start|> self.session = session.Session(self.token) self.url = 'https://example.com/foo' @responses.activate def test_token_is_present_in_headers(self): responses.add(responses.GET, self.url) self.session.get(self.url) self.assertEqual(response...
class RequestTests(unittest.TestCase):
Predict the next line for this snippet: <|code_start|> class SessionTests(unittest.TestCase): def setUp(self): self.token = 'abc123' self.session = session.Session(self.token) self.url = 'https://example.com/foo' @responses.activate <|code_end|> with the help of current file imports...
def test_token_is_present_in_headers(self):
Given the following code snippet before the placeholder: <|code_start|> class SessionTests(unittest.TestCase): def setUp(self): self.token = 'abc123' self.session = session.Session(self.token) self.url = 'https://example.com/foo' @responses.activate def test_token_is_present_in_h...
self.assertIn('content-type', headers)
Next line prediction: <|code_start|> class BlocksTests(unittest.TestCase): def setUp(self): self.m_session = mock.Mock() self.user_id = 'foo' self.blocks = blocks.Blocks(self.m_session, self.user_id) class BlocksListTests(BlocksTests): def setUp(self): super().setUp() ...
def test_user_id_is_in_params(self):
Using the snippet: <|code_start|> class ListBotsTests(BotsTests): def setUp(self): super().setUp() self.m_session.get.return_value = mock.Mock(data=[{'x': 'X'}]) self.results = self.bots.list() def test_results_are_bots(self): self.assertTrue(all(isinstance(b, bots.Bot) for b in...
def test_details_in_payload(self):
Given the following code snippet before the placeholder: <|code_start|> class MangerTests(unittest.TestCase): def setUp(self): self.manager = base.Manager(mock.Mock(), path='foo') def test_url_contains_path(self): self.assertEqual(self.manager.url, self.manager.base_url + 'foo') class Resou...
self.data = {'foo': 'bar'}
Given snippet: <|code_start|> def test_result_is_not_ready(self): self.assertFalse(self.is_ready) def test_getting_result_raises_not_ready_exception(self): with self.assertRaises(ResultsNotReady): self.request.get() class ExpiredResultsTests(MembershipRequestTests): def setUp(s...
self.assertNotEqual(len(self.results.members), len(self.requests))
Given the following code snippet before the placeholder: <|code_start|> def test_result_is_ready(self): self.assertTrue(self.is_ready) def test_results_are_members(self): for member in self.results.members: with self.subTest(member=member): self.assertIsInstance(memb...
self.request.get()
Predict the next line after this snippet: <|code_start|> def setUp(self): super().setUp() self.member.unblock() def test_uses_user_id(self): self.assert_kwargs(self._blocks.unblock, other_user_id=self.data['user_id']) class RemoveMemberTests(MemberTests): ...
def setUp(self):
Next line prediction: <|code_start|> with self.assertRaises(ResultsExpired): self.memberships.check('bar') def test_results_available(self): data = {'members': [{'baz': 'qux'}]} self.m_session.get.return_value = get_fake_response(data=data) result = self.memberships.check...
self.assertEqual(self.member, member)
Predict the next line for this snippet: <|code_start|>class RemoveMembershipTests(MembershipsTests): def test_result_is_True(self): self.m_session.post.return_value = mock.Mock(ok=True) self.assertTrue(self.memberships.remove('bar')) class MemberTests(TestCase): @mock.patch('groupy.api.members...
super().setUp()
Given snippet: <|code_start|> class ExpiredResultsTests(MembershipRequestTests): def setUp(self): super().setUp() self.m_manager.check.side_effect = ResultsExpired(response=None) self.is_ready = self.request.is_ready() def test_result_is_ready(self): self.assertTrue(self.is_rea...
self.assertEqual(self.results.failures, self.requests[:1])
Here is a snippet: <|code_start|> def test_path_appending(self): url = utils.urljoin(self.url, 'bar') self.assertEqual(url, 'http://example.com/foo/bar') class TrailingSlashUrlJoinTests(UrlJoinTests): url = 'http://example.com/foo/' class ParseShareUrlTests(unittest.TestCase): url = 'http...
mock.Mock(foo='bar', baz=1),
Using the snippet: <|code_start|> class UrlJoinTests(unittest.TestCase): url = 'http://example.com/foo' def test_result_is_base_when_no_path(self): self.assertEqual(utils.urljoin(self.url), self.url) def test_path_appending(self): url = utils.urljoin(self.url, 'bar') self.assertEq...
class TrailingSlashParseShareUrlTests(ParseShareUrlTests):
Based on the snippet: <|code_start|> class PagerTests(unittest.TestCase): def setUp(self): self.m_manager = mock.Mock() self.m_endpoint = mock.Mock() self.m_endpoint.side_effect = ['abc', 'xyz'] self.params = {'x': 42} self.pager = pagers.Pager(self.m_manager, self.m_endpoi...
self.assertEqual(items, list('abcxyz'))
Given the code snippet: <|code_start|> class ImagesTests(unittest.TestCase): def setUp(self): self.m_session = mock.Mock() self.images = attachments.Images(self.m_session) class UploadImageTests(ImagesTests): def setUp(self): super().setUp() self.m_session.post.return_value =...
def test_result_is_content(self):
Predict the next line for this snippet: <|code_start|># # Zoe documentation build configuration file, created by # sphinx-quickstart on Fri Sep 11 15:11:20 2015. # # This file is execfile()d with the current directory set to its # containing dir. # # Note that not all possible configuration values are present in this #...
'sphinx.ext.coverage',
Predict the next line for this snippet: <|code_start|> def can_handle(opts, spec: str) -> bool: """The gen spec follows gen:[key=value[,key=value]] format.""" return spec.startswith("gen:") @staticmethod def check(opts, spec: str) -> Tuple[couchbaseConstants.PUMP_ERROR, Optional[Dict[str, An...
'xattr': False}
Predict the next line for this snippet: <|code_start|> if not buckets: return f'error: no bucket subdirectories at: {d}', None return 0, {'spec': spec, 'buckets': buckets} @staticmethod def vbucket_states(opts, spec, bucket_dir) -> Tuple[couchbaseConstants.PUMP_ERROR, Optional[Dict[...
if vbucket_states:
Using the snippet: <|code_start|> vbucket_id = None # Level of indirection since we can't use python 3 nonlocal statement. abatch: List[pump.Batch] = [pump.Batch(self)] def change_callback(doc_info): if doc_info: # Handle the new key name spacing for collecti...
rev_meta_bytes = doc_info.revMeta.get_bytes()
Here is a snippet: <|code_start|> else: return f'error: {str_msg}', None, None elif r_status == couchbaseConstants.ERR_UNKNOWN_COMMAND: if self.op_map == OP_MAP: if not retry: return f'erro...
m = self.op_map.get(op, None)
Given the following code snippet before the placeholder: <|code_start|> # Send all of the keys in quiet for opaque, kv in opaqued.items(): self._send_cmd(couchbaseConstants.CMD_SETQ, kv[0], kv[1], opaque, extra) self._send_cmd(couchbaseConstants.CMD_NOOP, b'', b'', terminal) ...
self._send_cmd(couchbaseConstants.CMD_DELETEQ, k, b'', opaque, extra)
Here is a snippet: <|code_start|> return failed def del_multi(self, items): """Multi-delete (using delq). Give me a collection of keys.""" opaqued = dict(enumerate(items)) terminal = len(opaqued) + 10 extra = b'' # Send all of the keys in quiet for...
def stats(self, sub: bytes = b''):
Next line prediction: <|code_start|> self.vbucket_id = vbucket return self._do_cmd(couchbaseConstants.CMD_GET_VBUCKET_STATE, b'', b'') def delete_vbucket(self, vbucket: int): assert isinstance(vbucket, int) self.vbucket_id = vbucket return self._do_cmd(couchbaseConstants.CMD_...
else:
Given the following code snippet before the placeholder: <|code_start|> return self._do_cmd(couchbaseConstants.CMD_SET_PARAM, key, val, type_bytes) def set_vbucket_state(self, vbucket: int, state_name: str): assert isinstance(vbucket, int) self.vbucket_id = vbucket state = struct.pac...
self._send_cmd(couchbaseConstants.CMD_GETQ, v, b'', k)
Given snippet: <|code_start|> """Get values for any available keys in the given iterable. Returns a dict of matched keys to their values.""" opaqued = dict(enumerate(keys)) terminal = len(opaqued) + 10 # Send all of the keys in quiet for k, v in opaqued.items(): ...
items = items.items()
Based on the snippet: <|code_start|> opaque, cas, data = self._handle_single_response(None) # type: ignore if opaque != terminal: rv[opaqued[opaque]] = self.__parse_get((opaque, cas, data)) # type: ignore else: done = True return rv def ...
while not done:
Here is a snippet: <|code_start|> return self._do_cmd(couchbaseConstants.CMD_SET_PARAM, key, val, type_bytes) def set_vbucket_state(self, vbucket: int, state_name: str): assert isinstance(vbucket, int) self.vbucket_id = vbucket state = struct.pack(couchbaseConstants.VB_SET_PKT_FMT, ...
self._send_cmd(couchbaseConstants.CMD_GETQ, v, b'', k)
Given the following code snippet before the placeholder: <|code_start|> class Assinatura(_Assinatura): def assina_xml(self, xml_element): cert, key = extract_cert_and_key_from_pfx(self.arquivo, self.senha) for element in xml_element.iter("*"): if element.text is not None and not eleme...
signature = signed_root.find(
Predict the next line for this snippet: <|code_start|> class Assinatura(_Assinatura): def assina_xml(self, xml_element): cert, key = extract_cert_and_key_from_pfx(self.arquivo, self.senha) for element in xml_element.iter("*"): if element.text is not None and not element.text.strip(): ...
)
Next line prediction: <|code_start|># -*- coding: utf-8 -*- # © 2016 Danimar Ribeiro, Trustcode # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). class Assinatura(object): def __init__(self, arquivo, senha): self.arquivo = arquivo self.senha = senha def assina_xml(self, xm...
digest_algorithm="sha1",
Given snippet: <|code_start|># -*- coding: utf-8 -*- # © 2016 Danimar Ribeiro, Trustcode # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). class Assinatura(object): def __init__(self, arquivo, senha): self.arquivo = arquivo self.senha = senha def assina_xml(self, xml_eleme...
ns = {}
Here is a snippet: <|code_start|>__author__ = 'JunSong<songjun54cm@gmail.com>' # Date: 2018/12/13 class TFDatasetDataProvider(BasicDataProvider): def __init__(self): super(TFDatasetDataProvider, self).__init__() self.train_data_iter = None self.valid_data_iter = None self.test_dat...
raise NotImplementError
Predict the next line for this snippet: <|code_start|># # Hornet - SSH Honeypot # # Copyright (C) 2015 Aniket Panse <aniketpanse@gmail.com> # # This program 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, eith...
def tearDown(self):
Predict the next line for this snippet: <|code_start|> gevent.sleep(0) port = honeypot.server.server_port client = paramiko.SSHClient() client.set_missing_host_key_policy(paramiko.AutoAddPolicy()) # If we log in properly, this should raise no errors client.connect('127...
command_output = '\r\n'.join(lines[1:-1])
Next line prediction: <|code_start|> gevent.sleep(0) # :-( output = '' while not output.endswith('$ '): output += channel.recv(1) lines = output.split('\r\n') command = lines[0] command_output = '\r\n'.join(lines[1:-1]) next_prompt = lines[-1] ...
while not channel.recv_ready():
Predict the next line for this snippet: <|code_start|> self.assertTrue(lines[1].startswith('--')) self.assertTrue('http://pathod.net/response_preview?spec=200:r' in lines[1]) self.assertEquals('Resolving pathod.net (pathod.net)... ' 'failed: Name or service not known.', ...
welcome += channel.recv(1)
Predict the next line for this snippet: <|code_start|># !/usr/bin/env python # # Hornet - SSH Honeypot # # Copyright (C) 2015 Aniket Panse <aniketpanse@gmail.com> # # This program 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 So...
test_config = os.path.join(os.path.dirname(hornet.__file__), 'data', 'default_config.json')
Next line prediction: <|code_start|> self.shell.writeline('HTTP request sent, awaiting response... 200 OK') self.shell.writeline('Length: {} ({}) [{}]'.format( self.total_size, human_readable(self.total_size), self.content_type )) self.shell.writeline('...
)
Predict the next line for this snippet: <|code_start|># 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. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WAR...
'a': 1,
Based on the snippet: <|code_start|> account.followers_count = user['followers_count'] # If the endorser is set, update it. if endorser is not None: account.endorser = endorser account.save() except Account.DoesNotExist: ...
name=user['name'],
Given the following code snippet before the placeholder: <|code_start|> class TestShortenFilter(TestCase): expected = { 12345678: '12M', 1234567: '1.2M', <|code_end|> , predict the next line using imports from the current file: from django.test import TestCase from endorsements.templatetags.endor...
123456: '123K',
Predict the next line for this snippet: <|code_start|> URL = 'https://en.wikipedia.org/w/api.php?action=parse&page={slug}&prop=text&format=json&section={section}' SLUG = 'United_States_presidential_election,_2016' SECTION = 36 class Command(BaseCommand): help = 'Bulk import all the election results by state' ...
)
Predict the next line for this snippet: <|code_start|> def add_arguments(self, parser): parser.add_argument( '--create', action='store_true', dest='create', default=False, help="Creates everything (otherwise, it's a dry run)", ) def ha...
continue
Based on the snippet: <|code_start|> response = requests.get(url) data = response.json() text = data['parse']['text']['*'] soup = BS(text) results = {} for i, table_row in enumerate(soup.findAll('tr')): if i < 5 or i > 60: continue ...
(table_cells[3].string or '0').strip('%')
Continue the code snippet: <|code_start|> data = response.json() text = data['parse']['text']['*'] soup = BS(text) results = {} for i, table_row in enumerate(soup.findAll('tr')): if i < 5 or i > 60: continue table_cells = table_row.findAll...
),