Instruction stringlengths 362 7.83k | output_code stringlengths 1 945 |
|---|---|
Given snippet: <|code_start|>
class ResourceTests(TestCase):
def setUp(self):
self.TEST_URL = 'https://www.google.com'
<|code_end|>
, continue by predicting the next line. Consider current file imports:
import os
import requests
from unittest import TestCase
from mock import patch, call, Mock
from new... | @patch.object(os.environ, 'get', spec_set=True) |
Given the following code snippet before the placeholder: <|code_start|>
class NRLabelsTests(TestCase):
def setUp(self):
super(NRLabelsTests, self).setUp()
self.label = Labels(api_key='dummy_key')
label = {
"key": "Ambition:Production",
"category": "Ambition",
<|co... | "name": "Production", |
Next line prediction: <|code_start|>
class NRBrowserApplicationsTests(TestCase):
def setUp(self):
super(NRBrowserApplicationsTests, self).setUp()
self.browser_application = BrowserApplications(api_key='dummy_key')
browser_application = {
"id": 1234567,
"name": "Ac... | "\n</script>\n" |
Predict the next line for this snippet: <|code_start|>
class NRNotificationChannelsTests(TestCase):
def setUp(self):
super(NRNotificationChannelsTests, self).setUp()
self.channels = NotificationChannels(api_key='dummy_key')
self.list_response = {
"channels": [
<|code_end|>
w... | { |
Continue the code snippet: <|code_start|> def setUp(self):
super(NRKeyTransactionsTests, self).setUp()
self.key_transactions = KeyTransactions(api_key='dummy_key')
self.key_transactions_list_response = {
"key_transactions": [
{
"id": 333112,
... | 'key_transaction': self.key_transactions_list_response['key_transactions'][0] |
Given snippet: <|code_start|>
class NRUsersTests(TestCase):
def setUp(self):
super(NRUsersTests, self).setUp()
self.user = Users(api_key='dummy_key')
self.user_list_response = {
'users': [
{
<|code_end|>
, continue by predicting the next line. Consider current... | "id": 333113, |
Given the following code snippet before the placeholder: <|code_start|>
class ControllerPipeline(Pipeline):
def definition(self):
pass
<|code_end|>
, predict the next line using imports from the current file:
from motorway.pipeline import Pipeline
and context including class names, function names, and ... | if __name__ == '__main__': |
Continue the code snippet: <|code_start|>
logging.config.dictConfig({
'version': 1,
'disable_existing_loggers': False,
'formatters': {
'colored': {
'()': 'colorlog.ColoredFormatter',
'format': "%(log_color)s%(levelname)-8s%(reset)s %(name)-32s %(processName)-32s %(blu... | } |
Here is a snippet: <|code_start|> compiler = scss.Scss(scss_opts = {
'style': 'compressed' if not app.debug else None
}, search_paths=[
os.path.join(os.getcwd(), 'styles')
])
# Compile styles (scss)
d = os.walk('styles')
for f in list(d)[0][2]:
if os.path.splitext(f)[1] =... | copyfile(inputpath, outputpath) |
Continue the code snippet: <|code_start|>
app.static_folder = os.path.join(os.getcwd(), "static")
def prepare():
if os.path.exists(app.static_folder):
rmtree(app.static_folder)
os.makedirs(app.static_folder)
compiler = scss.Scss(scss_opts = {
'style': 'compressed' if not app.debug else Non... | parts = f.rsplit('.') |
Using the snippet: <|code_start|>
app.static_folder = os.path.join(os.getcwd(), "static")
def prepare():
if os.path.exists(app.static_folder):
rmtree(app.static_folder)
os.makedirs(app.static_folder)
compiler = scss.Scss(scss_opts = {
'style': 'compressed' if not app.debug else None
<|code... | }, search_paths=[ |
Next line prediction: <|code_start|>from __future__ import with_statement
sys.path.append(os.getcwd())
# this is the Alembic Config object, which provides
# access to the values within the .ini file in use.
config = context.config
# Interpret the config file for Python logging.
# This line sets up loggers basically.
... | fileConfig(config.config_file_name) |
Next line prediction: <|code_start|>def confirm_user(username, confirmation):
user = User.query.filter(User.username == username).first()
if not user:
return { 'success': False, 'error': 'User not found.' }, 404
if (not current_user or not current_user.admin) and (confirmation != user.confirmation):... | if not current_user or not current_user.admin: |
Given the following code snippet before the placeholder: <|code_start|> if not package:
return { 'success': False, 'error': 'Package not found.' }, 404
if not current_user == package.user and not current_user.admin:
return { 'success': False, 'error': 'You do not have permission to move this pack... | if '/' in info.name: |
Here is a snippet: <|code_start|> def __repr__(self):
return '<User %r>' % self.username
# Flask.Login stuff
# We don't use most of these features
def is_authenticated(self):
return True
def is_active(self):
return True
def is_anonymous(self):
return False
def... | description = Column(Unicode(1024)) |
Given the code snippet: <|code_start|> allow = False
for ip in _cfg("hook_ips").split(","):
parts = ip.split("/")
range = 32
if len(parts) != 1:
range = int(parts[1])
addr = networkMask(parts[0], range)
if addressInNetwork(dottedQuadToNum(request.remote_addr), ... | 'request': request, |
Predict the next line after this snippet: <|code_start|>
app = Flask(__name__)
app.secret_key = _cfg("secret-key")
app.jinja_env.cache = None
init_db()
login_manager = LoginManager()
login_manager.init_app(app)
@login_manager.user_loader
def load_user(username):
return User.query.filter(User.username == usernam... | pass |
Predict the next line after this snippet: <|code_start|>
app = Flask(__name__)
app.secret_key = _cfg("secret-key")
app.jinja_env.cache = None
init_db()
login_manager = LoginManager()
login_manager.init_app(app)
@login_manager.user_loader
def load_user(username):
return User.query.filter(User.username == username)... | except: |
Based on the snippet: <|code_start|> except:
# shit shit
sys.exit(1)
return render_template("internal_error.html"), 500
# Error handler
if _cfg("error-to") != "":
mail_handler = SMTPHandler((_cfg("smtp-host"), _cfg("smtp-port")),
_cfg("error-from"),
... | addr = networkMask(parts[0], range) |
Based on the snippet: <|code_start|>
app = Flask(__name__)
app.secret_key = _cfg("secret-key")
app.jinja_env.cache = None
init_db()
login_manager = LoginManager()
login_manager.init_app(app)
@login_manager.user_loader
def load_user(username):
return User.query.filter(User.username == username).first()
login_ma... | pass |
Using the snippet: <|code_start|>
def send_confirmation(user):
if _cfg("smtp-host") == "":
return
smtp = smtplib.SMTP(_cfg("smtp-host"), _cfgi("smtp-port"))
smtp.ehlo()
smtp.starttls()
smtp.login(_cfg("smtp-user"), _cfg("smtp-password"))
with open("emails/confirm-account") as f:
... | message['Subject'] = "Reset your password for the KnightOS Package Index" |
Continue the code snippet: <|code_start|>
def send_confirmation(user):
if _cfg("smtp-host") == "":
return
smtp = smtplib.SMTP(_cfg("smtp-host"), _cfgi("smtp-port"))
smtp.ehlo()
smtp.starttls()
smtp.login(_cfg("smtp-user"), _cfg("smtp-password"))
with open("emails/confirm-account") as f:... | message['To'] = user.email |
Given the following code snippet before the placeholder: <|code_start|>
def send_reset(user):
if _cfg("smtp-host") == "":
return
smtp = smtplib.SMTP(_cfg("smtp-host"), _cfgi("smtp-port"))
smtp.ehlo()
smtp.starttls()
smtp.login(_cfg("smtp-user"), _cfg("smtp-password"))
with open("emails/p... | message['To'] = ';'.join(targets) |
Given the code snippet: <|code_start|>
engine = create_engine(_cfg('connection-string'))
db = scoped_session(sessionmaker(autocommit=False, autoflush=False, bind=engine))
Base = declarative_base()
Base.query = db.query_property()
<|code_end|>
, generate the next line using the imports in this file:
from sqlalchemy i... | def init_db(): |
Using the snippet: <|code_start|> print("Connected to " + str(ble_device.address))
@classmethod
def on_disconnect(cls, adapter_address, device_address):
print("Disconnected from " + device_address)
@classmethod
def uart_notify(cls, notifying, characteristic):
if notifying:
... | ble_uart.add_characteristic(srv_id=1, chr_id=1, uuid=RX_CHARACTERISTIC, |
Predict the next line for this snippet: <|code_start|> def on_connect(cls, ble_device: device.Device):
print("Connected to " + str(ble_device.address))
@classmethod
def on_disconnect(cls, adapter_address, device_address):
print("Disconnected from " + device_address)
@classmethod
def... | ble_uart.add_service(srv_id=1, uuid=UART_SERVICE, primary=True) |
Using the snippet: <|code_start|>
# Bluezero modules
# constants
UART_SERVICE = '6E400001-B5A3-F393-E0A9-E50E24DCCA9E'
RX_CHARACTERISTIC = '6E400002-B5A3-F393-E0A9-E50E24DCCA9E'
TX_CHARACTERISTIC = '6E400003-B5A3-F393-E0A9-E50E24DCCA9E'
class UARTDevice:
tx_obj = None
<|code_end|>
, determine the next line of c... | @classmethod |
Predict the next line for this snippet: <|code_start|>
def main():
eddystone_beacon.EddystoneURL('https://github.com/ukBaz')
if __name__ == '__main__':
<|code_end|>
with the help of current file imports:
from bluezero import eddystone_beacon
and context from other files:
# Path: bluezero/eddystone_beacon.py
... | main() |
Using the snippet: <|code_start|>
@property
def repeat(self):
"""Return the repeat value"""
return self.player_props.Get(
constants.MEDIA_PLAYER_IFACE, 'Repeat')
@repeat.setter
def repeat(self, value):
"""Possible values: "off", "singletrack", "alltracks" or "group""... | @property |
Given snippet: <|code_start|> found_address = dbus_tools.get_device_address_from_dbus_path(path)
if device_address == found_address:
return path
raise MediaPlayerError("No player found for the device")
class MediaPlayer:
"""Bluetooth MediaPlayer Class.
This class instantiates an... | return self.player_props.Get( |
Here is a snippet: <|code_start|> """Bluetooth MediaPlayer Class.
This class instantiates an object that is able to interact with
the player of a Bluetooth device and get audio from its source.
"""
def __init__(self, device_addr):
"""Default initialiser.
Creates the interface to the... | return self.player_props.Get( |
Using the snippet: <|code_start|> # all files called
if len(list(set(ref_files) - set(test_files))) == 0:
logger.info('All files are called during %s' % run_type)
# some files not called
if len(list(set(ref_files) - set(test_files))) != 0:
names = ':'.join([name fo... | logger.error('There is a mismatch. Running debug...') |
Predict the next line for this snippet: <|code_start|>
adapter_props = tests.obj_data.full_ubits
def mock_get(iface, prop):
return tests.obj_data.full_ubits['/org/bluez/hci0'][iface][prop]
<|code_end|>
with the help of current file imports:
import unittest
import tests.obj_data
from unittest.mock import Magic... | def mock_set(iface, prop, value): |
Next line prediction: <|code_start|># pi@RPi3:~ $ bluetoothctl
# [bluetooth]# agent NoInputNoOutput
# Agent registered
# [bluetooth]# discoverable on
# Changing discoverable on succeeded
# [CHG] Controller B8:27:EB:22:57:E0 Discoverable: yes
#
# Now we have made the Raspberry Pi discoverable we... | print(f'{detail} : {track_details[detail]}') |
Given the following code snippet before the placeholder: <|code_start|># bluetoothctl tool
# pi@RPi3:~ $ bluetoothctl
# [bluetooth]# agent NoInputNoOutput
# Agent registered
# [bluetooth]# discoverable on
# Changing discoverable on succeeded
# [CHG] Controller B8:27:EB:22:57:E0 Discoverable: ye... | for detail in track_details: |
Next line prediction: <|code_start|>
def main():
alt = broadcaster.Beacon()
alt.add_manufacturer_data(
'ffff', # Manufacturer ID (0xffff = Not for production)
b'\xBE\xAC' # beacon code for Alt Beacon
+ 16 * b'\xbe' # Beacon UUID
+ 4 * b'\x00' # Free
+ b'\x01') # T... | alt.start_beacon() |
Based on the snippet: <|code_start|> return large_query_client
@pytest.fixture(scope="function")
def large_query(large_query_client):
# Use the client for this test instead of the global.
return large_query_client.query(
kind=populate_datastore.LARGE_CHARACTER_KIND,
namespace=populate_datas... | page_query.add_filter("alive", "=", False) |
Given snippet: <|code_start|> assert len(entities) == expected_matches
def test_query_w_multiple_filters(ancestor_query):
query = ancestor_query
query.add_filter("appearances", ">=", 26)
query = query.add_filter("family", "=", "Stark")
expected_matches = 4
# We expect 4, but allow the query to... | query.order = "appearances" |
Predict the next line for this snippet: <|code_start|>
__protobuf__ = proto.module(
package="google.datastore.v1",
manifest={
"EntityResult",
"Query",
"KindExpression",
"PropertyReference",
"Projection",
"PropertyOrder",
"Filter",
"CompositeFilter"... | This field is set for |
Predict the next line for this snippet: <|code_start|> The mutations to perform.
When mode is ``TRANSACTIONAL``, mutations affecting a single
entity are applied in order. The following sequences of
mutations affecting a single entity are not permitted in a
sin... | [Datastore.Commit][google.datastore.v1.Datastore.Commit]. |
Using the snippet: <|code_start|># Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# li... | }, |
Here is a snippet: <|code_start|> OPERATION_TYPE_UNSPECIFIED = 0
EXPORT_ENTITIES = 1
IMPORT_ENTITIES = 2
CREATE_INDEX = 3
DELETE_INDEX = 4
class CommonMetadata(proto.Message):
r"""Metadata common to all Datastore Admin operations.
Attributes:
start_time (google.protobuf.timestamp_p... | INITIALIZING = 1 |
Based on the snippet: <|code_start|>
class CommonMetadata(proto.Message):
r"""Metadata common to all Datastore Admin operations.
Attributes:
start_time (google.protobuf.timestamp_pb2.Timestamp):
The time that work began on the operation.
end_time (google.protobuf.timestamp_pb2.Times... | CANCELLED = 7 |
Given the following code snippet before the placeholder: <|code_start|># -*- coding: utf-8 -*-
# Copyright 2022 Google LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.a... | class DatastoreAdminTransport(abc.ABC): |
Predict the next line after this snippet: <|code_start|># distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
@pytest.mark.s... | ds_api = make_datastore_api(client) |
Given the code snippet: <|code_start|>
# +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
# generate the solution string from the array data
@staticmethod
def solutionToString(length, depthPhase1=- 1):
s = []
for i in range(length):
step = ''
if... | @staticmethod |
Here is a snippet: <|code_start|>__author__ = 'Victor'
class DupedFacelet(Exception):
pass
class NoSolution(Exception):
pass
class SolverTimeoutError(Exception):
pass
class Search(object):
<|code_end|>
. Write the next line using the current file imports:
import time
import rubik_solver.FaceCube a... | ax = [0] * 31 # The axis of the move |
Continue the code snippet: <|code_start|>
self.assertTrue(m.clockwise)
self.assertFalse(m.counterclockwise)
self.assertFalse(m.double)
m.double = True
self.assertFalse(m.clockwise)
self.assertFalse(m.counterclockwise)
self.assertTrue(m.double)
m.... | self.assertTrue(m1.counterclockwise) |
Continue the code snippet: <|code_start|> """"""
_name = 'infrastructure.server_docker_image'
_description = 'Server Docker Image'
_rec_name = 'docker_image_id'
docker_image_id = fields.Many2one(
'infrastructure.docker_image',
'Docker Image',
required=True,
)
server_i... | if image.tag_ids: |
Predict the next line after this snippet: <|code_start|>
start-stop-daemon --stop --quiet --pidfile /var/run/${NAME}.pid \
--oknodo
sleep 1
start-stop-daemon --start --quiet --pidfile /var/run/${NAME}.pid \
--chuid ${USER}... | start-stop-daemon --start --quiet --pidfile /var/run/${NAME}.pid \ |
Predict the next line for this snippet: <|code_start|># -*- coding: utf-8 -*-
##############################################################################
# For copyright and license notices, see __openerp__.py file in module root
# directory
###########################################################################... | ('unmet_deps', 'Unmet Dependencies'), |
Here is a snippet: <|code_start|>
def cli(args=None) -> int:
parser = argparse.ArgumentParser(
prog='sismic-bdd',
description='Command-line utility to execute Gherkin feature files using Behave.\n'
'Extra parameters will be passed to Behave.')
parser.add_argument('statechart', metavar... | if args.show_steps: |
Here is a snippet: <|code_start|>
def test_deprecated_interpreter(self, microwave):
with pytest.warns(DeprecationWarning):
microwave.bind_property_statechart(microwave)
def test_synchronised_time(self, microwave, property_statechart):
assert microwave.time == property_statechart.tim... | state.on_entry = 'notify("test", x=1, y="hello")' |
Predict the next line after this snippet: <|code_start|>
class TestInterpreterMetaEvents:
@pytest.fixture
def property_statechart(self, microwave, mocker):
prop_sc = mocker.MagicMock(name='Interpreter', spec=microwave)
prop_sc.queue = mocker.MagicMock(return_value=None)
prop_sc.execute... | with pytest.warns(DeprecationWarning): |
Based on the snippet: <|code_start|> microwave.execute()
assert property_statechart.queue.call_args_list[0][0][0] == MetaEvent('step started', time=0)
assert property_statechart.queue.call_args_list[-1][0][0] == MetaEvent('step ended')
for call in property_statechart.queue.call_args_list... | call_list = [ |
Given snippet: <|code_start|>
class TestInterpreterMetaEvents:
@pytest.fixture
def property_statechart(self, microwave, mocker):
prop_sc = mocker.MagicMock(name='Interpreter', spec=microwave)
prop_sc.queue = mocker.MagicMock(return_value=None)
prop_sc.execute = mocker.MagicMock(return_... | microwave.bind_property_statechart(microwave) |
Predict the next line after this snippet: <|code_start|>
def test_writer(writer):
writer.queue(
Event('keyPress', key='bonjour '),
Event('toggle'),
Event('keyPress', key='a '),
Event('toggle'),
Event('toggle_bold'),
Event('keyPress', key='tous !'),
Event('l... | writer.execute() |
Continue the code snippet: <|code_start|>
def test_writer(writer):
writer.queue(
Event('keyPress', key='bonjour '),
Event('toggle'),
Event('keyPress', key='a '),
Event('toggle'),
Event('toggle_bold'),
Event('keyPress', key='tous !'),
Event('leave')
<|code_e... | ) |
Given snippet: <|code_start|> def test_speed_with_automatic(self, clock):
clock.speed = 2
clock.start()
sleep(0.1)
assert clock.time >= 0.2
clock.stop()
clock.time = 10
clock.speed = 0.1
clock.start()
sleep(0.1)
clock.stop()
... | def clock(self): |
Continue the code snippet: <|code_start|> assert clock.time >= 0.2
clock.stop()
clock.time = 10
clock.speed = 0.1
clock.start()
sleep(0.1)
clock.stop()
assert 10 < clock.time < 10.1
def test_start_stop(self, clock):
clock.sta... | current_time = clock.time |
Based on the snippet: <|code_start|>
def test_initial_value(self, clock):
assert clock.time == 0
def test_manual_increment(self, clock):
clock.time += 1
assert clock.time == 1
def test_monotonicity(self, clock):
clock.time = 10
with pytest.raises(ValueError):
... | clock.time = 20 |
Here is a snippet: <|code_start|>
def before_scenario(context, scenario):
# Create interpreter
statechart = context.config.userdata.get('statechart')
interpreter_klass = context.config.userdata.get('interpreter_klass')
context.interpreter = interpreter_klass(statechart)
# Log trace
context.tra... | def before_step(context, step): |
Given the following code snippet before the placeholder: <|code_start|> raise exceptions.UnsupportedLibraryError(NO_CRYPTO_MSG)
hasher = hashing.Hash(hashing.SHA1(), backend=backends.default_backend())
hasher.update(b'\x99')
hasher.update(struct.pack(">H", len(pubkey_packet_data)))
hasher.update(bytes(pubke... | else: # pragma: no cover (unreachable) |
Continue the code snippet: <|code_start|> """
if not CRYPTO: # pragma: no cover
raise exceptions.UnsupportedLibraryError(NO_CRYPTO_MSG)
hasher = hashing.Hash(hashing.SHA1(), backend=backends.default_backend())
hasher.update(b'\x99')
hasher.update(struct.pack(">H", len(pubkey_packet_data)))
hasher.update... | length = struct.unpack(">I", data[1:length_len])[0] |
Continue the code snippet: <|code_start|> hasher.update(bytes(pubkey_packet_data))
return binascii.hexlify(hasher.finalize()).decode("ascii")
def parse_subpacket_header(data):
""" Parse out subpacket header as per RFC4880 5.2.3.1. Signature Subpacket
Specification. """
# NOTE: Although the RFC does not state... | def parse_subpackets(data): |
Using the snippet: <|code_start|> None
<Returns>
The RFC4880-compliant hashed buffer
"""
if not CRYPTO: # pragma: no cover
raise exceptions.UnsupportedLibraryError(NO_CRYPTO_MSG)
hasher = hashing.Hash(hashing.SHA1(), backend=backends.default_backend())
hasher.update(b'\x99')
hasher.update(struc... | length = ((data[0] - 192 << 8) + (data[1] + 192)) |
Given the following code snippet before the placeholder: <|code_start|>GPG_DSA_PUBKEY_SCHEMA = _create_gpg_pubkey_with_subkey_schema(
_GPG_DSA_PUBKEY_SCHEMA)
GPG_ED25519_PUBKEYVAL_SCHEMA = SCHEMA.Object(
object_name = "GPG_ED25519_PUBKEYVAL_SCHEMA",
q = HEX_SCHEMA,
)
# C.f. comment above _GPG_RSA_PUBKEY_SCHEM... | keyid = KEYID_SCHEMA, |
Based on the snippet: <|code_start|># An ed25519 key.
ED25519KEY_SCHEMA = SCHEMA.Object(
object_name = 'ED25519KEY_SCHEMA',
keytype = SCHEMA.String('ed25519'),
scheme = ED25519_SIG_SCHEMA,
keyid = KEYID_SCHEMA,
keyid_hash_algorithms = SCHEMA.Optional(HASHALGORITHMS_SCHEMA),
keyval = KEYVAL_SCHEMA)
# GPG ke... | schema._required.append(subkey_schema_tuple) # pylint: disable=protected-access |
Given snippet: <|code_start|>
Neither D801 nor DC0C are in the appropriate set.
This form cannot be used to map to the character which is
expressed as D801 DC0C in UTF-16, specifically U+1040C.
This character can be correctly mapped by using the
glyph name "u1040C.
"""
with pytest.raises(Key... | def test_name2unicode_uni_pua_lowercase(): |
Based on the snippet: <|code_start|>
Neither D801 nor DC0C are in the appropriate set.
This form cannot be used to map to the character which is
expressed as D801 DC0C in UTF-16, specifically U+1040C.
This character can be correctly mapped by using the
glyph name "u1040C.
"""
with pytest.rai... | def test_name2unicode_uni_pua_lowercase(): |
Based on the snippet: <|code_start|>
def test_name2unicode_u_with_4_digits():
"""The components "Lcommaaccent," "uni013B," and "u013B" all map to the
string U+013B"""
assert "\u013B" == name2unicode("u013B")
def test_name2unicode_u_with_4_digits_lowercase():
"""The components "Lcommaaccent," "uni013B... | "Lcommaaccent_uni20AC0308_u1040C.alternate" |
Predict the next line after this snippet: <|code_start|>
LITERAL_DEVICE_GRAY = LIT("DeviceGray")
LITERAL_DEVICE_RGB = LIT("DeviceRGB")
LITERAL_DEVICE_CMYK = LIT("DeviceCMYK")
class PDFColorSpace:
def __init__(self, name: str, ncomponents: int) -> None:
self.name = name
self.ncomponents = ncompone... | ("Pattern", 1), |
Given the following code snippet before the placeholder: <|code_start|>def dehex(b):
"""decode('hex')"""
return binascii.unhexlify(b)
class TestAscii85:
def test_ascii85decode(self):
"""The sample string is taken from:
http://en.wikipedia.org/w/index.php?title=Ascii85"""
assert asc... | assert ( |
Predict the next line for this snippet: <|code_start|>def dehex(b):
"""decode('hex')"""
return binascii.unhexlify(b)
class TestAscii85:
def test_ascii85decode(self):
"""The sample string is taken from:
http://en.wikipedia.org/w/index.php?title=Ascii85"""
assert ascii85decode(b"9jqo... | assert ( |
Given the following code snippet before the placeholder: <|code_start|>def dehex(b):
"""decode('hex')"""
return binascii.unhexlify(b)
class TestAscii85:
def test_ascii85decode(self):
"""The sample string is taken from:
http://en.wikipedia.org/w/index.php?title=Ascii85"""
assert asc... | assert ( |
Based on the snippet: <|code_start|>def hex(b):
"""encode('hex')"""
return binascii.hexlify(b)
def dehex(b):
"""decode('hex')"""
return binascii.unhexlify(b)
class TestAscii85:
def test_ascii85decode(self):
"""The sample string is taken from:
http://en.wikipedia.org/w/index.php?t... | ) |
Here is a snippet: <|code_start|>def hex(b):
"""encode('hex')"""
return binascii.hexlify(b)
def dehex(b):
"""decode('hex')"""
return binascii.unhexlify(b)
class TestAscii85:
def test_ascii85decode(self):
"""The sample string is taken from:
http://en.wikipedia.org/w/index.php?titl... | ) |
Given snippet: <|code_start|>
def test_font_size():
path = absolute_sample_path("font-size-test.pdf")
for page in extract_pages(path):
<|code_end|>
, continue by predicting the next line. Consider current file imports:
from helpers import absolute_sample_path
from pdfminer.high_level import extract_pages
from... | for text_box in page: |
Given snippet: <|code_start|>
def test_font_size():
path = absolute_sample_path("font-size-test.pdf")
for page in extract_pages(path):
<|code_end|>
, continue by predicting the next line. Consider current file imports:
from helpers import absolute_sample_path
from pdfminer.high_level import extract_pages
from... | for text_box in page: |
Predict the next line for this snippet: <|code_start|>
def run(filename, options=None):
absolute_path = absolute_sample_path(filename)
with TemporaryFilePath() as output_file_name:
if options:
s = "dumppdf -o %s %s %s" % (output_file_name, options, absolute_path)
else:
... | run("simple2.pdf", "-t -a") |
Here is a snippet: <|code_start|># Copyright (c) 2015 Huawei Technologies India Pvt.Limited.
# All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http:/... | versions = ['2.0'] |
Here is a snippet: <|code_start|># Copyright (c) 2015 Huawei Technologies India Pvt.Limited.
# All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http:/... | resource_path = '/sfc/%s/%%s' % resource_plural |
Here is a snippet: <|code_start|># Copyright (c) 2015 Huawei Technologies India Pvt.Limited.
# All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http:/... | resource_path = '/sfc/%s/%%s' % resource_plural |
Next line prediction: <|code_start|> base.RULE_ANY,
'Create a port chain',
[
{
'method': 'POST',
'path': '/sfc/port_chains',
},
]
),
policy.DocumentedRuleDefault(
'update_port_chain',
base.RULE_ADMIN_OR_OWNER,... | ), |
Based on the snippet: <|code_start|># Copyright (c) 2015 Huawei Technologies India Pvt.Limited.
# All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# htt... | PORT_PAIR_GROUP_RESOURCE, |
Based on the snippet: <|code_start|># distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
PORT_PAIR_GROUP_RESOURC... | metavar='PORT-PAIR', |
Given the following code snippet before the placeholder: <|code_start|> policy.DocumentedRuleDefault(
'update_port_pair_group',
base.RULE_ADMIN_OR_OWNER,
'Update a port pair group',
[
{
'method': 'PUT',
'path': '/sfc/port_pair_groups/{id}',
... | }, |
Here is a snippet: <|code_start|>#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
... | object_path = '/sfc/%s' % resource_plural |
Predict the next line after this snippet: <|code_start|># http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express... | ext_pkg = 'neutronclient.common.extension' |
Predict the next line after this snippet: <|code_start|># Copyright (c) 2015 Huawei Technologies India Pvt.Limited.
# All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the Licens... | resource_path = '/sfc/%s/%%s' % resource_plural |
Based on the snippet: <|code_start|> [
{
'method': 'PUT',
'path': '/sfc/port_pairs/{id}',
},
]
),
policy.DocumentedRuleDefault(
'delete_port_pair',
base.RULE_ADMIN_OR_OWNER,
'Delete a port pair',
[
... | }, |
Given the code snippet: <|code_start|># http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See t... | if type_ == 'table' and (name.startswith('alembic') or |
Predict the next line for this snippet: <|code_start|>
class SfcAgentExtensionTestCase(base.BaseTestCase):
def setUp(self):
super(SfcAgentExtensionTestCase, self).setUp()
conn_patcher = mock.patch('neutron.agent.ovsdb.impl_idl._connection')
conn_patcher.start()
self.addCleanup(con... | self.sfc_ext.update_flow_rules(self.context, flowrule_entries={}) |
Given snippet: <|code_start|># Copyright 2015 Huawei Technologies India Pvt. Ltd.
# All Rights Reserved
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.... | def setUp(self): |
Using the snippet: <|code_start|>
rules = [
policy.DocumentedRuleDefault(
'create_service_graph',
base.RULE_ANY,
'Create a service graph',
[
{
'method': 'POST',
'path': '/sfc/service_graphs',
},
]
),
policy.Do... | 'Delete a service graph', |
Predict the next line for this snippet: <|code_start|># http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# Se... | host=self.host, port_id=port_id) |
Predict the next line for this snippet: <|code_start|> )
def test_invalid_max_port(self):
self.assertRaises(
exceptions.InvalidInput,
ovs_ext_lib.get_port_mask,
100, 65536
)
def test_invalid_port_range(self):
self.assertRaises(
exc... | masks |
Based on the snippet: <|code_start|> 'method': 'POST',
'path': '/sfc/flow_classifiers',
},
]
),
policy.DocumentedRuleDefault(
'update_flow_classifier',
base.RULE_ADMIN_OR_OWNER,
'Update a flow classifier',
[
{
... | 'Get flow classifiers', |
Next line prediction: <|code_start|> 'mpls_label': 61641,
'priority': 1,
'table': 10
}],
self.added_flows
)
self.assertEqual(
{},
self.group_mapping
)
self.assertEqual(
[{
... | 'nsh', False) |
Here is a snippet: <|code_start|>
class PortPairDetailNotFound(n_exc.NotFound):
message = _("Portchain port brief %(port_id)s could not be found")
class NodeNotFound(n_exc.NotFound):
message = _("Portchain node %(node_id)s could not be found")
# name changed to ChainPathId
class UuidIntidAssoc(model_base.BA... | return getinstance |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.