Instruction stringlengths 362 7.83k | output_code stringlengths 1 945 |
|---|---|
Using the snippet: <|code_start|># -*- coding: utf-8 -*-
class ProfileForm(forms.ModelForm):
first_name = forms.CharField(label=_('First name'), required=False)
last_name = forms.CharField(label=_('Last name'), required=False)
email = forms.EmailField(label=_('E-mail'))
def __init__(self, *args, **k... | if not up_settings.PROFILE_ALLOW_EMAIL_CHANGE: |
Based on the snippet: <|code_start|># -*- coding: utf-8 -*-
class ChangeEmailForm(forms.Form):
new_email = forms.EmailField(label=_('New e-mail address'), required=True)
def clean_new_email(self):
new_email = self.cleaned_data['new_email']
user_emails = User.objects.filter(email__iexact=new... | verification_emails = EmailVerification.objects.filter( |
Continue the code snippet: <|code_start|>
class ModelsTests(TestCase):
def setUp(self):
self.data = {
'username': 'newuser',
'email': 'newuser@example.com',
'password': 'newuserpass',
}
def test_activate_user(self):
<|code_end|>
. Use current file imports:... | user = AccountVerification.objects.create_inactive_user( |
Here is a snippet: <|code_start|>
class ModelsTests(TestCase):
def setUp(self):
self.data = {
'username': 'newuser',
'email': 'newuser@example.com',
'password': 'newuserpass',
}
def test_activate_user(self):
user = AccountVerification.objects.creat... | days=up_settings.ACCOUNT_VERIFICATION_DAYS, seconds=1) |
Given the code snippet: <|code_start|> verification = self.get(activation_key=activation_key)
except self.model.DoesNotExist:
return False
if not verification.activation_key_expired():
user = verification.user
user.is_active = True
... | 'expiration_days': up_settings.ACCOUNT_VERIFICATION_DAYS, |
Given the following code snippet before the placeholder: <|code_start|># -*- coding: utf-8 -*-
class AccountVerificationAdmin(admin.ModelAdmin):
list_display = ('__unicode__', 'activation_key_expired')
search_fields = ('user__username', 'user__first_name', 'user__last_name')
<|code_end|>
, predict the next ... | admin.site.register(AccountVerification, AccountVerificationAdmin) |
Predict the next line for this snippet: <|code_start|>
@override_settings(USE_ACCOUNT_VERIFICATION=True)
class ViewTests(TestCase):
def setUp(self):
self.data = {
'username': 'newuser',
'email': 'newuser@example.com',
'password': 'newuserpass',
}
def test_... | AccountVerification.objects.create_inactive_user( |
Continue the code snippet: <|code_start|># -*- coding: utf-8 -*-
def generate_token():
return str(uuid.uuid4())
def generate_confirm_expire_date():
<|code_end|>
. Use current file imports:
from datetime import timedelta
from django.contrib.auth.models import User
from django.db import models
from django.util... | return timezone.now() + timedelta(days=up_settings.EMAIL_VERIFICATION_DAYS) |
Given snippet: <|code_start|># -*- coding: utf-8 -*-
class EmailVerificationAdmin(admin.ModelAdmin):
list_display = ('user', 'old_email', 'new_email', 'expiration_date',
'is_approved', 'is_expired')
list_filter = ('is_approved', 'is_expired')
<|code_end|>
, continue by predicting the next line. Cons... | admin.site.register(EmailVerification, EmailVerificationAdmin) |
Based on the snippet: <|code_start|>
class ProfileRegistrationForm(RegistrationForm):
short_info = forms.CharField(widget=forms.Textarea)
def save_profile(self, new_user, *args, **kwargs):
<|code_end|>
, predict the immediate next line with the help of imports:
from django import forms
from .models import P... | Profile.objects.create( |
Given the code snippet: <|code_start|>
class EmailChangeView(LoginRequiredMixin, FormView):
template_name = 'userprofiles/email_change.html'
form_class = ChangeEmailForm
def form_valid(self, form):
form.save(self.request.user)
return redirect('userprofiles_email_change_requested')
email_... | verification = EmailVerification.objects.get(token=token, code=code, |
Based on the snippet: <|code_start|># -*- coding: utf-8 -*-
class EmailChangeView(LoginRequiredMixin, FormView):
template_name = 'userprofiles/email_change.html'
form_class = ChangeEmailForm
def form_valid(self, form):
form.save(self.request.user)
return redirect('userprofiles_email_chan... | 'expiration_days': up_settings.EMAIL_VERIFICATION_DAYS |
Here is a snippet: <|code_start|>
class SettingsTests(TestCase):
@override_settings(USERPROFILES_USE_ACCOUNT_VERIFICATION=True,
INSTALLED_APPS=list(set(settings.INSTALLED_APPS) - set(
['userprofiles.contrib.accountverification'])))
def test_account_verification(self):
<|code_end|>
. Write ... | self.assertRaises(ImproperlyConfigured, validate_settings) |
Given the code snippet: <|code_start|># -*- coding: utf-8 -*-
class RegistrationForm(forms.Form):
username = forms.RegexField(label=_("Username"), max_length=30,
regex=r'^[\w.-]+$', error_messages={'invalid': _(
'This value may contain only letters, numbers and ./-/_ characters.')})
ema... | if not up_settings.DOUBLE_CHECK_EMAIL: |
Predict the next line for this snippet: <|code_start|>
class UtilsTests(TestCase):
def test_get_profile_module_disabled(self):
self.assertEqual(utils.get_profile_model(), None)
@override_settings(USERPROFILES_USE_PROFILE=True)
def test_get_profile_module_enabled(self):
settings.AUTH_PROFI... | forms.RegistrationForm) |
Given the following code snippet before the placeholder: <|code_start|># -*- coding: utf-8 -*-
class RegistrationActivateView(TemplateView):
template_name = 'userprofiles/registration_activate.html'
def get_context_data(self, **kwargs):
activation_key = kwargs['activation_key'].lower()
<|code_end|>
... | account = AccountVerification.objects.activate_user(activation_key) |
Predict the next line for this snippet: <|code_start|># -*- coding: utf-8 -*-
class RegistrationActivateView(TemplateView):
template_name = 'userprofiles/registration_activate.html'
def get_context_data(self, **kwargs):
activation_key = kwargs['activation_key'].lower()
account = AccountVerif... | 'expiration_days': up_settings.ACCOUNT_VERIFICATION_DAYS |
Predict the next line for this snippet: <|code_start|>
@override_settings(USERPROFILES_USE_PROFILE=True, AUTH_PROFILE_MODULE='test_accounts.Profile')
class ViewTests(TestCase):
def setUp(self):
self.data = {
'username': 'newuser',
'email': 'newuser@example.com',
'new_em... | Profile(user=self.user).save() |
Based on the snippet: <|code_start|># -*- coding: utf-8 -*-
class ProfileView(LoginRequiredMixin, TemplateView):
template_name = 'userprofiles/profile.html'
def get_context_data(self, **kwargs):
return {
'user': self.request.user,
}
profile = ProfileView.as_view()
class Profil... | form_class = get_form_class(up_settings.PROFILE_FORM) |
Given the code snippet: <|code_start|>
class ViewTests(TestCase):
def setUp(self):
self.data = {
'username': 'newuser',
'email': 'newuser@example.com',
'email_repeat': 'newuser@example.com',
'password': 'newuserpass',
'password_repeat': 'newuserp... | reverse(up_settings.REGISTRATION_REDIRECT)) |
Given snippet: <|code_start|> as dictionaries mapping vertices to lists of neighbors,
however dictionaries of edges have many advantages
over lists: they can store extra information (here,
the lengths), they support fast existence tests,
and they allow easy modification of the gra... | Q = priorityDictionary() # est.dist. of non-final vert. |
Predict the next line after this snippet: <|code_start|> OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-----------------------------------------------------------------------------
"""
class SchemaFactory(object):
"""
Allows to instantiate a pickled schema.
"""
_schema_entit... | raise MockgunError("Cannot locate Mockgun schema file '%s'!" % schema_path) |
Here is a snippet: <|code_start|> def __repr__(self):
return '<%s "%s">' % (type(self).__name__, self.title)
WORKS_PATH = ['orcid-profile', 'orcid-activities','orcid-works',]
def _parse_publications(l):
if l is not None:
#logger.debug(json.dumps(l, sort_keys=True, indent=4, separators=(',', ': ... | resp = requests.get(ORCID_PUBLIC_BASE_URL + self.orcid |
Given snippet: <|code_start|> return []
CitationBase = dictmapper('CitationBase', {
'text':['citation'],
'type':['work-citation-type']
})
class Citation(CitationBase):
def __unicode__(self):
return self.text
def __repr__(self):
return '<%s [type: %s]>' % (type(self).__name__, self.... | 'citation': to(['work-citation'], lambda d: Citation(d) if d is not None else None), |
Given snippet: <|code_start|>
class Snippet(Model):
org = String()
user = String()
text = String()
keywords = String(required=False)
lang = String()
<|code_end|>
, continue by predicting the next line. Consider current file imports:
import time
from codebox.utils.models import Model, String, Floa... | created_at = Float(default=time.time) |
Based on the snippet: <|code_start|>
languages = [
('text', 'Plaintext'),
('diff', 'Diff'),
('javascript', 'JavaScript'),
('html', 'HTML'),
('php', 'PHP'),
('python', 'Python'),
('ruby', 'Ruby'),
('applescript', 'AppleScript'),
('bash', 'Bash')... | return User.objects.get(self.user) |
Using the snippet: <|code_start|>
class User(Model):
name = String()
email = String(required=False)
avatar = String(required=False)
<|code_end|>
, determine the next line of code. You have imports:
import time
from codebox.utils.models import Model, String, Float, Boolean
from codebox.apps.organiz... | created_at = Float(default=time.time) |
Predict the next line after this snippet: <|code_start|>
class User(Model):
name = String()
email = String(required=False)
avatar = String(required=False)
created_at = Float(default=time.time)
api_token = String(required=False)
class Meta:
unique = (('email',), ('api_token',))
def... | verified = Boolean(default=False) |
Continue the code snippet: <|code_start|> return ret
def get_minutes(self):
ct = self.cuts_time()
if ct is None:
# if there are no cuts, use scheduled time
delta = self.end - self.start
minutes = delta.days*60*24 + delta.seconds/60.0
else:
... | def titlecase(self): |
Based on the snippet: <|code_start|>#!/usr/bin/python
# ckblip.py
# checks metadata on blib
# like 'is there a flash version?'
# or 'if a format is not on blip, is it local?'
# and maybe upload it.
# and maybe delete it:
# if the .fvl is not the same file size as the local copy on disk,
# delete the one on blip.
... | role=roles.get(ext, {'description':"extra",'num':'9'}) |
Continue the code snippet: <|code_start|> 'postgresql': "concurrency.triggers.PostgreSQL",
'mysql': "concurrency.triggers.MySQL",
'sqlite3': "concurrency.triggers.Sqlite3",
'sqlite': "concurrency.triggers.Sqlite3",
}
}
def __init__(self, prefix):
"... | func = get_callable(value) |
Based on the snippet: <|code_start|> old_value = getattr(model_instance, self.attname, 0)
return max(int(old_value) + 1, (int(time.time() * 1000000) - OFFSET))
class AutoIncVersionField(VersionField):
"""
Version Field increment the revision number each commit
"""
form_class = form... | if self not in _TRIGGERS: |
Here is a snippet: <|code_start|>
def test_basic_term_variables():
assert_true("term_variables(X, [X]).")
assert_false("term_variables(X, []).")
assert_true("term_variables(f(X, Y), [X, Y]).")
assert_true("term_variables(a, []).")
assert_true("term_variables(123, []).")
assert_true("term_variabl... | e = get_engine(""" |
Based on the snippet: <|code_start|> self.engine = engine
self.nextcont = None
self._candiscard = True
self.seen = seen
self.module = self.engine.modulewrapper.user_module
def is_done(self):
return False
def activate(self, fcont, heap):
original_heap = heap... | e = get_engine(""" |
Given snippet: <|code_start|> self.module = self.engine.modulewrapper.user_module
def is_done(self):
return False
def activate(self, fcont, heap):
original_heap = heap
# hack: use _dot to count size of tree
seen = set()
list(fcont._dot(seen))
assert len(se... | query = Callable.build("f", [Number(100)]) |
Given the following code snippet before the placeholder: <|code_start|>
if not option.slow:
py.test.skip("slow tests")
def test_parser():
def f(x):
if x:
s = "a(X, Y, Z)."
else:
s = "f(a, X, _, _, X, f(X, 2.455))."
<|code_end|>
, predict the next line using imports from ... | term = parsing.parse_file(s) |
Given snippet: <|code_start|> if x:
s = "a(X, Y, Z)."
else:
s = "f(a, X, _, _, X, f(X, 2.455))."
term = parsing.parse_file(s)
assert isinstance(term, parsing.Nonterminal)
return term.symbol
assert f(True) == "file"
assert f(True) == "file"
t = T... | if isinstance(v0, Atom): |
Based on the snippet: <|code_start|> make_varlist(Num1, R).
when_ground_list(Num, Millis) :-
make_varlist(Num, List),
statistics(walltime, [T1, _]),
when(ground(List), Z = 1),
when_ground_list_inner(List),
statistics(walltime, [T2, _]),
... | t1 = parse_query_term("app([1, 2, 3, 4, 5, 6], [8, 9], X), X == [1, 2, 3, 4, 5, 6, 8, 9].") |
Based on the snippet: <|code_start|>class o:
view = False
viewloops = True
conftest.option = o
class TestLLtype(LLJitMixin):
def test_append(self):
<|code_end|>
, predict the immediate next line with the help of imports:
import sys
from rpython import conftest
from rpython.jit.metainterp.test.test_ajit i... | e = get_engine(""" |
Continue the code snippet: <|code_start|>
class EnumerationMemo(object):
"""A memo object to enumerate the variables in a term"""
def __init__(self):
self.seen = {}
self.varcount = 0
def get(self, var):
res = self.seen.get(var, None)
if not res:
<|code_end|>
. Use current fi... | self.seen[var] = res = NumberedVar(-1) |
Given the code snippet: <|code_start|>
def test_eq():
sig1 = Signature("a", 0)
assert sig1.eq(sig1)
sig2 = Signature("a", 0)
assert sig1.eq(sig2)
sig3 = Signature("a", 1)
assert not sig1.eq(sig3)
sig4 = Signature("b", 0)
assert not sig1.eq(sig4)
def test_cache():
<|code_end|>
, gener... | factory = SignatureFactory() |
Based on the snippet: <|code_start|>#coding=utf-8
def test_strings():
assert_true('X = "abc", X = [97, 98, 99].')
assert_true('X = "", X = [].')
assert_true('X = [97], X = "a".')
assert_true('X = [97], X = Y, Y = "a".')
<|code_end|>
, predict the immediate next line with the help of imports:
import p... | assert_false('X = "a", X = \'a\'.') |
Predict the next line for this snippet: <|code_start|> def activate(self, fcont, heap):
all.append((X.dereference(heap).name(), Y.dereference(heap).name()))
raise error.UnificationFailed
e.add_rule(Callable.build("f", [Callable.build("x")]), True)
e.add_rule(Callable.build("f", [C... | e.run_query_in_current(parse_query_term("g(-1, Y), Y == b, g(1, Z), Z == a."), |
Predict the next line after this snippet: <|code_start|> def is_done(self):
return False
def discard(self):
pass
def activate(self, fcont, heap):
all.append((X.dereference(heap).name(), Y.dereference(heap).name()))
raise error.UnificationFailed
... | e = get_engine(""" |
Predict the next line for this snippet: <|code_start|> query = Callable.build(",", [Callable.build("f", [X]), Callable.build("g", [Y])])
py.test.raises(error.UnificationFailed,
e.run_query, query, e.modulewrapper.user_module, CollectContinuation())
assert all == [("x", "a"), ("x", "b"), ("... | t, vars = get_query_and_vars("f(X).") |
Predict the next line after this snippet: <|code_start|>
def test_driver():
order = []
done = DoneFailureContinuation(None)
class FakeC(object):
rule = None
cont_type_name = "FakeC"
def __init__(self, next, val):
self.next = next
self.val = val
def ... | raise error.UnificationFailed |
Given snippet: <|code_start|># ___________________________________________________________________
# integration tests
def test_trivial():
e = get_engine("""
f(a).
""")
t, vars = get_query_and_vars("f(X).")
e.run_query_in_current(t)
assert vars['X'].dereference(None).name()== "a"
def test_... | heaps = collect_all(e, "f(X, Y, Z).") |
Predict the next line for this snippet: <|code_start|> e.run_query_in_current(parse_query_term("mul(succ(0), 0, 0)."))
e.run_query_in_current(parse_query_term("mul(succ(succ(0)), succ(0), succ(succ(0)))."))
e.run_query_in_current(parse_query_term("mul(succ(succ(0)), succ(succ(0)), succ(succ(succ(succ(0))))).... | assert_true("start(Z).", e) |
Here is a snippet: <|code_start|>
def test_get_source():
content = "some important content"
name = "__testfile__"
try:
create_file(name, content)
<|code_end|>
. Write the next line using the current file imports:
import py
import os
from prolog.builtin.sourcehelper import get_source
from prolog.int... | source, file_name = get_source(name) |
Next line prediction: <|code_start|>
def test_get_source():
content = "some important content"
name = "__testfile__"
try:
<|code_end|>
. Use current file imports:
(import py
import os
from prolog.builtin.sourcehelper import get_source
from prolog.interpreter.test.tool import collect_all, assert_false, asse... | create_file(name, content) |
Given the following code snippet before the placeholder: <|code_start|>
def test_get_source():
content = "some important content"
name = "__testfile__"
try:
create_file(name, content)
source, file_name = get_source(name)
finally:
<|code_end|>
, predict the next line using imports from th... | delete_file(name) |
Based on the snippet: <|code_start|>
def test_get_source():
content = "some important content"
name = "__testfile__"
try:
create_file(name, content)
source, file_name = get_source(name)
finally:
delete_file(name)
assert source == content
assert file_name == os.path.abspat... | py.test.raises(CatchableError, "get_source('this_file_does_not_exist')") |
Given the following code snippet before the placeholder: <|code_start|>
def get_uncaught_error(query, e):
if isinstance(query, str):
(query, _) = get_query_and_vars(query)
return pytest.raises(UncaughtError, e.run_query_in_current, query).value
def test_errstr():
<|code_end|>
, predict the next line ... | e = get_engine(""" |
Given the code snippet: <|code_start|>
def get_uncaught_error(query, e):
if isinstance(query, str):
(query, _) = get_query_and_vars(query)
<|code_end|>
, generate the next line using the imports in this file:
import py, pytest
from prolog.interpreter.parsing import get_engine
from prolog.interpreter.parsi... | return pytest.raises(UncaughtError, e.run_query_in_current, query).value |
Given snippet: <|code_start|> self.trail_var[i] = var
self.trail_binding[i] = var.binding
self.i = i + 1
def _is_created_in_self(self, var):
created_in = var.created_after_choice_point
if self is created_in: # fast path
return True
if created_in is not Non... | result = BindingVar() |
Continue the code snippet: <|code_start|> created_in = var.created_after_choice_point
if self is created_in: # fast path
return True
if created_in is not None and created_in.discarded:
# unroll _find_not_discarded once for better jittability
created_in = create... | result = AttVar() |
Continue the code snippet: <|code_start|> return {
'--account': None,
'--dependents': [],
'--dump-file': None,
'--exact': [],
'--exclude': [],
'--help': False,
'--no-build': False,
'--upto': [],
'--x-assert-hostname': False,
'-H': None,
... | cli.process_arguments( |
Here is a snippet: <|code_start|>from __future__ import absolute_import
def default_args():
return argparse.Namespace(dirty=False, pull_cache=False)
def test_sample(tmpdir, capsys):
path = str(tmpdir.join('shipwright-sample'))
source = pkg_resources.resource_filename(
__name__,
'exam... | shipw_cli.run( |
Here is a snippet: <|code_start|>from __future__ import absolute_import
def default_args():
return argparse.Namespace(dirty=False, pull_cache=False)
def test_sample(tmpdir, capsys):
path = str(tmpdir.join('shipwright-sample'))
source = pkg_resources.resource_filename(
__name__,
'exam... | repo = create_repo(path, source) |
Based on the snippet: <|code_start|>from __future__ import absolute_import
def default_args():
return argparse.Namespace(dirty=False, pull_cache=False)
def test_sample(tmpdir, capsys):
path = str(tmpdir.join('shipwright-sample'))
source = pkg_resources.resource_filename(
__name__,
'e... | args = get_defaults() |
Here is a snippet: <|code_start|>from __future__ import absolute_import
class Shipwright(object):
def __init__(self, source_control, docker_client, tags, cache):
self.source_control = source_control
self.docker_client = docker_client
self.tags = tags
self._cache = cache
def t... | if isinstance(evt, BuildComplete): |
Continue the code snippet: <|code_start|>from __future__ import absolute_import
def test_docker_push(tmpdir, docker_client, registry):
path = str(tmpdir.join('shipwright-localhost-sample'))
source = pkg_resources.resource_filename(
__name__,
'examples/shipwright-localhost-sample',
)
... | shipw_cli.run( |
Continue the code snippet: <|code_start|> assert set(base['RepoTags']) == {
'localhost:5000/base:master',
'localhost:5000/base:latest',
'localhost:5000/base:' + tag,
}
finally:
old_images = (
cli.images(name='localhost:5000/service1', quiet=True... | commit_untracked(repo) |
Based on the snippet: <|code_start|>from __future__ import absolute_import
def test_docker_push(tmpdir, docker_client, registry):
path = str(tmpdir.join('shipwright-localhost-sample'))
source = pkg_resources.resource_filename(
__name__,
'examples/shipwright-localhost-sample',
)
<|code_e... | repo = create_repo(path, source) |
Predict the next line for this snippet: <|code_start|>
assert set(base['RepoTags']) == {
'localhost:5000/base:master',
'localhost:5000/base:latest',
'localhost:5000/base:' + new_tag,
'localhost:5000/base:' + tag,
}
finally:
old_images = (
... | args = default_args() |
Continue the code snippet: <|code_start|>from __future__ import absolute_import
def test_docker_push(tmpdir, docker_client, registry):
path = str(tmpdir.join('shipwright-localhost-sample'))
source = pkg_resources.resource_filename(
__name__,
'examples/shipwright-localhost-sample',
)
... | defaults = get_defaults() |
Using the snippet: <|code_start|>from __future__ import absolute_import
def test_sample(tmpdir, docker_client):
path = str(tmpdir.join('shipwright-sample'))
source = pkg_resources.resource_filename(
__name__,
'examples/shipwright-sample',
)
repo = create_repo(path, source)
tag ... | shipw_cli.run( |
Based on the snippet: <|code_start|> cli.images(name='shipwright/service1', quiet=True) +
cli.images(name='shipwright/base', quiet=True)
)
for image in old_images:
cli.remove_image(image, force=True)
def test_clean_tree_avoids_rebuild(tmpdir, docker_client):
tmp ... | commit_untracked(repo) |
Given the code snippet: <|code_start|>from __future__ import absolute_import
def test_sample(tmpdir, docker_client):
path = str(tmpdir.join('shipwright-sample'))
source = pkg_resources.resource_filename(
__name__,
'examples/shipwright-sample',
)
<|code_end|>
, generate the next line us... | repo = create_repo(path, source) |
Given snippet: <|code_start|> )
create_repo(path, source)
tmp.join('service1/base.txt').write('Some text')
client_cfg = docker_utils.kwargs_from_env()
args = get_defaults()
result = shipw_cli.run(
path=path,
client_cfg=client_cfg,
arguments=args,
environ={},
... | args = default_args() |
Given the code snippet: <|code_start|>from __future__ import absolute_import
def test_sample(tmpdir, docker_client):
path = str(tmpdir.join('shipwright-sample'))
source = pkg_resources.resource_filename(
__name__,
'examples/shipwright-sample',
)
repo = create_repo(path, source)
... | arguments=get_defaults(), |
Predict the next line for this snippet: <|code_start|>from __future__ import absolute_import
def test_mkcontext(tmpdir):
tmp = tmpdir.mkdir('image')
docker_path = tmp.join('Dockerfile')
docker_path.write('FROM example.com/r/image')
tmp.join('bogus').write('hi mom')
<|code_end|>
with the help of cu... | with tar.mkcontext('xyz', str(docker_path)) as f: |
Here is a snippet: <|code_start|> registry_logins = _flatten(new_style_args.registry_login)
namespace = config['namespace']
name_map = config.get('names', {})
scm = source_control.source_control(path, namespace, name_map)
if not dirty and scm.is_dirty():
return (
'Aborting bu... | sw = Shipwright(scm, client, arguments['tags'], the_cache) |
Here is a snippet: <|code_start|> raise drc
registry_config = parse_registry_logins(registry_logins)
registries = {}
for server, config in registry_config.items():
registries[server] = drc.BaseClient(
config['server'],
username=config['user... | if isinstance(event, Message): |
Based on the snippet: <|code_start|>
def do_build(client, build_ref, targets, cache):
"""
Generic function for building multiple images while
notifying a callback function with output produced.
Given a list of targets it builds the target with the given
build_func while streaming the output throug... | yield BuildComplete(target) |
Given the following code snippet before the placeholder: <|code_start|>from __future__ import absolute_import
def test_default_tags_works_with_detached_head(tmpdir):
tmp = tmpdir.join('shipwright-sample')
path = str(tmp)
source = pkg_resources.resource_filename(
__name__,
'examples/ship... | scm = source_control.GitSourceControl( |
Based on the snippet: <|code_start|>from __future__ import absolute_import
def test_default_tags_works_with_detached_head(tmpdir):
tmp = tmpdir.join('shipwright-sample')
path = str(tmp)
source = pkg_resources.resource_filename(
__name__,
'examples/shipwright-sample',
)
repo = cr... | commit_untracked(repo) |
Using the snippet: <|code_start|>from __future__ import absolute_import
def test_default_tags_works_with_detached_head(tmpdir):
tmp = tmpdir.join('shipwright-sample')
path = str(tmp)
source = pkg_resources.resource_filename(
__name__,
'examples/shipwright-sample',
)
<|code_end|>
, d... | repo = create_repo(path, source) |
Predict the next line for this snippet: <|code_start|>from __future__ import absolute_import
def names_list(targets):
return sorted(n.name for n in targets)
def _names(tree):
<|code_end|>
with the help of current file imports:
from shipwright._lib import dependencies, image, source_control
and context from ... | return [n.name for n in dependencies._brood(tree)] |
Predict the next line for this snippet: <|code_start|>from __future__ import absolute_import
def names_list(targets):
return sorted(n.name for n in targets)
def _names(tree):
return [n.name for n in dependencies._brood(tree)]
def target(name, dir_path, path, parent):
return source_control.Target(
<|c... | image.Image(name, dir_path, path, parent, name, frozenset([path])), |
Given the following code snippet before the placeholder: <|code_start|>from __future__ import absolute_import
def names_list(targets):
return sorted(n.name for n in targets)
def _names(tree):
return [n.name for n in dependencies._brood(tree)]
def target(name, dir_path, path, parent):
<|code_end|>
, predi... | return source_control.Target( |
Next line prediction: <|code_start|>def test_extra_tags(tmpdir):
tmp = tmpdir.join('shipwright-sample')
path = str(tmp)
source = pkg_resources.resource_filename(
__name__,
'examples/shipwright-sample',
)
repo = utils.create_repo(path, source)
commit = repo.head.ref.commit.hexsha[... | with pytest.raises(exceptions.SourceControlNotFound): |
Given the following code snippet before the placeholder: <|code_start|>from __future__ import absolute_import
def test_simple(tmpdir):
tmp = tmpdir.join('shipwright-sample')
path = str(tmp)
source = pkg_resources.resource_filename(
__name__,
'examples/shipwright-sample',
)
repo ... | assert targets.targets(path=path) == [ |
Based on the snippet: <|code_start|> >>> root = Node("root")
>>> s1 = Node("sub1", parent=root, bar=17)
>>> l = SymlinkNode(s1, parent=root, baz=18)
>>> l0 = Node("l0", parent=l)
>>> print(RenderTree(root))
Node('/root')
βββ Node('/root/sub1', bar=17, baz=18)
... | return _repr(self, [repr(self.target)], nameblacklist=("target", )) |
Given the code snippet: <|code_start|>
@property
def anchestors(self):
"""
All parent nodes and their parent nodes - see :any:`ancestors`.
The attribute `anchestors` is just a typo of `ancestors`. Please use `ancestors`.
This attribute will be removed in the 3.0.0 release.
... | return tuple(PreOrderIter(self))[1:] |
Here is a snippet: <|code_start|>
>>> marc.is_root
False
>>> marc.parent = None
>>> marc.is_root
True
"""
try:
return self.__parent
except AttributeError:
return None
@parent.setter
def parent(self, value):
if value... | raise LoopError(msg % (self, )) |
Given the following code snippet before the placeholder: <|code_start|> Node('/Marc')
βββ Node('/Marc/Lian')
**Attach**
>>> marc.parent = udo
>>> print(RenderTree(udo))
Node('/Udo')
βββ Node('/Udo/Marc')
βββ Node('/Udo/Marc/Lian')
**Detach**
... | raise TreeError(msg) |
Next line prediction: <|code_start|> ... "children": [
... {
... "a": "sub0",
... "children": [
... {
... "a": "sub0A",
... "b": "foo"
... },
... {
... "a": "sub0B"
... | dictimporter = self.dictimporter or DictImporter() |
Given the code snippet: <|code_start|> >>> print(exporter.export(root))
{
"a": "root",
"children": [
{
"a": "sub0",
"children": [
{
"a": "sub0A",
"b": "foo"
},
{... | dictexporter = self.dictexporter or DictExporter() |
Predict the next line for this snippet: <|code_start|> >>> g = Node("g", parent=f)
>>> i = Node("i", parent=g)
>>> h = Node("h", parent=i)
>>> print(RenderTree(f, style=AsciiStyle()).by_attr())
f
|-- b
| |-- a
| +-- d
| |-- c
| +-- e
+-- g
+-- i
... | result = tuple(PreOrderIter(node, filter_, stop, maxlevel)) |
Given the code snippet: <|code_start|> >>> e = Node("e", parent=d)
>>> g = Node("g", parent=f)
>>> i = Node("i", parent=g)
>>> h = Node("h", parent=i)
>>> print(RenderTree(f, style=AsciiStyle()).by_attr())
f
|-- b
| |-- a
| +-- d
| |-- c
| +-- e
+-- g
... | _iter = LevelOrderGroupIter(children[0], filter_, stop, maxlevel) |
Given the code snippet: <|code_start|>"""Utility methods."""
def housecode_to_byte(housecode):
"""Return the byte value of an X10 housecode."""
return HC_LOOKUP.get(housecode.lower())
def unitcode_to_byte(unitcode):
"""Return the byte value of an X10 unitcode."""
<|code_end|>
, generate the next line ... | return UC_LOOKUP.get(unitcode) |
Continue the code snippet: <|code_start|>"""Utility methods."""
def housecode_to_byte(housecode):
"""Return the byte value of an X10 housecode."""
return HC_LOOKUP.get(housecode.lower())
def unitcode_to_byte(unitcode):
"""Return the byte value of an X10 unitcode."""
return UC_LOOKUP.get(unitcode)
... | X10_COMMAND_ALL_UNITS_OFF, |
Given the following code snippet before the placeholder: <|code_start|>
def housecode_to_byte(housecode):
"""Return the byte value of an X10 housecode."""
return HC_LOOKUP.get(housecode.lower())
def unitcode_to_byte(unitcode):
"""Return the byte value of an X10 unitcode."""
return UC_LOOKUP.get(uni... | X10_COMMAND_ALL_LIGHTS_ON, |
Based on the snippet: <|code_start|>
def housecode_to_byte(housecode):
"""Return the byte value of an X10 housecode."""
return HC_LOOKUP.get(housecode.lower())
def unitcode_to_byte(unitcode):
"""Return the byte value of an X10 unitcode."""
return UC_LOOKUP.get(unitcode)
def byte_to_housecode(bytec... | X10_COMMAND_ALL_LIGHTS_OFF, |
Based on the snippet: <|code_start|>"""Utility methods."""
def housecode_to_byte(housecode):
"""Return the byte value of an X10 housecode."""
return HC_LOOKUP.get(housecode.lower())
def unitcode_to_byte(unitcode):
"""Return the byte value of an X10 unitcode."""
return UC_LOOKUP.get(unitcode)
def... | command_type = X10CommandType.DIRECT |
Predict the next line after this snippet: <|code_start|> """Return a hexadecimal representation of the message flags."""
return binascii.hexlify(self.bytes).decode()
# pylint: disable=no-self-use
def _normalize(self, flags):
"""Take any format of flags and turn it into a hex string."""
... | self._extended = (flagByte[0] & MESSAGE_FLAG_EXTENDED_0X10) >> 4 |
Based on the snippet: <|code_start|>
@property
def isBroadcast(self):
"""Test if the message is a broadcast message type."""
return (
self._messageType & MESSAGE_TYPE_BROADCAST_MESSAGE
== MESSAGE_TYPE_BROADCAST_MESSAGE
)
@property
def isDirect(self):
... | return self._messageType == MESSAGE_TYPE_ALL_LINK_BROADCAST |
Next line prediction: <|code_start|> self._messageType & MESSAGE_TYPE_BROADCAST_MESSAGE
== MESSAGE_TYPE_BROADCAST_MESSAGE
)
@property
def isDirect(self):
"""Test if the message is a direct message type."""
direct = self._messageType == 0x00
if self.isDirec... | return self._messageType == MESSAGE_TYPE_ALL_LINK_CLEANUP |
Given the code snippet: <|code_start|> def isDirect(self):
"""Test if the message is a direct message type."""
direct = self._messageType == 0x00
if self.isDirectACK or self.isDirectNAK:
direct = True
return direct
@property
def isDirectACK(self):
"""Test ... | return self._messageType == MESSAGE_TYPE_ALL_LINK_CLEANUP_ACK |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.