Instruction stringlengths 362 7.83k | output_code stringlengths 1 945 |
|---|---|
Next line prediction: <|code_start|>
User = get_user_model()
TEST_USERNAME = "admin"
TEST_PASSWORD = "battery-horse-staple"
class AdminTest(TestCase):
@classmethod
def setUpTestData(self):
<|code_end|>
. Use current file imports:
(from django.contrib.auth import get_user_model
from django.test import TestC... | User.objects.create_superuser( |
Based on the snippet: <|code_start|> self.assertContains(response, self.wikipedia.name)
with override("nl"):
response = self.client.get(url)
self.assertEqual(response.status_code, 200)
self.assertContains(response, self.wikipedia.name)
... | response = self.client.get(url("frog")) |
Based on the snippet: <|code_start|> template_name = "table.html"
class FilteredBlogListView(FilterView, tables.SingleTableView):
table_class = BlogTable
model = Blog
template_name = "table.html"
filterset_class = BlogFilter
class BlogView(DetailView):
model = Blog
template_name = "blog.... | with open("data/species.json") as f: |
Predict the next line for this snippet: <|code_start|>
class BlogTable(tables.Table):
title_i18n = tables.LinkColumn("blog_detail", args=(tables.A("pk"),))
edit = tables.TemplateColumn(
template_code="""<a href="{% url 'blog-edit' pk=record.pk %}" class="btn btn-sm btn-primary">edit</a>""",
e... | "title_en", |
Given the following code snippet before the placeholder: <|code_start|>
admin.site.has_permission = disable_admin_login()
@admin.register(Blog)
class BlogAdmin(ActiveLanguageMixin, admin.ModelAdmin):
<|code_end|>
, predict the next line using imports from the current file:
from django.contrib import admin
from mod... | list_display = ("title_i18n", "category") |
Given snippet: <|code_start|>
admin.site.has_permission = disable_admin_login()
@admin.register(Blog)
class BlogAdmin(ActiveLanguageMixin, admin.ModelAdmin):
<|code_end|>
, continue by predicting the next line. Consider current file imports:
from django.contrib import admin
from modeltrans.admin import ActiveLangu... | list_display = ("title_i18n", "category") |
Next line prediction: <|code_start|>
admin.site.has_permission = disable_admin_login()
@admin.register(Blog)
class BlogAdmin(ActiveLanguageMixin, admin.ModelAdmin):
list_display = ("title_i18n", "category")
<|code_end|>
. Use current file imports:
(from django.contrib import admin
from modeltrans.admin import ... | search_fields = ("title_i18n", "category__name_i18n") |
Based on the snippet: <|code_start|>
admin.site.has_permission = disable_admin_login()
@admin.register(Blog)
class BlogAdmin(ActiveLanguageMixin, admin.ModelAdmin):
<|code_end|>
, predict the immediate next line with the help of imports:
from django.contrib import admin
from modeltrans.admin import ActiveLanguageM... | list_display = ("title_i18n", "category") |
Given the following code snippet before the placeholder: <|code_start|>
class Category(models.Model):
name = models.CharField(max_length=255)
i18n = TranslationField(fields=("name",))
class Meta:
indexes = [GinIndex(fields=["i18n"])]
verbose_name_plural = "categories"
def __str__(se... | title = models.CharField(max_length=255) |
Continue the code snippet: <|code_start|>
class FallbackConfTest(TestCase):
@override_settings(MODELTRANS_FALLBACK={"fy": ("nl", "en")})
def test_fallback_must_have_default(self):
message = "MODELTRANS_FALLBACK setting must have a `default` key."
with self.assertRaisesMessage(ImproperlyConfig... | @override_settings( |
Predict the next line after this snippet: <|code_start|>
class FallbackConfTest(TestCase):
@override_settings(MODELTRANS_FALLBACK={"fy": ("nl", "en")})
def test_fallback_must_have_default(self):
message = "MODELTRANS_FALLBACK setting must have a `default` key."
with self.assertRaisesMessage(I... | with self.assertRaisesMessage(ImproperlyConfigured, message): |
Given the following code snippet before the placeholder: <|code_start|>
@admin.register(Blog)
class BlogAdmin(admin.ModelAdmin):
list_display = ("title_i18n", "category")
search_fields = ("title_i18n", "category__name_i18n", "site__name")
@admin.register(Category)
class CategoryAdmin(ActiveLanguageMixin, a... | pass |
Predict the next line for this snippet: <|code_start|>
try:
# django==3.1 moved JSONField into django.db.models
except ImportError:
SUPPORTED_FIELDS = (fields.CharField, fields.TextField)
DEFAULT_LANGUAGE = get_default_language()
<|code_end|>
with the help of current file imports:
from django.core.exception... | def translated_field_factory(original_field, language=None, *args, **kwargs): |
Using the snippet: <|code_start|>
try:
# django==3.1 moved JSONField into django.db.models
except ImportError:
SUPPORTED_FIELDS = (fields.CharField, fields.TextField)
DEFAULT_LANGUAGE = get_default_language()
def translated_field_factory(original_field, language=None, *args, **kwargs):
if not isinstance(o... | ) |
Using the snippet: <|code_start|>
try:
# django==3.1 moved JSONField into django.db.models
except ImportError:
SUPPORTED_FIELDS = (fields.CharField, fields.TextField)
DEFAULT_LANGUAGE = get_default_language()
def translated_field_factory(original_field, language=None, *args, **kwargs):
if not isinstance(o... | return Specific(original_field, language, *args, **kwargs) |
Predict the next line for this snippet: <|code_start|>
try:
# django==3.1 moved JSONField into django.db.models
except ImportError:
SUPPORTED_FIELDS = (fields.CharField, fields.TextField)
DEFAULT_LANGUAGE = get_default_language()
def translated_field_factory(original_field, language=None, *args, **kwargs):
... | class Specific(TranslatedVirtualField, original_field.__class__): |
Given snippet: <|code_start|>
try:
# django==3.1 moved JSONField into django.db.models
except ImportError:
SUPPORTED_FIELDS = (fields.CharField, fields.TextField)
DEFAULT_LANGUAGE = get_default_language()
def translated_field_factory(original_field, language=None, *args, **kwargs):
<|code_end|>
, continue by ... | if not isinstance(original_field, SUPPORTED_FIELDS): |
Given the following code snippet before the placeholder: <|code_start|>
FRIENDLY_NAME = 'Time'
class Form(forms.Form):
when = SmartDateField(label='Expire on')
<|code_end|>
, predict the next line using imports from the current file:
from django import forms
from web.models import Quota
from web.forms import Sma... | def descript(q, is_admin=False): |
Based on the snippet: <|code_start|>#!/usr/bin/env python
# -*- coding: utf-8 -*-
#
# Shadowsocks service
#
from __future__ import absolute_import, print_function
config = {
"executable": "ssserver",
"config-file": "/etc/shadowsocks.json",
<|code_end|>
, predict the immediate next line with the help of impor... | "manager-address": "/var/run/shadowsocks-manager.sock", |
Based on the snippet: <|code_start|>#!/usr/bin/env python
# -*- coding: utf-8 -*-
#
# Shadowsocks service
#
from __future__ import absolute_import, print_function
config = {
"executable": "ssserver",
"config-file": "/etc/shadowsocks.json",
"manager-address": "/var/run/shadowsocks-manager.sock",
<|code_en... | "statistic_interval": 7200, |
Continue the code snippet: <|code_start|>#!/usr/bin/env python
# -*- coding: utf-8 -*-
#
# Shadowsocks service
#
from __future__ import absolute_import, print_function
config = {
"executable": "ssserver",
"config-file": "/etc/shadowsocks.json",
"manager-address": "/var/run/shadowsocks-manager.sock",
... | } |
Given snippet: <|code_start|>#!/usr/bin/env python
# -*- coding: utf-8 -*-
#
# Shadowsocks service
#
from __future__ import absolute_import, print_function
config = {
"executable": "ssserver",
"config-file": "/etc/shadowsocks.json",
"manager-address": "/var/run/shadowsocks-manager.sock",
"statistic_i... | "method": "", |
Using the snippet: <|code_start|>#!/usr/bin/env python
# -*- coding: utf-8 -*-
#
# Shadowsocks service
#
from __future__ import absolute_import, print_function
config = {
"executable": "ssserver",
"config-file": "/etc/shadowsocks.json",
<|code_end|>
, determine the next line of code. You have imports:
impor... | "manager-address": "/var/run/shadowsocks-manager.sock", |
Given the code snippet: <|code_start|># Purpose: manage header section
# Created: 12.03.2011
# Copyright (C) 2011, Manfred Moitzi
# License: MIT License
from __future__ import unicode_literals
__author__ = "mozman <mozman@gmx.at>"
MIN_HEADER_TEXT = """ 0
SECTION
2
HEADER
9
$ACADVER
1
AC1009
<|code_end|>
, gen... | 9 |
Next line prediction: <|code_start|># Purpose: manage header section
# Created: 12.03.2011
# Copyright (C) 2011, Manfred Moitzi
# License: MIT License
from __future__ import unicode_literals
__author__ = "mozman <mozman@gmx.at>"
MIN_HEADER_TEXT = """ 0
SECTION
2
<|code_end|>
. Use current file imports:
(from col... | HEADER |
Given the code snippet: <|code_start|># Purpose: manage header section
# Created: 12.03.2011
# Copyright (C) 2011, Manfred Moitzi
# License: MIT License
from __future__ import unicode_literals
__author__ = "mozman <mozman@gmx.at>"
MIN_HEADER_TEXT = """ 0
SECTION
2
<|code_end|>
, generate the next line using the i... | HEADER |
Using the snippet: <|code_start|># Purpose: manage header section
# Created: 12.03.2011
# Copyright (C) 2011, Manfred Moitzi
# License: MIT License
from __future__ import unicode_literals
__author__ = "mozman <mozman@gmx.at>"
MIN_HEADER_TEXT = """ 0
SECTION
2
HEADER
9
$ACADVER
1
AC1009
9
$DWGCODEPAGE
3
AN... | 5 |
Predict the next line for this snippet: <|code_start|># Purpose: manage header section
# Created: 12.03.2011
# Copyright (C) 2011, Manfred Moitzi
# License: MIT License
from __future__ import unicode_literals
__author__ = "mozman <mozman@gmx.at>"
MIN_HEADER_TEXT = """ 0
SECTION
2
HEADER
9
$ACADVER
1
<|code_en... | AC1009 |
Based on the snippet: <|code_start|> return is_point_code(tag[0])
def cast_tag(tag, types=TYPE_TABLE):
caster = types.get(tag[0], ustr)
try:
return DXFTag(tag[0], caster(tag[1]))
except ValueError:
if caster is int: # convert float to int
return DXFTag(tag[0], int(float(tag... | code = tag.code |
Using the snippet: <|code_start|># Purpose: database module
# Created: 11.03.2011
# Copyright (C) 2011, Manfred Moitzi
# License: MIT License
from __future__ import unicode_literals
__author__ = "mozman <mozman@gmx.at>"
def factory():
<|code_end|>
, determine the next line of code. You have imports:
from .tools.bin... | return EntityDB() |
Given the following code snippet before the placeholder: <|code_start|># Purpose: database module
# Created: 11.03.2011
# Copyright (C) 2011, Manfred Moitzi
# License: MIT License
from __future__ import unicode_literals
__author__ = "mozman <mozman@gmx.at>"
def factory():
<|code_end|>
, predict the next line using i... | return EntityDB() |
Predict the next line after this snippet: <|code_start|># License: MIT License
from __future__ import unicode_literals
__author__ = "mozman <mozman@gmx.at>"
BINARY_DATA_CODES = frozenset(range(310, 320))
ENTITIES_WITH_PROXY_GRAPHIC = frozenset(['MESH', 'BODY', 'REGION', '3DSOLID', 'SURFACE', 'PLANESURFACE', 'HELIX',... | if len(compress_tasks): |
Predict the next line after this snippet: <|code_start|># Purpose: binary data management
# Created: 03.05.2014
# Copyright (C) 2014, Manfred Moitzi
# License: MIT License
from __future__ import unicode_literals
__author__ = "mozman <mozman@gmx.at>"
BINARY_DATA_CODES = frozenset(range(310, 320))
ENTITIES_WITH_PROXY_... | dxftype = tags.dxftype() |
Continue the code snippet: <|code_start|> self.build(faces)
@property
def nvertices(self):
return len(self.vertices)
@property
def nfaces(self):
return len(self.faces)
def get_vertices(self):
vertices = self.vertices[:]
vertices.extend(self.faces)
re... | try: |
Based on the snippet: <|code_start|># Purpose: classified tags
# Created: 30.04.2011
# Copyright (C) 2011, Manfred Moitzi
# License: MIT License
from __future__ import unicode_literals
__author__ = "mozman <mozman@gmx.at>"
APP_DATA_MARKER = 102
<|code_end|>
, predict the immediate next line with the help of imports:
... | SUBCLASS_MARKER = 100 |
Here is a snippet: <|code_start|># Purpose: classified tags
# Created: 30.04.2011
# Copyright (C) 2011, Manfred Moitzi
# License: MIT License
from __future__ import unicode_literals
__author__ = "mozman <mozman@gmx.at>"
APP_DATA_MARKER = 102
SUBCLASS_MARKER = 100
<|code_end|>
. Write the next line using the current fi... | XDATA_MARKER = 1001 |
Given snippet: <|code_start|># Purpose: classified tags
# Created: 30.04.2011
# Copyright (C) 2011, Manfred Moitzi
# License: MIT License
from __future__ import unicode_literals
__author__ = "mozman <mozman@gmx.at>"
APP_DATA_MARKER = 102
SUBCLASS_MARKER = 100
XDATA_MARKER = 1001
NoneTag = DXFTag(None, None)
<|code_... | class ClassifiedTags(object): |
Given the code snippet: <|code_start|># Purpose: classified tags
# Created: 30.04.2011
# Copyright (C) 2011, Manfred Moitzi
# License: MIT License
from __future__ import unicode_literals
__author__ = "mozman <mozman@gmx.at>"
APP_DATA_MARKER = 102
SUBCLASS_MARKER = 100
XDATA_MARKER = 1001
NoneTag = DXFTag(None, None)
... | class ClassifiedTags(object): |
Given the code snippet: <|code_start|>class DefaultChunk(object):
def __init__(self, tags, drawing):
self.tags = tags
self._drawing = drawing
@property
def dxffactory(self):
return self._drawing.dxffactory
@property
def name(self):
return self.tags[1].value.lower()
... | tag = next(tagreader) |
Given the code snippet: <|code_start|># Purpose: default chunk
# Created: 12.03.2011
# Copyright (C) 2011, Manfred Moitzi
# License: MIT License
from __future__ import unicode_literals
__author__ = "mozman <mozman@gmx.at>"
class DefaultChunk(object):
def __init__(self, tags, drawing):
self.tags = tags
... | def dxffactory(self): |
Next line prediction: <|code_start|># Purpose: default chunk
# Created: 12.03.2011
# Copyright (C) 2011, Manfred Moitzi
# License: MIT License
from __future__ import unicode_literals
__author__ = "mozman <mozman@gmx.at>"
class DefaultChunk(object):
def __init__(self, tags, drawing):
self.tags = tags
... | def dxffactory(self): |
Given snippet: <|code_start|># Purpose: entity section
# Created: 13.03.2011
# Copyright (C) 2011, Manfred Moitzi
# License: MIT License
from __future__ import unicode_literals
__author__ = "mozman <mozman@gmx.at>"
class ClassesSection(AbstractSection):
name = 'classes'
def __init__(self, tags, drawing):
... | def __iter__(self): # no layout setting required/possible |
Given snippet: <|code_start|># Purpose: dxf tag type def
# Created: 30.04.2014
# Copyright (C) 2014, Manfred Moitzi
# License: MIT License
from __future__ import unicode_literals
__author__ = "mozman <mozman@gmx.at>"
class CompressedString(object):
def __init__(self, s):
self._data = zlib.compress(unic... | def write(self, stream): |
Using the snippet: <|code_start|># Purpose: entity section
# Created: 13.03.2011
# Copyright (C) 2011, Manfred Moitzi
# License: MIT License
from __future__ import unicode_literals
__author__ = "mozman <mozman@gmx.at>"
class ObjectsSection(ClassesSection):
name = 'objects'
@property
<|code_end|>
, determine... | def roothandle(self): |
Continue the code snippet: <|code_start|># Copyright (C) 2014, Manfred Moitzi
# License: MIT License
from __future__ import unicode_literals
__author__ = "mozman <mozman@gmx.at>"
_decode_table = {
0x20: ' ',
0x40: '_',
0x5F: '@',
}
for c in range(0x41, 0x5F):
_decode_table[c] = chr(0x41 + (0x5E - c))... | s += dectab[c] |
Given the following code snippet before the placeholder: <|code_start|># Purpose: DXF Pretty Printer
# Created: 16.07.2015
# Copyright (C) 2015, Manfred Moitzi
# License: MIT License
from __future__ import unicode_literals
__author__ = "mozman <mozman@gmx.at>"
if __name__ == "__main__":
options.compress_binary_d... | try: |
Continue the code snippet: <|code_start|> '$UCSBASE': partial(SingleValue, code=2),
'$UCSNAME': partial(SingleValue, code=2),
'$UCSORG': Point3D,
'$UCSORGBACK': Point3D,
'$UCSORGBOTTOM': Point3D,
'$UCSORGFRONT': Point3D,
'$UCSORGLEFT': Point3D,
'$UCSORGRIGHT': Point3D,
'$UCSORGTOP': P... | } |
Predict the next line for this snippet: <|code_start|># Purpose: trusted string tag reader & stream tag reader
# Created: 10.04.2016
# Copyright (C) 2016, Manfred Moitzi
# License: MIT License
from __future__ import unicode_literals
__author__ = "mozman <mozman@gmx.at>"
DUMMY_TAG = DXFTag(999, '')
<|code_end|>
wit... | def string_tagger(s): |
Based on the snippet: <|code_start|># This file is part of the Edison Project.
# Please refer to the LICENSE document that was supplied with this software for information on how it can be used.
# Models for Change Management System
class ChangeStatus(models.Model):
Description = models.CharField(max_length=128)
Clos... | return self.Name |
Given the code snippet: <|code_start|># This file is part of the Edison Project.
# Please refer to the LICENSE document that was supplied with this software for information on how it can be used.
# Create your models here.
# log the packages that are updated every time the package manager runs
#
# Need to write a yum/... | class Meta: |
Using the snippet: <|code_start|> Name = models.CharField(max_length=255)
Creator = models.ForeignKey(User)
Notes = models.TextField()
AffectedItems = models.ManyToManyField(ConfigurationItem)
def __unicode__(self):
return self.Name
class Meta:
verbose_name = 'Orchestration Class'
verbose_name_plural = 'Or... | return u'%s = %s' % (self.Name,self.Value) |
Predict the next line after this snippet: <|code_start|># THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
# A PARTICULAR PURPOSE ARE DIS... | data_files=[('share/dizzy/', ['lib/std_string_lib.txt'])], |
Given snippet: <|code_start|># contributors may be used to endorse or promote products derived from
# this software without specific prior written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, B... | self.assertTrue(result) |
Given the following code snippet before the placeholder: <|code_start|> def test_eq(self):
v1 = Value(b"\x01\x23", 10)
v2 = Value(b"\x01\x23", 10)
v3 = Value(b"\x02", 2)
self.assertEqual(v1, v2)
self.assertNotEqual(v2, v3)
def test_add_aligned(self):
chars1 = b"Th... | v3 = v1 + v2 |
Continue the code snippet: <|code_start|># modification, are permitted provided that the following conditions are
# met:
#
# * Redistributions of source code must retain the above copyright
# notice, this list of conditions and the following disclaimer.
# * Redistributions in bina... | def next(self): |
Given snippet: <|code_start|># distribution.
# * Neither the name of the nor the names of its
# contributors may be used to endorse or promote products derived from
# this software without specific prior written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND ... | def func(dizzy_iterator): |
Given the code snippet: <|code_start|> v = Value(l.rstrip(b'\n'))
self.lib[listname].append(v)
return self.lib[listname]
class dizz_library(object):
def __init__(self):
self.lib = {}
self.load_strings(CONFIG["GLOBALS"]["DEFAULT_STR_LIB"])
def get_n... | if libidx == None: |
Predict the next line after this snippet: <|code_start|># "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
# OWNER OR CONTRIBUTORS BE LI... | self.lib[listname].append(v) |
Using the snippet: <|code_start|># Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are
# met:
#
# * Redistributions of source code must retain the above copyright
# notice, this list of conditions and... | config_parser.add_section("probe") |
Predict the next line for this snippet: <|code_start|># notice, this list of conditions and the following disclaimer.
# * Redistributions in binary form must reproduce the above
# copyright notice, this list of conditions and the following disclaimer
# in the documentation and/or other mat... | if not obj.obj.extra_encoding is None: |
Continue the code snippet: <|code_start|> print_dizzy("pcap/init: using bpf '%s'." % self.filter, VERBOSE_1)
self.snaplen = config.getint("snaplen", 8192)
self.promisc = config.getboolean("promisc", True)
self.to_ms = config.getint("to_ms", 10)
self.cooldown = config.getint("c... | sleep(self.cooldown) |
Using the snippet: <|code_start|> except:
print_dizzy("No usable pcap library found. Be sure you have pcapy installed!")
print_dizzy("Pcap recording disabled!")
self.pcap = None
return
self.interface = config.get("interface", "any")
check_root("use ... | self.pcap_dumper = self.pcap_object.dump_open(self.filename) |
Using the snippet: <|code_start|> def __init__(self, config, filename):
Thread.__init__(self)
try:
self.pcap = pcapy
except:
print_dizzy("No usable pcap library found. Be sure you have pcapy installed!")
print_dizzy("Pcap recording disabled!")
s... | self.pcap_object = self.pcap.open_live(self.interface, self.snaplen, self.promisc, self.to_ms) |
Given the following code snippet before the placeholder: <|code_start|># LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
# SPECIAL,... | if not self.filter is "": |
Continue the code snippet: <|code_start|># notice, this list of conditions and the following disclaimer.
# * Redistributions in binary form must reproduce the above
# copyright notice, this list of conditions and the following disclaimer
# in the documentation and/or other materials provid... | self.cur = self.iter.call_functions() |
Next line prediction: <|code_start|>#
# * Redistributions of source code must retain the above copyright
# notice, this list of conditions and the following disclaimer.
# * Redistributions in binary form must reproduce the above
# copyright notice, this list of conditions and the following d... | self.config = self.zipimport.load_module("config") |
Next line prediction: <|code_start|># met:
#
# * Redistributions of source code must retain the above copyright
# notice, this list of conditions and the following disclaimer.
# * Redistributions in binary form must reproduce the above
# copyright notice, this list of conditions and th... | self.zipimport = zipimporter(path) |
Predict the next line for this snippet: <|code_start|>
class DizzyModule(object):
def __init__(self, path, config):
self.path = path
self.global_config = config
self.zipimport = zipimporter(path)
self.config = self.zipimport.load_module("config")
def load(self):
inventor... | act = __import__(self.name + ".act").act |
Here is a snippet: <|code_start|># Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are
# met:
#
# * Redistributions of source code must retain the above copyright
# notice, this list of conditions and... | self.assertEqual(f.name, "test") |
Here is a snippet: <|code_start|># Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are
# met:
#
# * Redistributions of source code must retain the above copyright
# notice, this list of conditions and... | self.assertEqual(f.name, "test") |
Using the snippet: <|code_start|> {'ip': self.equipment.ip,
'index': port})
else:
# Refresh port
nport = self.equipment.ports[port]
# We ask PostgreSQL to compare MAC addresses for us
txn.... | INSERT INTO port |
Given the code snippet: <|code_start|> else:
# Refresh port
nport = self.equipment.ports[port]
# We ask PostgreSQL to compare MAC addresses for us
txn.execute("SELECT 1 WHERE %(mac1)s::macaddr = %(mac2)s::macaddr",
{'... | VALUES (%(ip)s, %(port)s, %(name)s, %(alias)s, %(state)s, %(address)s, |
Based on the snippet: <|code_start|>
COMPLETE_LIMIT = 10
class CompleteResource(rend.Page):
addSlash = True
docFactory = loaders.stan(T.html [ T.body [ T.p [ "Nothing here" ] ] ])
<|code_end|>
, predict the immediate next line with the help of imports:
import re
from nevow import rend, tags as T, loaders
... | def __init__(self, dbpool): |
Here is a snippet: <|code_start|>
class MainPage(rend.Page):
docFactory = loaders.xmlstr(resource_string(__name__, "main.xhtml"))
def __init__(self, config, dbpool, collector):
self.config = config['web']
self.dbpool = dbpool
self.collector = collector
rend.Page.__init__(sel... | def render_logo(self, ctx, data): |
Using the snippet: <|code_start|>
def render(self, data):
return [("%s / Host" % self.discovery_name,
T.invisible(data=data[0][2],
render=T.directive("hostname")),
data[0][2]),
("%s / IP" % self.discovery_name,
... | FROM cdp_full WHERE equipment=%(ip)s |
Next line prediction: <|code_start|> vlanlist.append(str(row[0]))
vid = T.td[T.span(data=row[0], render=T.directive("vlan"))]
if row[1] is None:
r.append(T.tr(_class=(i%2) and "odd" or "even")[
vid, notpresent,
T.td[r... | ON a.mac = f.mac AND a.deleted='infinity' |
Given snippet: <|code_start|> self.input_faa_2 = resource_filename(__name__, 'data/target_fasta.faa')
self.input_gb_1 = resource_filename(__name__, 'data/query_genbank.gb')
self.input_gb_2 = resource_filename(__name__, 'data/target_genbank.gb')
self.outdir = tempfile.mkdtemp(prefix='test_... | self.instance.run() |
Based on the snippet: <|code_start|>'''
Created on March 13, 2013
@author: tbeek
'''
class Test(unittest.TestCase):
''' Runs the application as the end-user would, testing for correct exception handling
as well as final output checks comparing generated output to reference (curated)
output. '''
... | self.input_faa_2 = resource_filename(__name__, 'data/target_fasta.faa') |
Given snippet: <|code_start|>'''This module contains the different readers used to parse both the
target and the query records from files.'''
class Reader(object):
'''The generic reader from which other readers inherit some common functionalities.
Each reader should implement '''
def __init__(self, logger... | self.logger.debug('Initializing reader finished.') |
Based on the snippet: <|code_start|>'''This module contains the different readers used to parse both the
target and the query records from files.'''
class Reader(object):
'''The generic reader from which other readers inherit some common functionalities.
Each reader should implement '''
def __init__(self,... | self.limitlength = limitlength |
Given the following code snippet before the placeholder: <|code_start|> pushed = restore_organization_to_ckan(self.catalog, 'owner_org',
'portal', 'apikey', identifiers)
self.assertEqual([identifiers[1]], pushed)
mock_push_thm.assert_called_with(self.... | catalog_id=None, |
Next line prediction: <|code_start|> 'url': 'otherlicense.com', 'id': '2'}]
elif action == 'package_update':
self.assertEqual('notspecified', data_dict['license_id'])
return data_dict
else:
return []
mock_portal.retu... | catalog_id=self.minimum_catalog_id) |
Given snippet: <|code_start|>
class DistributionUrlsValidator(UrlValidator):
def validate(self):
datasets = self.catalog.get('dataset')
metadata = []
urls = []
for dataset_idx, dataset in enumerate(datasets):
distributions = dataset.get('distribution')
for ... | dataset_idx = actual_metadata["dataset_idx"] |
Continue the code snippet: <|code_start|> "dist_title": distribution_title
})
urls += [access_url, download_url]
sync_res = threading_helper \
.apply_threading(urls,
self.is_working_url,
sel... | distribution_idx, |
Here is a snippet: <|code_start|>
class LandingPagesValidator(UrlValidator):
def validate(self):
datasets = self.catalog.get('dataset')
datasets = filter(lambda x: x.get('landingPage'), datasets)
metadata = []
urls = []
for dataset_idx, dataset in enumerate(datasets):
... | landing_page = act_metadata["landing_page"] |
Here is a snippet: <|code_start|>#!/usr/bin/env python
# -*- coding: utf-8 -*-
class LandingPagesValidator(UrlValidator):
def validate(self):
datasets = self.catalog.get('dataset')
datasets = filter(lambda x: x.get('landingPage'), datasets)
metadata = []
urls = []
for d... | self.threads_count) |
Given the code snippet: <|code_start|> """Convierte el resultado de action.status_show() en metadata a nivel de
catálogo."""
catalog = dict()
catalog_mapping = {
"site_title": "title",
"site_description": "description"
}
for status_key, catalog_key in iteritems(catalog_mapping):... | completar catalog['publisher'['%s'].""", |
Based on the snippet: <|code_start|> ))
# tiempo de espera padra evitar baneos
time.sleep(0.2)
# itera leyendo todos los temas del portal
groups = [portal.call_action(
'group_show', {'id': grp},
requests_kwargs={"verify": False})
f... | "site_title": "title", |
Next line prediction: <|code_start|> for grp in groups_list]
catalog = map_status_to_catalog(status)
catalog["dataset"] = map_packages_to_datasets(
packages, portal_url)
catalog["themeTaxonomy"] = map_groups_to_themes(groups)
except (CKANAPIError, RequestException) a... | La clave '%s' no está en el endpoint de status. No se puede |
Given the code snippet: <|code_start|># -*- coding: utf-8 -*-
class ThreadingTests(TestCase):
def test_threading(self):
elements = [1, 2, 3, 4]
def function(x):
<|code_end|>
, generate the next line using the imports in this file:
from unittest import TestCase
from pydatajson.threading_helper ... | return x ** 2 |
Next line prediction: <|code_start|> })
def malformed_accrualperiodicity():
return dataset_error({
'message': "%s is not valid under any of the given schemas"
% jsonschema_str('RP1Y'),
})
def malformed_temporal():
return dataset_error({
"instance": "2015-01-1/2015-1... | }, |
Given the code snippet: <|code_start|>#!/usr/bin/env python
# -*- coding: utf-8 -*-
class DistributionDownloadUrlsValidator(UrlValidator):
def validate(self):
async_results = []
for dataset in self.catalog.get('dataset', []):
distribution_urls = \
<|code_end|>
, generate the next line... | [distribution.get('downloadURL', '') |
Given snippet: <|code_start|>#!/usr/bin/env python
# -*- coding: utf-8 -*-
class DistributionDownloadUrlsValidator(UrlValidator):
def validate(self):
async_results = []
for dataset in self.catalog.get('dataset', []):
distribution_urls = \
[distribution.get('downloadURL... | result = 0 |
Using the snippet: <|code_start|> catalog = os.path.join(self.SAMPLES_DIR, "full_data.json")
self.dj.generate_datasets_report(catalog, export_path="una ruta")
pydatajson.writers.write_table.assert_called_once()
def test_generate_harvester_config_freq_none(self):
"""generate_harvest... | }, |
Given snippet: <|code_start|> "dataset_accrualPeriodicity": "eventual",
"harvest": 1
},
{
"catalog_metadata_url": "URL Catalogo B",
"dataset_title": "Dataset Invalido",
"dataset_accrualPeriodicity": "eventual",
"harvest": 0
}... | expected = [expected_catalog, expected_catalog] |
Based on the snippet: <|code_start|> "dataset_organization": "organizacion-en-ckan",
"catalog_id": "organismo",
}
]
self.dj.generate_datasets_report = mock.MagicMock(
return_value=datasets_report)
actual_config = self.dj.generate_harvester... | return_value=CATALOG.copy()) |
Continue the code snippet: <|code_start|>#!/usr/bin/env python
# -*- coding: utf-8 -*-
try:
except ImportError:
EXTENSIONS_EXCEPTIONS = ["zip", "php", "asp", "aspx"]
class ConsistentDistributionFieldsValidator(SimpleValidator):
def validate(self):
for dataset_idx, dataset in enumerate(self.catalog["da... | @staticmethod |
Here is a snippet: <|code_start|> for value in valid_values:
datajson["dataset"][0]["accrualPeriodicity"] = value
res = self.dj.is_valid_catalog(datajson)
assert_true(res, msg=value)
invalid_values = ['RP10Y', 'R/PY', 'R/P3', 'RR/P2Y', 'R/PnY',
... | assert_true( |
Based on the snippet: <|code_start|>
def setUp(self):
self.dj = pydatajson.DataJson(self.get_sample("full_data.json"))
self.catalog = pydatajson.readers.read_catalog(
self.get_sample("full_data.json"))
self.maxDiff = None
self.longMessage = True
self.requests_mock... | ensure_ascii=False |
Given the following code snippet before the placeholder: <|code_start|> errors = [(
['error', 'catalog', 'errors', ],
"%s is too short" % jsonschema_str('')
)]
for path, regex in errors:
with my_vcr.use_cassette('test_validate_bad_rem... | datajson_path = "tests/samples/full_data.json" |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.