Instruction stringlengths 362 7.83k | output_code stringlengths 1 945 |
|---|---|
Given snippet: <|code_start|> for i in range(self.record_count):
flow_format = u.unpack_uint()
flow_head = u.unpack_opaque()
flow_u = xdrlib.Unpacker(flow_head)
d = flows.getDecoder(flow_format)
if d:
self.flows[flow_format] = d(flow_u)... | print("Unknown format:", counter_format) |
Continue the code snippet: <|code_start|>
class Sflow(object):
def __init__(self, payload, host):
self.host = host
assert isinstance(payload, bytes)
u = xdrlib.Unpacker(payload)
self.version = u.unpack_uint()
self.samplers = {
1: FlowSample,
2: Cou... | self.address = u.unpack_fstring(16) |
Given the following code snippet before the placeholder: <|code_start|> print(ethernet.type, repr(data))
class IPv6Header(object):
def __init__(self, u):
pass
class IEEE80211MACHeader(object):
def __init__(self, u):
pass
class PPPHeader(object):
def __init__(self, u):
p... | if self.samplers.get(self.protocol): |
Predict the next line after this snippet: <|code_start|>#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This ... | self._get_languages_names_codes = get_languages_names_codes |
Given snippet: <|code_start|> gettext.bindtextdomain('gedit-plugins')
gettext.textdomain('gedit-plugins')
_ = gettext.gettext
except:
_ = lambda s: s
class SessionSaverAppActivatable(GObject.Object, Gedit.AppActivatable):
app = GObject.Property(type=Gedit.App)
__instance = None
def __ini... | item = Gio.MenuItem.new(_("_Manage Saved Sessions…"), "win.managedsession") |
Given the code snippet: <|code_start|> def get_default_language_codes(self):
return 'en|es'
def get_api_hint(self):
return _("You need to obtain an API key at <a href='https://yandex.com/dev/translate/'>https://yandex.com/dev/translate/</a>")
def has_api_key(self):
return True
... | def get_language_pair_name(self, source, target, locales_names=None): |
Using the snippet: <|code_start|> dirname = os.path.dirname(self.filename)
if not os.path.isdir(dirname):
os.makedirs(dirname)
fp = open(self.filename, "wb")
fp.write(bytes('<?xml version="1.0" encoding="UTF-8"?>\n','UTF-8'))
fp.write(bytes(self.dump(),'UTF-8'))
... | assert self._current_session is None |
Predict the next line for this snippet: <|code_start|># along with gedit Session Saver Plugin; if not, write to the Free Software
# Foundation, Inc., 51 Franklin St, Fifth Floor,
# Boston, MA 02110-1301 USA
class XMLSessionStore(SessionStore):
def __init__(self, filename = None):
super(XMLSessionStore, ... | return '<saved-sessions>\n%s</saved-sessions>\n' % ''.join(dump) |
Here is a snippet: <|code_start|> del self._highlight_tag
def update_location(self):
gfile = self._doc.get_file().get_location()
if gfile is None:
return
if self.gfile is None or gfile.get_uri() != self.gfile.get_uri():
SynctexWindowActivatable.view_dict[gfi... | def _highlight(self): |
Using the snippet: <|code_start|> def get_default_language_codes(self):
return 'eng|spa'
def has_api_key(self):
return False
def set_api_key(self, key):
pass
def set_server(self, server):
self.server = server
def get_api_hint(self):
pass
def init(self)... | def _get_lang_from_langcountry(self, language): |
Given the following code snippet before the placeholder: <|code_start|> def __init__(self):
super(SessionStore, self).__init__()
self._sessions = []
def __iter__(self):
return iter(self._sessions)
def __getitem__(self, index):
return self._sessions[index]
def __getslice... | self.emit('session-added', session) |
Next line prediction: <|code_start|> self.__del__()
class SaveSessionDialog(Dialog):
def __init__(self, window, sessions, current_session, on_updated_sessions, data_dir):
super(SaveSessionDialog, self).__init__('save-session-dialog',
data_dir,
... | if model.get_value(piter, self.NAME_COLUMN) == option_name: |
Given the code snippet: <|code_start|>#
# The program is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
# See the GNU General Public License for more details.
#
# You should have received a copy of... | self.underline = False |
Next line prediction: <|code_start|>
def fetch_cached(self, context):
cache_key = self.get_cache_key()
user = context['request'].user
if not user.is_staff and caching_enabled and cache.has_key(cache_key):
cached_value = cache.get(cache_key)
rendered_content = cached_v... | variables = dict(var_for_context(var) for var in vars_qs) |
Given the following code snippet before the placeholder: <|code_start|> 'Enter a comma separated list of choices that will be '
'available in the dropdown variable when adding and '
'configuring the custom component on a page.'))
@property
def choices_list(self):
retu... | return |
Next line prediction: <|code_start|>
@property
def choices_list(self):
return ([choice.strip() for choice in self.choices.split(',') if choice.strip()]
if self.choices else [])
def save(self, *args, **kwargs):
self.widget = 'DropDownField'
super(DropDownVariable, sel... | cache.delete(key) |
Predict the next line after this snippet: <|code_start|> ordering = ['name']
verbose_name = _('Custom Component')
verbose_name_plural = _('Custom Components')
def __init__(self, *args, **kwargs):
#hack due to
# https://code.djangoproject.com/ticket/16433#no1
for r... | return self.name |
Based on the snippet: <|code_start|> related_name='variables')
value = models.TextField()
snippet = models.ForeignKey(SmartSnippetPointer, related_name='variables')
class Meta:
unique_together = (('snippet_variable', 'snippet'))
@property
def formatt... | return self.snippet_variable.resources_dict.get('css', set()) |
Here is a snippet: <|code_start|> name = 'Text Field'
template = 'smartsnippets/widgets/textfield/widget.html'
class TextAreaField(SmartSnippetWidgetBase):
name = 'TextArea Field'
template = 'smartsnippets/widgets/textareafield/widget.html'
class DropDownField(SmartSnippetWidgetBase):
name = 'Dro... | return json.loads( |
Based on the snippet: <|code_start|> name = 'Text Field'
template = 'smartsnippets/widgets/textfield/widget.html'
class TextAreaField(SmartSnippetWidgetBase):
name = 'TextArea Field'
template = 'smartsnippets/widgets/textareafield/widget.html'
class DropDownField(SmartSnippetWidgetBase):
name = '... | return json.loads( |
Predict the next line after this snippet: <|code_start|> self._settings.pop(namespace, None)
def register_widget(self, widget):
if not issubclass(widget, SmartSnippetWidgetBase):
raise ImproperlyConfigured(
'Smartsnippets widgets must be subclasses of WidgetBase, %s i... | def get_all_widgets(self, has_model=False, snippet=None): |
Predict the next line after this snippet: <|code_start|>
class WidgetPool(object):
def __init__(self):
self.widgets = {}
self._settings = defaultdict(dict)
<|code_end|>
using the current file's imports:
from django.core.exceptions import ImproperlyConfigured
from cms.utils.django_load import load... | self.discovered = False |
Using the snippet: <|code_start|>
class WidgetPool(object):
def __init__(self):
self.widgets = {}
self._settings = defaultdict(dict)
self.discovered = False
def discover_widgets(self):
if self.discovered:
return
self.discovered = True
load('widgets')... | def register_settings(self, namespace, settings_dict): |
Next line prediction: <|code_start|>
class InheritPageContent(CMSPlugin):
# from which page
from_page = models.ForeignKey(Page)
# from which section
from_placeholder = models.CharField(max_length=255, db_index=True)
class Meta:
<|code_end|>
. Use current file imports:
(from django.db import model... | db_table = 'cmsplugin_inheritpagecontent' |
Predict the next line after this snippet: <|code_start|> label=_("page"), queryset=Page.objects.drafts())
site = None
current_page = None
class Meta:
model = InheritPageContent
fields = ('from_page', 'from_placeholder')
@property
def media(self):
_media = super(Inher... | if not slot: |
Using the snippet: <|code_start|>
class InheritPageForm(ModelForm):
from_page = forms.ModelChoiceField(
label=_("page"), queryset=Page.objects.drafts())
site = None
current_page = None
class Meta:
model = InheritPageContent
fields = ('from_page', 'from_placeholder')
@prope... | site_pages = Page.objects.drafts().on_site(self.site) |
Given the following code snippet before the placeholder: <|code_start|>
class InheritPageForm(ModelForm):
from_page = forms.ModelChoiceField(
label=_("page"), queryset=Page.objects.drafts())
site = None
current_page = None
class Meta:
model = InheritPageContent
fields = ('from_... | _media = super(InheritPageForm, self).media |
Next line prediction: <|code_start|>
@csrf_protect
def variables_edit_view(request, plugin_id):
plugin = get_object_or_404(InheritPageContent, id=plugin_id)
if not has_plugin_permission(request.user, plugin.plugin_type, "change"):
raise PermissionDenied
snippet_plugin_id = None
if request.met... | variables = snippet_plugin.variables.filter( |
Given the code snippet: <|code_start|>
@csrf_protect
def variables_edit_view(request, plugin_id):
plugin = get_object_or_404(InheritPageContent, id=plugin_id)
if not has_plugin_permission(request.user, plugin.plugin_type, "change"):
raise PermissionDenied
snippet_plugin_id = None
if request.m... | variables = variables.select_related('snippet_variable') |
Using the snippet: <|code_start|> variables = variables.select_related('snippet_variable')
overwrite_variables = []
for var in variables:
new_value = request.POST.get("_%s_" % var.snippet_variable.name)
if new_value is None:
continue
try:
... | } |
Using the 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 applicable law or ag... | def __init__(self): |
Given the following code snippet before the placeholder: <|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 ... | def __get_client_from_osc(*args): |
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... | self.api_client.get.assert_called_once_with( |
Predict the next line after this snippet: <|code_start|># Copyright 2019 Objectif Libre
#
# 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/LIC... | self.api_client.get.assert_called_once_with('/v2/rating/modules') |
Given the following code snippet before the placeholder: <|code_start|># License for the specific language governing permissions and limitations
# under the License.
#
class TestReport(base.BaseAPIEndpointTestCase):
def test_get_summary(self):
self.report.get_summary()
self.api_client.get.a... | def test_get_total_with_begin_end(self): |
Based on the snippet: <|code_start|># Copyright 2019 objectif Libre
#
# 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
#
# Unle... | self.api_client = utils.FakeHTTPClient() |
Using the snippet: <|code_start|> os.replace(src=temp_path, dst=path)
def has(self, *args, **kwargs):
if not params_legal(args, kwargs):
return None
path = self.path_function(*args, **kwargs)
return path.exists()
class Storage:
def __init__(self, storage_path):
... | return self.storage_path / "secret/token.json" |
Using the snippet: <|code_start|>
def build(prod_id, build_id):
storagedb = get_storagedb()
product = storagedb.product.load(prod_id)
if product is None:
flask.abort(404)
repository_raw = storagedb.repository.load(prod_id, build_id)
if repository_raw is None:
flask.abort(404)
<|co... | build_data = [b for b in product.builds if b.id == build_id][0] |
Based on the snippet: <|code_start|> #"installDirectory": "Fallout 2",
#"projectName": "Fallout 2",
"rootGameID": None,
"support_commands": [],
"timestamp": None
}
def load_repository_v1(data):
source = FallbackDict(data["product"], REPOSITORY_V1_DEFAULTS)
return model.RepositoryV1(
... | "symlinkType": None, |
Using the snippet: <|code_start|> builds = orm.relationship(
"Build", back_populates="product", cascade="all, delete-orphan",
order_by="desc(Build.date_published)")
pricehistory = orm.relationship(
"PriceRecord", back_populates="product", cascade="all, delete-orphan",
order_by="Pr... | return self.dl_systems |
Given snippet: <|code_start|>
def __repr__(self):
return "<Product(id={}, slug='{}')>".format(self.id, self.slug)
class Language(Base):
__tablename__ = "languages"
prod_id = Column(
sql.Integer, sql.ForeignKey("products.id"), primary_key=True)
isocode = Column(sql.String(20), primary_... | self.prod_id, self.slug) |
Given the code snippet: <|code_start|>
class Product(Base):
__tablename__ = "products"
id = Column(sql.Integer, primary_key=True, autoincrement=False)
title = Column(sql.String(120), nullable=True)
slug = Column(sql.String(120), nullable=True)
title_norm = Column(sql.String(120), default="", nul... | dl_mac = Column(sql.Boolean, nullable=True) |
Predict the next line after this snippet: <|code_start|> sql.Integer, sql.ForeignKey("products.id"), nullable=False)
action = Column(sql.String(20), nullable=False)
type_prim = Column(sql.String(40), nullable=False)
type_sec = Column(sql.String(40), nullable=True)
resource = Column(sql.String(120... | def action_type(self): |
Using the snippet: <|code_start|> (
idx_change.id,
idx_change.title,
idx_change.timestamp.timestamp(),
idx_change.action,
idx_change.category,
idx_change.dl_type,
idx_change.bonus_type,
... | ids = db.ids.load() |
Given the following code snippet before the placeholder: <|code_start|> if changerec.download_record.dl_old_bonus is not None:
# Just set it potentially twice because it has to be the same value anyway
idx_change.bonus_type = changerec.download_record.dl_old_bonus.bonus_type
... | prod.id, |
Next line prediction: <|code_start|> id = Column(sql.Integer, primary_key=True, autoincrement=True)
repo_id = Column(
sql.Integer, sql.ForeignKey("repository_v2.id"),
nullable=False)
manifest_id = Column(
sql.Integer, sql.ForeignKey("depotmanifest_v2.id"),
nullable=False)
... | if self.bitness_32 is True: values.append("32") |
Predict the next line for this snippet: <|code_start|>
class DlFile(Base):
__tablename__ = "files"
__table_args__ = (sql.UniqueConstraint("download_id", "slug"),)
download_id = Column(sql.Integer, sql.ForeignKey("downloads.id"),
<|code_end|>
with the help of current file imports:
import sqlalchemy as s... | primary_key=True, autoincrement=False) |
Given snippet: <|code_start|>
class PriceRecord(Base):
__tablename__ = "pricerecords"
id = Column(sql.Integer, primary_key=True, autoincrement=True)
prod_id = Column(sql.Integer, sql.ForeignKey("products.id"), nullable=False)
price_base = Column(sql.Numeric, nullable=True)
price_final = Column(sql... | return discount_rounded |
Using the snippet: <|code_start|> magnitude = int(math.floor(math.log(num, 1000)))
val = num / math.pow(1000, magnitude)
if magnitude >= len(BINARY_PREFIXES):
magnitude = len(BINARY_PREFIXES) - 1
prefix = BINARY_PREFIXES[magnitude]
if magnitude == 0:
return '{:.0f}{}'.format(val, unit... | elif item.type == "dir": |
Predict the next line for this snippet: <|code_start|>
PRODUCTS_PER_PAGE = 20
def product_list():
page = int(flask.request.args.get("page", "1"))
search = flask.request.args.get("search", "").strip()
# Filter illegal characters and resulting empty strings
search_words = list(filter(None, (normalize... | for word in search_words: |
Based on the snippet: <|code_start|> order_string = "sale_rank DESC, LENGTH(title) ASC"
else:
filter_string = ""
order_string = "sale_rank DESC"
cur.execute("SELECT COUNT(*) FROM products {};".format(filter_string))
num_products = cur.fetchone()[0]
page_info = calc_pageinfo(page,... | "product_list", page=page_info["page"] + 1, search=search) |
Given the following code snippet before the placeholder: <|code_start|>
def product_list():
page = int(flask.request.args.get("page", "1"))
search = flask.request.args.get("search", "").strip()
# Filter illegal characters and resulting empty strings
search_words = list(filter(None, (normalize_search(wo... | "SELECT * FROM products {} ORDER BY {} LIMIT ? OFFSET ?;".format(filter_string, order_string), |
Predict the next line for this snippet: <|code_start|> if len(search) == 10 and search.isdecimal():
return flask.redirect(flask.url_for("product_info", prod_id=search), 303)
elif search_words:
query_filters = []
# Add a filter for each search word
for word in search_words:
... | type = prod_res["product_type"], |
Predict the next line for this snippet: <|code_start|> async def fetch_repo_v1(self, repo_url, prod_id, build_id):
return await self.get_json(
f"repo v1 {repo_url}",
url=repo_url,
path=self.storage_path / f"raw/repo_v1/{prod_id}_{build_id}.json",
caching=self.c... | url=manifest_url, |
Given snippet: <|code_start|> n_prod.dlcs = [l_dlc.id for l_dlc in l_prod.dlcs]
n_prod.description = l_prod.description_full
n_prod.changelog = l_prod.changelog or None
for l_dl in l_prod.downloads:
if l_dl.deleted:
continue
if l_dl.type == "bonus_content":
n_pro... | version = l_build.version, |
Here is a snippet: <|code_start|> cur_history = []
changelog = storagedb.changelog.load(prod_id)
history_chart = {"labels": [], "values": [], "max": 0}
if cur_history:
current_price = copy.copy(cur_history[-1])
current_price.date = datetime.datetime.now(datetime.timezone.utc)
... | "price_base": start.price_base_decimal |
Given snippet: <|code_start|> comp_systems = []
def __init__(self, product_id):
self.id = product_id
def product_info(prod_id):
storagedb = get_storagedb()
product = storagedb.product.load(prod_id)
if product is None:
flask.abort(404)
# Allow loading pre 2019 prices
if fl... | cur_history.append(current_price) |
Continue the code snippet: <|code_start|> "dlcs": product.dlcs
}
all_references = set(itertools.chain.from_iterable(referenced_ids.values()))
all_products = {}
if all_references:
cur = get_indexdb().cursor()
placeholders = ", ".join(itertools.repeat("?", len(all_references)))
... | referenced_products=referenced_products, |
Based on the snippet: <|code_start|>
recordgroups = []
for groupkey, items in itertools.groupby(
changes, key=lambda record: (record.timestamp, record.id)):
recordgroups.append(list(items))
page_info["prev_link"] = flask.url_for(
view, page=page_info["page"] - 1)
page_info["... | def changelog_ext(): |
Based on the snippet: <|code_start|> record = class_from_json(model.ChangeRecord, record_dict)
)
changes.append(change)
recordgroups = []
for groupkey, items in itertools.groupby(
changes, key=lambda record: (record.timestamp, record.id)):
recordgroups.append(list... | def changelog_atom(): |
Here is a snippet: <|code_start|> title = change_res["product_title"],
timestamp = datetime.datetime.fromtimestamp(change_res["timestamp"], datetime.timezone.utc),
action = change_res["action"],
category = change_res["category"],
dl_type = change_res["dl_type"]... | else: |
Given snippet: <|code_start|>ITEMS_PER_PAGE = 100
def changelog():
page = int(flask.request.args.get("page", "1"))
cur = get_indexdb().cursor()
# Get total number of entries
cur.execute("SELECT COUNT(*) FROM changelog_summary;")
total_entries = cur.fetchone()[0]
page_info = calc_pageinfo(pag... | page_info["next_link"] = flask.url_for( |
Based on the snippet: <|code_start|>
ITEMS_PER_PAGE = 100
def changelog():
page = int(flask.request.args.get("page", "1"))
cur = get_indexdb().cursor()
# Get total number of entries
cur.execute("SELECT COUNT(*) FROM changelog_summary;")
total_entries = cur.fetchone()[0]
page_info = calc_pa... | cur.execute( |
Continue the code snippet: <|code_start|>
class BlogLoader:
@classmethod
def find_by_id(cls, db, blog_id):
with db.cursor() as cursor:
<|code_end|>
. Use current file imports:
from hakoblog.model.blog import Blog
and context (classes, functions, or code) from other files:
# Path: hakoblog/model/blog... | cursor.execute( |
Next line prediction: <|code_start|>
class UserLoader:
@classmethod
def find_by_name(cls, db, name):
with db.cursor() as cursor:
<|code_end|>
. Use current file imports:
(from hakoblog.model.user import User)
and context including class names, function names, or small code snippets from other files:
... | cursor.execute( |
Predict the next line after this snippet: <|code_start|>
def test_create():
db = DB()
name = random_string(10)
UserAction.create(db, name)
user = UserLoader.find_by_name(db, name)
assert user.name == name
def test_ensure_global_user_created():
db = DB()
with global_user(random_string(... | assert user_again.id == user.id |
Based on the snippet: <|code_start|>
def test_create():
db = DB()
name = random_string(10)
UserAction.create(db, name)
user = UserLoader.find_by_name(db, name)
assert user.name == name
def test_ensure_global_user_created():
db = DB()
with global_user(random_string(10)) as global_user_... | assert user_again.id == user.id |
Given the code snippet: <|code_start|>
def test_create():
db = DB()
name = random_string(10)
UserAction.create(db, name)
user = UserLoader.find_by_name(db, name)
assert user.name == name
def test_ensure_global_user_created():
db = DB()
with global_user(random_string(10)) as global_use... | assert user_again.id == user.id |
Here is a snippet: <|code_start|>
def test_create():
db = DB()
name = random_string(10)
UserAction.create(db, name)
user = UserLoader.find_by_name(db, name)
<|code_end|>
. Write the next line using the current file imports:
import tests.hakoblog # noqa: F401
from hakoblog.db import DB
from hakoblo... | assert user.name == name |
Given snippet: <|code_start|>
found_entry = EntryLoader.find_by_id(db, entry.id)
assert isinstance(found_entry, Entry)
assert found_entry.id == entry.id
not_found_entry = EntryLoader.find_by_id(db, 10)
assert not_found_entry is None
def test_find_entries():
"EntryLoader.find_entries can find ... | ] == [e.id for e in entries[0:2]] |
Predict the next line after this snippet: <|code_start|>
def test_find_by_id():
"EntryLoader.find_by_id() can find a entry by id"
db = DB()
entry = create_entry()
found_entry = EntryLoader.find_by_id(db, entry.id)
assert isinstance(found_entry, Entry)
assert found_entry.id == entry.id
... | with freeze_time('2017-01-13 12:00:00'): |
Using the snippet: <|code_start|>
def test_find_by_id():
"EntryLoader.find_by_id() can find a entry by id"
db = DB()
entry = create_entry()
found_entry = EntryLoader.find_by_id(db, entry.id)
assert isinstance(found_entry, Entry)
assert found_entry.id == entry.id
not_found_entry = Entry... | assert not_found_entry is None |
Given the following code snippet before the placeholder: <|code_start|>
def test_find_by_id():
"EntryLoader.find_by_id() can find a entry by id"
db = DB()
entry = create_entry()
found_entry = EntryLoader.find_by_id(db, entry.id)
assert isinstance(found_entry, Entry)
<|code_end|>
, predict the n... | assert found_entry.id == entry.id |
Given snippet: <|code_start|>
def test_find_by_id():
"EntryLoader.find_by_id() can find a entry by id"
db = DB()
entry = create_entry()
found_entry = EntryLoader.find_by_id(db, entry.id)
assert isinstance(found_entry, Entry)
assert found_entry.id == entry.id
not_found_entry = EntryLoader.... | assert [e.id for e in found_entries] == [e.id for e in entries] |
Using the snippet: <|code_start|>
blog = create_blog()
entry_id = EntryAction.post(
db,
blog_id=blog.id,
title='タイトル',
body='こんにちは',
)
found_entry = EntryLoader.find_by_id(db, entry_id)
assert found_entry.blog_id == blog.id
assert found_entry.title == 'タイトル'
... | entry_id=entry_id, |
Using the snippet: <|code_start|>
def test_post():
db = DB()
blog = create_blog()
entry_id = EntryAction.post(
db,
blog_id=blog.id,
title='タイトル',
<|code_end|>
, determine the next line of code. You have imports:
import tests.hakoblog # noqa: F401
from hakoblog.db import DB
fro... | body='こんにちは', |
Given the following code snippet before the placeholder: <|code_start|>
def test_post():
db = DB()
blog = create_blog()
entry_id = EntryAction.post(
db,
blog_id=blog.id,
title='タイトル',
body='こんにちは',
)
found_entry = EntryLoader.find_by_id(db, entry_id)
assert ... | assert found_entry.title == 'タイトル' |
Using the snippet: <|code_start|> blog = create_blog()
entry_id = EntryAction.post(
db,
blog_id=blog.id,
title='タイトル',
body='こんにちは',
)
found_entry = EntryLoader.find_by_id(db, entry_id)
assert found_entry.blog_id == blog.id
assert found_entry.title == 'タイトル'
... | title='タイトルafter', |
Using the snippet: <|code_start|> assert found_entry.blog_id == blog.id
assert found_entry.title == 'タイトル'
assert found_entry.body == 'こんにちは'
def test_edit():
db = DB()
blog = create_blog()
entry_id = EntryAction.post(
db,
blog_id=blog.id,
title='タイトルbefore',
b... | def test_delete(): |
Continue the code snippet: <|code_start|>
def test_find_by_name():
db = DB()
user = create_user()
found_user = UserLoader.find_by_name(db, user.name)
assert isinstance(found_user, User)
assert found_user.name == user.name
not_found_user = UserLoader.find_by_name(db, random_string(10))
<|co... | assert not_found_user is None |
Based on the snippet: <|code_start|>
def test_find_by_name():
db = DB()
user = create_user()
found_user = UserLoader.find_by_name(db, user.name)
assert isinstance(found_user, User)
<|code_end|>
, predict the immediate next line with the help of imports:
import tests.hakoblog # noqa: F401
from hak... | assert found_user.name == user.name |
Given snippet: <|code_start|>
def test_find_by_name():
db = DB()
user = create_user()
found_user = UserLoader.find_by_name(db, user.name)
assert isinstance(found_user, User)
<|code_end|>
, continue by predicting the next line. Consider current file imports:
import tests.hakoblog # noqa: F401
from... | assert found_user.name == user.name |
Given the code snippet: <|code_start|>
def test_init():
blog = Blog(
id=0,
owner_id=1,
title='僕のブログ',
)
<|code_end|>
, generate the next line using the imports in this file:
import tests.hakoblog # noqa: F401
from hakoblog.model.blog import Blog
and context (functions, classes, or o... | assert blog.id == 0 |
Here is a snippet: <|code_start|>
def test_init():
user = User(
id=0,
name='hakobe932'
)
<|code_end|>
. Write the next line using the current file imports:
import tests.hakoblog # noqa: F401
from hakoblog.model.user import User
and context from other files:
# Path: hakoblog/model/user.py
#... | assert user.id == 0 |
Given the following code snippet before the placeholder: <|code_start|>
def test_entry():
db = DB()
with global_user(random_string(5)):
blog = BlogAction.ensure_global_blog_created(db)
entry = create_entry(blog=blog)
res1 = web_client().get('/entry/' + str(entry.id))
assert ... | d = pq(res1.data) |
Predict the next line after this snippet: <|code_start|>
def test_entry():
db = DB()
with global_user(random_string(5)):
blog = BlogAction.ensure_global_blog_created(db)
entry = create_entry(blog=blog)
res1 = web_client().get('/entry/' + str(entry.id))
assert res1.status == ... | d = pq(res1.data) |
Based on the snippet: <|code_start|>
def test_entry():
db = DB()
with global_user(random_string(5)):
blog = BlogAction.ensure_global_blog_created(db)
entry = create_entry(blog=blog)
res1 = web_client().get('/entry/' + str(entry.id))
assert res1.status == '200 OK'
<|code_end|... | d = pq(res1.data) |
Here is a snippet: <|code_start|>
def test_entry():
db = DB()
with global_user(random_string(5)):
blog = BlogAction.ensure_global_blog_created(db)
entry = create_entry(blog=blog)
res1 = web_client().get('/entry/' + str(entry.id))
<|code_end|>
. Write the next line using the current ... | assert res1.status == '200 OK' |
Given the following code snippet before the placeholder: <|code_start|>
def test_find_by_id():
db = DB()
user = create_user()
blog = create_blog(user=user)
found_blog = BlogLoader.find_by_id(db, blog.id)
assert found_blog.id == blog.id
assert BlogLoader.find_by_id(db, -1) is None
<|code... | def test_find_by_owner_id(): |
Continue the code snippet: <|code_start|>
def test_find_by_id():
db = DB()
user = create_user()
blog = create_blog(user=user)
found_blog = BlogLoader.find_by_id(db, blog.id)
assert found_blog.id == blog.id
assert BlogLoader.find_by_id(db, -1) is None
<|code_end|>
. Use current file impo... | def test_find_by_owner_id(): |
Based on the snippet: <|code_start|>
def test_find_by_id():
db = DB()
user = create_user()
blog = create_blog(user=user)
found_blog = BlogLoader.find_by_id(db, blog.id)
assert found_blog.id == blog.id
assert BlogLoader.find_by_id(db, -1) is None
<|code_end|>
, predict the immediate next... | def test_find_by_owner_id(): |
Next line prediction: <|code_start|>
def test_find_by_id():
db = DB()
user = create_user()
blog = create_blog(user=user)
found_blog = BlogLoader.find_by_id(db, blog.id)
<|code_end|>
. Use current file imports:
(import tests.hakoblog # noqa: F401
from hakoblog.db import DB
from hakoblog.loader.bl... | assert found_blog.id == blog.id |
Using the snippet: <|code_start|>
class BlogAction:
@classmethod
def create(self, db, owner_id, title):
now = datetime.now()
new_id = db.uuid_short()
<|code_end|>
, determine the next line of code. You have imports:
from datetime import datetime
from hakoblog.action.user import UserAction
fro... | with db.cursor() as cursor: |
Predict the next line for this snippet: <|code_start|>
class BlogAction:
@classmethod
def create(self, db, owner_id, title):
<|code_end|>
with the help of current file imports:
from datetime import datetime
from hakoblog.action.user import UserAction
from hakoblog.loader.blog import BlogLoader
and context ... | now = datetime.now() |
Using the snippet: <|code_start|>
def test_index():
with global_user(random_string(5)) as global_user_name:
res = web_client().get('/')
assert res.status == '200 OK'
d = pq(res.data)
assert d('h1').text() == "%s's blog" % (global_user_name, )
<|code_end|>
, determine the next ... | def test_index_with_entries(): |
Predict the next line after this snippet: <|code_start|>
def test_index():
with global_user(random_string(5)) as global_user_name:
res = web_client().get('/')
assert res.status == '200 OK'
d = pq(res.data)
assert d('h1').text() == "%s's blog" % (global_user_name, )
def test_in... | with freeze_time('2017-01-13 12:00:02'): |
Predict the next line for this snippet: <|code_start|>
def test_index():
with global_user(random_string(5)) as global_user_name:
res = web_client().get('/')
assert res.status == '200 OK'
d = pq(res.data)
assert d('h1').text() == "%s's blog" % (global_user_name, )
def test_index_... | assert [ |
Predict the next line after this snippet: <|code_start|>
def test_index():
with global_user(random_string(5)) as global_user_name:
res = web_client().get('/')
assert res.status == '200 OK'
d = pq(res.data)
assert d('h1').text() == "%s's blog" % (global_user_name, )
def test_in... | entries = [] |
Predict the next line after this snippet: <|code_start|>
def test_index():
with global_user(random_string(5)) as global_user_name:
res = web_client().get('/')
assert res.status == '200 OK'
d = pq(res.data)
assert d('h1').text() == "%s's blog" % (global_user_name, )
def test_in... | entries = [] |
Using the snippet: <|code_start|>
def test_create():
db = DB()
user = create_user()
title = random_string(10)
blog_id = BlogAction.create(
<|code_end|>
, determine the next line of code. You have imports:
import tests.hakoblog # noqa: F401
from hakoblog.db import DB
from hakoblog.loader.user impor... | db, |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.