Instruction stringlengths 362 7.83k | output_code stringlengths 1 945 |
|---|---|
Based on the snippet: <|code_start|>from __future__ import with_statement
config = context.config
config.set_main_option('sqlalchemy.url', app.config['SQLALCHEMY_DATABASE_URI'])
target_metadata = db.metadata
def run_migrations_offline():
url = config.get_main_option("sqlalchemy.url")
context.configure(url=u... | prefix='sqlalchemy.', |
Predict the next line after this snippet: <|code_start|>
def authz_collections(action):
if action == 'read' and request.authz_lists.get('read') is None:
request.authz_lists['read'] = Collection.user_ids(current_user)
if action == 'write' and request.authz_lists.get('write') is None:
request.au... | def collection_read(id): |
Given the code snippet: <|code_start|>def index():
q = Collection.all_by_user(current_user)
data = Pager(q).to_dict()
results = []
for lst in data.pop('results'):
ldata = lst.to_dict()
ldata['permissions'] = {
'write': authz.collection_write(lst.id)
}
results.... | return jsonify(data) |
Predict the next line after this snippet: <|code_start|>
blueprint = Blueprint('collections', __name__)
@blueprint.route('/api/1/collections', methods=['GET'])
def index():
q = Collection.all_by_user(current_user)
data = Pager(q).to_dict()
results = []
for lst in data.pop('results'):
ldata = ... | ldata['permissions'] = { |
Given the code snippet: <|code_start|>
blueprint = Blueprint('collections', __name__)
@blueprint.route('/api/1/collections', methods=['GET'])
def index():
q = Collection.all_by_user(current_user)
data = Pager(q).to_dict()
results = []
for lst in data.pop('results'):
ldata = lst.to_dict()
... | results.append(ldata) |
Next line prediction: <|code_start|>
log = logging.getLogger(__name__)
class Selector(db.Model):
id = db.Column(db.Integer, primary_key=True)
_text = db.Column('text', db.Unicode, index=True)
normalized = db.Column(db.Unicode, index=True)
created_at = db.Column(db.DateTime, default=datetime.utcnow)... | def text(self): |
Given the following code snippet before the placeholder: <|code_start|> }
@classmethod
def create(cls, data, user):
lst = cls()
lst.update(data, user)
lst.owner = user
db.session.add(lst)
return lst
def update(self, data, user):
data = CollectionForm(... | return q.first() |
Predict the next line after this snippet: <|code_start|> 'id': self.id,
'api_url': url_for('collections.view', id=self.id),
'entities_api_url': url_for('entities.index', list=self.id),
'slug': self.slug,
'public': self.public,
'owner': self.owner,
... | def by_slug(cls, login, slug): |
Using the snippet: <|code_start|> self.slug = data.get('slug')
if data.get('public') is not None:
self.public = data.get('public')
def delete(self):
# for entity in self.entities:
# entity.delete()
db.session.delete(self)
@classmethod
def by_slug(cls,... | return [] |
Using the snippet: <|code_start|>
log = logging.getLogger(__name__)
class Collection(db.Model):
id = db.Column(db.Unicode(50), primary_key=True)
slug = db.Column(db.Unicode(250))
public = db.Column(db.Boolean, default=False)
owner_id = db.Column(db.Integer(), db.ForeignKey('user.id'),
... | } |
Here is a snippet: <|code_start|> login = db.Column(db.Unicode(255))
email = db.Column(db.Unicode, nullable=True)
oauth_id = db.Column(db.Unicode)
api_key = db.Column(db.Unicode, default=make_token)
is_admin = db.Column(db.Boolean, nullable=False, default=False)
created_at = db.Column(db.DateTi... | return { |
Given the code snippet: <|code_start|>
def to_dict(self):
return {
'id': self.id,
'login': self.login,
'is_admin': self.is_admin,
'created_at': self.created_at,
'updated_at': self.updated_at,
'api_url': url_for('users.view', login=self.... | @classmethod |
Given the following code snippet before the placeholder: <|code_start|> def is_active(self):
return True
def is_authenticated(self):
return True
def is_anonymous(self):
return False
def get_id(self):
return self.login
def __repr__(self):
return '<User(%r,%r... | self.email = data.get('email') |
Given the following code snippet before the placeholder: <|code_start|> def update(self, data):
data = UserForm().deserialize(data)
self.email = data.get('email')
@classmethod
def load(cls, data):
user = cls.by_oauth_id(data.get('oauth_id'))
if user is None:
user... | def by_api_key(cls, api_key): |
Next line prediction: <|code_start|># from kombu import Exchange, Queue
# from celery import Celery
logging.basicConfig(level=logging.DEBUG)
# specific loggers
logging.getLogger('requests').setLevel(logging.WARNING)
logging.getLogger('urllib3').setLevel(logging.WARNING)
<|code_end|>
. Use current file imports:
(imp... | logging.getLogger('amqp').setLevel(logging.INFO) |
Predict the next line after this snippet: <|code_start|>
blueprint = Blueprint('users', __name__)
@blueprint.route('/api/1/users', methods=['GET'])
def index():
authz.require(authz.logged_in())
q = User.all()
return jsonify(Pager(q))
@blueprint.route('/api/1/users/<login>', methods=['GET'])
def view(l... | data = user.to_dict() |
Next line prediction: <|code_start|>
blueprint = Blueprint('users', __name__)
@blueprint.route('/api/1/users', methods=['GET'])
def index():
authz.require(authz.logged_in())
q = User.all()
return jsonify(Pager(q))
@blueprint.route('/api/1/users/<login>', methods=['GET'])
def view(login):
user = ob... | if user.id == current_user.id: |
Next line prediction: <|code_start|>
blueprint = Blueprint('users', __name__)
@blueprint.route('/api/1/users', methods=['GET'])
def index():
authz.require(authz.logged_in())
q = User.all()
return jsonify(Pager(q))
@blueprint.route('/api/1/users/<login>', methods=['GET'])
def view(login):
user = ob... | return view(login) |
Given snippet: <|code_start|>
blueprint = Blueprint('sessions', __name__)
twitter = oauth.remote_app('twitter',
base_url='https://api.twitter.com/1.1/',
request_token_url='https://api.twitter.com/oauth/request_token',
access_token_url=... | @blueprint.route('/api/1/sessions/logout', methods=['POST']) |
Given the following code snippet before the placeholder: <|code_start|>
@blueprint.route('/api/1/sessions/logout', methods=['POST'])
def logout():
logout_user()
return redirect(request.args.get('next_url', url_for('ui')))
@blueprint.route('/api/1/sessions/login')
def login():
if current_user.is_authentic... | } |
Here is a snippet: <|code_start|>
blueprint = Blueprint('sessions', __name__)
twitter = oauth.remote_app('twitter',
base_url='https://api.twitter.com/1.1/',
request_token_url='https://api.twitter.com/oauth/request_token',
access_token_ur... | logout_user() |
Next line prediction: <|code_start|>
blueprint = Blueprint('sessions', __name__)
twitter = oauth.remote_app('twitter',
base_url='https://api.twitter.com/1.1/',
request_token_url='https://api.twitter.com/oauth/request_token',
access_tok... | return session.get('twitter_token') |
Using the snippet: <|code_start|> 'api_key': current_user.api_key if authz.logged_in() else None,
'user': current_user if authz.logged_in() else None,
'logout': url_for('.logout')
})
@blueprint.route('/api/1/sessions/logout', methods=['POST'])
def logout():
logout_user()
return redi... | res = twitter.get('users/show.json?user_id=%s' % resp.get('user_id')) |
Predict the next line for this snippet: <|code_start|> 'logout': url_for('.logout')
})
@blueprint.route('/api/1/sessions/logout', methods=['POST'])
def logout():
logout_user()
return redirect(request.args.get('next_url', url_for('ui')))
@blueprint.route('/api/1/sessions/login')
def login():
i... | 'login': res.data.get('screen_name'), |
Here is a snippet: <|code_start|> self.category = data.get('category')
selectors = set(data.get('selectors'))
selectors.add(self.label)
existing = list(self.selectors)
for sel in list(existing):
if sel.text in selectors:
selectors.remove(sel.text)
... | def by_collections(cls, collections, prefix=None): |
Based on the snippet: <|code_start|># FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
# more details.
#
# You should have received a copy of the GNU General Public License along with
# HyperKitty. If not, see <http://www.gnu.org/licenses/>.
#
# Author: Aurelien Bompard <abompard@fedoraproject... | return matching[0] |
Based on the snippet: <|code_start|>#
# You should have received a copy of the GNU General Public License along with
# HyperKitty. If not, see <http://www.gnu.org/licenses/>.
#
# Author: Aurelien Bompard <abompard@fedoraproject.org>
#
class PostingFailed(Exception):
pass
def post_to_list(request, mlist, sub... | if not request.user.first_name and not request.user.last_name: |
Continue the code snippet: <|code_start|># -*- coding: utf-8 -*-
# Copyright (C) 1998-2012 by the Free Software Foundation, Inc.
#
# This file is part of HyperKitty.
#
# HyperKitty 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
# S... | return redirect(reverse('hk_root')) |
Continue the code snippet: <|code_start|># HyperKitty is distributed in the hope that it will be useful, but WITHOUT
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
# more details.
#
# You should have received a copy of ... | 'year': year, |
Given snippet: <|code_start|># Copyright (C) 1998-2012 by the Free Software Foundation, Inc.
#
# This file is part of HyperKitty.
#
# HyperKitty 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... | return redirect(reverse('hk_list_overview', |
Predict the next line for this snippet: <|code_start|>
from __future__ import absolute_import, print_function
__all__ = ['READABLE', 'WRITABLE']
READABLE = pyuv.UV_READABLE
WRITABLE = pyuv.UV_WRITABLE
if __debug__:
def dump(mp):
print('== Dumping MultiPoll {!r}'.format(mp))
# [total, nreaders... | print('Poll FD: {}'.format(mp._poll.fileno())) |
Next line prediction: <|code_start|>#
# This file is part of Gruvi. Gruvi is free software available under the
# terms of the MIT license. See the file "LICENSE" that was provided
# together with this source file for the licensing terms.
#
# Copyright (c) 2012-2014 the Gruvi authors. See the file "AUTHORS" for a
# comp... | stats[1] += 1 |
Given the code snippet: <|code_start|>#
# This file is part of Gruvi. Gruvi is free software available under the
# terms of the MIT license. See the file "LICENSE" that was provided
# together with this source file for the licensing terms.
#
# Copyright (c) 2012-2014 the Gruvi authors. See the file "AUTHORS" for a
# co... | stats = [0, 0, 0, 0, 0] |
Predict the next line for this snippet: <|code_start|>#
# This file is part of Gruvi. Gruvi is free software available under the
# terms of the MIT license. See the file "LICENSE" that was provided
# together with this source file for the licensing terms.
#
# Copyright (c) 2012-2014 the Gruvi authors. See the file "AUT... | stats[1] += 1 |
Given snippet: <|code_start|>
READABLE = pyuv.UV_READABLE
WRITABLE = pyuv.UV_WRITABLE
if __debug__:
def dump(mp):
print('== Dumping MultiPoll {!r}'.format(mp))
# [total, nreaders, nwriters, nreadwrite, disabled]
stats = [0, 0, 0, 0, 0]
def walker(callback, args):
stat... | print('Callbacks that are inactive: {}'.format(stats[4])) |
Predict the next line for this snippet: <|code_start|>#! -*- coding:utf-8 -*-
class Adres(models.Model):
kullanici = models.ForeignKey(IsVeren,related_name="adres")
adres_basligi = models.CharField(max_length=50)
adres = models.CharField(max_length=80)
sehir = models.CharField(max_length=40)
ilce =... | return self.kullanici.kullanici.username + " " + self.adres_basligi |
Given the code snippet: <|code_start|>
# Register your models here.
admin.site.register(IsArayan)
class IsVerenInline(admin.StackedInline):
model = Adres
<|code_end|>
, generate the next line using the imports in this file:
from django.contrib import admin
from .models import IsArayan,IsVeren
from adres.mode... | class ExtendedVendorAdmin(admin.ModelAdmin): |
Given the following code snippet before the placeholder: <|code_start|>
# Register your models here.
admin.site.register(IsArayan)
class IsVerenInline(admin.StackedInline):
model = Adres
class ExtendedVendorAdmin(admin.ModelAdmin):
<|code_end|>
, predict the next line using imports from the current file:
fro... | inlines = (IsVerenInline,) |
Using the snippet: <|code_start|>
class Ilan(models.Model):
kullanici = models.ForeignKey(IsVeren,related_name="is_veren")
hizmetDescr = models.ForeignKey(HizmetDescription,related_name="hizmet_descr")
hizmet = models.ForeignKey(Hizmet,blank=True,null=True,related_name="hizmet_tipi")
adres = models.Fore... | butceTipleri = ( |
Continue the code snippet: <|code_start|>
sureUzunlugu = models.CharField(max_length=3, choices=sureUzunluklari,default="G")
sure = models.IntegerField()
butceTipi = models.CharField(max_length=3, choices=butceTipleri,default="TL")
butce = models.IntegerField()
yayin_tarihi = models.DateTimeField(au... | ilan.sureUzunlugu = self.sureUzunlugu |
Given snippet: <|code_start|>
class Ilan(models.Model):
kullanici = models.ForeignKey(IsVeren,related_name="is_veren")
hizmetDescr = models.ForeignKey(HizmetDescription,related_name="hizmet_descr")
hizmet = models.ForeignKey(Hizmet,blank=True,null=True,related_name="hizmet_tipi")
adres = models.ForeignK... | sureUzunlugu = models.CharField(max_length=3, choices=sureUzunluklari,default="G") |
Next line prediction: <|code_start|>
class Ilan(models.Model):
kullanici = models.ForeignKey(IsVeren,related_name="is_veren")
hizmetDescr = models.ForeignKey(HizmetDescription,related_name="hizmet_descr")
hizmet = models.ForeignKey(Hizmet,blank=True,null=True,related_name="hizmet_tipi")
adres = models.F... | sure = models.IntegerField() |
Based on the snippet: <|code_start|> cinsiyetSecenekleri = (
('E', 'Erkek'),
('K', 'Kadın'),
)
cinsiyet = models.CharField(max_length=1, choices=cinsiyetSecenekleri,blank=True, null=True)
dogumGunu = models.DateField(blank=True, null=True,default=datetime.date.today)
telefon = models.... | cinsiyet = models.CharField(max_length=1, choices=CinsiyetSecenekleri,blank=True, null=True) |
Predict the next line for this snippet: <|code_start|>
class Teklif(models.Model):
ilan = models.ForeignKey(Ilan,blank=True,null=True,related_name="odeme_ilanı")
teklif_veren = models.OneToOneField(IsArayan,related_name="is_arayan")
butce = models.IntegerField()
sure = models.IntegerField()
ona... | verbose_name_plural="Teklif" |
Predict the next line for this snippet: <|code_start|>
class Teklif(models.Model):
ilan = models.ForeignKey(Ilan,blank=True,null=True,related_name="odeme_ilanı")
teklif_veren = models.OneToOneField(IsArayan,related_name="is_arayan")
<|code_end|>
with the help of current file imports:
from django.db import mod... | butce = models.IntegerField() |
Based on the snippet: <|code_start|>
class Teklif(models.Model):
ilan = models.ForeignKey(Ilan,blank=True,null=True,related_name="odeme_ilanı")
teklif_veren = models.OneToOneField(IsArayan,related_name="is_arayan")
butce = models.IntegerField()
sure = models.IntegerField()
onay_durumu = models.... | def save(self, *args, **kwargs): |
Predict the next line for this snippet: <|code_start|>
class DateTimeParserTest(unittest.TestCase):
@defer.inlineCallbacks
def test_parsing_and_getting_date(self):
processor = datetime_processors.DateTimeParser(format_string='%Y-%m-%dT%H:%M:%S', as_date=True)
result = yield processor.process(... | def test_parse_simple(self): |
Given the code snippet: <|code_start|> def test_replacement_errors(self):
self.assertRaises(ValueError, self.graph.replace_edge_from, 'a', 'b', 'd')
self.graph.add_edge('a', 'b')
self.graph.add_edge('a', 'c')
self.assertRaises(ValueError, self.graph.replace_edge_from, 'a', 'b', 'c')... | def __cmp__(self, other): |
Here is a snippet: <|code_start|># Copyright (c) 2010-2011, Found IT A/S and Piped Project Contributors.
# See LICENSE for details.
class TestPythonLoggingObserver(unittest.TestCase):
def setUp(self):
self.observer = log.PythonLoggingObserver()
def test_system_logger(self):
self.observer.emi... | self.assertIn('twisted', self.observer.loggers) |
Predict the next line after this snippet: <|code_start|>
return items()
# -----------------------------------------------------------
def __init__(self, items=None):
super(Dict, self).__init__(self.to_items(items))
# -----------------------------------------------------------
def __i... | other[key] = value |
Next line prediction: <|code_start|> @classmethod
def __to_items(cls, items_str):
if not is_string(items_str):
return items_str
sep = cls._separator
for s in cls._other_separators:
items_str = items_str.replace(s, sep)
items = []
for v in filter... | super(_SplitDictBase, self).__init__(self.__to_items(items)) |
Given the code snippet: <|code_start|> return FilePathBase(drive)
# -----------------------------------------------------------
def change(self, dirname=None, name=None, ext=None, prefix=None):
self_dirname, self_filename = os.path.split(self)
self_name, self_ext = os.path.splitext(sel... | def __new__(cls, value=None): |
Given the code snippet: <|code_start|>__all__ = (
'FilePath',
'AbsFilePath',
)
# ==============================================================================
if os.path.normcase('ABC') == os.path.normcase('abc'):
FilePathBase = IgnoreCaseString
else:
FilePathBase = String
try:
_splitunc = os.pa... | def __setstate__(self, state): |
Given snippet: <|code_start|> # -----------------------------------------------------------
@staticmethod
def _is_aql_db(filename):
magic_tag = b".AQL.DB."
with open_file(filename, read=True, binary=True) as f:
tag = f.read(len(magic_tag))
return tag == magic_tag
... | except (sqlite3.DataError, sqlite3.IntegrityError): |
Next line prediction: <|code_start|>
if self.data_begin != data_begin:
raise AssertionError("self.data_begin(%s) != data_begin(%s)" %
(self.data_begin, data_begin))
# -----------------------------------------------------------
items = sorted(self.id... | (meta.offset, self.meta_end)) |
Here is a snippet: <|code_start|> # 4 bytes (offset of data area)
_META_TABLE_HEADER_STRUCT = struct.Struct(">L")
_META_TABLE_HEADER_SIZE = _META_TABLE_HEADER_STRUCT.size
_META_TABLE_HEADER_OFFSET = _KEY_OFFSET + _KEY_SIZE
_META_TABLE_OFFSET = _META_TABLE_HEADER_OFFSET + _META_TABLE_HEADER_SIZE
... | self.handle = _IOFile(filename) |
Based on the snippet: <|code_start|>
task_id = task.task_id
if task_id is not None:
task_result = TaskResult(task_id=task_id)
else:
task_result = None
try:
result = task(task_lock)
if task_result is not No... | 'threads', |
Continue the code snippet: <|code_start|> try:
self.remove(value)
except ValueError:
break
return self
# -----------------------------------------------------------
@staticmethod
def __to_list(values):
if isinstance(va... | def __gt__(self, other): |
Based on the snippet: <|code_start|> self.__add_values(values)
return self
# -----------------------------------------------------------
def __add__(self, values):
other = UniqueList(self)
other.__add_values(values)
return other
# -----------------------------------... | def extend(self, values): |
Based on the snippet: <|code_start|> if value in values_set:
values_list.remove(value)
else:
values_set.add(value)
values_list.insert(0, value)
# -----------------------------------------------------------
def __add_value(self, value):
values_set = self... | values_list_append(value) |
Here is a snippet: <|code_start|> def __init__(self):
pass
@staticmethod
def _fix_paths(job):
"""Modelled after hadoop_jar.HadoopJarJobRunner._fix_paths.
"""
tmp_files = []
args = []
for x in job.args():
if isinstance(x, luigi.LocalTarget): # input... | return job.main() |
Next line prediction: <|code_start|>
logging.basicConfig(level=logging.DEBUG)
def local_target_generator(task):
return None
def setUpModule():
global cnf, conf
cnf = get_custom_config()
cnf.clear()
conf = get_config()
conf.clear()
def tearDownModule():
cnf.clear()
conf.clear()
class ... | def test_register_handler(self): |
Given the following code snippet before the placeholder: <|code_start|>
logging.basicConfig(level=logging.DEBUG)
def local_target_generator(task):
return None
def setUpModule():
global cnf, conf
cnf = get_custom_config()
cnf.clear()
conf = get_config()
<|code_end|>
, predict the next line using im... | conf.clear() |
Here is a snippet: <|code_start|>
logging.basicConfig(level=logging.DEBUG)
def local_target_generator(task):
return None
def setUpModule():
global cnf, conf
cnf = get_custom_config()
cnf.clear()
conf = get_config()
conf.clear()
<|code_end|>
. Write the next line using the current file imports... | def tearDownModule(): |
Continue the code snippet: <|code_start|>
logging.basicConfig(level=logging.DEBUG)
def local_target_generator(task):
return None
def setUpModule():
global cnf, conf
cnf = get_custom_config()
cnf.clear()
conf = get_config()
conf.clear()
def tearDownModule():
cnf.clear()
<|code_end|>
. Use ... | conf.clear() |
Next line prediction: <|code_start|>
logging.basicConfig(level=logging.DEBUG)
def local_target_generator(task):
return None
def setUpModule():
global cnf, conf
cnf = get_custom_config()
cnf.clear()
conf = get_config()
conf.clear()
<|code_end|>
. Use current file imports:
(import os
import gl... | def tearDownModule(): |
Continue the code snippet: <|code_start|>class SamtoolsJobTask(JobTask):
"""Main samtools job task"""
executable = luigi.Parameter(default="samtools")
parent_task = luigi.Parameter(default=("ratatosk.lib.tools.samtools.InputSamFile", ), is_list=True)
suffix = luigi.Parameter(default=".bam")
def job... | return self.suffix |
Based on the snippet: <|code_start|> suffix = luigi.Parameter(default=".bam")
def job_runner(self):
return SamtoolsJobRunner()
class SamToBam(SamtoolsJobTask):
sub_executable = "view"
options = luigi.Parameter(default=("-bSh",), is_list=True)
parent_task = luigi.Parameter(default=("ratatosk... | return [self.input()[0], output_prefix] |
Using the snippet: <|code_start|> executable = luigi.Parameter(default="samtools")
parent_task = luigi.Parameter(default=("ratatosk.lib.tools.samtools.InputSamFile", ), is_list=True)
suffix = luigi.Parameter(default=".bam")
def job_runner(self):
return SamtoolsJobRunner()
class SamToBam(Samtool... | def args(self): |
Next line prediction: <|code_start|>class SamtoolsJobTask(JobTask):
"""Main samtools job task"""
executable = luigi.Parameter(default="samtools")
parent_task = luigi.Parameter(default=("ratatosk.lib.tools.samtools.InputSamFile", ), is_list=True)
suffix = luigi.Parameter(default=".bam")
def job_runn... | return self.suffix |
Given the code snippet: <|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 specific language governing permissions and... | arglist += job.opts() |
Continue the code snippet: <|code_start|> output file but rather an output directory"""
def _make_arglist(self, job):
arglist = [job.exe()]
if job.opts():
arglist += job.opts()
(tmp_files, job_args) = DefaultShellJobRunner._fix_paths(job)
(tmpdir, outdir) = tmp_files[0... | parent_task = luigi.Parameter(default = "ratatosk.lib.tools.fastqc.InputFastqFile") |
Given the following code snippet before the placeholder: <|code_start|>logger = get_logger()
class InputBamFile(ratatosk.lib.files.input.InputBamFile):
pass
class InputFastqFile(ratatosk.lib.files.input.InputFastqFile):
pass
# This was a nightmare to get right. Temporary output is a directory,
# so would nee... | (stdout, stderr, returncode) = shell.exec_cmd(cmd, shell=True) |
Given the code snippet: <|code_start|># Copyright (c) 2013 Per Unneberg
#
# 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 a... | def test_sample(self): |
Continue the code snippet: <|code_start|># Copyright (c) 2013 Per Unneberg
#
# 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 b... | } |
Given snippet: <|code_start|># Copyright (c) 2013 Per Unneberg
#
# 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... | 'sampleindex' : (Template(filename=os.path.join(TEMPLATEPATH, "source", "samples", "index.mako")), '.rst'), |
Using the snippet: <|code_start|># Copyright (c) 2013 Per Unneberg
#
# 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 applic... | def _setup_directories(root): |
Given the code snippet: <|code_start|>
logging.basicConfig(level=logging.DEBUG)
sample = "P001_101_index3_TGACCA_L001"
bam = os.path.join(sample + ".bam")
localconf = "mock.yaml"
ratatosk_conf = os.path.join(os.path.dirname(__file__), os.pardir, "config", "ratatosk.yaml")
def setUpModule():
global cnf
cnf = ge... | 'InsertMetrics' : |
Given snippet: <|code_start|>
logging.basicConfig(level=logging.DEBUG)
sample = "P001_101_index3_TGACCA_L001"
bam = os.path.join(sample + ".bam")
localconf = "mock.yaml"
ratatosk_conf = os.path.join(os.path.dirname(__file__), os.pardir, "config", "ratatosk.yaml")
def setUpModule():
global cnf
cnf = get_config(... | default_flow_style=False)) |
Here is a snippet: <|code_start|>
logging.basicConfig(level=logging.DEBUG)
sample = "P001_101_index3_TGACCA_L001"
bam = os.path.join(sample + ".bam")
localconf = "mock.yaml"
ratatosk_conf = os.path.join(os.path.dirname(__file__), os.pardir, "config", "ratatosk.yaml")
def setUpModule():
global cnf
cnf = get_con... | { |
Predict the next line for this snippet: <|code_start|> # target_generator_handler="test.test_wrapper.gatk_vcf_generator")
# self.assertEqual(['java', '-Xmx2g', '-jar', self.gatk, '-T CombineVariants', '-V', 'vcf1.vcf', '-V', 'vcf2.vcf', '-o', 'data/sample.so... | options=["-an", "QD", "-resource:hapmap,VCF,known=false,training=true,truth=true,prior=15.0", "data/hapmap_3.3.vcf"]) |
Given snippet: <|code_start|>
def test_select_variants(self):
task = ratatosk.lib.tools.gatk.SelectVariants(target=self.mergebam.replace(".bam", "-snp-all.vcf"))
self.assertEqual(['java', '-Xmx2g', '-jar', self.gatk, '-T SelectVariants', '--selectTypeToInclude', 'SNP', '--selectTypeToInclude', 'INDE... | _prune_luigi_tmp(task.job_runner()._make_arglist(task)[0])) |
Given snippet: <|code_start|> if path and path in cls._instance._custom_config_paths:
logger.debug("removing config path {}".format(path))
try:
i = cls._instance._custom_config_paths.index(path)
del cls._instance._custom_config_paths[i]
except V... | def setup_config(config_file=None, custom_config_file=None, **kwargs): |
Given snippet: <|code_start|> if path and path in cls._instance._custom_config_paths:
logger.debug("removing config path {}".format(path))
try:
i = cls._instance._custom_config_paths.index(path)
del cls._instance._custom_config_paths[i]
except V... | def setup_config(config_file=None, custom_config_file=None, **kwargs): |
Continue the code snippet: <|code_start|># Copyright (c) 2013 Per Unneberg
#
# 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 b... | class RatatoskConfigParser(object): |
Next line prediction: <|code_start|> @classmethod
def del_config_path(cls, path):
if path and path in cls._instance._custom_config_paths:
logger.debug("removing config path {}".format(path))
try:
i = cls._instance._custom_config_paths.index(path)
de... | return RatatoskCustomConfigParser.instance() |
Next line prediction: <|code_start|> # decoding can fail with a padding error when
# a line of encoded content runs across a read chunk
lines = content.split(b'\n')
# decode and yield all but the last line of encoded content
... | sections = chunk.split(binary_content_tag) |
Given the following code snippet before the placeholder: <|code_start|> try:
# decode method used by base64.decode
decoded_content = binascii.a2b_base64(content)
except binascii.Error:
# decoding can fail with a padding error whe... | yield chunk |
Here is a snippet: <|code_start|># 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, software
# distributed under the License is distribute... | return self._value |
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 ... | class TemplateTagTest(unittest.TestCase): |
Based on the snippet: <|code_start|># file eulfedora/templatetags/fedora.py
#
# Copyright 2010,2011 Emory University Libraries
#
# 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
#
# ... | def __init__(self, fedora_access, permission_denied=None, |
Given snippet: <|code_start|># file eulfedora/templatetags/fedora.py
#
# Copyright 2010,2011 Emory University Libraries
#
# 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:... | fedora_failed=None): |
Given the code snippet: <|code_start|> """Stream filter class."""
def decode(self, data, **kwargs):
"""Decode the encoded stream. Keyword arguments are the parameters from
the stream dictionary."""
if self.EOD:
end = data.find(bytes(self.EOD))
return self.decoder(d... | def register(cls, filter_name, decoder, eod=None, encoder=None): |
Given snippet: <|code_start|>"""
Abstract base class for stream filters
"""
base = namedtuple('StreamFilter', ('filter_name','decoder', 'EOD', 'encoder'))
base.__new__.__defaults__ = (None, None)
class StreamFilterBase(base):
"""Stream filter class."""
def decode(self, data, **kwargs):
"""Decode the en... | return self.decoder(data[:end if end > 0 else None], **kwargs) |
Next line prediction: <|code_start|>
class TestSimpleTypes(ParserTestCase):
def setUp(self):
super(TestSimpleTypes, self).__init__()
<|code_end|>
. Use current file imports:
(from .parser_test import ParserTestCase
from ..pdf_parser.exc import PdfParseError)
and context including class names, funct... | self.func = self.parser._parse_literal |
Given the following code snippet before the placeholder: <|code_start|> return data.decode('utf_16_be')
# If the string isn't UTF-16BE, it follows PDF standard encoding
# described in Appendix D of the reference.
return data.decode('pdf_doc')
ESCAPES = {b'n' : b'\n',
... | except KeyError: |
Continue the code snippet: <|code_start|>"""
PDF string-like objects
"""
# Go ahead and register the codec here, I guess.
register_codec()
class PdfString(PdfType):
"""Base class from which all of our string-like classes
will inherit"""
def __lt__(self, other): return self._parsed_bytes.__lt__(other)
... | def __hash__(self): return self._parsed_bytes.__hash__() |
Here is a snippet: <|code_start|>"""
PDF string-like objects
"""
# Go ahead and register the codec here, I guess.
register_codec()
class PdfString(PdfType):
"""Base class from which all of our string-like classes
will inherit"""
def __lt__(self, other): return self._parsed_bytes.__lt__(other)
def _... | def __ge__(self, other): return self._parsed_bytes.__ge__(other) |
Given the following code snippet before the placeholder: <|code_start|> """Detect the encoding method and return the decoded string"""
# Are we UTF-16BE? Good.
if data[:2] == '\xFE\xFF':
return data.decode('utf_16_be')
# If the string isn't UTF-16BE, it follows PDF standard e... | e_str = data.read(1) |
Predict the next line after this snippet: <|code_start|> return self._return()
def bytes_to_glyphs(self, string):
"""Converts a bytestring into a series of glyphs based upon the active
font's encoding"""
pass
@property
def active_font(self):
"""The PdfBaseFont represe... | CTM = self.gs.CTM |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.