Instruction stringlengths 362 7.83k | output_code stringlengths 1 945 |
|---|---|
Given the code snippet: <|code_start|>#!/usr/bin/env python3
# -*- coding: utf-8 -*-
def tearDownModule():
close_webdriver()
CURDIR = path.dirname(path.abspath(__file__))
ROOTDIR = path.dirname(path.dirname(CURDIR))
ENV = os.environ.copy()
ENV['PYTHONPATH'] = ROOTDIR
src_base = '''
import sys # noqa: F401... | from wdom.document import get_document |
Here is a snippet: <|code_start|>#!/usr/bin/env python3
# -*- coding: utf-8 -*-
def tearDownModule():
close_webdriver()
CURDIR = path.dirname(path.abspath(__file__))
ROOTDIR = path.dirname(path.dirname(CURDIR))
ENV = os.environ.copy()
ENV['PYTHONPATH'] = ROOTDIR
src_base = '''
import sys # noqa: F401
impo... | doc.body.appendChild(H1('FIRST', id='h1')) |
Predict the next line for this snippet: <|code_start|>#!/usr/bin/env python3
# -*- coding: utf-8 -*-
def tearDownModule():
close_webdriver()
CURDIR = path.dirname(path.abspath(__file__))
ROOTDIR = path.dirname(path.dirname(CURDIR))
ENV = os.environ.copy()
ENV['PYTHONPATH'] = ROOTDIR
src_base = '''
import s... | from wdom import server |
Next line prediction: <|code_start|>#!/usr/bin/env python3
# -*- coding: utf-8 -*-
def tearDownModule():
close_webdriver()
CURDIR = path.dirname(path.abspath(__file__))
ROOTDIR = path.dirname(path.dirname(CURDIR))
ENV = os.environ.copy()
ENV['PYTHONPATH'] = ROOTDIR
src_base = '''
<|code_end|>
. Use current... | import sys # noqa: F401 |
Predict the next line after this snippet: <|code_start|>#!/usr/bin/env python3
# -*- coding: utf-8 -*-
# flake8: noqa
name = 'Milligram'
project_url = 'http://milligram.github.io/'
project_repository = 'https://github.com/milligram/milligram'
license = 'MIT License'
license_url = 'https://github.com/milligram/milligr... | ] |
Based on the snippet: <|code_start|>Col12 = NewTag('Col12', 'div', Col12, class_='col-auto col-sm-auto col-md-auto col-lg-auto col-xl-auto')
extended_classes = [
Button,
DefaultButton,
PrimaryButton,
SecondaryButton,
SuccessButton,
InfoButton,
WarningButton,
DangerButton,
ErrorButto... | Col9, |
Given the code snippet: <|code_start|> ('wdom', 'element'),
('wdom.examples', 'data_binding'),
('wdom.examples', 'drag'),
('wdom.examples', 'rev_text'),
('wdom.examples', 'theming'),
('wdom', 'event'),
('wdom', 'node'),
('wdom', 'options'),
('wdom', 'parser'),
('wdom', 'server'),
... | stderr=subprocess.STDOUT, |
Predict the next line after this snippet: <|code_start|>#!/usr/bin/env python3
# -*- coding: utf-8 -*-
# flake8: noqa
name = 'MUI'
project_url = 'https://www.muicss.com/'
project_repository = 'https://github.com/muicss/mui'
license = 'MIT License'
license_url = 'https://github.com/muicss/mui/blob/master/LICENSE.txt'
... | ] |
Predict the next line after this snippet: <|code_start|>
css_files = [
'//cdn.jsdelivr.net/picnicss/5.1.0/picnic.min.css',
]
Button = NewTag('Button', bases=Button)
DefaultButton = NewTag('DefaultButton', 'button', Button, is_='default-button')
PrimaryButton = NewTag('PrimaryButton', 'button', Button, is_='primary... | extended_classes = [ |
Given the following code snippet before the placeholder: <|code_start|>
class MyButton(Button):
class_ = 'btn'
print(MyButton().html_noid)
# <button class="btn"></button>
# This is almost same as:
class MyButton2(Button):
def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
s... | ... |
Continue the code snippet: <|code_start|>Select = NewTag('Select', 'select', Select, class_='form-select')
Table = NewTag('Table', 'table', Table, class_='table')
Container = NewTag('Container', 'div', Container, class_='grid grid-fluid')
Wrapper = NewTag('Wrapper', 'div', Wrapper, class_='grid grid-fluid')
Row = New... | LinkButton, |
Based on the snippet: <|code_start|>#!/usr/bin/env python3
# -*- coding: utf-8 -*-
# flake8: noqa
name = 'Bootstrap3'
project_url = 'http://getbootstrap.com/'
project_repository = 'https://github.com/twbs/bootstrap'
license = 'MIT License'
<|code_end|>
, predict the immediate next line with the help of imports:
from... | license_url = 'https://github.com/twbs/bootstrap/blob/master/LICENSE' |
Given snippet: <|code_start|>
ul = Ul()
li1 = Li('item1')
li2 = Li('item2')
<|code_end|>
, continue by predicting the next line. Consider current file imports:
from wdom.tag import Ul, Li
and context:
# Path: wdom/tag.py
# class Tag(WdomElement):
# class NestedTag(Tag):
# class Input(Tag, HTMLInputElement):
# class ... | ... |
Using the snippet: <|code_start|>
ul = Ul()
li1 = Li('item1')
li2 = Li('item2')
...
ul.appendChild(li1)
ul.appendChild(li2)
...
print(ul.html_noid)
# by append
ul2 = Ul()
ul2.append(Li('item1'), Li('item2'))
<|code_end|>
, determine the next line of code. You have imports:
from wdom.tag import Ul, Li
and context (c... | print(ul2.html_noid) |
Continue the code snippet: <|code_start|>
extended_classes = [
Button,
DefaultButton,
PrimaryButton,
SecondaryButton,
SuccessButton,
InfoButton,
WarningButton,
DangerButton,
ErrorButton,
LinkButton,
FormGroup,
Input,
TextInput,
Textarea,
Select,
Table,
... | Col10, |
Given the following code snippet before the placeholder: <|code_start|>
# Making new class easily
MyButton = NewTagClass('MyButton', 'button', Button, class_='btn')
DefaultButton = NewTagClass('DefaultButton', 'button', MyButton, class_='btn-default')
print(MyButton().html_noid)
<|code_end|>
, predict the next line us... | print(DefaultButton().html_noid) |
Predict the next line after this snippet: <|code_start|>
# Making new class easily
MyButton = NewTagClass('MyButton', 'button', Button, class_='btn')
DefaultButton = NewTagClass('DefaultButton', 'button', MyButton, class_='btn-default')
print(MyButton().html_noid)
<|code_end|>
using the current file's imports:
from ... | print(DefaultButton().html_noid) |
Given the following code snippet before the placeholder: <|code_start|>#!/usr/bin/env python3
# -*- coding: utf-8 -*-
# flake8: noqa
name = 'Pure'
project_url = 'http://purecss.io/'
project_repository = 'https://github.com/yahoo/pure/'
license = 'BSD License'
license_url = 'https://github.com/yahoo/pure/blob/master/L... | css_files = [ |
Using the snippet: <|code_start|>Input = NewTag('Input', 'input', Input)
TextInput = NewTag('TextInput', 'input', TextInput)
Textarea = NewTag('Textarea', 'textarea', Textarea)
Select = NewTag('Select', 'ul', Ul, class_='dropdown-menu')
Option = NewTag('Option', 'li', Li)
Table = NewTag('Table', 'table', Table, class_... | InfoButton, |
Predict the next line for this snippet: <|code_start|>#!/usr/bin/env python3
# -*- coding: utf-8 -*-
class TestInitialize(unittest.TestCase):
def test_initialize(self):
old_doc = get_document()
old_app_tornado = _tornado.get_app()
reset()
self.assertIsNot(old_doc, get_document())... | self.assertIsNot(old_app_tornado, _tornado.get_app()) |
Continue the code snippet: <|code_start|>#!/usr/bin/env python3
# -*- coding: utf-8 -*-
class TestInitialize(unittest.TestCase):
def test_initialize(self):
old_doc = get_document()
<|code_end|>
. Use current file imports:
import unittest
from wdom.util import reset
from wdom.document import get_documen... | old_app_tornado = _tornado.get_app() |
Predict the next line for this snippet: <|code_start|> self.wd = get_webdriver()
self.port = free_port()
time.sleep(0.01)
cmd = [sys.executable, '-m', self.module, '--port', str(self.port)]
self.proc = subprocess.Popen(cmd, env=os.environ,
stdo... | time.sleep(0.5) |
Next line prediction: <|code_start|> text = 'Click!'
h1 = self.wd.find_element_by_tag_name('h1')
self.assertEqual(h1.text, text)
time.sleep(0.5)
h1.click()
time.sleep(0.5)
self.assertEqual(h1.text, text[::-1])
h1.click()
time.sleep(0.5)
self... | start_btn = self.wd.find_element_by_id('start_btn') |
Here is a snippet: <|code_start|> def tearDown(self):
self.proc.terminate()
self.proc.wait()
super().tearDown()
class TestReverseText(BaseTestCase, TestCase):
module = 'wdom.examples.rev_text'
def test_revtext(self):
text = 'Click!'
h1 = self.wd.find_element_by_tag_... | input.send_keys(k) |
Continue the code snippet: <|code_start|>
extended_classes = [
Button,
DefaultButton,
PrimaryButton,
SecondaryButton,
SuccessButton,
InfoButton,
WarningButton,
DangerButton,
ErrorButton,
LinkButton,
FormGroup,
Select,
Table,
Container,
Wrapper,
Row,
Co... | Col12, |
Predict the next line after this snippet: <|code_start|>
DefaultButton = NewTag('DefaultButton', 'button', Button, class_='bg-white')
PrimaryButton = NewTag('PrimaryButton', 'button', Button, class_='bg-blue')
SecondaryButton = NewTag('SecondaryButton', 'button', Button, class_='bg-grey')
SuccessButton = NewTag('Succes... | InfoButton, |
Given snippet: <|code_start|>Col12 = NewTag('Col12', 'div', Col12, class_='mdl-cell mdl-cell--12-col')
extended_classes = [
Button,
DefaultButton,
PrimaryButton,
SecondaryButton,
SuccessButton,
InfoButton,
WarningButton,
DangerButton,
ErrorButton,
LinkButton,
FormGroup,
... | Col2, |
Next line prediction: <|code_start|> self.win = self.doc.defaultView
self.conn_mock = MagicMock()
_tornado.connections.append(self.conn_mock)
def tearDown(self):
_tornado.connections.remove(self.conn_mock)
def test_custom_elements_registory(self):
self.assertIs(self.win.... | def test_add_event_handler_doc(self): |
Given snippet: <|code_start|>#!/usr/bin/env python3
# -*- coding: utf-8 -*-
class TestWindow(TestCase):
def setUp(self):
super().setUp()
self.doc = get_document()
self.win = self.doc.defaultView
self.conn_mock = MagicMock()
_tornado.connections.append(self.conn_mock)
... | mock = MagicMock(_is_coroutine=False) |
Based on the snippet: <|code_start|>
class TestWindow(TestCase):
def setUp(self):
super().setUp()
self.doc = get_document()
self.win = self.doc.defaultView
self.conn_mock = MagicMock()
_tornado.connections.append(self.conn_mock)
def tearDown(self):
_tornado.c... | self.win.js_exec.assert_called_once_with('addEventListener', 'click') |
Continue the code snippet: <|code_start|>#!/usr/bin/env python3
# -*- coding: utf-8 -*-
def setUpModule():
suppress_logging()
class TestDataBinding(PyppeteerTestCase):
def get_elements(self):
root = data_binding.sample_app()
return root
@sync
<|code_end|>
. Use current file imports:
... | async def test_app(self): |
Predict the next line after this snippet: <|code_start|>
h1 = H1(class_='title')
print(h1.html_noid) # <h1 class="title"></h1>
# this is equivalent to:
h1 = H1()
h1.setAttribute('class', 'title')
# also same as:
<|code_end|>
using the current file's imports:
from wdom.tag import H1
and any relevant context from ot... | h1.classList.add('title') |
Predict the next line after this snippet: <|code_start|>DefaultButton = NewTag('DefaultButton', 'button', Button, class_='hollow secondary', is_='default-button')
PrimaryButton = NewTag('PrimaryButton', 'button', Button, is_='primary-button')
SecondaryButton = NewTag('SecondaryButton', 'button', Button, class_='seconda... | SuccessButton, |
Continue the code snippet: <|code_start|>#!/usr/bin/env python3
# -*- coding: utf-8 -*-
# flake8: noqa
name = 'Vital'
project_url = 'https://vitalcss.com/'
project_repository = 'https://github.com/doximity/vital'
<|code_end|>
. Use current file imports:
from wdom.tag import NewTagClass as NewTag
from wdom.themes imp... | license = 'Apache 2.0' |
Continue the code snippet: <|code_start|>#!/usr/bin/env python3
# -*- coding: utf-8 -*-
# flake8: noqa
name = 'Semantic UI (Semantic)'
project_url = 'http://semantic-ui.com/'
project_repository = 'https://github.com/semantic-org/semantic-ui/'
license = 'MIT License'
license_url = 'https://github.com/Semantic-Org/Sema... | ] |
Continue the code snippet: <|code_start|>#!/usr/bin/env python3
# -*- coding: utf-8 -*-
# flake8: noqa
name = 'Kube'
project_url = 'https://imperavi.com/kube/'
project_repository = 'https://github.com/imperavi/kube'
<|code_end|>
. Use current file imports:
from wdom.tag import NewTagClass as NewTag
from wdom.themes ... | license = 'MIT License' |
Predict the next line for this snippet: <|code_start|>#!/usr/bin/env python3
# -*- coding: utf-8 -*-
def setUpModule():
suppress_logging()
def tearDownModule():
close_webdriver()
class SimpleTestCase(WebDriverTestCase, TestCase):
<|code_end|>
with the help of current file imports:
from selenium.webdr... | def setUp(self): |
Here is a snippet: <|code_start|>Wrapper = NewTag('Wrapper', 'div', Wrapper, class_='container')
Row = NewTag('Row', 'div', Row, class_='row')
Col = NewTag('Col', 'div', Col, class_='col')
Col1 = NewTag('Col1', 'div', Col1, class_='col xs-1 sm-1 md-1 lg-1 xl-1')
Col2 = NewTag('Col2', 'div', Col2, class_='col xs-2 sm-2... | Textarea, |
Here is a snippet: <|code_start|>#!/usr/bin/env python
# -*- coding: utf-8 -*-
# @Date : 2016-05-06 14:35:53
# @Author : moling (365024424@qq.com)
# @Link : http://www.qiangtaoli.com
# @Version : 0.1
_RE_EMAIL = re.compile(r'^[a-zA-Z0-9\.\-\_]+\@[a-zA-Z0-9\-\_]+(\.[a-zA-Z0-9\-\_]+){1,4}$')
_RE_SHA1 = re.compile... | self.offset = size * (index - 1) # 数据库查询用,偏移N个元素 |
Given snippet: <|code_start|> elif isinstance(limit, tuple) and len(limit) == 2: # limit可以取2个参数,表示一个范围
sql.append('limit ?, ?')
args.extend(limit)
else:
raise ValueError('Invalid limit value: %s' % limit)
resultset = await select(' '.join(... | rows = await execute(self.__insert__, args) |
Given the following code snippet before the placeholder: <|code_start|>#!/usr/bin/env python3
from __future__ import unicode_literals
sys.path.append('..')
# Generic tests for ReflectRPC command-line utils
class CmdlineTests(unittest.TestCase):
def __init__(self, *args, **kwargs):
super(CmdlineTests, ... | outfile = '' |
Here is a snippet: <|code_start|>
statinfo = os.stat(filename)
self.assertGreater(statinfo.st_size, 0)
finally:
server.stop()
shutil.rmtree(dirname)
def test_rpcdoc_http_basic_auth(self):
try:
server = ServerRunner('../examples/serverhttp.... | finally: |
Given the following code snippet before the placeholder: <|code_start|>#!/usr/bin/env python3
from __future__ import unicode_literals
sys.path.append('..')
class RpcGenCodeTests(unittest.TestCase):
def test_basic_operation(self):
server = ServerRunner('../examples/server.py', 5500)
server.run()... | packagedir = os.path.join(dirname, 'example') |
Predict the next line for this snippet: <|code_start|>from __future__ import unicode_literals
# The below compiled regex (`textplusstuff_re`) matches the following pattern:
# {% textplusstuff '%(content_type__app_label)s'
# ':%(content_type__model)s:%(pk)d'
# ':%(rendition_key)s:%(field)s' %}... | def __init__(self, raw_val): |
Given snippet: <|code_start|>from __future__ import unicode_literals
try:
except ImportError:
class TextPlusStuffWidget(Textarea):
def render(self, name, value, attrs=None):
<|code_end|>
, continue by predicting the next line. Consider current file imports:
from django.forms.utils import flatatt
from ... | value = value or '' |
Predict the next line for this snippet: <|code_start|>from __future__ import unicode_literals
class TextPlusStuffRegisteredModelAdmin(admin.ModelAdmin):
change_form_template = 'textplusstuff/change_form_with_renditions.html'
def change_view(self, request, object_id, form_url='', extra_context=None):
... | ) |
Predict the next line after this snippet: <|code_start|>
class RegisteredModelStuff(registry.ModelStuff):
# The queryset used to retrieve instances of TestModel
# within the front-end interface. For instance, you could
# exclude 'unpublished' instances or anything else you can
# query the ORM against
... | path_to_template='RegisteredModel_test_rendition.html', |
Using the snippet: <|code_start|>
class RegisteredModelStuff(registry.ModelStuff):
# The queryset used to retrieve instances of TestModel
# within the front-end interface. For instance, you could
# exclude 'unpublished' instances or anything else you can
# query the ORM against
queryset = Registe... | description='Displays a Test Rendition rendered.', |
Continue the code snippet: <|code_start|>from __future__ import unicode_literals
class RegisteredModelSerializer(ExtraContextSerializerMixIn,
serializers.ModelSerializer):
class Meta:
model = RegisteredModel
<|code_end|>
. Use current file imports:
from rest_framework ... | fields = ('title',) |
Predict the next line for this snippet: <|code_start|>from __future__ import unicode_literals
class RegisteredModelSerializer(ExtraContextSerializerMixIn,
serializers.ModelSerializer):
class Meta:
model = RegisteredModel
fields = ('title',)
class TPSTestModelS... | class Meta: |
Next line prediction: <|code_start|>from __future__ import unicode_literals
class RegisteredModelSerializer(ExtraContextSerializerMixIn,
serializers.ModelSerializer):
class Meta:
model = RegisteredModel
<|code_end|>
. Use current file imports:
(from rest_framework impo... | fields = ('title',) |
Based on the snippet: <|code_start|># This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
class SSL(TcpListener):
def __init__(self, host, port, cert, pkey, timeout=0.2... | do_handshake_on_connect=False) |
Here is a snippet: <|code_start|> raise PeachException("Unable to open %s" % self.pkey)
self.privateKey = tlslite.api.parsePEMKey(pkey_content, private=True)
def accept(self):
print("[*] Waiting for incoming connection")
sys.stdout.flush()
client, addr = self._listen.acc... | print("done!") |
Predict the next line for this snippet: <|code_start|># This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
class PhoneNumber(Transformer):
def __init__(self):
T... | segments = "".join([i[1] + i[0] for i in segments]) |
Given snippet: <|code_start|> err = _zlib.deflateEnd(C.byref(self.st))
class Decompressor(object):
def __init__(self, dictionary=None):
self.dictionary = dictionary
self.st = _z_stream()
err = _zlib.inflateInit2_(C.byref(self.st), 15, ZLIB_VERSION,
... | if err in [Z_OK, Z_STREAM_END]: |
Here is a snippet: <|code_start|># This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
usingLightBlue = False
usingBluetooth = False
if sys.platform == "darwin":
try:
... | print("[*] Library: PyBluez (%s)" % sys.platform) |
Given snippet: <|code_start|> return services
def lightblue_server_test():
# L2CAP server sockets not currently supported :(
s = lightblue.socket(lightblue.L2CAP)
s.bind(("", 0x1001))
s.listen(1)
lightblue.advertise("Peach", s, lightblue.L2CAP)
conn, addr = s.accept()
print("Connected b... | def __init__(self, ba_addr, port, timeout=8.0, giveup=3.0): |
Next line prediction: <|code_start|>
def start(self):
if self._connected:
return
print("[*] Connecting to %s:%d ..." % (self.host, self.port))
try:
self.smtp = smtplib.SMTP(self.host, self.port)
except:
raise PeachException("Peer %s:%d is down or ... | try: |
Predict the next line after this snippet: <|code_start|> except:
raise PeachException("The SMTP publisher parameter for port is not a valid number.")
self.debugLevel = int(debugLevel)
self.mailFrom = mailFrom
self.mailTo = mailTo
self.username = username
self.p... | try: |
Given the following code snippet before the placeholder: <|code_start|> 8, 9, 10, 11, 12, 13,
12, 13, 14, 15, 16, 17,
16, 17, 18, 19, 20, 21,
20, 21, 22, 23, 24, 25,
24, 25, 26, 27, 28, 29,
28, 29, 30, 31, 32, 1,
)
# S-boxes.
S = (
(
14, 4, 13, 1, 2, 15, 11, 8, 3, 10, 6, 12,... | 13, 8, 11, 5, 6, 15, 0, 3, 4, 7, 2, 12, 1, 10, 14, 9, |
Given the code snippet: <|code_start|> '-CreateProfile', self.profile_name],
stderr=subprocess.STDOUT)
output = output.strip()
if "Success: created profile" not in output:
raise Exception("Unexpected output whi... | shutil.rmtree(profile_path) |
Given snippet: <|code_start|> self.unitsep = unitsep
def fixup(self):
values = string.split(self.values, self.listsep)
if values is None:
raise Exception("Error: LogicalField was unable to locate its "
"values.")
rndIndex = random.randint(0, le... | raise Exception("Error: RandomField was unable to locate maxlen.") |
Based on the snippet: <|code_start|># This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
try:
class _DbgEventHandler(PyDbgEng.IDebugOutputCallbacksSink, PyDbgEng.IDe... | TakeStackTrace = True |
Based on the snippet: <|code_start|># This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
sys.path.append("..")
sys.path.append("../..")
g_socketData = None
g_faultDetected... | g_stopReactor = False |
Using the snippet: <|code_start|># This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
class Data7Bit(Transformer):
def __init__(self):
Transformer.__init__(self... | this = ord(c) << (8 - count) |
Based on the snippet: <|code_start|># This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
try:
except ImportError:
try:
# Todo: Test monitors on Windows and check Python ... | if sys.platform == 'win32': |
Predict the next line after this snippet: <|code_start|> assert files.lower_extension('FOO') == 'FOO'
assert files.lower_extension('archive.tar.gz') == 'archive.tar.gz'
assert files.lower_extension('ARCHIVE.TAR.GZ') == 'ARCHIVE.TAR.gz'
assert files.lower_extension('audio.m4a') == 'audio.m4a'
assert f... | def test_mime_default_to_none(): |
Predict the next line for this snippet: <|code_start|> assert tester.file
assert tester.file.filename == expected_filename
assert expected_filename in storage
assert tester.to_mongo() == {
'file': {
'filename': expected_filename,
}
}
... | } |
Given snippet: <|code_start|>
tester.save()
tester = Tester.objects.get(id=tester.id)
assert tester.file.filename == filename
def test_save_from_filestorage(self, storage, utils):
class Tester(db.Document):
file = FileField(fs=storage)
filename = 'test.txt'
... | assert tester.file.filename == filename |
Predict the next line for this snippet: <|code_start|> 'xe': u'ɛ',
'e': u'eɪ',
'xi': u'ɪ',
'i': u'iː',
'o': u'oʊ',
'xo': u'ɔɪ',
'xu': u'ʊ',
'u': u'uː',
'b': u'b',
'xc': u'ʧ',
'd': u'd',
'xd': u'ð',
'f': u'f',
... | 'z': u'z', |
Continue the code snippet: <|code_start|>
"""
def __init__(self, corpus, log=logger.null_logger(),
random_seed=None, prune=True):
self.log = log
self.prune = prune
self.corpus = corpus
# seed the random generator
if random_seed is not None:
s... | return 0.5 |
Next line prediction: <|code_start|> represent the proportion of the dataset to include in the
train split. If None, the value is automatically set to the
complement of the test size. (default is None)
"""
def __init__(self, corpus, log=logger.null_logger(),
rando... | try: |
Here is a snippet: <|code_start|> kaldi.options.make_option(
'add-layers-period', default=2, type=int,
help='add new layers every <int> iterations'),
kaldi.options.make_option(
'num-hidden-layers', default=3, type=int, help=''),
kaldi.options.make_option(
... | help=('limits the number of jobs with lots of I/O running ' |
Here is a snippet: <|code_start|> corrupted_wavs.append(utt_id)
if corrupted_wavs != []:
self.log.debug('some utterances have no associated wav: {}'
.format(corrupted_wavs))
return text
def make_lexicon(self):
# To generate the l... | entry = dictionary.group(1) |
Continue the code snippet: <|code_start|> '4oez0e04','4odz0e03','4odx0e01','4odz0e04',
'4odz0e01','4odz0e02','4ojz0e03','4ojz0e04',
'4ojz0e01','4ojz0e02','4ojx0e01','4ogz0e03',
'4ogz0e04','4ogz0e02','4ogx0e01','4ogz0e01',
'4ocz0e04','4ocz0e01','4ocx0e01','4ocz0e03',
'4ocz0... | '4n8x0201','4n8x0101','4n9x0101','4n9x0201', |
Here is a snippet: <|code_start|> else:
print(body % (low, high, val, stars,
_stars(val, val_max, stars)))
def _print_linear_hist(vals, val_type, strip_leading_zero):
global stars_max
log2_dist_max = 64
idx_max = -1
val_max = 0
for i, v in enumerate(val... | _stars(val, val_max, stars))) |
Given snippet: <|code_start|> return key
def leaf_scanf(self, leaf_str):
leaf = self.Leaf()
res = lib.bpf_table_leaf_sscanf(self.bpf.module, self.map_id, leaf_str,
ct.byref(leaf))
if res < 0:
raise Exception("Could not scanf leaf")
... | def itervalues(self): |
Predict the next line after this snippet: <|code_start|> # Using print+sys.exit instead of raising exceptions,
# because exceptions are caught by the caller.
print("Type: '%s' not recognized. Please define the data with ctypes manually."
% field_type, file=sys.stderr... | elif ttype == BPF_MAP_TYPE_STACK_TRACE: |
Given snippet: <|code_start|> body = "%20d -> %-20d : %-8d |%-*s|"
stars = int(stars_max / 2)
if idx_max > 0:
print(header % val_type)
for i in range(1, idx_max + 1):
low = (1 << i) >> 1
high = (1 << i) - 1
if (low == high):
low -= 1
val = val... | if v > val_max: val_max = v |
Here is a snippet: <|code_start|>
def Table(bpf, map_id, map_fd, keytype, leaftype, name, **kwargs):
"""Table(bpf, map_id, map_fd, keytype, leaftype, **kwargs)
Create a python object out of a reference to a bpf table handle"""
ttype = lib.bpf_table_type_id(bpf.module, map_id)
t = None
if ttype ==... | t = CgroupArray(bpf, map_id, map_fd, keytype, leaftype) |
Given the code snippet: <|code_start|>
def __init__(self, left_op, right_op):
super(Binary, self).__init__()
self.left_op, self.right_op = left_op, right_op
def forward(self, *inputs):
left_out, right_out = (
self.left_op.forward(*inputs),
self.right_op.forward(*... | def is_initialized(self): |
Here is a snippet: <|code_start|>class Add(Binary):
def combinator(self, a, b):
return a + b
def __repr__(self):
return "{} + {}".format(
self.left_op,
self.right_op
)
class Sub(Binary):
def combinator(self, a, b):
return a - b
def __repr__(se... | self.right_op |
Given the code snippet: <|code_start|># (c) Copyright 2014,2015 Hewlett-Packard Development Company, L.P.
#
# 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... | name='restore'), |
Continue the code snippet: <|code_start|># (c) Copyright 2014,2015 Hewlett-Packard Development Company, L.P.
#
# 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/licen... | navigation_kwarg_name = "name" |
Based on 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 agreed to in writing... | return ungettext_lazy( |
Given the following code snippet before the placeholder: <|code_start|>#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the spec... | client = freezer_api.Client(self.request).get(kwargs['client_id'], |
Given the following code snippet before the placeholder: <|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... | return [] |
Predict the next line for this snippet: <|code_start|> def get_sessions_data(self):
return freezer_api.Session(self.request).list(limit=100)
@shield('Unable to get job list.', redirect='sessions:index')
def get_jobs_data(self):
if self.kwargs['session_id']:
return freezer_api.Ses... | class CreateSessionWorkflow(workflows.WorkflowView): |
Using the snippet: <|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 License.
class IndexView(tables.DataTab... | return {'data': pprint.pformat(action)} |
Continue the code 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 agreed to in wr... | template_name = "disaster_recovery/actions/index.html" |
Given the code snippet: <|code_start|># not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS"... | template_name = 'disaster_recovery/actions/detail.html' |
Next line prediction: <|code_start|> backup = freezer_api.Backup(self.request).get(kwargs['backup_id'],
json=True)
return {'data': pprint.pformat(backup)}
class RestoreView(workflows.WorkflowView):
workflow_class = restore_workflow.Restore
... | return workflow |
Given snippet: <|code_start|>
class DetailView(generic.TemplateView):
template_name = 'disaster_recovery/backups/detail.html'
@shield('Unable to get backup.', redirect='backups:index')
def get_context_data(self, **kwargs):
backup = freezer_api.Backup(self.request).get(kwargs['backup_id'],
... | def get_initial(self): |
Given snippet: <|code_start|> )
@shield("Unable to delete session", redirect="sessions:index")
def delete(self, request, session_id):
return freezer_api.Session(request).delete(session_id)
class EditSession(tables.LinkAction):
name = "edit_session"
verbose_name = _("Edit Session")
... | u"Delete Jobs", |
Predict the next line after this snippet: <|code_start|># (c) Copyright 2014,2015 Hewlett-Packard Development Company, L.P.
#
# 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.a... | ] |
Continue the code snippet: <|code_start|>
class Restore(tables.LinkAction):
name = "restore"
verbose_name = _("Restore")
classes = ("ajax-modal", "btn-launch")
ajax = True
def get_link_url(self, datum=None):
return reverse("horizon:disaster_recovery:backups:restore",
... | count |
Given the code snippet: <|code_start|>
class Restore(tables.LinkAction):
name = "restore"
verbose_name = _("Restore")
classes = ("ajax-modal", "btn-launch")
ajax = True
def get_link_url(self, datum=None):
return reverse("horizon:disaster_recovery:backups:restore",
k... | count |
Predict the next line after this snippet: <|code_start|>
class ObjectFilterAction(tables.FilterAction):
def allowed(self, request, datum):
return bool(self.table.kwargs['job_id'])
class AttachJobToSession(tables.LinkAction):
name = "attach_job_to_session"
verbose_name = _("Attach To Session")
... | ) |
Given the following code snippet before the placeholder: <|code_start|> @shield("Unable to get actions for this job.", redirect='jobs:index')
def get_actions_in_job_data(self):
if self.kwargs['job_id']:
return freezer_api.Job(self.request).actions(self.kwargs['job_id'])
return []
cl... | class EditJobWorkflowView(workflows.WorkflowView): |
Based on the snippet: <|code_start|>
@shield("Unable to get job", redirect="jobs:index")
def get_initial(self):
initial = super(EditJobWorkflowView, self).get_initial()
if self.is_update():
initial.update({'job_id': None})
job = freezer_api.Job(self.request).get(self.kwar... | return initial |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.