Instruction stringlengths 362 7.83k | output_code stringlengths 1 945 |
|---|---|
Predict the next line after this snippet: <|code_start|># GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
class tag_OMX_GetComponentVersion(skema.tag.SkemaTag):
"""
"... | err = get_string_from_il_enum(interror, "OMX_Error") |
Predict the next line for this snippet: <|code_start|># Copyright (C) 2011-2017 Aratelia Limited - Juan A. Rubio
#
# This program 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... | cname = (c_ubyte * OMX_MAX_STRINGNAME_SIZE)() |
Using the snippet: <|code_start|># Copyright (C) 2011-2017 Aratelia Limited - Juan A. Rubio
#
# This program 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 optio... | log_api ("%s '%s'" % (element.tag, name)) |
Given the code snippet: <|code_start|># You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
class tag_OMX_GetComponentVersion(skema.tag.SkemaTag):
"""
"""
def run(self, element, context):
alias = element.ge... | log_line () |
Given snippet: <|code_start|>
class tag_OMX_GetComponentVersion(skema.tag.SkemaTag):
"""
"""
def run(self, element, context):
alias = element.get('alias')
name = context.cnames[alias]
log_api ("%s '%s'" % (element.tag, name))
handle = context.handles[alias]
cname ... | log_param (name, str(getattr(cversion.s, name)), 2) |
Based on the snippet: <|code_start|> name = context.cnames[alias]
log_api ("%s '%s'" % (element.tag, name))
handle = context.handles[alias]
cname = (c_ubyte * OMX_MAX_STRINGNAME_SIZE)()
cversion = OMX_VERSIONTYPE()
specversion = OMX_VERSIONTYPE()
cuuid = OMX_UUID... | log_result(element.tag, err) |
Based on the snippet: <|code_start|># the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program 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... | log_api ("%s %s:Port-%d' 'Allocator:%s' 'Mode:%s' 'Uri:%s'" \ |
Predict the next line for this snippet: <|code_start|>#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
class tag_OMX_BaseProfilePort(skema.tag.SkemaTag):
"""
"""
def run(self, element, context):
alias ... | log_result (element.tag, "OMX_ErrorNone") |
Based on the snippet: <|code_start|># Copyright (C) 2011-2017 Aratelia Limited - Juan A. Rubio
#
# This program 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 op... | log_api ("%s %s:Port-%s'" % (element.tag, name, portstr)) |
Here is a snippet: <|code_start|>#
# This program 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.
#
# This program is distributed in th... | log_result (element.tag, "OMX_ErrorNone") |
Next line prediction: <|code_start|>#
# This program 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.
#
# This program is distributed in... | log_line () |
Predict the next line for this snippet: <|code_start|># This program 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.
#
# This program i... | log_api("EventHandler '%s'" % (name)) |
Given the code snippet: <|code_start|># Copyright (C) 2011-2017 Aratelia Limited - Juan A. Rubio
#
# This program 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 ... | config = get_config() |
Predict the next line for this snippet: <|code_start|>#
# This program 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.
#
# This program... | index = get_il_enum_from_string(indexstr) |
Given snippet: <|code_start|># MERCHANTABILITY or 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 this program. If not, see <http://www.gnu.org/licenses/>.
class tag_OMX_GetContentURI(skem... | err = get_string_from_il_enum(interror, "OMX_Error") |
Here is a snippet: <|code_start|># This program 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.
#
# This program is distributed in the ... | param_type = OMX_PARAM_CONTENTURITYPE |
Using the snippet: <|code_start|># This program 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 the GN... | omxerror = OMX_GetParameter(handle, index, byref(param_struct)) |
Using the snippet: <|code_start|># Copyright (C) 2011-2017 Aratelia Limited - Juan A. Rubio
#
# This program 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 optio... | log_api ("%s '%s' '%s'" \ |
Using the snippet: <|code_start|>
class tag_OMX_GetContentURI(skema.tag.SkemaTag):
"""
"""
def run(self, element, context):
indexstr = "OMX_IndexParamContentURI"
alias = element.get('alias')
name = context.cnames[alias]
log_api ("%s '%s' '%s'" \
%... | log_line () |
Using the snippet: <|code_start|> """
"""
def run(self, element, context):
indexstr = "OMX_IndexParamContentURI"
alias = element.get('alias')
name = context.cnames[alias]
log_api ("%s '%s' '%s'" \
% (element.tag, indexstr, name))
handle = contex... | log_param (name, uristr.value, 1) |
Given snippet: <|code_start|> indexstr = "OMX_IndexParamContentURI"
alias = element.get('alias')
name = context.cnames[alias]
log_api ("%s '%s' '%s'" \
% (element.tag, indexstr, name))
handle = context.handles[alias]
index = get_il_enum_from_string(i... | log_result (element.tag, err) |
Predict the next line for this snippet: <|code_start|># Copyright (C) 2011-2017 Aratelia Limited - Juan A. Rubio
#
# This program 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... | log_line () |
Predict the next line for this snippet: <|code_start|>#
# This program 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.
#
# This program... | log_result (msg, "OMX_ErrorNone") |
Given the following code snippet before the placeholder: <|code_start|># Copyright (C) 2011-2017 Aratelia Limited - Juan A. Rubio
#
# This program 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... | log_api ("%s '%s'" \ |
Continue the code snippet: <|code_start|> suite.install()
except RuntimeError as strerror:
print "Suite installation error: %s" % strerror
sys.exit(1)
class cmd_run_suite(skema.command.SkemaCmd):
"""
Run suites
"""
arglist = ['*suitename']
options = [make... | config = get_config() |
Given the code snippet: <|code_start|>#
# This program 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... | log_line () |
Next line prediction: <|code_start|># 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 the GNU General Public License
# along with this program. If not, se... | log_result (msg, "OMX_ErrorNone") |
Continue the code snippet: <|code_start|># Copyright (C) 2011-2017 Aratelia Limited - Juan A. Rubio
#
# This program 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 yo... | log_api ("%s '%s' '%s'" \ |
Continue the code snippet: <|code_start|># 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.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; withou... | self.cbacks = OMX_CALLBACKTYPE() |
Based on the snippet: <|code_start|> def print_(self, printer, print_):
return ''.join(map('//{}\n'.format, self.lines))
class MethodDef(object):
def __init__(self, class_, flags, name, desc, retType, paramDecls, body):
self.flagstr = flags + ' ' if flags else ''
self.retType, self.param... | header += '{}{} {}({})'.format(self.flagstr, print_(self.retType), escape(name), argstr) |
Based on the snippet: <|code_start|>
class Comments(object):
def __init__(self):
self.lines = []
def add(self, s):
self.lines.extend(s.strip('\n').split('\n'))
def print_(self, printer, print_):
return ''.join(map('//{}\n'.format, self.lines))
class MethodDef(object):
def __in... | self.clsname = ast.TypeName(objtypes.TypeTT(class_.name, 0)) |
Based on the snippet: <|code_start|> k = min(numzeroes, (y-x+1).bit_length()-1)
out.append((x,k))
x += 1<<k
assert(x == y+1)
return out
def propagateBitwise(arg1, arg2, op, usemin, usemax):
ranges1 = split_pow2ranges(arg1.min, arg1.max)
ranges2 = split_pow2ranges(arg2.min, arg2.m... | return IntConstraint.range(arg1.width, min(vals), max(vals)) |
Here is a snippet: <|code_start|>
class BaseOp(SSAFunctionBase):
def __init__(self, parent, arguments, makeException=False, makeMonad=False):
super(BaseOp, self).__init__(parent,arguments)
self.rval = None
self.outException = None
self.outMonad = None
if makeException:
<|co... | self.outException = parent.makeVariable(SSA_OBJECT, origin=self) |
Predict the next line for this snippet: <|code_start|>
class BaseOp(SSAFunctionBase):
def __init__(self, parent, arguments, makeException=False, makeMonad=False):
super(BaseOp, self).__init__(parent,arguments)
self.rval = None
self.outException = None
self.outMonad = None
i... | self.outMonad = parent.makeVariable(SSA_MONAD, origin=self) |
Predict the next line after this snippet: <|code_start|> return yname in ('java/lang/Object','java/lang/Cloneable','java/io/Serializable')
else:
return isBaseTClass(x) and isBaseTClass(y) and env.isSubclass(xname, yname)
#Will not return interface unless all inputs are same interface or null
def com... | _verifierConvert = {vtypes.T_INT:IntTT, vtypes.T_FLOAT:FloatTT, vtypes.T_LONG:LongTT, |
Using the snippet: <|code_start|>
class Field(object):
flagVals = {'PUBLIC':0x0001,
'PRIVATE':0x0002,
'PROTECTED':0x0004,
'STATIC':0x0008,
'FINAL':0x0010,
'VOLATILE':0x0040,
'TRANSIENT':0x0080,
'SYNTHETIC... | self.attributes = fixAttributeNames(attributes_raw, cpool) |
Using the snippet: <|code_start|>
def getScopes(self): return self,
def print_(self, printer, print_):
assert(self.labelable or self.label is None)
contents = '\n'.join(print_(x) for x in self.statements)
indented = [' '+line for line in contents.splitlines()]
# indented[:0] ... | _assignable_sprims = objtypes.ByteTT, objtypes.ShortTT, objtypes.CharTT |
Given the code snippet: <|code_start|>
def print_(self, printer, print_):
return 'new {}({})'.format(print_(self.typename), ', '.join(print_(x) for x in self.params))
def tree(self, printer, tree):
return [self.__class__.__name__, map(tree, self.params), tree(self.typename)]
def addCasts_s... | name = escapeString(printer.fieldName(cls, name, desc)) |
Given snippet: <|code_start|>
# A simple throws declaration inferrer that only considers throw statements within the method
# this is mostly just useful to make sure the ExceptionHandlers test compiles
def _visit_statement(env, stmt):
if isinstance(stmt, ast.ThrowStatement):
return stmt.expr.dtype
<|code_... | result = objtypes.NullTT |
Here is a snippet: <|code_start|>
def parseFieldDescriptors(desc_str, unsynthesize=True):
baseTypes = {'B':T_BYTE, 'C':T_CHAR, 'D':T_DOUBLE, 'F':T_FLOAT,
'I':T_INT, 'J':T_LONG, 'S':T_SHORT, 'Z':T_BOOL}
fields = []
while desc_str:
oldlen = len(desc_str)
desc_str = desc_str.l... | baset = T_OBJECT(name) |
Given the following code snippet before the placeholder: <|code_start|> 'I':T_INT, 'J':T_LONG, 'S':T_SHORT, 'Z':T_BOOL}
fields = []
while desc_str:
oldlen = len(desc_str)
desc_str = desc_str.lstrip('[')
dim = oldlen - len(desc_str)
if dim > 255:
raise... | baset = T_ARRAY(baset, dim) |
Next line prediction: <|code_start|> oldlen = len(desc_str)
desc_str = desc_str.lstrip('[')
dim = oldlen - len(desc_str)
if dim > 255:
raise ValueError('Dimension {} > 255 in descriptor'.format(dim))
if not desc_str:
raise ValueError('Descriptor contains [s... | baset = unSynthesizeType(baset) |
Given snippet: <|code_start|> if dim > 255:
raise ValueError('Dimension {} > 255 in descriptor'.format(dim))
if not desc_str:
raise ValueError('Descriptor contains [s at end of string')
if desc_str[0] == 'L':
end = desc_str.find(';')
if end == -1:
... | if baset in cat2tops: |
Predict the next line for this snippet: <|code_start|> S = set(innodes)
for old, new in dups:
for p in old.predecessors[:]:
if p in S:
old.predecessors.remove(p)
new.predecessors.append(p)
new.replaceSuccessors(dupmap)
for c in new.successors:
... | n.invars = [v for v in invars if v.type != ssa_types.SSA_MONAD] |
Given the following code snippet before the placeholder: <|code_start|>
def loadConstValue(cpool, index):
entry_type = cpool.pool[index][0]
args = cpool.getArgs(index)
#Note: field constant values cannot be class literals
<|code_end|>
, predict the next line using imports from the current file:
import s... | tt = {'Int':objtypes.IntTT, 'Long':objtypes.LongTT, |
Given snippet: <|code_start|>
def loadConstValue(cpool, index):
entry_type = cpool.pool[index][0]
args = cpool.getArgs(index)
#Note: field constant values cannot be class literals
tt = {'Int':objtypes.IntTT, 'Long':objtypes.LongTT,
'Float':objtypes.FloatTT, 'Double':objtypes.DoubleTT,
... | dtype = objtypes.verifierToSynthetic(parseFieldDescriptor(desc, unsynthesize=False)[0]) |
Next line prediction: <|code_start|> initexpr = None
if field.static:
cpool = field.class_.cpool
const_attrs = [data for name,data in field.attributes if name == 'ConstantValue']
if const_attrs:
assert(len(const_attrs) == 1)
data = const_attrs[0]
index ... | fi = set(reserved_identifiers) |
Given snippet: <|code_start|> token_t = tokenize.wordget[name]
if token_t == 'OP_LBL':
assert(len(args) == 1)
args[0] = getlbl(args[0]+pos)
elif token_t in funcs:
args[0] = funcs[token_t](args[0])
parts = [name] + map(str, args)
return '\t' + '... | b = binUnpacker(code.bytecode_raw) |
Based on the snippet: <|code_start|> elif tag == 'enum':
val = poolm.utfref(bytes_.get('>H')) + ' ' + poolm.utfref(bytes_.get('>H'))
elif tag == 'array':
val = ''
add(indent + '{} {} {}'.format(prefix, tag, val))
if ... | _classflags = [(v,k.lower()) for k,v in ClassFile.flagVals.items()] |
Using the snippet: <|code_start|>
def compute_photon_energy(nm_axis):
"""Return the photon energy (in erg) computed for all the wavelength along
a given wavelength axis.
:param nm_axis: Wavelength axis in nm
"""
return (orb.constants.PLANCK
* orb.constants.LIGHT_VEL_KMS * 1e12
... | star = Gaussian([0,1,N/2,N/2,fwhm_pix]).array2d(N,N) |
Given the code snippet: <|code_start|>
def create_triggers(cls):
sa.event.listen(
cls.__table__,
'after_create',
sa.schema.DDL(
procedure_sql.format(
temporary_transaction_sql=CreateTemporaryTransactionTableSQL(),
insert_temporary_transaction_sql=(... | class TransactionFactory(ModelFactory): |
Here is a snippet: <|code_start|> Activity.target == article
)
)
.. _activity stream specification:
http://www.activitystrea.ms
.. _generic relationships:
https://sqlalchemy-utils.readthedocs.io/en/latest/generic_relationship.html
"""
class ActivityBase(object):
id = sa.Column(... | class ActivityFactory(ModelFactory): |
Continue the code snippet: <|code_start|> manager = self
transaction_id = sa.Column(
sa.BigInteger,
index=True,
nullable=False
)
data = sa.Column(JSONType)
object_type = sa.Column(sa.String(255))
o... | version_cls = version_class(model) |
Using the snippet: <|code_start|> class Activity(
manager.declarative_base,
ActivityBase
):
__tablename__ = 'activity'
manager = self
transaction_id = sa.Column(
sa.BigInteger,
index=True,
nullabl... | object_version = version_obj(session, obj) |
Predict the next line after this snippet: <|code_start|> ).group_by(
*association_cols
).having(
sa.func.max(association_table_alias.c[tx_column]) ==
self.association_version_table.c[tx_column]
).correlate(self.association_version_table)... | builder = TableBuilder( |
Given snippet: <|code_start|>
association_exists = sa.exists(
sa.select(
[1]
).where(
sa.and_(
association_table_alias.c[tx_column] <=
getattr(obj, tx_column),
association_table_alias.c[join_colum... | adapt_columns(self.property.secondaryjoin), |
Given the code snippet: <|code_start|> many-to-many associations.
"""
column = list(self.property.remote_side)[0]
self.manager.association_tables.add(column.table)
builder = TableBuilder(
self.manager,
column.table
)
metadata = column.table... | self.local_cls = version_class(self.model) |
Continue the code snippet: <|code_start|>
class RelationshipBuilder(object):
def __init__(self, versioning_manager, model, property_):
self.manager = versioning_manager
self.property = property_
self.model = model
def one_to_many_subquery(self, obj):
<|code_end|>
. Use current file im... | tx_column = option(obj, 'transaction_column_name') |
Using the snippet: <|code_start|> if not hasattr(self.version_class, 'transaction'):
self.version_class.transaction = sa.orm.relationship(
tx_class,
primaryjoin=tx_class.id == transaction_column,
foreign_keys=[transaction_column],
)
def... | inherit_condition = adapt_columns( |
Given the following code snippet before the placeholder: <|code_start|>
def find_closest_versioned_parent(manager, model):
"""
Finds the closest versioned parent for current parent model.
"""
for class_ in model.__bases__:
if class_ in manager.version_class_map:
return manager.vers... | option(model, 'base_classes') |
Predict the next line after this snippet: <|code_start|>
subquery = self.version_validity_subquery(
parent,
version_obj,
alias=sa.orm.aliased(class_.__table__)
)
try:
subquery = subquery.scala... | end_tx_column_name(version_obj): |
Continue the code snippet: <|code_start|> def create_transaction(self, session):
"""
Create transaction object for given SQLAlchemy session.
:param session: SQLAlchemy session object
"""
args = self.transaction_args(session)
Transaction = self.manager.transaction_cls... | version_cls = version_class(target.__class__) |
Continue the code snippet: <|code_start|>
class UnitOfWork(object):
def __init__(self, manager):
self.manager = manager
self.reset()
def reset(self, session=None):
"""
Reset the internal state of this UnitOfWork object. Normally this is
called after transaction has bee... | is_session_modified(session) or |
Given the following code snippet before the placeholder: <|code_start|> parent object and newly created version object.
This method is only used when using 'validity' versioning strategy.
:param parent: SQLAlchemy declarative parent object
:parem version_obj: SQLAlchemy declarative vers... | tx_column_name(version_obj) |
Predict the next line for this snippet: <|code_start|>
:param session: SQLAlchemy session object
"""
if not self.manager.options['versioning']:
return
if self.pending_statements:
self.create_association_versions(session)
if self.operations:
s... | for prop in versioned_column_properties(parent_obj): |
Using the snippet: <|code_start|>
def parent_identity(obj_or_class):
return tuple(
getattr(obj_or_class, column_key)
for column_key in get_primary_keys(obj_or_class).keys()
<|code_end|>
, determine the next line of code. You have imports:
import operator
import sqlalchemy as sa
from sqlalchemy_uti... | if column_key != tx_column_name(obj_or_class) |
Continue the code snippet: <|code_start|>class SubqueryFetcher(VersionObjectFetcher):
def previous_query(self, obj):
"""
Returns the query that fetches the previous version relative to this
version in the version history.
"""
return self._next_prev_query(obj, 'previous')
... | getattr(obj, end_tx_column_name(obj)), |
Predict the next line for this snippet: <|code_start|> def __str__(self):
return self.name
@property
def events(self):
return self.event_set
def create_relation(self, obj, distinction=None, inheritable=True):
"""
Creates a CalendarRelation between self and obj.
... | return EventListManager(self.events.all()).occurrences_after(date) |
Here is a snippet: <|code_start|> "Jeremy's Calendar"
"""
try:
return self.get_calendar_for_object(obj, distinction)
except Calendar.DoesNotExist:
if name is None:
calendar = Calendar(name=str(obj))
else:
calendar = Calen... | class Calendar(with_metaclass(ModelBase, *get_model_bases())): |
Predict the next line after this snippet: <|code_start|> # image todo
panels = [
FieldPanel('name'),
FieldPanel('capacity'),
]
def __str__(self):
return self.name
class Booking(models.Model):
"""
access from Room with .booking_set
create from Room with .booking_set... | class RoomsWeekly(StandardPage): |
Next line prediction: <|code_start|>from __future__ import division
register = template.Library()
@register.inclusion_tag("schedule/_month_table.html", takes_context=True)
def month_table(context, calendar, month, size="regular", shift=None):
if shift:
if shift == -1:
month = month.prev()
... | context['day_names'] = weekday_names |
Given the code snippet: <|code_start|>from __future__ import division
register = template.Library()
@register.inclusion_tag("schedule/_month_table.html", takes_context=True)
def month_table(context, calendar, month, size="regular", shift=None):
if shift:
if shift == -1:
month = month.prev()
... | context['day_names'] = weekday_abbrs |
Using the snippet: <|code_start|>from __future__ import division, unicode_literals
# -*- coding: utf-8 -*-
class EventManager(models.Manager):
def get_for_object(self, content_object, distinction=None, inherit=True):
return EventRelation.objects.get_events_for_object(content_object, distinction, inherit... | class Event(with_metaclass(ModelBase, *get_model_bases())): |
Given snippet: <|code_start|> label=_("Telefon"),
widget=forms.TextInput(), required=True)
street = forms.CharField(
label=_("Straße"),
max_length=100,
)
plz_city = forms.CharField(
label=_("PLZ / Stadt"),
widget=forms.TextInput(), requi... | if not qs.exists() or not settings.ACCOUNT_EMAIL_UNIQUE: |
Based on the snippet: <|code_start|> phone = forms.CharField(
label=_("Telefon"),
widget=forms.TextInput(), required=True)
street = forms.CharField(
label=_("Straße"),
max_length=100,
)
plz_city = forms.CharField(
label=_("PLZ / Stadt"),
... | qs = EmailAddress.objects.filter(email__iexact=value) |
Predict the next line after this snippet: <|code_start|> label=_("Password"),
widget=forms.PasswordInput(render_value=False)
)
password_confirm = forms.CharField(
label=_("Password (again)"),
widget=forms.PasswordInput(render_value=False)
)
email = forms.Em... | lookup_kwargs = get_user_lookup_kwargs({ |
Continue the code snippet: <|code_start|> if not next_url:
# try the session if available
if hasattr(request, "session"):
session_key_value = kwargs.get("session_key_value", "redirect_to")
if session_key_value in request.session:
next_url = request.session[sess... | return settings.ACCOUNT_USER_DISPLAY(user) |
Given snippet: <|code_start|>sys.path.append('') # need to import from base
parser = get_parser()
parser.add_argument('--upload_directory', default=False, action="store_true", help='upload all xls and fasta files in directory')
parser.add_argument('--vtype', default=None, help="type of virus, if applicable")
parser.a... | class flu_upload(upload): |
Given the code snippet: <|code_start|>sys.path.append('') # need to import from base
class rethink_interact(object):
def __init__(self, **kwargs):
<|code_end|>
, generate the next line using the imports in this file:
import os, shutil, sys, datetime, re, subprocess, json
import boto3
from rethinkdb import r
from... | self.rethink_io = rethink_io() |
Given the following code snippet before the placeholder: <|code_start|> parser.add_argument('--present', nargs='+', type=str, default=[], help="Select specific fields to be non-null ie \'--present field1 field2\'")
parser.add_argument('--interval', nargs='+', type=str, default=[], help="Select interval of values... | self.rethink_io = rethink_io() |
Continue the code snippet: <|code_start|># If your documentation needs a minimal Sphinx version, state it here.
needs_sphinx = '1.1'
# Add any Sphinx extension module names here, as strings. They can be extensions
# coming with Sphinx (named 'sphinx.ext.*') or your custom ones.
extensions = ['sphinx.ext.autodoc', 'sph... | version = VERSION |
Continue the code snippet: <|code_start|>
def test_chunk():
data_length = 1000
chunk_length = 7
data = list(range(data_length))
<|code_end|>
. Use current file imports:
import collections
from sider import utils
and context (classes, functions, or code) from other files:
# Path: sider/utils.py
# def chu... | chunks = utils.chunk(data, chunk_length) |
Next line prediction: <|code_start|>from __future__ import with_statement
try:
except ImportError:
def readme():
try:
with open(os.path.join(os.path.dirname(__file__), 'README.rst')) as f:
return f.read()
except (IOError, OSError):
return ''
setup(name='Sider',
packages=['s... | version=VERSION, |
Here is a snippet: <|code_start|> key_type=self.key_type, value_type=self.value_type)
if value:
pipe = session.client.pipeline()
pipe.delete(key)
obj._raw_update(value, pipe)
pipe.execute()
else:
session.client.delete(key)
... | return list.List(session, key, value_type=self.value_type) |
Given the code snippet: <|code_start|> pipe.execute()
return obj
def __hash__(self):
return super(List, self).__hash__() * hash(self.value_type)
def __eq__(self, operand):
if super(List, self).__eq__(operand):
return self.value_type == operand.value_type
retu... | return set.Set(session, key, value_type=self.value_type) |
Using the snippet: <|code_start|> def save_value(self, session, key, value):
if not isinstance(value, collections.Set):
raise TypeError('expected a set-like object, not ' +
repr(value))
obj = set.Set(session, key, value_type=self.value_type)
pipe = sess... | return sortedset.SortedSet(session, key, value_type=self.value_type) |
Using the snippet: <|code_start|> tzinfo=sider.datetime.Utc())
>>> b = dt.parse_datetime('2012-03-28T18:21:34.638972+09:00')
>>> b # doctest: +NORMALIZE_WHITESPACE
datetime.datetime(2012, 3, 28, 18, 21, 34, 638972,
tzinfo=sider.d... | tzinfo = UTC |
Predict the next line for this snippet: <|code_start|> True
:param bulk: a :rfc:`3339` formatted string
:type bulk: :class:`basestring`
:returns: a parsing result
:rtype: :class:`datetime.datetime`
.. note::
It is for internal use and :meth:`decode()` meth... | tzinfo = FixedOffset(tzoffset if tzplus else -tzoffset) |
Next line prediction: <|code_start|> finally:
if cc is not None:
cc.switch(*next_args)
c1 = greenlet.greenlet(test)
c2 = greenlet.greenlet(test)
c1.switch(generator(),
(c2, (generator(), (c1, ())) + args2),
... | local = LocalDict() |
Given the following code snippet before the placeholder: <|code_start|>
if greenlet:
def coro_test(generator, args1=(), args2=()):
def test(g, v, *args):
cc, next_args = v
next(g)
for arg in args:
try:
g.send(arg)
excep... | local[get_ident()] = value |
Given the code snippet: <|code_start|>def test_rooms_get(logged_rocket):
rooms_get = logged_rocket.rooms_get().json()
assert rooms_get.get("success")
def test_rooms_clean_history(logged_rocket):
rooms_clean_history = logged_rocket.rooms_clean_history(
room_id="GENERAL",
latest="2016-09-30T... | with pytest.raises(RocketMissingParamException): |
Continue the code snippet: <|code_start|>
def test_im_list_everyone(logged_rocket):
im_list_everyone = logged_rocket.im_list_everyone().json()
assert im_list_everyone.get("success")
def test_im_history(logged_rocket, recipient_user):
im_create = logged_rocket.im_create(recipient_user).json()
room_id ... | with pytest.raises(RocketMissingParamException): |
Predict the next line for this snippet: <|code_start|> _test_group_id = (
logged_rocket.groups_create(test_group_name).json().get("group").get("_id")
)
return _test_group_id
def test_groups_list_all(logged_rocket):
groups_list = logged_rocket.groups_list_all().json()
assert groups_list.get... | with pytest.raises(RocketMissingParamException): |
Continue the code snippet: <|code_start|> self.server_url + self.API_path + method,
data=reduced_args,
files=files,
headers=self.headers,
verify=self.ssl_verify,
cert=self.cert,
proxies=self.proxies,
timeout=self.timeout,
... | raise RocketAuthenticationException() |
Predict the next line after this snippet: <|code_start|> def login(self, user, password):
request_data = {"password": password}
if re.match(
r"^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,4})$",
user,
):
request_data["user"] = user
... | raise RocketConnectionException() |
Predict the next line after this snippet: <|code_start|> yield _testuser_id
logged_rocket.users_delete(_testuser_id)
def test_channels_list(logged_rocket):
channels_list = logged_rocket.channels_list().json()
assert channels_list.get("success")
assert "channels" in channels_list
def test_channel... | with pytest.raises(RocketMissingParamException): |
Continue the code snippet: <|code_start|>
class RocketChatUsers(RocketChatBase):
def me(self, **kwargs):
"""Displays information about the authenticated user."""
return self.call_api_get("me", kwargs=kwargs)
def users_info(self, user_id=None, username=None, **kwargs):
"""Gets a user’s... | raise RocketMissingParamException("userID or username required") |
Using the snippet: <|code_start|>
def test_chat_post_notext_message(logged_rocket):
chat_post_message = logged_rocket.chat_post_message(None, channel="GENERAL").json()
assert chat_post_message.get("channel") == "GENERAL"
assert chat_post_message.get("message").get("msg") == ""
assert chat_post_message... | with pytest.raises(RocketMissingParamException): |
Given the code snippet: <|code_start|>
@pytest.fixture
def delete_user2(logged_rocket):
user2_exists = logged_rocket.users_info(username="user2").json().get("success")
if user2_exists:
user_id = (
logged_rocket.users_info(username="user2").json().get("user").get("_id")
)
l... | with pytest.raises(RocketAuthenticationException): |
Here is a snippet: <|code_start|> assert login.get("status") == "success"
assert "authToken" in login.get("data")
assert "userId" in login.get("data")
def test_me(logged_rocket, user):
me = logged_rocket.me().json()
assert me.get("success")
assert me.get("username") == user.name
assert me.g... | with pytest.raises(RocketMissingParamException): |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.