Instruction stringlengths 362 7.83k | output_code stringlengths 1 945 |
|---|---|
Continue the code snippet: <|code_start|># -*- coding: utf-8 -*-
# (c) 2015 Andreas Motl <andreas.motl@getkotori.org>
# https://pypi.python.org/pypi/twisted-mqtt
# https://github.com/astrorafael/twisted-mqtt/
from __future__ import absolute_import
log = Logger()
class TwistedMqttAdapter(BaseMqttAdapter, Service):
... | log.info('gotProtocol, connecting {name}', name=self.name) |
Predict the next line for this snippet: <|code_start|># -*- coding: utf-8 -*-
# (c) 2016-2021 Andreas Motl <andreas@getkotori.org>
log = Logger()
class QueryTransformer(object):
@classmethod
<|code_end|>
with the help of current file imports:
import arrow
from arrow.parser import DateTimeParser
from datetime ... | def transform(cls, data): |
Predict the next line after this snippet: <|code_start|> # Check response.
response = deferred.result
assert response.status_code == 200
assert response.content == json.dumps([
{"type": "info", "message": "Received header fields ['temperature', 'humidity']"},
{"type": "info", "message": "... | Runtime;BatVolt;batPercent;Date;Time;Startflag;alt[ft];Pressure[hpa];SensorTemp[Deg];QNH[hpa];VAR[m/s];Envelope Temp[Deg];HDG[deg];GS[kt];GPS_Alt[m];Lat[deg];Lon[deg]; |
Here is a snippet: <|code_start|># -*- coding: utf-8 -*-
# (c) 2020-2021 Andreas Motl <andreas@getkotori.org>
logger = logging.getLogger(__name__)
@pytest_twisted.inlineCallbacks
@pytest.mark.http
<|code_end|>
. Write the next line using the current file imports:
import json
import logging
import pytest
import py... | def test_http_json_valid(machinery, create_influxdb, reset_influxdb): |
Predict the next line after this snippet: <|code_start|> response = deferred.result
assert response.status_code == 200
assert response.content == json.dumps([
{"type": "info", "message": "Received header fields ['temperature', 'humidity']"},
{"type": "info", "message": "Received #1 readings"}... | 05;4.0;75.67;21/09/21;07:21:55;0;2213.7;934.79;17.03;1013.25; +0.0;0.00; 0;0.0; 0;0.000000;0.000000; |
Predict the next line for this snippet: <|code_start|># -*- coding: utf-8 -*-
# (c) 2020-2021 Andreas Motl <andreas@getkotori.org>
logger = logging.getLogger(__name__)
@pytest_twisted.inlineCallbacks
@pytest.mark.http
<|code_end|>
with the help of current file imports:
import json
import logging
import pytest
im... | def test_http_json_valid(machinery, create_influxdb, reset_influxdb): |
Predict the next line after this snippet: <|code_start|># -*- coding: utf-8 -*-
# (c) 2014 Andreas Motl, Elmyra UG <andreas.motl@elmyra.de>
class BinaryInputPort(object):
def __init__(self, portname, signal=None):
self.portname = portname
self.signal = signal
# detect edge on port
... | if self.signal: |
Given the code snippet: <|code_start|># -*- coding: utf-8 -*-
# (c) 2014 Andreas Motl, Elmyra UG <andreas.motl@elmyra.de>
class BinaryInputPort(object):
def __init__(self, portname, signal=None):
self.portname = portname
self.signal = signal
# detect edge on port
self.gpio = Gpi... | print("DEBUG: Port {0} EVENT".format(self.portname)) |
Given snippet: <|code_start|># -*- coding: utf-8 -*-
# (c) 2020-2021 Andreas Motl <andreas@getkotori.org>
logger = logging.getLogger(__name__)
@pytest_twisted.inlineCallbacks
@pytest.mark.http
@pytest.mark.export
<|code_end|>
, continue by predicting the next line. Consider current file imports:
import json
impor... | def test_export(machinery, create_influxdb, reset_influxdb): |
Next line prediction: <|code_start|># -*- coding: utf-8 -*-
# (c) 2020-2021 Andreas Motl <andreas@getkotori.org>
logger = logging.getLogger(__name__)
@pytest_twisted.inlineCallbacks
@pytest.mark.http
<|code_end|>
. Use current file imports:
(import json
import logging
import io
import pandas as pd
import pytest
i... | @pytest.mark.export |
Predict the next line after this snippet: <|code_start|># -*- coding: utf-8 -*-
# (c) 2020-2021 Andreas Motl <andreas@getkotori.org>
logger = logging.getLogger(__name__)
@pytest_twisted.inlineCallbacks
@pytest.mark.http
<|code_end|>
using the current file's imports:
import json
import logging
import io
import pa... | @pytest.mark.export |
Given the code snippet: <|code_start|># -*- coding: utf-8 -*-
# (c) 2020-2021 Andreas Motl <andreas@getkotori.org>
logger = logging.getLogger(__name__)
@pytest_twisted.inlineCallbacks
@pytest.mark.http
<|code_end|>
, generate the next line using the imports in this file:
import json
import logging
import io
impor... | @pytest.mark.export |
Based on the snippet: <|code_start|>
class PlainRouter(BaseRouter):
def get_hosts(self, **kwargs):
return self.hosts
class ShuffleRouter(BaseRouter):
def __init__(self, solr, hosts):
super().__init__(solr, hosts)
# only shuffle the hosts once, so they're in a different order in all yo... | def get_hosts(self, **kwargs): |
Given the code snippet: <|code_start|># from sklearn.utils import class_weight as cw
def create_gridsearch_model(logger, rparams, gparams, options, exp_settings, scoring, select_model, input_shape, output_shape):
sklearn_params = {
'param_distributions': gparams,
'n_iter': options.n_iter,
... | 'random_state': exp_settings["random_state"]} |
Next line prediction: <|code_start|>
def create_cv(smiles, split_type, n_cv, random_state, y=False):
if split_type == "scaffold":
count = n_cv
<|code_end|>
. Use current file imports:
(import sys
import numpy as np
from moloi.splits.scaffold_split import scaffold_split
from moloi.splits.cluster_split impo... | n_cv = [([], []) for _ in range(count)] |
Predict the next line for this snippet: <|code_start|> # print(len(test))
# print(len(train))
# n_cv[i][0].append(train)
# n_cv[i][1].append(test)
elif split_type == "random" or split_type == "cluster":
count = n_cv
n_cv = [([], []) for _ in range(coun... | count = n_cv |
Next line prediction: <|code_start|> train, test = scaffold_split(smiles, frac_train=1 - ((len(smiles)/count)/(len(smiles)/100))/100,
seed=random_state)
n_cv[i][0].append(train)
n_cv[i][1].append(test)
# The cluster size can not be specifi... | elif split_type == "stratified": |
Given the following code snippet before the placeholder: <|code_start|>
if sys.version_info[0] == 2:
else:
def read_model_config(config_path, section):
model_config = ConfigParser.ConfigParser()
model_config.read(config_path)
epochs = eval(model_config.get('DEFAULT', 'epochs'))
rparams = eval(model_c... | return epochs, rparams, gparams |
Given the following code snippet before the placeholder: <|code_start|>#!/usr/bin/env python
BACKEND = 'loki'
if BACKEND not in BACKENDS.keys():
BACKEND = 'multiprocessing'
# mlp.use('Agg')
params = {
'axes.labelsize': 8,
'font.size': 8,
'legend.fontsize': 10,
'xtick.labelsize': 10,
'ytick.... | pylab.rcParams.update(params) |
Next line prediction: <|code_start|>
def correlation(logger, X, path):
logger.info("Creating correlation plot")
try:
X = pd.DataFrame(X)
corr = X.corr()
sns.heatmap(corr, cmap='RdYlGn_r', square=True)
plt.title('Features correlation')
plt.savefig(path, dpi=150)
pl... | logger.info("Creating history plot") |
Using the snippet: <|code_start|> 'font.size': 8,
'legend.fontsize': 10,
'xtick.labelsize': 10,
'ytick.labelsize': 10,
'figure.figsize': [8, 4]
}
pylab.rcParams.update(params)
def correlation(logger, X, path):
logger.info("Creating correlation plot")
try:
X = pd.DataFrame(X)
... | plt.clf() |
Continue the code snippet: <|code_start|>from __future__ import division, print_function, absolute_import
class SilenceableStreamHandler(logging.StreamHandler):
def __init__(self, *args, **kwargs):
super(SilenceableStreamHandler, self).__init__(*args, **kwargs)
self.silenced = False
def emi... | class LoggingMgr(object): |
Given the following code snippet before the placeholder: <|code_start|>from __future__ import division, print_function, absolute_import
# noinspection PyUnresolvedReferences
# noinspection PyPackageRequirements
__all__ = ['is_posdef', 'randpd', 'stacked_randpd', 'normalize_logspace', 'sq_distance',
'parti... | 'canonize_labels'] |
Given the following code snippet before the placeholder: <|code_start|> picture = Column(GUID, ForeignKey('user_pictures.id'))
karma = Column(Integer, default=0)
notify_by_mail = Column(Boolean, default=True)
twitter_origination = Column(Boolean, default=False)
twitter_oauth_key = Column(UnicodeText)... | pass |
Given snippet: <|code_start|>
class Submission(Base):
__tablename__ = 'submissions'
id = Column(GUID, primary_key=True)
title = Column(UnicodeText, nullable=False)
description = Column(UnicodeText)
points = Column(Integer)
comment_tally = Column(Integer)
category = Column(GUID)
url = ... | slug = Column(UnicodeText, unique=True) |
Based on the snippet: <|code_start|>
class Submission(Base):
__tablename__ = 'submissions'
id = Column(GUID, primary_key=True)
title = Column(UnicodeText, nullable=False)
description = Column(UnicodeText)
points = Column(Integer)
comment_tally = Column(Integer)
category = Column(GUID)
<|c... | url = Column(UnicodeText) |
Here is a snippet: <|code_start|>
class AuthPolicy(object):
def authenticated_userid(self, request):
if not request.session['users.id']:
return None
return users.get_user_by_id(request.session['users.id'])
def unauthenticated_userid(self, request):
if not request.session['us... | def effective_principals(self, request): |
Next line prediction: <|code_start|>
class Section(Base):
__tablename__ = 'sections'
id = Column(GUID, primary_key=True)
name = Column(UnicodeText)
description = Column(UnicodeText)
subscribe_by_default = Column(Boolean, default=False)
parent = Column(GUID, ForeignKey('sections.id'), nullable... | self.subscribe_by_default = subscribe_by_default |
Predict the next line after this snippet: <|code_start|>
dbsession = sqlahelper.get_session()
def get_sublists():
return dbsession.query(Sublist).all()
def get_sublist_by_title(title):
return dbsession.query(Sublist).filter(Sublist.title == title).all()
def get_sublist_members(sublist_id):
members = dbse... | return True |
Here is a snippet: <|code_start|>
dbsession = sqlahelper.get_session()
def get_sublists():
return dbsession.query(Sublist).all()
def get_sublist_by_title(title):
return dbsession.query(Sublist).filter(Sublist.title == title).all()
<|code_end|>
. Write the next line using the current file imports:
import sql... | def get_sublist_members(sublist_id): |
Next line prediction: <|code_start|>
dbsession = sqlahelper.get_session()
def get_sublists():
return dbsession.query(Sublist).all()
def get_sublist_by_title(title):
return dbsession.query(Sublist).filter(Sublist.title == title).all()
def get_sublist_members(sublist_id):
members = dbsession.query(SublistM... | return True |
Using the snippet: <|code_start|>
class Sublist(Base):
__tablename__ = 'sublists'
id = Column(GUID, primary_key=True)
title = Column(UnicodeText)
<|code_end|>
, determine the next line of code. You have imports:
from raggregate.models import *
from sqlalchemy import Column
from sqlalchemy import UnicodeTex... | description = Column(UnicodeText) |
Predict the next line for this snippet: <|code_start|>
class Notify(Base):
__tablename__ = 'notifications'
id = Column(GUID, primary_key=True)
user_id = Column(GUID, ForeignKey('users.id'))
target_id = Column(GUID)
target_type = Column(UnicodeText)
added_on = Column(DateTime)
added_by = Col... | else: |
Next line prediction: <|code_start|>
class UserPreference(Base):
__tablename__ = 'user_preferences'
id = Column(GUID, primary_key=True)
user_id = Column(GUID, ForeignKey('users.id'))
preference_list = Column(UnicodeText)
user = relationship('User', backref='preferences')
<|code_end|>
. Use curr... | def __init__(self, user_id, preference_list): |
Predict the next line for this snippet: <|code_start|>
def upgrade(migrate_engine):
meta = MetaData(bind=migrate_engine)
comments = Table('comments', meta, autoload=True)
unreadc = Column('unread', Boolean, default=True)
in_reply_toc = Column('in_reply_to', GUID, nullable=True)
unreadc.create(commen... | meta = MetaData(bind=migrate_engine) |
Given the code snippet: <|code_start|>
md = markdown.Markdown( safe_mode='escape', )
def render_md(s):
if s:
return md.convert(s)
else:
<|code_end|>
, generate the next line using the imports in this file:
import markdown
import queries
from raggregate.queries import submission
from raggregate.model... | return "" |
Predict the next line after this snippet: <|code_start|>
class Comment(Base):
__tablename__ = 'comments'
id = Column(GUID, primary_key=True)
submission_id = Column(GUID, ForeignKey('submissions.id'), nullable=False)
user_id = Column(GUID, ForeignKey('users.id'), nullable=False)
parent_id = Colum... | added_on = Column(DateTime(timezone=True), default=sqlalchemy.sql.func.now()) |
Given snippet: <|code_start|>
class MOTD(Base):
__tablename__ = 'motds'
id = Column(GUID, primary_key=True)
message = Column(UnicodeText, nullable=False)
author = Column(UnicodeText)
<|code_end|>
, continue by predicting the next line. Consider current file imports:
from raggregate.models import *
from... | source = Column(UnicodeText) |
Given the code snippet: <|code_start|>
@view_config(renderer='search.mak', route_name='search')
def search(request):
r = request
ses = r.session
try:
sc = request.registry.solr_conn
except AttributeError:
r.session['message'] = 'I could not find the search engine.'
return {'code'... | stories = [] |
Given snippet: <|code_start|>
@view_config(renderer='search.mak', route_name='search')
def search(request):
r = request
ses = r.session
try:
sc = request.registry.solr_conn
except AttributeError:
r.session['message'] = 'I could not find the search engine.'
return {'code': 'ENOSOL... | if type(vd) == dict: |
Predict the next line after this snippet: <|code_start|>
class SublistMember(Base):
__tablename__ = 'sublists_members'
id = Column(GUID, primary_key=True)
sublist_id = Column(GUID, ForeignKey('sublists.id'))
member_id = Column(GUID, ForeignKey('submissions.id'))
added_by = Column(GUID, ForeignKey('u... | self.added_by = added_by |
Based on the snippet: <|code_start|>
meta = MetaData()
def make_subscriptions_table(meta):
users = Table('users', meta, autoload=True)
sections = Table('sections', meta, autoload=True)
users_subscriptions = Table(
'users_subscriptions', meta,
Column('id', GUID, primary_key=True),
... | def downgrade(migrate_engine): |
Predict the next line for this snippet: <|code_start|> __tablename__ = 'epistles'
id = Column(GUID, primary_key=True)
recipient = Column(GUID, ForeignKey('users.id'))
sender = Column(GUID, ForeignKey('users.id'))
body = Column(UnicodeText)
subject = Column(UnicodeText)
unread = Column(Boolea... | if self.subject is not None: |
Using the snippet: <|code_start|>
class UserPicture(Base):
__tablename__ = 'user_pictures'
id = Column(GUID, primary_key=True)
orig_filename = Column(UnicodeText)
filename = Column(UnicodeText)
file_hash = Column(UnicodeText)
# 0 for user's computer
# 1 for twitter
# 2 for facebook
... | self.orig_filename = orig_filename |
Continue the code snippet: <|code_start|> if key in post and post[key] != '':
return post[key]
else:
return None
def realize_timedelta_constructor(con_str):
""" Converts a timedelta constructor parameter list into a real timedelta.
@param con_str: the constructor parameters to convert"""... | sa.value = value |
Predict the next line for this snippet: <|code_start|>
dbsession = sqlahelper.get_session()
def start_auth(request):
app_twit = request.registry.app_twit
auth_toks = app_twit.get_authentication_tokens()
return auth_toks
<|code_end|>
with the help of current file imports:
import sqlalchemy
import sqla... | def complete_auth(request, auth_toks): |
Based on the snippet: <|code_start|>
class Ban(Base):
__tablename__ = 'bans'
id = Column(GUID, primary_key=True)
# 0 for IP, 1 for username, 2 for ip/username pair
# left as integer for possible expansion
ban_type = Column(Integer, default = 0)
expires = Column(DateTime(timezone=True), defaul... | self.ip = ip |
Using the snippet: <|code_start|>
class Vote(Base):
__tablename__ = 'votes'
id = Column(GUID, primary_key=True)
# we do not coalesce these into a generic item column
# because things are easier/safer with the FK support.
# the tradeoff here is size on various db structures.
submission_id = Col... | elif target_type == 'submission': |
Predict the next line after this snippet: <|code_start|> 'granite_armour' : 'granite_armour',
'faint' : 'faint',
'quicksand' : 'quicksand',
'blizzard' : 'blizzard',
'frost_storm' : 'frost_storm',
'... | def play_sound(self, sound_name): |
Predict the next line after this snippet: <|code_start|>
pygame.font.init()
title_font = pygame.font.Font(FONT_ALEX_BRUSH, 84)
cursive_small = pygame.font.Font(FONT_ALEX_BRUSH, 48)
menu_item_font = pygame.font.SysFont('serif', 32)
huge_font = pygame.font.SysFont('serif', 64)
large_font = pygame.font.SysFont('serif', 48... | return menu_item_font.render(text, 1, colour) |
Based on the snippet: <|code_start|>
def render_title(text, colour = colours.COLOUR_AMLSERVINYOUR):
return title_font.render(text, 1, colour)
def render_menu_item(text, colour = colours.COLOUR_AMLSERVINYOUR):
return menu_item_font.render(text, 1, colour)
def render_huge_text(text, colour = colours.COLOUR_AMLS... | while text: |
Here is a snippet: <|code_start|> else:
# Invalid target! Don't do anything
print("Invalid target")
print("")
return {"success" : False, "caster" :self, "reason" : "invalid target"}
try:
# Cast the spell!
summary... | def take_damage(self, damage): |
Next line prediction: <|code_start|>class ImageManager:
class __ImageManager:
def __init__(self):
self.images = {}
image_files = os.listdir(IMAGE_DIR)
for image_name in image_files:
self.images[os.path.splitext(image_name)[0]] = pygame.image.load(os.pat... | clip_x*self.tile_size, |
Predict the next line for this snippet: <|code_start|>
class MusicManager:
class __MusicManager:
def __init__(self, settings):
self.music = {}
self.now_playing = ""
if settings == None:
self.settings = {
"sound" :
... | } |
Predict the next line after this snippet: <|code_start|> self.scores[team.get_short_name()] = 0
def get_matches_list(self):
return self.matches
def get_current_match(self):
return self.current_match
def get_scores(self):
return self.scores
def record_result(self, b... | return False |
Here is a snippet: <|code_start|> try:
self.write_message(dumps({'action': action, 'data': data}, json_options=RELAXED_JSON_OPTIONS))
except Exception as e:
logger.error('Exception in send_message: %s %s', action, data, exc_info=e)
self.on_close()
self.clos... | exc_info = '' |
Given the following code snippet before the placeholder: <|code_start|>
class EditIssueDialog(Dialog):
exit_keys = ['esc', 'f4']
def __init__(self, issue, db):
self.issue = issue
self.db = db
self.edit_boxes = {}
self.type_dict = {}
rows = []
for prop in issue:... | return value |
Predict the next line for this snippet: <|code_start|> def _to_str(self, prop, value):
t = type(value)
self.type_dict[prop] = t
if t == str:
return value
if t == bytes:
return value.decode('utf-8', errors='ignore')
if t == datetime:
return ... | def save_modifications(self, btn): |
Predict the next line for this snippet: <|code_start|># Copyright (c) 2016-2022 Renata Hodovan, Akos Kiss.
#
# Licensed under the BSD 3-Clause License
# <LICENSE.rst or https://opensource.org/licenses/BSD-3-Clause>.
# This file may not be copied, modified, or distributed except
# according to those terms.
class Di... | style = dict(body='warning', title='warning_title', border='warning_border') |
Here is a snippet: <|code_start|># Copyright (c) 2016-2022 Renata Hodovan, Akos Kiss.
#
# Licensed under the BSD 3-Clause License
# <LICENSE.rst or https://opensource.org/licenses/BSD-3-Clause>.
# This file may not be copied, modified, or distributed except
# according to those terms.
class Dialog(PopUpTarget):
... | else: |
Here is a snippet: <|code_start|> else:
style = dict(body='warning', title='warning_title', border='warning_border')
self.walker = SimpleListWalker(body)
self.listbox = ListBox(self.walker)
self.frame = Frame(body=AttrMap(self.listbox, style['body']),
... | return super().keypress(size, key) |
Next line prediction: <|code_start|> def _to_str(self, prop, value):
t = type(value)
self.type_dict[prop] = t
if t == str:
return value
if t == bytes:
return value.decode('utf-8', errors='ignore')
if t == datetime:
return value.strftime('%Y... | def save_modifications(self, btn): |
Given the following code snippet before the placeholder: <|code_start|> colorscheme "mint-examples2"
"""
config2 = r"""
[layout]
style layout
[node]
style poly
fontName $FONTNAME
fontSize $FONTSIZE
textBaselineCorrect... | style poly |
Based on the snippet: <|code_start|>
class Direction(object):
Top, Right, Bottom, Left = range(4)
def opposite_dir(d):
if d == Direction.Bottom:
return Direction.Top
if d == Direction.Right:
return Direction.Left
if d == Direction.Top:
return Direction.Bottom
... | raise ValueError, 'Invalid direction: %s' % d
|
Predict the next line after this snippet: <|code_start|>
sys.path.append(os.path.join('..'))
class TestCSS3Colors(unittest.TestCase):
def test_valid(self):
r, g, b, a = color_to_rgba('aquamarine')
c = rgba_to_color(r, g, b, a, format='rgb')
self.assertEquals('rgb(127, 255, 21... | self.assertEquals('#112233', c)
|
Given the code snippet: <|code_start|> numSides 6
strokeWidth 3
textPadX 15
textPadY 15
[connection]
style curve
[color]
style cycle
colorscheme "mint-examples"
"""
config3 = r"""
[layo... | [color] |
Next line prediction: <|code_start|>
class Layout(object):
def __init__(self, config):
properties = {
'horizontalBalance': (NumberProperty, {}),
'verticalAlignFactor': (NumberProperty, {'min': 0.0,
<|code_end|>
. Use current file imports:
(import math, os, ... | 'max': 1.0}),
|
Predict the next line for this snippet: <|code_start|>
sys.path.append(os.path.join('..'))
deg = math.degrees
rad = math.radians
class TestEvalExpr(unittest.TestCase):
def assert_equals(self, a, b):
self.assertTrue(abs(a - b) < 1e-12)
def test_constructor_cartesian1(self):
... | def test_normalize(self):
|
Here is a snippet: <|code_start|>ctx.fill(c)
ctx.rect(x, y, w, h)
x += w + padx
c = c.blend(white, f)
ctx.fill(c)
ctx.rect(x, y, w, h)
y += h + pady
x = xo
ctx.fill(textcol)
ctx.text('darken', 84, y + 36)
c = col2
ctx.fill(c)
ctx.rect(x, y, w, h)
x += w + padx
c = c.darken(f)
ctx.fill(c)
ctx.rect(x, y, w, h)
x ... | x += w + padx |
Given the code snippet: <|code_start|>COLOR_CONFIG = 'color'
##############################################################################
# Properties
##############################################################################
class Property(object):
def __init__(self, name):
self.name = name
... | def _validate(self): |
Predict the next line after this snippet: <|code_start|>
class ColorProperty(Property):
def _validate(self):
if type(self.value).__name__ != 'Color':
raise ConfigError("Property '%s' must evaluate to a color"
% self.name, self.expr)
class EnumProperty(Property):
... | "numeric value: %s" % (self.name, n)), self.expr) |
Predict the next line for this snippet: <|code_start|> textPadX 14
textPadY 14
[connection]
style curve
[color]
style cycle
colorscheme "mint-examples"
"""
config2 = r"""
[layout]
style layout
[nod... | colorscheme "mint-examples3" |
Given snippet: <|code_start|>
def drawconn(ctx, linewidth_start, linewidth_end, x1, y1, x2, y2,
cx1, cx2, cy1, cy2):
ctx.strokewidth(linewidth_end)
x2 -= linewidth_end / 2
cx1 = (x2 - x1) * cx1
<|code_end|>
, continue by predicting the next line. Consider current file imports:
import os, s... | cx2 = (x2 - x1) * cx2 |
Given the following code snippet before the placeholder: <|code_start|>
config1 = r"""
[layout]
style layout
horizontalBalance 0
rootPadX 110
nodePadY 10
radialMinNodes 1000
sameWidthSiblings no
snapParentToChildren ye... | [connection] |
Predict the next line after this snippet: <|code_start|>
config1 = r"""
[layout]
style layout
[node]
style rect
fontName $FONTNAME
fontSize $FONTSIZE
textBaselineCorrection $BASELINE_CORR
strokeWidth 3
roundnes... | style layout |
Given the following code snippet before the placeholder: <|code_start|>
config1 = r"""
[layout]
style layout
[node]
style line
fontName $FONTNAME
fontSize $FONTSIZE
textBaselineCorrection $BASELINE_CORR
strokeWidth ... | [color] |
Predict the next line for this snippet: <|code_start|># Copyright (C) 2007 Giampaolo Rodola' <g.rodola@gmail.com>.
# Use of this source code is governed by MIT license that can be
# found in the LICENSE file.
try:
except ImportError:
try:
except ImportError:
pwd = grp = None
try:
except ImportError:
try:
... | def _memoize(fun): |
Predict the next line after this snippet: <|code_start|># Copyright (C) 2007 Giampaolo Rodola' <g.rodola@gmail.com>.
# Use of this source code is governed by MIT license that can be
# found in the LICENSE file.
try:
except ImportError:
try:
except ImportError:
pwd = grp = None
<|code_end|>
using the current fil... | try: |
Using the snippet: <|code_start|>
context = super(KioskView, self).get_context_data(**kwargs)
context['kiosk'] = kiosk.name
return context
@csrf_exempt
def kiosk_data(request, **kwargs):
slug = kwargs['name']
kiosk = get_object_or_404(Kiosk, name=slug)
currentPresentation = kiosk.pr... | ) |
Using the snippet: <|code_start|>Table = NewTag('Table', 'table', Table, class_='table')
H1 = NewTag('H1', 'h1', H1, class_='title is-1')
H2 = NewTag('H2', 'h2', H2, class_='title is-2')
H3 = NewTag('H3', 'h3', H3, class_='title is-3')
H4 = NewTag('H4', 'h4', H4, class_='title is-4')
H5 = NewTag('H5', 'h5', H5, class_... | PrimaryButton, |
Given the code snippet: <|code_start|>Row = NewTag('Row', 'div', Row, class_='row')
Col = NewTag('Col', 'div', Col, class_='span')
Col1 = NewTag('Col1', 'div', (Col1, Col), class_='one')
Col2 = NewTag('Col2', 'div', (Col2, Col), class_='two')
Col3 = NewTag('Col3', 'div', (Col3, Col), class_='three')
Col4 = NewTag('Col4... | Col5, |
Predict the next line after this snippet: <|code_start|>#!/usr/bin/env python3
# -*- coding: utf-8 -*-
# fake connection
_tornado.connections.append(1) # type: ignore
root = Path(__file__).absolute().parent.parent
html_file = root / 'docs/_build/html/node.html'
with open(html_file) as f:
real_html = f.read()
... | <span b="2">text</span> |
Predict the next line for this snippet: <|code_start|>#!/usr/bin/env python3
# -*- coding: utf-8 -*-
# fake connection
_tornado.connections.append(1) # type: ignore
root = Path(__file__).absolute().parent.parent
html_file = root / 'docs/_build/html/node.html'
with open(html_file) as f:
real_html = f.read()
sr... | <div a="1"> |
Given snippet: <|code_start|>LinkButton = NewTag('LinkButton', 'a', class_='button-alt', is_='link-button')
Col1 = NewTag('Col1', 'div', Col, class_='col-1', is_='col1')
Col2 = NewTag('Col2', 'div', Col, class_='col-2', is_='col2')
Col3 = NewTag('Col3', 'div', Col, class_='col-3', is_='col3')
Col4 = NewTag('Col4', 'di... | Col5, |
Based on the snippet: <|code_start|>
input = Input(type='checkbox')
print(input.html_noid) # <input type="checkbox">
# this is equivalent to:
input = Input()
<|code_end|>
, predict the immediate next line with the help of imports:
from wdom.tag import Input
and context (classes, functions, sometimes code) from othe... | input.setAttribute('type', 'checkbox') |
Given the following code snippet before the placeholder: <|code_start|>#!/usr/bin/env python3
# -*- coding: utf-8 -*-
class Item(Tag):
tag = 'span'
def __init__(self, *args, **kwargs) -> None:
super().__init__(*args, **kwargs)
def sample_page(**kwargs) -> Document:
app = Container()
title ... | item = Item() |
Predict the next line after this snippet: <|code_start|>#!/usr/bin/env python3
# -*- coding: utf-8 -*-
class Item(Tag):
tag = 'span'
def __init__(self, *args, **kwargs) -> None:
super().__init__(*args, **kwargs)
def sample_page(**kwargs) -> Document:
app = Container()
title = H1(parent=app... | item = Item() |
Continue the code snippet: <|code_start|>#!/usr/bin/env python3
# -*- coding: utf-8 -*-
class Item(Tag):
tag = 'span'
def __init__(self, *args, **kwargs) -> None:
super().__init__(*args, **kwargs)
def sample_page(**kwargs) -> Document:
app = Container()
title = H1(parent=app)
title.tex... | item.append('New Item') |
Predict the next line for this snippet: <|code_start|>#!/usr/bin/env python3
# -*- coding: utf-8 -*-
class Item(Tag):
tag = 'span'
def __init__(self, *args, **kwargs) -> None:
super().__init__(*args, **kwargs)
def sample_page(**kwargs) -> Document:
app = Container()
title = H1(parent=app)
... | item = Item() |
Predict the next line after this snippet: <|code_start|>
class Item(Tag):
tag = 'span'
def __init__(self, *args, **kwargs) -> None:
super().__init__(*args, **kwargs)
def sample_page(**kwargs) -> Document:
app = Container()
title = H1(parent=app)
title.textContent = 'Todo example'
fo... | add_button.addEventListener('click', new_item) |
Given snippet: <|code_start|>
class Item(Tag):
tag = 'span'
def __init__(self, *args, **kwargs) -> None:
super().__init__(*args, **kwargs)
def sample_page(**kwargs) -> Document:
app = Container()
title = H1(parent=app)
title.textContent = 'Todo example'
form = FormGroup(parent=app)
... | add_button.addEventListener('click', new_item) |
Predict the next line for this snippet: <|code_start|>
class Col(Div):
column = None
is_ = 'col'
def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
if self.column:
self.setAttribute('column', str(self.column))
Col1 = NewTag('Col1', 'div', Col, column=1, is_='... | DangerButton, |
Given the following code snippet before the placeholder: <|code_start|>Container = NewTag('Container', 'div', Container, class_='container')
Wrapper = NewTag('Wrapper', 'div', Wrapper, class_='container')
Row = NewTag('Row', 'div', Row, class_='row')
Col = NewTag('Col', 'div', Col, class_='columns')
Col1 = NewTag('Col1... | Col8, |
Given the following code snippet before the placeholder: <|code_start|>Row = NewTag('Row', 'div', Row, class_='row')
Col1 = NewTag('Col1', 'div', Col1, class_='one twelfth')
Col2 = NewTag('Col2', 'div', Col2, class_='one sixth')
Col3 = NewTag('Col3', 'div', Col3, class_='one fourth')
Col4 = NewTag('Col4', 'div', Col4, ... | Col6, |
Continue the code snippet: <|code_start|>
def test_default_loglevel(self):
parse_command_line()
set_loglevel()
logger = logging.getLogger('wdom')
self.assertEqual(logger.getEffectiveLevel(), logging.INFO)
@parameterized.expand([
('debug', logging.DEBUG),
('info',... | assert logger.getEffectiveLevel() == logging.WARN |
Predict the next line for this snippet: <|code_start|> logger = logging.getLogger('wdom')
self.assertEqual(logger.getEffectiveLevel(), level)
reset_options()
def test_debug_without_logging(self):
sys.argv.extend(['--debug'])
parse_command_line()
logger = logging.getLo... | reset_options() |
Predict the next line for this snippet: <|code_start|> super().tearDown()
def test_default_loglevel(self):
parse_command_line()
set_loglevel()
logger = logging.getLogger('wdom')
self.assertEqual(logger.getEffectiveLevel(), logging.INFO)
@parameterized.expand([
('... | logger = logging.getLogger('wdom') |
Based on the snippet: <|code_start|>
_argv = copy(sys.argv)
_config = copy(vars(config))
def reset_options():
sys.argv = copy(_argv)
for k, v in _config.items():
setattr(config, k, v)
class TestOptions(TestCase):
def tearDown(self):
reset_options()
super().tearDown()
def ... | ]) |
Continue the code snippet: <|code_start|>
ul = Ul()
ul.innerHTML = '''\
<li>item1</li>
<li>item2</li>
<|code_end|>
. Use current file imports:
from wdom.tag import Ul
and context (classes, functions, or code) from other files:
# Path: wdom/tag.py
# class Tag(WdomElement):
# class NestedTag(Tag):
# class Input(Tag, H... | <li>item3</li> |
Given snippet: <|code_start|>#!/usr/bin/env python3
# -*- coding: utf-8 -*-
def tearDownModule():
close_webdriver()
CURDIR = path.dirname(path.abspath(__file__))
ROOTDIR = path.dirname(path.dirname(CURDIR))
ENV = os.environ.copy()
ENV['PYTHONPATH'] = ROOTDIR
src_base = '''
import sys # noqa: F401
import a... | from wdom.document import get_document |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.