Instruction stringlengths 362 7.83k | output_code stringlengths 1 945 |
|---|---|
Given snippet: <|code_start|> print "Copying /static..."
outdir = os.path.join(get_output_dir(), 'static')
if os.path.isdir(outdir):
shutil.rmtree(outdir)
shutil.copytree(app.static_folder, outdir)
freeze_request('/index.html')
freeze_request('/faq.html')
freeze_request('/api.html')
... | for (text, rb) in [('labeled', True), ('raw', False)]: |
Given the code snippet: <|code_start|>
client = app.test_client()
def get_output_dir():
return os.path.join( app.root_path, '..', 'build')
#return '/Users/fl/tmp/regenesis'
def freeze_request(req_path):
print "Freezing %s..." % req_path
path = os.path.join(get_output_dir(), req_path.lstrip('/'))
d... | freeze_request('/%s/index.html' % catalog) |
Given the code snippet: <|code_start|>
client = app.test_client()
def get_output_dir():
return os.path.join( app.root_path, '..', 'build')
#return '/Users/fl/tmp/regenesis'
def freeze_request(req_path):
print "Freezing %s..." % req_path
path = os.path.join(get_output_dir(), req_path.lstrip('/'))
<|co... | dirname = os.path.dirname(path) |
Here is a snippet: <|code_start|>
def freeze_html():
print "Copying /static..."
outdir = os.path.join(get_output_dir(), 'static')
if os.path.isdir(outdir):
shutil.rmtree(outdir)
shutil.copytree(app.static_folder, outdir)
freeze_request('/index.html')
freeze_request('/faq.html')
freez... | cube['cube_name']) |
Next line prediction: <|code_start|>
client = app.test_client()
def get_output_dir():
return os.path.join( app.root_path, '..', 'build')
#return '/Users/fl/tmp/regenesis'
def freeze_request(req_path):
print "Freezing %s..." % req_path
path = os.path.join(get_output_dir(), req_path.lstrip('/'))
di... | def freeze_html(): |
Continue the code snippet: <|code_start|>
blueprint = Blueprint('dimension', __name__)
def get_statistics(dimension_name=None):
ct = cube_table.table.alias('cube')
st = statistic_table.table.alias('statistic')
rt = reference_table.table.alias('reference')
tables = [ct, st, rt]
wheres = [
st.... | has_values = len(values) > 0 |
Given the following code snippet before the placeholder: <|code_start|>
blueprint = Blueprint('dimension', __name__)
def get_statistics(dimension_name=None):
ct = cube_table.table.alias('cube')
st = statistic_table.table.alias('statistic')
rt = reference_table.table.alias('reference')
tables = [ct, st... | wheres = [ |
Next line prediction: <|code_start|>
blueprint = Blueprint('dimension', __name__)
def get_statistics(dimension_name=None):
ct = cube_table.table.alias('cube')
st = statistic_table.table.alias('statistic')
rt = reference_table.table.alias('reference')
tables = [ct, st, rt]
<|code_end|>
. Use current fi... | wheres = [ |
Predict the next line for this snippet: <|code_start|>
blueprint = Blueprint('dimension', __name__)
def get_statistics(dimension_name=None):
ct = cube_table.table.alias('cube')
st = statistic_table.table.alias('statistic')
rt = reference_table.table.alias('reference')
tables = [ct, st, rt]
wheres ... | dimension=dimension) |
Given snippet: <|code_start|>
blueprint = Blueprint('dimension', __name__)
def get_statistics(dimension_name=None):
ct = cube_table.table.alias('cube')
st = statistic_table.table.alias('statistic')
rt = reference_table.table.alias('reference')
tables = [ct, st, rt]
wheres = [
st.c.name==ct.c... | @blueprint.route('/<catalog>/dimensions/<name>.html') |
Here is a snippet: <|code_start|>
blueprint = Blueprint('dimension', __name__)
def get_statistics(dimension_name=None):
ct = cube_table.table.alias('cube')
st = statistic_table.table.alias('statistic')
rt = reference_table.table.alias('reference')
tables = [ct, st, rt]
wheres = [
st.c.name==... | has_values = len(values) > 0 |
Next line prediction: <|code_start|>
@pytest.fixture
def client():
app.testing = True
return app.test_client()
def test_binary_request(client):
# This data defines a binary cloudevent
attributes = {
"type": "com.example.sampletype1",
"source": "https://example.com/event-producer",
... | def test_structured_request(client): |
Here is a snippet: <|code_start|>
@pytest.fixture
def client():
app.testing = True
return app.test_client()
def test_binary_request(client):
# This data defines a binary cloudevent
attributes = {
"type": "com.example.sampletype1",
"source": "https://example.com/event-producer",
<|cod... | } |
Using the snippet: <|code_start|> def EventTime(self) -> str:
return self.ce__time.get()
def Subject(self) -> str:
return self.ce__subject.get()
def SchemaURL(self) -> str:
return self.ce__schemaurl.get()
def Data(self) -> object:
return self.ce__data.get()
def Ext... | self.Set("id", eventID) |
Predict the next line for this snippet: <|code_start|>
def SetExtensions(self, extensions: dict) -> base.BaseEvent:
self.Set("extensions", extensions)
return self
def SetContentType(self, contentType: str) -> base.BaseEvent:
self.Set("datacontenttype", contentType)
return self
... | def schema_url(self) -> str: |
Continue the code snippet: <|code_start|> assert event_dict[key] == val
# test data was properly marshalled into data_base64
data_base64 = event_dict["data_base64"].encode()
test_data_base64 = base64.b64encode(data)
assert data_base64 == test_data_base64
@pytest.mark.parametrize("specversion"... | raw_data = {"data-key": "val"} |
Given snippet: <|code_start|>
event = CloudEvent(test_attributes, data)
event_json = to_json(event)
event_dict = json.loads(event_json)
for key, val in test_attributes.items():
assert event_dict[key] == val
# test data was properly marshalled into data_base64
data_base64 = event_dict["... | assert event[key] == val |
Given the code snippet: <|code_start|># 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.org/licenses/LICENSE-2.0
#
# Unless requ... | for key, val in test_attributes.items(): |
Given the code snippet: <|code_start|># not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distrib... | assert o != o2 |
Predict the next line for this snippet: <|code_start|># 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.org/licenses/LICENSE-2.0
#
... | f"{event['type']} and specversion {event['specversion']}" |
Next line prediction: <|code_start|>#
# 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.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or... | raise Exception("not implemented") |
Next line prediction: <|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 permi... | app.run(port=3000) |
Continue the code snippet: <|code_start|>
class BaseEvent(EventGetterSetter):
_ce_required_fields = set()
_ce_optional_fields = set()
def Properties(self, with_nullable=False) -> dict:
props = dict()
for name, value in self.__dict__.items():
if str(name).startswith("ce__"):
... | attr.set(value) |
Using the snippet: <|code_start|>
def test_v1_time_property():
event = v1.Event()
time1 = "1234"
event.time = time1
assert event.EventTime() == time1
time2 = "4321"
event.SetEventTime(time2)
assert event.time == time2
def test_v1_subject_property():
event = v1.Event()
subject1 ... | event.schema = schema1 |
Here is a snippet: <|code_start|># 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.org/licenses/LICENSE-2.0
#
# Unless required ... | "type": "com.example.string", |
Predict the next line after this snippet: <|code_start|># 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.org/licenses/LICENSE-2.0
... | attributes = { |
Here is a snippet: <|code_start|># under the License.
resp = requests.get(
"https://raw.githubusercontent.com/cncf/artwork/master/projects/cloudevents/horizontal/color/cloudevents-horizontal-color.png" # noqa
)
image_bytes = resp.content
def send_binary_cloud_event(url: str):
# Create cloudevent
at... | "type": "com.example.base64", |
Here is a snippet: <|code_start|> _ce_optional_fields = {"datacontenttype", "dataschema", "subject", "time"}
def __init__(self):
self.ce__specversion = opt.Option("specversion", "1.0", True)
self.ce__id = opt.Option("id", None, True)
self.ce__source = opt.Option("source", None, True)
... | def Subject(self) -> str: |
Using the 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
... | return self.ce__specversion.get() |
Given snippet: <|code_start|>
contentType = "application/json"
ce_type = "word.found.exclamation"
ce_id = "16fb5f0b-211e-1102-3dfe-ea6e2806f124"
source = "pytest"
eventTime = "2018-10-23T12:28:23.3464579Z"
body = '{"name":"john"}'
headers = {
v03.Event: {
"ce-specversion": "1.0",
"ce-type": ce_typ... | "specversion": "1.0", |
Predict the next line for this snippet: <|code_start|># 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.org/licenses/LICENSE-2.0
#
# Unless required by a... | "ce-specversion": "1.0", |
Next line prediction: <|code_start|> data = '{"name":"john"}'
event1 = CloudEvent(attributes, data)
event2 = CloudEvent(attributes, data)
assert event1 == event2
# Test different attributes
for key in attributes:
if key == "specversion":
continue
else:
attr... | "type": "tests.cloudevents.override", |
Based on the snippet: <|code_start|> assert f"Missing required keys: {set(['source'])}" in str(e.value)
attributes = {"source": "s"}
with pytest.raises(cloud_exceptions.MissingRequiredFields) as e:
_ = CloudEvent(attributes, None)
assert f"Missing required keys: {set(['type'])}" in str(e.value)
... | assert len(event) == 0 |
Here is a 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 permis... | "Programming Language :: Python :: 3.9", |
Predict the next line for this snippet: <|code_start|># 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.org/licenses/LICENSE-2.0
#
... | with pytest.deprecated_call(): |
Given the following code snippet before the placeholder: <|code_start|># 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.org/licens... | with pytest.deprecated_call(): |
Based on the snippet: <|code_start|># 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.org/licenses/LICENSE-2.0
#
# Unless requir... | def test_to_structured_http_deprecated(event): |
Predict the next line for this snippet: <|code_start|> subject1 = "<my-subject>"
event.subject = subject1
assert event.Subject() == subject1
subject2 = "<my-subject2>"
event.SetSubject(subject2)
assert event.subject == subject2
def test_v03_schema_url_property():
event = v03.Event()
s... | assert event.datacontentencoding == datacontentencoding2 |
Predict the next line for this snippet: <|code_start|># 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.org/licenses/LICENSE-2.0
#
... | cnvtr.can_read(None) |
Predict the next line after this 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 la... | cnvtr.read(None, None, None, None) |
Predict the next line for this snippet: <|code_start|># 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.org/licenses/LICENSE-2.0
#
... | with pytest.raises(Exception): |
Predict the next line for this snippet: <|code_start|># 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.org/licenses/LICENSE-2.0
#
... | ) -> bool: |
Here is a snippet: <|code_start|># WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
# TODO: Singleton?
class JSONHTTPCloudEventConverter(base.Converter):
TYPE = "structured"
MIME_... | body: typing.IO, |
Given the following code snippet before the placeholder: <|code_start|>class JSONHTTPCloudEventConverter(base.Converter):
TYPE = "structured"
MIME_TYPE = "application/cloudevents+json"
def can_read(
self, content_type: str, headers: typing.Dict[str, str] = {}
) -> bool:
return (
... | ) -> (dict, bytes): |
Predict the next line for this snippet: <|code_start|># 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.org/licenses/LICENSE-2.0
#
... | assert res[0] == "val" and res[1] is True |
Predict the next line after this snippet: <|code_start|>
event = CloudEvent(attributes, data)
headers, body = to_binary(event)
# send and print event
requests.post(url, headers=headers, data=body)
print(f"Sent {event['id']} from {event['source']} with " f"{event.data}")
def send_structured_cloud_... | "Usage: python with_requests.py " "<CloudEvents controller URL>" |
Given snippet: <|code_start|># 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.org/licenses/LICENSE-2.0
#
# Unless required by a... | } |
Based on the snippet: <|code_start|> attributes = {
"type": "com.example.sampletype1",
"source": "https://example.com/event-producer",
}
data = {"message": "Hello World!"}
event = CloudEvent(attributes, data)
headers, body = to_binary(event)
# send and print event
requests.p... | if __name__ == "__main__": |
Given snippet: <|code_start|> except StopIteration:
finished = True
def nb_voters(self):
"""Returns the number of voters of the poll (performs a DB query)."""
return VotingScore.objects.filter(candidate__poll=self).values('voter__id').distinct().count()
... | for j in range(i + 1, nb_candidates): |
Next line prediction: <|code_start|> return VotingScore.objects.filter(candidate__poll=self).values('voter__id').distinct().count()
def voting_profile_matrix(self):
"""Returns the voting profile as a matrix.
In the matrix returned by the function, each row represents
... | matrix[j][i] += 1 |
Based on the snippet: <|code_start|>
uuid4 = "[a-f0-9]{8}-?[a-f0-9]{4}-?4[a-f0-9]{3}-?[89ab][a-f0-9]{3}-?[a-f0-9]{12}"
urlpatterns = [
url(r'^login/$', views.login_view, name='login'),
url(r'^logout/$', views.logout_view, name='logout'),
url(r'^register/$', views.Register.as_view(), name='register'),
ur... | auth_views.password_reset_confirm, name='password_reset_confirm'), |
Next line prediction: <|code_start|>class LoginForm(forms.Form):
email = forms.EmailField(label=_('Email address *'),widget=forms.EmailInput(attrs={ 'placeholder': _('Enter your email')}), max_length=255, required=True)
password = forms.CharField(widget=forms.PasswordInput(attrs={ 'placeholder': _('Enter your p... | return user |
Given the following code snippet before the placeholder: <|code_start|>
handler400 = 'polls.views.bad_request'
handler403 = 'polls.views.permission_denied'
handler404 = 'polls.views.page_not_found'
handler500 = 'polls.views.server_error'
urlpatterns = [
url(r'^admin/', include(admin.site.urls)),
url(r'^polls/'... | url(r'^accounts/', include('accounts.urls')), |
Predict the next line after this snippet: <|code_start|>
uuid4="[a-f0-9]{8}-?[a-f0-9]{4}-?4[a-f0-9]{3}-?[89ab][a-f0-9]{3}-?[a-f0-9]{12}"
urlpatterns = [
url(r'^$', views.home, name='home'),
url(r'^redirectPage/$', views.redirect_page, name='redirectPage'),
url(r'^choosePollType$', views.choose_poll_type, na... | url(r'^about$', TemplateView.as_view(template_name='polls/about.html'), name='about'), |
Predict the next line after this snippet: <|code_start|>
def twitchapi_handler(q_twitchbeagle, q_twitchapi):
logger = logging.getLogger("Rotating Log")
logger.setLevel(logging.ERROR)
handler = RotatingFileHandler("twitchapi-log.txt", maxBytes=10000,
backupCount=5)
formatter = logging.For... | + ' - %(message)s') |
Here is a snippet: <|code_start|>
def react_chat_settitle(args):
config = ConfigParser.ConfigParser()
config.read('config.ini')
<|code_end|>
. Write the next line using the current file imports:
from twitchapi.krakenv5.channels import setChannelTitle, getChannelId
import ConfigParser
and context from other fi... | channelName = config.get('CHAT', 'channel') |
Predict the next line after this snippet: <|code_start|>@app.route('/streamlabsauth')
def slauth():
firsttimecheck = checkforfirstsetup()
if firsttimecheck:
return firsttimecheck
if request.args.get('code'):
url = 'https://streamlabs.com/api/v1.0/token'
authorize_call = {
... | f.write(a_token) |
Using the snippet: <|code_start|>
def addcom(user, args):
# Concatenate a list of strings down to a single, space delimited string.
queueEvent = {}
if len(args) < 2:
queueEvent['msg'] = "Proper usage: !addcom <cmd> <Text to send>"
else:
commandHead = "!" + args[0]
commands[comm... | with open("commands.json", "w") as f: |
Given the following code snippet before the placeholder: <|code_start|>
message_bits = json.loads(message_check['message'])
bits_used = str(message_bits['data']['bits_used'])
user_name = message_bits['data']['user_name']
channel_name = message_bits['data'... | queueEvent['eventType'] = 'twitchchatbot' |
Given snippet: <|code_start|> self._current_font_color = self._font_color
self._value = None
self._sorting_column = 0
self._t = perf_counter()
def __lt__(self, other):
if self._sorting_column == 1:
self_value = self._value
if self_value is None:
... | return super().__lt__(other) |
Predict the next line after this snippet: <|code_start|># -*- coding: utf-8 -*-
class ErrorDialog(Ui_ErrorDialog, QtWidgets.QDialog):
def __init__(self, title, message, trace, *args, **kwargs):
if "remote" in kwargs:
remote = kwargs.pop("remote")
if "timeout" in kwargs:
... | icon.addPixmap( |
Continue the code snippet: <|code_start|>
self.layout.setStretch(0, 0)
self.layout.setStretch(1, 0)
self.layout.setStretch(2, 1)
if remote:
self._timeout = timeout
self._thread = Thread(target=self.count_down, args=())
self._thread.start()
... | self.trace.hide() |
Using the snippet: <|code_start|># -*- coding: utf-8 -*-
class WindowSelectionDialog(Ui_WindowSelectionDialog, QtWidgets.QDialog):
def __init__(self, options=("Plot", "Numeric", "Tabular"), *args, **kwargs):
super().__init__(*args, **kwargs)
self.setupUi(self)
for i, name in enumerate(o... | return radio.text() |
Given the code snippet: <|code_start|># -*- coding: utf-8 -*-
class WindowSelectionDialog(Ui_WindowSelectionDialog, QtWidgets.QDialog):
def __init__(self, options=("Plot", "Numeric", "Tabular"), *args, **kwargs):
super().__init__(*args, **kwargs)
self.setupUi(self)
for i, name in enumer... | if i == 0: |
Using the snippet: <|code_start|> #
# self.table.setCellWidget(
# j,
# 2 * i + 1,
# label,
# )
self.table.setItem(
j, 2 * i, QtWidgets.QTableWidgetItem(str(sig.timestamps[j]))
... | name = self.header[index // 2] |
Given snippet: <|code_start|> self.channels.setColumnCount(3)
self.channels.setObjectName("channels")
self.verticalLayout.addWidget(self.channels)
self.horizontalLayout = QtWidgets.QHBoxLayout()
self.horizontalLayout.setObjectName("horizontalLayout")
self.timestamp = ... | self.groupBox.setObjectName("groupBox")
|
Given the following code snippet before the placeholder: <|code_start|> def dragEnterEvent(self, e):
e.accept()
def dropEvent(self, e):
if e.source() is self:
super().dropEvent(e)
self.items_rearranged.emit()
else:
data = e.mimeData()
if d... | iterator = QtWidgets.QTreeWidgetItemIterator(self) |
Given the following code snippet before the placeholder: <|code_start|>
if entry == (-1, -1):
info = {
"name": item.name,
"computation": item.computation,
}
else:
info = item.name
ranges = [dict(... | drag.exec(QtCore.Qt.CopyAction) |
Given the following code snippet before the placeholder: <|code_start|> )
if len(timebase):
line = L.polyline(
np.column_stack(
[self.latitude_signal.samples, self.longitude_signal.samples]
).tolist()
)
line.addTo(se... | self.set_timestamp(stamp) |
Based on the snippet: <|code_start|> self.latitude = self.longitude = None
self._min = self._max = 0
self._inhibit = False
if len(timebase):
self._min = timebase[0]
self._max = timebase[-1]
else:
self._min = float("inf")
self.... | self.map |
Based on the snippet: <|code_start|># -*- coding: utf-8 -*-
class SearchWidget(Ui_SearchWidget, QtWidgets.QWidget):
selectionChanged = QtCore.pyqtSignal()
def __init__(self, sorted_keys, channels_db, *args, **kwargs):
<|code_end|>
, predict the immediate next line with the help of imports:
from PyQt5 imp... | super().__init__(*args, **kwargs) |
Predict the next line after this snippet: <|code_start|> )
elif self.int_format == "bin":
try:
self._target = int(target, 2)
self.target.setText(f"0b{self._target:b}")
e... | None, |
Predict the next line after this snippet: <|code_start|> f"{column_name} requires an integer target value",
)
elif kind == "f":
try:
self._target = float(target)
except:
... | elif self._target.strip('"') != target: |
Given the code snippet: <|code_start|># -*- coding: utf-8 -*-
class ChannelGroupInfoDialog(QtWidgets.QDialog):
def __init__(self, mdf, group, index, *args, **kwargs):
super().__init__(*args, **kwargs)
self.setWindowFlags(QtCore.Qt.Window)
layout = QtWidgets.QVBoxLayout()
self.se... | self.setStyleSheet('font: 8pt "Consolas";}') |
Given the following code snippet before the placeholder: <|code_start|># -*- coding: utf-8 -*-
class ChannelGroupInfoDialog(QtWidgets.QDialog):
def __init__(self, mdf, group, index, *args, **kwargs):
super().__init__(*args, **kwargs)
self.setWindowFlags(QtCore.Qt.Window)
layout = QtWidg... | self.setStyleSheet('font: 8pt "Consolas";}') |
Continue the code snippet: <|code_start|># -*- coding: utf-8 -*-
class DatabaseItem(Ui_DatabaseItemUI, QtWidgets.QWidget):
def __init__(self, database, bus_type="CAN"):
super().__init__()
self.setupUi(self)
items = [f"Any {bus_type} bus"] + [
f"{bus_type} {i:>2} only" for i... | self.bus.addItems(items) |
Based on the snippet: <|code_start|># -*- coding: utf-8 -*-
class ChannelInfoDialog(QtWidgets.QDialog):
def __init__(self, channel, *args, **kwargs):
super().__init__(*args, **kwargs)
<|code_end|>
, predict the immediate next line with the help of imports:
from PyQt5 import QtCore, QtGui, QtWidgets
fro... | self.setWindowFlags(QtCore.Qt.Window) |
Using the snippet: <|code_start|># -*- coding: utf-8 -*-
class ChannelInfoDialog(QtWidgets.QDialog):
def __init__(self, channel, *args, **kwargs):
super().__init__(*args, **kwargs)
self.setWindowFlags(QtCore.Qt.Window)
layout = QtWidgets.QVBoxLayout()
self.setLayout(layout)
... | icon = QtGui.QIcon() |
Predict the next line after this snippet: <|code_start|># -*- coding: utf-8 -*-
class Attachment(Ui_Attachment, QtWidgets.QWidget):
def __init__(self, index, mdf, *args, **kwargs):
super().__init__(*args, **kwargs)
self.setupUi(self)
self.extract_btn.clicked.connect(self.extract)
... | data, file_path, md5_sum = self.mdf.extract_attachment( |
Continue the code snippet: <|code_start|># -*- coding: utf-8 -*-
class Attachment(Ui_Attachment, QtWidgets.QWidget):
def __init__(self, index, mdf, *args, **kwargs):
super().__init__(*args, **kwargs)
<|code_end|>
. Use current file imports:
from pathlib import Path
from PyQt5 import QtWidgets
from ...b... | self.setupUi(self) |
Predict the next line for this snippet: <|code_start|>#!/usr/bin/env python
class TestATBLOCK(unittest.TestCase):
@classmethod
def setUpClass(cls):
cls.plain_text = "sample text"
cls.plain_bytes = b"##TX\x00\x00\x00\x00(\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00sample text\... | self.assertEqual(block.id, b"##TX") |
Continue the code snippet: <|code_start|>#!/usr/bin/env python
class TestATBLOCK(unittest.TestCase):
@classmethod
def setUpClass(cls):
cls.plain_text = "sample text"
cls.plain_bytes = b"##TX\x00\x00\x00\x00(\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00sample text\x00\x00\x00\x... | def test_read(self): |
Given snippet: <|code_start|> menu.addSeparator()
menu.addAction(self.tr("Relative time base shift"))
menu.addAction(self.tr("Set time base start offset"))
menu.addSeparator()
menu.addAction(self.tr("Insert computation using this channel"))
menu.add... | elif action.text() == "Paste display properties (Ctrl+Shift+P)": |
Continue the code snippet: <|code_start|> self.data_blocks.append(info)
yield info
except StopIteration:
break
def get_signal_data_blocks(self, index: int) -> Iterator[SignalDataBlockInfo]:
signal_data = self.signal_data[index]
if si... | "cycles_nr",
|
Predict the next line for this snippet: <|code_start|> signal_data = self.signal_data[index]
if signal_data is not None:
signal_data, signal_generator = signal_data
for blk in signal_data:
yield blk
while True:
try:
... | self.cycles_nr = 0
|
Based on the snippet: <|code_start|> __slots__ = (
"groups",
"record_size",
"cycles_nr",
)
def __init__(self) -> None:
self.groups = []
self.record_size = 0
self.cycles_nr = 0
def __repr__(self) -> None:
return f"VirtualChannelGroup(gr... | def components(
|
Using the snippet: <|code_start|> while True:
try:
info = next(signal_generator)
signal_data.append(info)
yield info
except StopIteration:
break
class VirtualChannelGroup:
"""starti... | def block_fields(obj: object) -> list[str]:
|
Here is a snippet: <|code_start|>class VirtualChannelGroup:
"""starting with MDF v4.20 it is possible to use remote masters and column
oriented storage. This means we now have virtual channel groups that can
span over multiple regular channel groups. This class facilitates the
handling of this virtu... | except AttributeError:
|
Predict the next line for this snippet: <|code_start|> while True:
try:
info = next(signal_generator)
signal_data.append(info)
yield info
except StopIteration:
break
class VirtualChannel... | def block_fields(obj: object) -> list[str]:
|
Here is a snippet: <|code_start|>
HANDSHAKE_SIGNAL = b'HANDSHAKE'
HANDSHAKE_ACK_SIGNAL = b'HANDSHAKE_ACK'
async def connect_handshake(connection, local_identity, timeout=10):
connection.send(b''.join([HANDSHAKE_SIGNAL, b';',
local_identity.encode('utf-8')]))
await connection.stream.drain(... | handshake_ack = await asyncio.wait_for(connection.recv(), timeout) |
Here is a snippet: <|code_start|>
class Connector:
def __init__(self, loop, settings, client_factory):
self.loop = loop
self.settings = settings
self.client_factory = client_factory
self.clients = {}
async def connect(self, pid):
hub_frontend, identity = pid
if... | continue |
Next line prediction: <|code_start|> def send(self, data):
self.stream.write(data + EOL)
# TODO think more about this, not sure if should be the default case.
# self.stream.writer.drain()
return data
async def recv(self):
data = await self.stream.readline()
if dat... | return None |
Next line prediction: <|code_start|> assert not get_access_token.called
return {'oauth_token': alphabet,
'another': "cba"}
async def oauth_verifier(oauth_token):
assert oauth_token == alphabet
a... | 'hello': "world"} |
Given the code snippet: <|code_start|> assert get_oauth_verifier.called
return {'consumer_key': consumer_key,
'consumer_secret': consumer_secret,
'oauth_token': "abcdef",
'oauth_token_secret': "gh... | side_effect=async_oauth_dance) as async_dance: |
Continue the code snippet: <|code_start|>
async def sign(self, *args, **kwargs):
self.token = alphabet
return self.copy()
def test_oauth2_dance(event_loop):
with patch.object(oauth_dance.oauth, 'OAuth2Headers',
side_effect=MockOAuth2Headers):
args = 'consumer_key'... | pass |
Continue the code snippet: <|code_start|> clsname=self.__class__.__name__,
prefix=self.prefix,
event=self.is_event
)
@classmethod
def event_handler(cls, event, prefix=None, **values):
def decorator(func):
event_handler = cls(
func=... | def __getitem__(self, key): |
Using the snippet: <|code_start|> args = args[:argcount]
return super().__call__(*args)
def __repr__(self):
return "<{clsname}: event:{event} prefix:{prefix}>".format(
clsname=self.__class__.__name__,
prefix=self.prefix,
event=self.is_event
)
... | self.functions = [getattr(self, func) |
Based on the snippet: <|code_start|># -*- coding: utf-8 -*-
on = 'on_{name}'
def _get_value(func):
value = func()
if value is None:
<|code_end|>
, predict the immediate next line with the help of imports:
from functools import wraps
from ..utils import get_args
from .event_handlers import EventHandler
a... | value = func.__name__ |
Predict the next line for this snippet: <|code_start|># -*- coding: utf-8 -*-
on = 'on_{name}'
def _get_value(func):
value = func()
if value is None:
value = func.__name__
<|code_end|>
with the help of current file imports:
from functools import wraps
from ..utils import get_args
from .event_ha... | return value |
Continue the code snippet: <|code_start|> 'hariyama',
'infernape',
'jumpluff',
'kangaskhan',
'lucario',
'... | assert {'uu', 'ou'} == set(processor.battle_info_sink.battles.keys()) |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.