Instruction stringlengths 362 7.83k | output_code stringlengths 1 945 |
|---|---|
Predict the next line for this snippet: <|code_start|>"""
.. module:: logger
:synopsis: Output which sends events to the standard logging output
.. moduleauthor:: Colin Alston <colin@imcol.in>
"""
<|code_end|>
with the help of current file imports:
from twisted.python import log
from duct.objects import Output... | class Logger(Output): |
Given the code snippet: <|code_start|>
class Options(usage.Options):
optParameters = [
["config", "c", "duct.yml", "Config file"],
]
@implementer(IServiceMaker, IPlugin)
class DuctServiceMaker(object):
tapname = "duct"
description = "A monitoring and data-moving-around-places agent"
... | return duct.makeService(ConfigFile(options['config'])) |
Given the following code snippet before the placeholder: <|code_start|>"""
.. module:: bosun
:synopsis: Bosun output
.. moduleauthor:: Colin Alston <colin@imcol.in>
"""
<|code_end|>
, predict the next line using imports from the current file:
import json
import base64
from twisted.internet import defer
from d... | class Bosun(opentsdb.OpenTSDB): |
Given the following code snippet before the placeholder: <|code_start|> :type maxsize: int.
:param maxrate: Maximum rate of documents added to index (default: 100)
:type maxrate: int.
:param interval: Queue check interval in seconds (default: 1.0)
:type interval: int.
:param user: Optional basic ... | return HTTPRequest().getBody(self.url + path, 'POST', headers=headers, |
Next line prediction: <|code_start|>"""
.. module:: null
:synopsis: Null event output. Does nothing
.. moduleauthor:: Colin Alston <colin@imcol.in>
"""
<|code_end|>
. Use current file imports:
(from duct.objects import Output)
and context including class names, function names, or small code snippets from other ... | class Null(Output): |
Here is a snippet: <|code_start|> return lambda events: caller(self, events)
def start(self):
"""Called when source is started
"""
pass
@defer.inlineCallbacks
def startTimer(self):
"""Starts the timer for this source"""
yield defer.maybeDeferred(self.start)
... | def fork(self, *a, **kw): |
Using the snippet: <|code_start|> """Receives a list of events and queues them
Arguments:
events -- list of `duct.objects.Event`
"""
# Make sure queue isn't oversized
if self.maxsize > 0:
if (self.maxsize < 1) or (len(self.events) < self.maxsize):
... | ssh = False |
Predict the next line for this snippet: <|code_start|>
class TestLogs(unittest.TestCase):
def test_logfollow(self):
try:
os.unlink('test.log.lf')
os.unlink('test.log')
except:
pass
log = open('test.log', 'wt')
log.write('foo\nbar\n')
... | f = follower.LogFollower('test.log', tmp_path=".", history=True) |
Given the code snippet: <|code_start|> self.assertEqual(r2, [])
self.assertEqual(r3[0], 'testing')
log.close()
# Move inode
os.rename('test.log', 'testold.log')
log = open('test.log', 'wt')
log.write('foo2\nbar2\n')
log.close()
r = f.get()
... | log = parsers.ApacheLogParser('combined') |
Using the snippet: <|code_start|> pbevent.metric_d = float(event.metric)
pbevent.metric_f = float(event.metric)
if event.attributes is not None:
for key, value in event.attributes.items():
attribute = pbevent.attributes.add()
attribute.... | @implementer(IDuctProtocol) |
Using the snippet: <|code_start|>"""
.. module:: opentsdb
:synopsis: OpenTSDB output
.. moduleauthor:: Colin Alston <colin@imcol.in>
"""
<|code_end|>
, determine the next line of code. You have imports:
from twisted.internet import defer, task
from twisted.python import log
from duct.objects import Output
from ... | class OpenTSDB(Output): |
Based on the snippet: <|code_start|> :param password: Optional basic auth password
:type password: str
:param debug: Log tracebacks from OpenTSDB
:type debug: str
"""
def __init__(self, *a):
Output.__init__(self, *a)
self.events = []
self.timer = task.LoopingCall(self.tick... | self.client = OpenTSDBClient(self.url, self.user, self.password) |
Predict the next line after this snippet: <|code_start|>
self.decode_samples(u)
# Sort samples by sequence number
self.samples.sort(key=lambda x: x.sequence)
def decode_samples(self, u):
"""Decode samples received
"""
for _i in range(self.sample_count):
... | self.flows = {} |
Predict the next line for this snippet: <|code_start|> self.dropped_packets = u.unpack_uint()
self.if_inIndex = u.unpack_uint()
self.if_outIndex = u.unpack_uint()
self.record_count = u.unpack_uint()
self.flows = {}
for _i in range(self.record_count):
flow_f... | self.counters = {} |
Predict the next line after this snippet: <|code_start|>"""
.. module:: server
:synopsis: SFlow UDP server
.. moduleauthor:: Colin Alston <colin@imcol.in>
"""
class DatagramReceiver(DatagramProtocol):
"""DatagramReceiver for sFlow packets
"""
def datagramReceived(self, data, address):
host, _... | sflow = protocol.Sflow(data, host) |
Using the snippet: <|code_start|>"""
.. module:: server
:synopsis: SFlow UDP server
.. moduleauthor:: Colin Alston <colin@imcol.in>
"""
class DatagramReceiver(DatagramProtocol):
"""DatagramReceiver for sFlow packets
"""
def datagramReceived(self, data, address):
host, _port = address
... | for v in flow.flows.values(): |
Using the snippet: <|code_start|>.. moduleauthor:: Colin Alston <colin@imcol.in>
"""
class DatagramReceiver(DatagramProtocol):
"""DatagramReceiver for sFlow packets
"""
def datagramReceived(self, data, address):
host, _port = address
sflow = protocol.Sflow(data, host)
for sample ... | for v in counter.counters.values(): |
Continue the code snippet: <|code_start|>"""
.. module:: elasticsearch
:synopsis: Elasticsearch protocol module
.. moduleauthor:: Colin Alston <colin@imcol.in>
"""
class ElasticSearch(object):
"""Twisted ElasticSearch API
"""
def __init__(self, url='http://localhost:9200', user=None, password=None,
... | return utils.HTTPRequest().getJson( |
Using the snippet: <|code_start|>
self.inter = float(self.config.get('interval', 1.0)) # tick interval
self.pressure = int(self.config.get('pressure', -1))
self.maxsize = int(self.config.get('maxsize', 250000))
self.expire = self.config.get('expire', False)
self.allow_nan = self... | self.factory = riemann.RiemannClientFactory(server, failover=failover) |
Based on the snippet: <|code_start|> :synopsis: Riemann output
.. moduleauthor:: Colin Alston <colin@imcol.in>
"""
# pylint: disable=C0412
try:
except:
SSL = None
if SSL:
class ClientTLSContext(ssl.ClientContextFactory):
"""SSL Context factory
"""
def __init__(self, key, cert):
... | class RiemannTCP(Output): |
Using the snippet: <|code_start|>COtzWOQ1H0ii478rbQAxwsOEMdR5lxEFOo8mC0p4mnWJti2DzJQorQC/fjbRRv7z
vfJamXvfEuHj3NPP9cumrskBtD+kRz/c2zgVJ8vwRgNPazdfJqGYjmFB0loVVyuu
x+hBHOD5zyMPFrJW9MNDTiTEaQREaje5tUOfNoA1Wa4s2bVLnhHCXdMSWmiDmJQp
HEYAIZI2OJhMe8V431t6dBx+nutApzParWqET5D0DWvlurDWFrHMnazh164RqsGu
E4Dg6ZsRnI+PEJmroia6gYEscUf... | s = basic.LoadAverage({ |
Predict the next line after this snippet: <|code_start|> :type index: str
"""
def __init__(self, *a):
Output.__init__(self, *a)
self.events = []
self.timer = task.LoopingCall(self.tick)
self.inter = float(self.config.get('interval', 1.0)) # tick interval
self.maxsize... | self.client = elasticsearch.ElasticSearch(self.url, self.user, |
Predict the next line for this snippet: <|code_start|>"""
.. module:: elasticsearch
:synopsis: Elasticsearch event output
.. moduleauthor:: Colin Alston <colin@imcol.in>
"""
<|code_end|>
with the help of current file imports:
import datetime
from twisted.internet import defer, task
from twisted.python import... | class ElasticSearch(Output): |
Here is a snippet: <|code_start|> IATP=0x75,
STP=0x76,
SRP=0x77,
UTI=0x78,
SMP=0x79,
SM=0x7A,
PTP=0x7B,
ISIS=0x7C,
... | self.ip.src = utils.IPv4Address(self.ip.src) |
Based on the snippet: <|code_start|>"""
.. module:: opentsdb
:synopsis: OpenTSDB protocol module
.. moduleauthor:: Colin Alston <colin@imcol.in>
"""
class OpenTSDBClient(object):
"""Twisted ElasticSearch API
"""
def __init__(self, url='http://localhost:4242', user=None, password=None):
self.u... | return utils.HTTPRequest().getJson( |
Given the code snippet: <|code_start|>fn = "benchmark_{0}".format(sys.platform)
if args.grad:
fn += "_grad"
elif args.george:
fn += "_george"
elif args.carma:
fn += "_carma"
fn += ".csv"
fn = os.path.join(args.outdir, fn)
print("filename: {0}".format(fn))
with open(fn, "w") as f:
f.write(header)
print(... | kernel = terms.RealTerm(1.0, 0.1) |
Continue the code snippet: <|code_start|># -*- coding: utf-8 -*-
from __future__ import division, print_function
__all__ = ["test_product", "test_jacobian"]
def test_product(seed=42):
np.random.seed(seed)
t = np.sort(np.random.uniform(0, 5, 100))
tau = t[:, None] - t[None, :]
<|code_end|>
. Use curren... | k1 = terms.RealTerm(log_a=0.1, log_c=0.5) |
Using the snippet: <|code_start|>
class TestLights(TestCore):
def setUp(self):
super().setUp()
[self.pyrep.step() for _ in range(10)]
<|code_end|>
, determine the next line of code. You have imports:
import unittest
import numpy as np
from tests.core import TestCore
from pyrep.objects.light impor... | self.spot_light = Light('spot_light') |
Given snippet: <|code_start|>
class Camera(Object):
"""Cameras can be associated with views.
"""
def __init__(self, name_or_handle: Union[str, int]):
super().__init__(name_or_handle)
@staticmethod
def create():
raise NotImplementedError("API does not provide simCreateCamera.")... | object_type_to_class[ObjectType.CAMERA] = Camera |
Given snippet: <|code_start|>
class Camera(Object):
"""Cameras can be associated with views.
"""
def __init__(self, name_or_handle: Union[str, int]):
super().__init__(name_or_handle)
@staticmethod
def create():
raise NotImplementedError("API does not provide simCreateCamera.")... | def _get_requested_type(self) -> ObjectType: |
Continue the code snippet: <|code_start|>
class TestGyroscope(TestCore):
def setUp(self):
super().setUp()
<|code_end|>
. Use current file imports:
import unittest
from tests.core import TestCore
from pyrep.sensors.gyroscope import Gyroscope
and context (classes, functions, or code) from other files:
# ... | self.sensor = Gyroscope('gyroscope') |
Next line prediction: <|code_start|>
class TestForceSensors(TestCore):
def setUp(self):
super().setUp()
<|code_end|>
. Use current file imports:
(import unittest
from tests.core import TestCore
from pyrep.objects.force_sensor import ForceSensor)
and context including class names, function names, or smal... | self.sensor = ForceSensor('force_sensor') |
Based on the snippet: <|code_start|> # with self.assertRaises(PyRepError):
# d.read()
class TestSignal(TestCore):
SIGNALS = [
(IntegerSignal, 99),
(FloatSignal, 55.3),
(DoubleSignal, 22.2),
(StringSignal, 'hello')
]
def test_set_get_clear_signals(self):... | with self.assertRaises(PyRepError): |
Predict the next line after this snippet: <|code_start|>
# TODO: These tests will be re-enabled once bug has been fixed in CoppeliaSim.
class TestMisc(TestCore):
pass
# def test_get_distance(self):
# Distance('dist_cubes')
# def test_read_distance(self):
# d = Distance('dist_cubes')
... | (IntegerSignal, 99), |
Here is a snippet: <|code_start|>
# TODO: These tests will be re-enabled once bug has been fixed in CoppeliaSim.
class TestMisc(TestCore):
pass
# def test_get_distance(self):
# Distance('dist_cubes')
# def test_read_distance(self):
# d = Distance('dist_cubes')
# dist = d.read()
... | (FloatSignal, 55.3), |
Predict the next line for this snippet: <|code_start|>
# TODO: These tests will be re-enabled once bug has been fixed in CoppeliaSim.
class TestMisc(TestCore):
pass
# def test_get_distance(self):
# Distance('dist_cubes')
# def test_read_distance(self):
# d = Distance('dist_cubes')
... | (DoubleSignal, 22.2), |
Given the code snippet: <|code_start|>
# TODO: These tests will be re-enabled once bug has been fixed in CoppeliaSim.
class TestMisc(TestCore):
pass
# def test_get_distance(self):
# Distance('dist_cubes')
# def test_read_distance(self):
# d = Distance('dist_cubes')
# dist = d.read... | (StringSignal, 'hello') |
Given snippet: <|code_start|>
# Pick one arm to test all of the joint group functionality.
# Simply checks for wiring mistakes between the joints.
class TestJointGroups(TestCore):
def setUp(self):
super().setUp()
self.robot = Panda()
self.num_joints = len(self.robot.joints)
def test_g... | [JointType.REVOLUTE] * self.num_joints) |
Here is a snippet: <|code_start|>
# Pick one arm to test all of the joint group functionality.
# Simply checks for wiring mistakes between the joints.
class TestJointGroups(TestCore):
def setUp(self):
super().setUp()
<|code_end|>
. Write the next line using the current file imports:
import unittest
impor... | self.robot = Panda() |
Given the following code snippet before the placeholder: <|code_start|>
class TestAccelerometer(TestCore):
def setUp(self):
super().setUp()
<|code_end|>
, predict the next line using imports from the current file:
import unittest
from tests.core import TestCore
from pyrep.sensors.accelerometer import Acc... | self.sensor = Accelerometer('accelerometer') |
Given the following code snippet before the placeholder: <|code_start|>
class TestCartesianPaths(TestCore):
def setUp(self):
super().setUp()
<|code_end|>
, predict the next line using imports from the current file:
import unittest
from tests.core import TestCore
from pyrep.objects.cartesian_path import C... | self.cart_path = CartesianPath('cartesian_path') |
Here is a snippet: <|code_start|>'''
Copyright 2013 Sven Reissmann <sven@0x80.io>
This file is part of ddserver.
ddserver is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as
published by the Free Software Foundation, either version 3 of the
License, o... | @require(web = 'ddserver.web:Web') |
Based on the snippet: <|code_start|> 'value']
def __init__(self, name, value):
self.name = name
self.value = value
def __str__(self):
if self.value:
return '%s %s' % (self.name, self.value)
else:
return '%s' % self.name
__repr__ = __str__
# Existing response codes... | @require(logger='ddserver.utils.logger:Logger', |
Predict the next line after this snippet: <|code_start|>'''
Copyright 2013 Dustin Frisch <fooker@lab.sh>
This file is part of ddserver.
ddserver is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as
published by the Free Software Foundation, either vers... | @export() |
Predict the next line for this snippet: <|code_start|> *args,
**kwargs):
if (bottle.request.query.username == "" or
bottle.request.query.authcode == ""):
messages.error('You have to provide username and authcode.')
bottle.redirect('/')
username = bott... | @extend('ddserver.interface.template:TemplateManager') |
Given the code snippet: <|code_start|>published by the Free Software Foundation, either version 3 of the
License, or (at your option) any later version.
ddserver is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR... | @require(db = 'ddserver.db:Database') |
Predict the next line after this snippet: <|code_start|>'''
Copyright 2013 Sven Reissmann <sven@0x80.io>
This file is part of ddserver.
ddserver is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as
published by the Free Software Foundation, either vers... | @require(db = 'ddserver.db:Database', |
Based on the snippet: <|code_start|>'''
Copyright 2013 Sven Reissmann <sven@0x80.io>
This file is part of ddserver.
ddserver is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as
published by the Free Software Foundation, either version 3 of the
License... | @authorized_admin() |
Next line prediction: <|code_start|>'''
Copyright 2013 Sven Reissmann <sven@0x80.io>
This file is part of ddserver.
ddserver is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as
published by the Free Software Foundation, either version 3 of the
License... | @require(db = 'ddserver.db:Database', |
Given the code snippet: <|code_start|>'''
Copyright 2013 Sven Reissmann <sven@0x80.io>
This file is part of ddserver.
ddserver is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as
published by the Free Software Foundation, either version 3 of the
Licen... | @authorized() |
Given the following code snippet before the placeholder: <|code_start|>'''
Copyright 2013 Dustin Frisch <fooker@lab.sh>
This file is part of ddserver.
ddserver is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as
published by the Free Software Foundati... | @export() |
Based on the snippet: <|code_start|>it under the terms of the GNU Affero General Public License as
published by the Free Software Foundation, either version 3 of the
License, or (at your option) any later version.
ddserver is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the im... | @require(session = 'ddserver.interface.session:SessionManager') |
Here is a snippet: <|code_start|> if not session.messages:
session.messages = []
session.messages.append(self.Message(level = level,
message = message))
session.save()
def success(self, message):
self.__push(self.Level.success, message)
def error(se... | @extend('ddserver.interface.template:TemplateManager') |
Using the snippet: <|code_start|>'''
Copyright 2013 Dustin Frisch<fooker@lab.sh>
This file is part of ddserver.
ddserver is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as
published by the Free Software Foundation, either version 3 of the
License, or... | @require(web = 'ddserver.web:Web') |
Here is a snippet: <|code_start|> ''' Provides a route to static files (like css, images, etc). '''
return bottle.static_file(path,
root = config.wsgi.static_files)
@route('/', method = 'GET')
@require(db = 'ddserver.db:Database',
templates = 'ddserver.interface.template:Temp... | @authorized() |
Continue the code snippet: <|code_start|>it under the terms of the GNU Affero General Public License as
published by the Free Software Foundation, either version 3 of the
License, or (at your option) any later version.
ddserver is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even t... | @require(config = 'ddserver.config:Config') |
Here is a snippet: <|code_start|>'''
Copyright 2013 Sven Reissmann <sven@0x80.io>
This file is part of ddserver.
ddserver is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as
published by the Free Software Foundation, either version 3 of the
License, o... | @extend('ddserver.config:ConfigDeclaration') |
Given the following code snippet before the placeholder: <|code_start|>'''
Copyright 2013 Dustin Frisch<fooker@lab.sh>
This file is part of ddserver.
ddserver is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as
published by the Free Software Foundatio... | @extend('ddserver.config:ConfigDeclaration') |
Continue the code snippet: <|code_start|>
You should have received a copy of the GNU Affero General Public License
along with ddserver. If not, see <http://www.gnu.org/licenses/>.
'''
@extend('ddserver.config:ConfigDeclaration')
def config_db(config_decl):
with config_decl.declare('db') as s:
s('host',
... | @export() |
Predict the next line for this snippet: <|code_start|>
@extend('ddserver.config:ConfigDeclaration')
def config_db(config_decl):
with config_decl.declare('db') as s:
s('host',
conv = str,
default = 'localhost')
s('port',
conv = int,
default = 3306)
s('name',
conv = str,
... | @require(config = 'ddserver.config:Config') |
Using the snippet: <|code_start|>'''
Copyright 2013 Sven Reissmann <sven@0x80.io>
This file is part of ddserver.
ddserver is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as
published by the Free Software Foundation, either version 3 of the
License, o... | @require(users = 'ddserver.interface.user:UserManager') |
Based on the snippet: <|code_start|>'''
Copyright 2013 Sven Reissmann <sven@0x80.io>
This file is part of ddserver.
ddserver is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as
published by the Free Software Foundation, either version 3 of the
License... | @require(config = 'ddserver.config:Config', |
Using the snippet: <|code_start|> users,
emails,
messages):
# Generate a authcode for the user
users.generate_authcode(data.username)
# Fetch user info
user = users[data.username]
emails.to_user('lostpasswd.mail',
user = user)
messages... | @authorized_by_code() |
Based on the snippet: <|code_start|>License, or (at your option) any later version.
ddserver is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.... | @captcha_check('/lostpass') |
Next line prediction: <|code_start|>'''
Copyright 2013 Dustin Frisch <fooker@lab.sh>
This file is part of ddserver.
ddserver is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as
published by the Free Software Foundation, either version 3 of the
License... | @export() |
Continue the code snippet: <|code_start|>
@extend('ddserver.config:ConfigDeclaration')
def config_email(config_decl):
with config_decl.declare('smtp') as s:
s('host',
conv = str,
default = 'localhost')
s('port',
conv = int,
default = 25)
with config_decl.declare('contact') as s:
... | @export() |
Continue the code snippet: <|code_start|>'''
Copyright 2013 Sven Reissmann <sven@0x80.io>
This file is part of ddserver.
ddserver is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as
published by the Free Software Foundation, either version 3 of the
Li... | @extend('ddserver.config:ConfigDeclaration') |
Based on the snippet: <|code_start|> s('port',
conv = int,
default = 25)
with config_decl.declare('contact') as s:
s('name',
conv = str,
default = 'Your Administrator')
s('email',
conv = str)
with config_decl.declare('wsgi') as s:
s('protocol',
conv = str,
... | @require(config = 'ddserver.config:Config', |
Continue the code snippet: <|code_start|>'''
Copyright 2013 Sven Reissmann <sven@0x80.io>
This file is part of ddserver.
ddserver is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as
published by the Free Software Foundation, either version 3 of the
Li... | @extend('ddserver.config:ConfigDeclaration') |
Given the code snippet: <|code_start|>License, or (at your option) any later version.
ddserver is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more detail... | @require(template = 'ddserver.interface.template:TemplateManager') |
Predict the next line after this snippet: <|code_start|>published by the Free Software Foundation, either version 3 of the
License, or (at your option) any later version.
ddserver is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNES... | @authorized() |
Based on the snippet: <|code_start|>'''
Copyright 2013 Sven Reissmann <sven@0x80.io>
This file is part of ddserver.
ddserver is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as
published by the Free Software Foundation, either version 3 of the
License... | @require(db = 'ddserver.db:Database', |
Predict the next line for this snippet: <|code_start|>'''
Copyright 2013 Sven Reissmann <sven@0x80.io>
This file is part of ddserver.
ddserver is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as
published by the Free Software Foundation, either versio... | @authorized_admin() |
Given snippet: <|code_start|>'''
Copyright 2013 Dustin Frisch <fooker@lab.sh>
This file is part of ddserver.
ddserver is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as
published by the Free Software Foundation, either version 3 of the
License, or (a... | @extend('ddserver.config:ConfigDeclaration') |
Using the snippet: <|code_start|>
@extend('ddserver.config:ConfigDeclaration')
def config_captcha(config_decl):
with config_decl.declare('captcha') as s:
s('enabled',
conv = bool,
default = False)
s('recaptcha_public_key',
conv = str,
default = '')
s('recaptcha_private_key',
... | @require(config = 'ddserver.config:Config', |
Based on the snippet: <|code_start|>"""
Copyright 2013 Dustin Frisch<fooker@lab.sh>
This file is part of ddserver.
ddserver is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as
published by the Free Software Foundation, either version 3 of the
License,... | @require(web='ddserver.web:Web') |
Given snippet: <|code_start|>Copyright 2013 Sven Reissmann <sven@0x80.io>
This file is part of ddserver.
ddserver is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as
published by the Free Software Foundation, either version 3 of the
License, or (at yo... | @export() |
Given the following code snippet before the placeholder: <|code_start|>'''
Copyright 2013 Sven Reissmann <sven@0x80.io>
This file is part of ddserver.
ddserver is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as
published by the Free Software Foundati... | @extend('ddserver.web:Middleware') |
Based on the snippet: <|code_start|>
@property
def session(self):
return bottle.request.environ.get('beaker.session')
def __getattr__(self, key):
try:
return self.session[key]
except KeyError:
return None
def __setattr__(self, key, value):
self.session[key] = value
def __de... | @require(session = 'ddserver.interface.session:SessionManager') |
Given the code snippet: <|code_start|>'''
Copyright 2013 Dustin Frisch <fooker@lab.sh>
This file is part of ddserver.
ddserver is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as
published by the Free Software Foundation, either version 3 of the
Licen... | @export() |
Predict the next line after this snippet: <|code_start|>
def __getitem__(self, key):
''' Returns a template render function for the requested template.
@param key: the name of the template
'''
# Generate the globals and get the template from the environment
template = self.__environment.get... | @extend('ddserver.interface.template:TemplateManager') |
Given the code snippet: <|code_start|> def __getitem__(self, key):
''' Returns a template render function for the requested template.
@param key: the name of the template
'''
# Generate the globals and get the template from the environment
template = self.__environment.get_template(key)
... | @require(config = 'ddserver.config:Config') |
Predict the next line after this snippet: <|code_start|>'''
Copyright 2013 Dustin Frisch<fooker@lab.sh>
This file is part of ddserver.
ddserver is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of... | @extend('ddserver.config:ConfigDeclaration') |
Using the snippet: <|code_start|>
ddserver is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
ddserver is distributed in the hope that it will ... | @export(config = 'ddserver.config:Config') |
Based on the snippet: <|code_start|>
You should have received a copy of the GNU Affero General Public License
along with ddserver. If not, see <http://www.gnu.org/licenses/>.
"""
# See http://doc.powerdns.com/html/backends-detail.html#pipebackend
# for further protocol specification
# Declaration of the PowerDNS ... | formatter = FormatterDeclaration(splitter='\t', |
Given the code snippet: <|code_start|>
You should have received a copy of the GNU Affero General Public License
along with ddserver. If not, see <http://www.gnu.org/licenses/>.
'''
@extend('ddserver.config:ConfigDeclaration')
def config_signup(config_decl):
with config_decl.declare('signup') as s:
s('en... | @require(config = 'ddserver.config:Config', |
Based on the snippet: <|code_start|>'''
Copyright 2013 Sven Reissmann <sven@0x80.io>
This file is part of ddserver.
ddserver is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as
published by the Free Software Foundation, either version 3 of the
License... | @extend('ddserver.config:ConfigDeclaration') |
Given the following code snippet before the placeholder: <|code_start|> # Get user record
user = users[data.username]
messages.success('Your account has been created and will be reviewed by an administrator.')
# Notify the admin about the new account
if config.signup.notify_admin:
try:
emails... | @authorized_by_code() |
Given the code snippet: <|code_start|> conv = bool,
default = True)
@route('/signup', method = 'GET')
@require(config = 'ddserver.config:Config',
templates = 'ddserver.interface.template:TemplateManager',
messages = 'ddserver.interface.message:MessageManager',
session = 'ddserve... | @captcha_check('/signup') |
Next line prediction: <|code_start|> exposure_structure,
exposure_population,
exposure_road,
]
for layer_path, expected_definition in zip(
layer_paths, expected_definitions):
path = standard_data_path(*layer_path)
layer, _ = load... | generic_hazard_classes, |
Predict the next line for this snippet: <|code_start|> exposure_population,
exposure_road,
]
for layer_path, expected_definition in zip(
layer_paths, expected_definitions):
path = standard_data_path(*layer_path)
layer, _ = load_layer(path)
... | earthquake_mmi_scale, |
Predict the next line after this snippet: <|code_start|> exposure_road,
]
for layer_path, expected_definition in zip(
layer_paths, expected_definitions):
path = standard_data_path(*layer_path)
layer, _ = load_layer(path)
actual_definition = ... | tsunami_hazard_classes, |
Next line prediction: <|code_start|> ]
for layer_path, expected_definition in zip(
layer_paths, expected_definitions):
path = standard_data_path(*layer_path)
layer, _ = load_layer(path)
actual_definition = layer_definition_type(layer)
try:
... | cyclone_au_bom_hazard_classes, |
Next line prediction: <|code_start|> self.layer_paths_list = [
['gisv4', 'hazard', 'classified_vector.geojson'],
['gisv4', 'hazard', 'earthquake.asc'],
['gisv4', 'hazard', 'tsunami_vector.geojson'],
['gisv4', 'hazard', 'cyclone_AUBOM_km_h.asc'],
['gisv4... | layer, _ = load_layer(path) |
Given snippet: <|code_start|># coding=utf-8
"""Definitions relating to pre-processing."""
__copyright__ = "Copyright 2017, The InaSAFE Project"
__license__ = "GPL version 3"
__email__ = "info@inasafe.org"
__revision__ = '$Format:%H$'
LOGGER = logging.getLogger('InaSAFE')
def check_nearby_preprocessor(impact_func... | exposure_key = layer_purpose_exposure['key'] |
Given snippet: <|code_start|># coding=utf-8
"""Definitions relating to pre-processing."""
__copyright__ = "Copyright 2017, The InaSAFE Project"
__license__ = "GPL version 3"
__email__ = "info@inasafe.org"
__revision__ = '$Format:%H$'
LOGGER = logging.getLogger('InaSAFE')
def check_nearby_preprocessor(impact_func... | hazard_key = layer_purpose_hazard['key'] |
Given snippet: <|code_start|> """Fake nearby preprocessor.
We can put here the function to generate contours or nearby places.
It must return a layer with a specific layer_purpose.
:return: The output layer.
:rtype: QgsMapLayer
"""
_ = impact_function # NOQA
fake_layer = load_test_vec... | 'value': layer_purpose_nearby_places, |
Here is a snippet: <|code_start|>def fake_nearby_preprocessor(impact_function):
"""Fake nearby preprocessor.
We can put here the function to generate contours or nearby places.
It must return a layer with a specific layer_purpose.
:return: The output layer.
:rtype: QgsMapLayer
"""
_ = imp... | 'key': layer_purpose, |
Predict the next line for this snippet: <|code_start|>
def earthquake_contour_preprocessor(impact_function):
"""Preprocessor to create contour from an earthquake
:param impact_function: Impact function to run.
:type impact_function: ImpactFunction
:return: The contour layer.
:rtype: QgsMapLayer
... | 'value': layer_purpose_earthquake_contour, |
Given the following code snippet before the placeholder: <|code_start|> description = """
<table border="0" width="100%%">
<tr><td><b>%s</b>: </td><td>%s</td></tr>
<tr><td><b>%s</b>: </td><td>%s</td></tr>
%s
%s
<tr><td><b>%s</b>: </td><td>%s... | geom_type = layer_geometry_line['key'] |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.