Instruction
stringlengths
362
7.83k
output_code
stringlengths
1
945
Here is a snippet: <|code_start|> class AnalysisRequest(db.Document): analysis_system = ReferenceField(AnalysisSystem, required=True) sample = ReferenceField(Sample, required=True) analysis_requested = DateTimeField(default=TimeFunctions.get_timestamp, required=True) priority = IntField(default=0, requ...
def __repr__(self):
Predict the next line for this snippet: <|code_start|> def _gen_uuid(): return str(uuid4()) class AnalysisSystemInstance(db.Document, AbstractAuthEntity): @property def is_authenticated(self): return True def get_roles(self): return ['analysis_system_instance'] @property def...
def __repr__(self):
Next line prediction: <|code_start|> def _gen_uuid(): return str(uuid4()) class AnalysisSystemInstance(db.Document, AbstractAuthEntity): @property def is_authenticated(self): return True def get_roles(self): return ['analysis_system_instance'] @property def max_tlp_level(sel...
}
Given snippet: <|code_start|> def _gen_uuid(): return str(uuid4()) class AnalysisSystemInstance(db.Document, AbstractAuthEntity): @property def is_authenticated(self): return True def get_roles(self): return ['analysis_system_instance'] @property def max_tlp_level(self): ...
return self.__repr__()
Continue the code snippet: <|code_start|> return str(uuid4()) class AnalysisSystemInstance(db.Document, AbstractAuthEntity): @property def is_authenticated(self): return True def get_roles(self): return ['analysis_system_instance'] @property def max_tlp_level(self): re...
def update_last_seen(self):
Predict the next line for this snippet: <|code_start|> class UserMixin(AbstractAuthEntity): user_level = UserLevel.USER_LEVEL_ANONYMOUS def get_roles(self): roles = [] if self.is_user: roles.append('user') if self.is_privileged: roles.append('privileged') ...
return self.user_level >= UserLevel.USER_LEVEL_PRIVILEGED
Based on the snippet: <|code_start|> USER_LEVEL_ADMIN = 4 class UserLevelField(IntField): def __init__(self, *args, **kwargs): kwargs['choices'] = [ UserLevel.USER_LEVEL_ANONYMOUS, UserLevel.USER_LEVEL_USER, UserLevel.USER_LEVEL_PRIVILEGED, UserLevel.USER...
def is_authenticated(self):
Predict the next line for this snippet: <|code_start|> username = StringField(min_length=3, max_length=50, unique=True, required=True) password_hash = StringField(min_length=5, max_length=200) user_level = UserLevelField(default=UserLevel.USER_LEVEL_USER, required=True) def set_password(self, password):...
return False
Next line prediction: <|code_start|> roles.append('admin') return roles def is_authenticated(self): return False @property def is_anonymous(self): return self.user_level == UserLevel.USER_LEVEL_ANONYMOUS @property def is_user(self): return self.user_leve...
elif self.is_privileged:
Given the code snippet: <|code_start|> class ScheduledAnalysis(db.Document): analysis_system_instance = ReferenceField(AnalysisSystemInstance, required=True) sample = ReferenceField(Sample, required=True) analysis_scheduled = DateTimeField(default=TimeFunctions.get_timestamp, required=True) priority = ...
meta = {
Predict the next line for this snippet: <|code_start|> class ScheduledAnalysis(db.Document): analysis_system_instance = ReferenceField(AnalysisSystemInstance, required=True) sample = ReferenceField(Sample, required=True) analysis_scheduled = DateTimeField(default=TimeFunctions.get_timestamp, required=True)...
priority = IntField(default=0, required=True)
Given the code snippet: <|code_start|> class ScheduledAnalysis(db.Document): analysis_system_instance = ReferenceField(AnalysisSystemInstance, required=True) sample = ReferenceField(Sample, required=True) analysis_scheduled = DateTimeField(default=TimeFunctions.get_timestamp, required=True) priority = ...
}
Using the snippet: <|code_start|> class ScheduledAnalysis(db.Document): analysis_system_instance = ReferenceField(AnalysisSystemInstance, required=True) sample = ReferenceField(Sample, required=True) analysis_scheduled = DateTimeField(default=TimeFunctions.get_timestamp, required=True) priority = IntFi...
'ordering': ['-analysis_scheduled'],
Using the snippet: <|code_start|> @webui_blueprint.route('/profile/', methods=['GET']) @privilege_required(RolePrivilege('user')) def profile(): api_key = UserAPIKey.get_or_create(current_authenticated_entity).generate_auth_token() <|code_end|> , determine the next line of code. You have imports: from flask impo...
return render_template('profile.html', api_key=api_key)
Here is a snippet: <|code_start|> @webui_blueprint.route('/profile/', methods=['GET']) @privilege_required(RolePrivilege('user')) def profile(): api_key = UserAPIKey.get_or_create(current_authenticated_entity).generate_auth_token() <|code_end|> . Write the next line using the current file imports: from flask imp...
return render_template('profile.html', api_key=api_key)
Given the code snippet: <|code_start|> BASE = os.path.join(FileBASE,sub) commit = '0' branch = 'manual' describe = '' commit_short = '' if BASE is not None: try: os.chdir(BASE) branch = subprocess.check_output(['git', 'rev-parse', '--abbrev-ref', 'HEAD'], stder...
plgversion = get_plugins_version().split('-')[0]
Here is a snippet: <|code_start|># SmartHomeNG 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. # # SmartHomeNG is distributed in t...
_timezone = None
Predict the next line after this snippet: <|code_start|> try: except ImportError: # Django < 1.10 # Works perfectly for everyone using MIDDLEWARE_CLASSES MiddlewareMixin = object class MfaMiddleware(MiddlewareMixin): def process_request(self, request): if request.user.is_authenticated and ((is_m...
current_path = request.path
Given the code snippet: <|code_start|> try: except ImportError: # Django < 1.10 # Works perfectly for everyone using MIDDLEWARE_CLASSES MiddlewareMixin = object <|code_end|> , generate the next line using the imports in this file: from django.urls import reverse from django.shortcuts import resolve_url from...
class MfaMiddleware(MiddlewareMixin):
Given the following code snippet before the placeholder: <|code_start|> try: except ImportError: # Django < 1.10 # Works perfectly for everyone using MIDDLEWARE_CLASSES MiddlewareMixin = object class MfaMiddleware(MiddlewareMixin): def process_request(self, request): if request.user.is_authentic...
return None
Next line prediction: <|code_start|> def index(request): if request.user and request.user.is_authenticated: return HttpResponseRedirect(settings.LOGIN_REDIRECT_URL) if request.method == 'POST': form = LoginForm(request.POST, request.FILES) if form.is_valid(): user = form.use...
return render(request, 'login.html', context)
Predict the next line after this snippet: <|code_start|> user = form.user if is_u2f_enabled(user): request.session['u2f_pre_verify_user_pk'] = user.pk request.session['u2f_pre_verify_user_backend'] = user.backend login(request, form.user) re...
def home(request):
Here is a snippet: <|code_start|> try: except ImportError: warnings.warn("Pandas library not installed, dataframes disabled") pd = None <|code_end|> . Write the next line using the current file imports: import sys import warnings import requests import re import json import csv import pandas as pd im...
class NoResultException(Exception):
Here is a snippet: <|code_start|> try: except ImportError: warnings.warn("Pandas library not installed, dataframes disabled") pd = None class NoResultException(Exception): <|code_end|> . Write the next line using the current file imports: import sys import warnings import requests import re import json impor...
pass
Here is a snippet: <|code_start|> def gbif_query_for_single_name(name, rank): response = species.name_usage(name=name, rank=rank.upper())["results"] return response def process_gbif_response(list_of_response_dicts, rank): key = rank + "Key" extracted_ids = list( map( lambda x: _ma...
return extracted_ids
Predict the next line for this snippet: <|code_start|> def eol_search_query_for_single_name(name): # will replace later with either a pre-made package # or with an implementation of EoL in taxize response = ( Refactor( url="https://eol.org/api/search/1.0.json", request="get"...
return list(map(eol_taxa_query_for_single_PageID, list_of_ids))
Predict the next line after this snippet: <|code_start|> response = list(map(lambda x: {**x, "page_id": pid}, response)) return response def process_eol_search_response(name_response_tuple): user_input_name, list_of_response_dicts = name_response_tuple user_input_name = user_input_name.lower() extr...
"page_id": x.get("page_id", ""),
Here is a snippet: <|code_start|> dataset = data.DATASETS()[FLAGS.dataset]() log_width = utils.ilog2(dataset.width) model = CTAFSMixup( os.path.join(FLAGS.train_dir, dataset.name, CTAFSMixup.cta_name()), dataset, lr=FLAGS.lr, wd=FLAGS.wd, arch=FLAGS.arch, batch...
FLAGS.set_default('dataset', 'cifar10-1')
Given the code snippet: <|code_start|> def main(argv): utils.setup_main() del argv # Unused. dataset = data.DATASETS()[FLAGS.dataset]() log_width = utils.ilog2(dataset.width) model = CTAFSMixup( os.path.join(FLAGS.train_dir, dataset.name, CTAFSMixup.cta_name()), dataset, lr=...
flags.DEFINE_integer('scales', 0, 'Number of 2x2 downscalings in the classifier.')
Based on the snippet: <|code_start|> def main(argv): utils.setup_main() del argv # Unused. dataset = data.DATASETS()[FLAGS.dataset]() log_width = utils.ilog2(dataset.width) model = CTAFSMixup( os.path.join(FLAGS.train_dir, dataset.name, CTAFSMixup.cta_name()), dataset, lr=F...
flags.DEFINE_float('dropout', 0, 'Dropout on embedding layer.')
Given snippet: <|code_start|> utils.setup_main() del argv # Unused. dataset = data.PAIR_DATASETS()[FLAGS.dataset]() log_width = utils.ilog2(dataset.width) model = AB_FixMatch_Momentum( os.path.join(FLAGS.train_dir, dataset.name, AB_FixMatch_Momentum.cta_name()), dataset, lr=F...
flags.DEFINE_integer('scales', 0, 'Number of 2x2 downscalings in the classifier.')
Given the following code snippet before the placeholder: <|code_start|> model = AB_FixMatch_Momentum( os.path.join(FLAGS.train_dir, dataset.name, AB_FixMatch_Momentum.cta_name()), dataset, lr=FLAGS.lr, wd=FLAGS.wd, arch=FLAGS.arch, batch=FLAGS.batch, nclass=dat...
FLAGS.set_default('augment', 'd.d.d')
Predict the next line for this snippet: <|code_start|> post_ops.append(ema_op) train_op = tf.train.MomentumOptimizer(lr, 0.9, use_nesterov=True).minimize( loss_xe + wu * loss_xeu + wd * loss_wd, colocate_gradients_with_ops=True) with tf.control_dependencies([train_op]): t...
filters=FLAGS.filters,
Based on the snippet: <|code_start|>def main(argv): utils.setup_main() del argv # Unused. dataset = data.PAIR_DATASETS()[FLAGS.dataset]() log_width = utils.ilog2(dataset.width) model = FixMatch_RA( os.path.join(FLAGS.train_dir, dataset.name), dataset, lr=FLAGS.lr, wd...
flags.DEFINE_integer('uratio', 7, 'Unlabeled batch size ratio.')
Given the following code snippet before the placeholder: <|code_start|>sys.path.extend(['.', '..']) inf = float('inf') _logger = get_logger() class BDT(Basic): <|code_end|> , predict the next line using imports from the current file: import json import time import pdb import sys import Orange import orang...
def __init__(self, **kwargs):
Next line prediction: <|code_start|># Parser for the assembly language # # Luz micro-controller assembler # Eli Bendersky (C) 2008-2010 # ## ## The following 'classes' are the intermediate form into which ## the parser reads the assembly code. ## Number = namedtuple('Number', 'val') Id = namedtuple('Id', 'id') Str...
class AsmParser(object):
Next line prediction: <|code_start|># Simulates the CPU control registers # # Luz micro-controller simulator # Eli Bendersky (C) 2008-2010 # Maps memory addresses of registers to names # cregs_memory_map = { ADDR_EXCEPTION_VECTOR: 'exception_vector', ADDR_CONTROL_1: 'control_1', ADDR_EXCE...
}
Predict the next line for this snippet: <|code_start|># Simulates the CPU control registers # # Luz micro-controller simulator # Eli Bendersky (C) 2008-2010 # Maps memory addresses of registers to names # cregs_memory_map = { ADDR_EXCEPTION_VECTOR: 'exception_vector', ADDR_CONTROL_1: 'control...
}
Based on the snippet: <|code_start|># Simulates the CPU control registers # # Luz micro-controller simulator # Eli Bendersky (C) 2008-2010 # Maps memory addresses of registers to names # cregs_memory_map = { ADDR_EXCEPTION_VECTOR: 'exception_vector', ADDR_CONTROL_1: 'control_1', ADDR_EXCE...
}
Next line prediction: <|code_start|># Simulates the CPU control registers # # Luz micro-controller simulator # Eli Bendersky (C) 2008-2010 # Maps memory addresses of registers to names # cregs_memory_map = { ADDR_EXCEPTION_VECTOR: 'exception_vector', ADDR_CONTROL_1: 'control_1', ADDR_EXCE...
}
Given the following code snippet before the placeholder: <|code_start|># Simulates the memory unit of the CPU. Provides memory mapping # for both the user-memory area and the CPU internal registers # and peripherals. # # Luz micro-controller simulator # Eli Bendersky (C) 2008-2010 USER_MEMORY_END = USER_MEMORY_START +...
self.user_image = user_image
Next line prediction: <|code_start|># Simulates the memory unit of the CPU. Provides memory mapping # for both the user-memory area and the CPU internal registers # and peripherals. # # Luz micro-controller simulator # Eli Bendersky (C) 2008-2010 USER_MEMORY_END = USER_MEMORY_START + USER_MEMORY_SIZE # Error classes...
class MemoryUnit(object):
Based on the snippet: <|code_start|># Assembler - main class # # Input: a single assembly source file # Output: an object file with the assembled source and other # linkage information (relocation table, list of unresolved # and exported labels). # # Luz micro-controller assembler # Eli Bendersky (C) 2008-2010 # ...
def __init__(self):
Using the snippet: <|code_start|># Assembler - main class # # Input: a single assembly source file # Output: an object file with the assembled source and other # linkage information (relocation table, list of unresolved # and exported labels). # # Luz micro-controller assembler # Eli Bendersky (C) 2008-2010 # cl...
def assemble(self, str=None, filename=None):
Here is a snippet: <|code_start|># Assembler - main class # # Input: a single assembly source file # Output: an object file with the assembled source and other # linkage information (relocation table, list of unresolved # and exported labels). # # Luz micro-controller assembler # Eli Bendersky (C) 2008-2010 # cl...
def assemble(self, str=None, filename=None):
Based on the snippet: <|code_start|># Assembler - main class # # Input: a single assembly source file # Output: an object file with the assembled source and other # linkage information (relocation table, list of unresolved # and exported labels). # # Luz micro-controller assembler # Eli Bendersky (C) 2008-2010 # ...
def assemble(self, str=None, filename=None):
Given the following code snippet before the placeholder: <|code_start|># Assembler - main class # # Input: a single assembly source file # Output: an object file with the assembled source and other # linkage information (relocation table, list of unresolved # and exported labels). # # Luz micro-controller assembler # E...
def __init__(self):
Predict the next line for this snippet: <|code_start|># Assembler - main class # # Input: a single assembly source file # Output: an object file with the assembled source and other # linkage information (relocation table, list of unresolved # and exported labels). # # Luz micro-controller assembler # Eli Bendersky (C) ...
def assemble(self, str=None, filename=None):
Here is a snippet: <|code_start|># Assembler - main class # # Input: a single assembly source file # Output: an object file with the assembled source and other # linkage information (relocation table, list of unresolved # and exported labels). # # Luz micro-controller assembler # Eli Bendersky (C) 2008-2010 # cl...
def __init__(self):
Given snippet: <|code_start|># Assembler - main class # # Input: a single assembly source file # Output: an object file with the assembled source and other # linkage information (relocation table, list of unresolved # and exported labels). # # Luz micro-controller assembler # Eli Bendersky (C) 2008-2010 # class ...
def __init__(self):
Continue the code snippet: <|code_start|># Assembler - main class # # Input: a single assembly source file # Output: an object file with the assembled source and other # linkage information (relocation table, list of unresolved # and exported labels). # # Luz micro-controller assembler # Eli Bendersky (C) 2008-2010 # ...
def assemble(self, str=None, filename=None):
Given snippet: <|code_start|># Assembler - main class # # Input: a single assembly source file # Output: an object file with the assembled source and other # linkage information (relocation table, list of unresolved # and exported labels). # # Luz micro-controller assembler # Eli Bendersky (C) 2008-2010 # class ...
def __init__(self):
Predict the next line for this snippet: <|code_start|> room: str mail: str mail_forwarded: bool mail_confirmed: bool properties: List[str] traffic_history: List[TrafficHistoryEntry] interfaces: List[Interface] finance_balance: Decimal finance_history: List[FinanceHistoryEntry] las...
id: int
Next line prediction: <|code_start|> DataRequired(lazy_gettext("Betreff muss angegeben werden!"))]) message = TextAreaField(label=lazy_gettext("Nachricht"), validators=[ DataRequired(lazy_gettext("Nachricht fehlt!")) ]) class OfficialContactForm(SpamProtectedForm): email = EmailField(label=...
])
Predict the next line after this snippet: <|code_start|> "https://api.github.com/repos/{}/{}/zipball/{}".format( user, repo_name, tag ), ) self.assertEqual(repr(release), 'GitRelease(title="Test")') def testGetRelease(self): release_by_id = self.releas...
self.setUpNewRelease()
Given snippet: <|code_start|> try: message.delete() except BadRequest as excp: if excp.message == "Message to delete not found": pass else: LOGGER.exception("Error deleting message in log channel. Should work ...
message = update.effective_message # type: Optional[Message]
Continue the code snippet: <|code_start|> @unique class Types(IntEnum): TEXT = 0 BUTTON_TEXT = 1 STICKER = 2 DOCUMENT = 3 PHOTO = 4 AUDIO = 5 VOICE = 6 VIDEO = 7 def get_note_type(msg: Message): data_type = None content = None text = "" raw_text = msg.text or msg.capti...
else:
Using the snippet: <|code_start|>__all__ = ["BaseResolver", "Resolver", "VersionedResolver"] # fmt: off # resolvers consist of # - a list of applicable version # - a tag # - a regexp # - a list of first characters to match implicit_resolvers = [ ([(1, 2)], u'tag:yaml.org,2002:bool', RegExp(u'''^(?...
u'tag:yaml.org,2002:float',
Using the snippet: <|code_start|> RegExp(u'''^(?:[-+]?0b[0-1_]+ |[-+]?0o?[0-7_]+ |[-+]?[0-9_]+ |[-+]?0x[0-9a-fA-F_]+)$''', re.X), list(u'-+0123456789')), ([(1, 1)], u'tag:yaml.org,2002:int', RegExp(u'''^(?:[-+]?0b[0-1_]+ |[-+]?0?[0-7_]+ |[-+]?(?...
list(u'0123456789')),
Given the code snippet: <|code_start|> |[-+]?\\.[0-9_]+(?:[eE][-+][0-9]+)? |[-+]?\\.(?:inf|Inf|INF) |\\.(?:nan|NaN|NAN))$''', re.X), list(u'-+0123456789.')), ([(1, 1)], u'tag:yaml.org,2002:float', RegExp(u'''^(?: [-+]?(?:[0-9][0-9_]*)\\.[0-9_]*(?:[eE][-+]?[0-9...
u'tag:yaml.org,2002:merge',
Given the code snippet: <|code_start|> RegExp(u'''^(?:[0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9] |[0-9][0-9][0-9][0-9] -[0-9][0-9]? -[0-9][0-9]? (?:[Tt]|[ \\t]+)[0-9][0-9]? :[0-9][0-9] :[0-9][0-9] (?:\\.[0-9]*)? (?:[ \\t]*(?:Z|[-+][0-9][0-9]?(?::[0-9][0-9])?))?)$''', re.X), ...
yaml_implicit_resolvers = {} # type: Dict[Any, Any]
Given the following code snippet before the placeholder: <|code_start|> |[-+]?0x[0-9a-fA-F_]+ |[-+]?[1-9][0-9_]*(?::[0-5]?[0-9])+)$''', re.X), # sexagesimal int list(u'-+0123456789')), ([(1, 2), (1, 1)], u'tag:yaml.org,2002:merge', RegExp(u'^(?:<<)$'), [u'<']), ([...
list(u'!&*')),
Continue the code snippet: <|code_start|> RegExp(u'''^(?:true|True|TRUE|false|False|FALSE)$''', re.X), list(u'tTfF')), ([(1, 1)], u'tag:yaml.org,2002:bool', RegExp(u'''^(?:y|Y|yes|Yes|YES|n|N|no|No|NO |true|True|TRUE|false|False|FALSE |on|On|ON|off|Off|OFF)$''', re.X),...
|[-+]?0o?[0-7_]+
Predict the next line after this snippet: <|code_start|> # type: (Any) -> Any x = type(self)(self + a) x._width = self._width # type: ignore x._underscore = ( # type: ignore self._underscore[:] if self._underscore is not None else None # type: ignore ) # NOQA ...
x._underscore = ( # type: ignore
Based on the snippet: <|code_start|> @property def anchor(self): # type: () -> Any if not hasattr(self, Anchor.attrib): setattr(self, Anchor.attrib, Anchor()) return getattr(self, Anchor.attrib) def yaml_anchor(self, any=False): # type: (bool) -> Any if n...
class OctalInt(ScalarInt):
Predict the next line after this snippet: <|code_start|># SCALAR(value, plain, style) # # RoundTripScanner # COMMENT(value) # # Read comments in the Scanner code for more details. # if False: # MYPY __all__ = ["Scanner", "RoundTripScanner", "ScannerError"] _THE_END = "\n\0\r\x85\u2028\u2029" _THE_END_SPACE_TAB = ...
self.index = index
Predict the next line after this snippet: <|code_start|># # RoundTripScanner # COMMENT(value) # # Read comments in the Scanner code for more details. # if False: # MYPY __all__ = ["Scanner", "RoundTripScanner", "ScannerError"] _THE_END = "\n\0\r\x85\u2028\u2029" _THE_END_SPACE_TAB = " \n\0\t\r\x85\u2028\u2029" _S...
self.line = line
Given the following code snippet before the placeholder: <|code_start|># if False: # MYPY __all__ = ["Scanner", "RoundTripScanner", "ScannerError"] _THE_END = "\n\0\r\x85\u2028\u2029" _THE_END_SPACE_TAB = " \n\0\t\r\x85\u2028\u2029" _SPACE_TAB = " \t" class ScannerError(MarkedYAMLError): pass class Simple...
class Scanner(object):
Continue the code snippet: <|code_start|># SCALAR(value, plain, style) # # RoundTripScanner # COMMENT(value) # # Read comments in the Scanner code for more details. # if False: # MYPY __all__ = ["Scanner", "RoundTripScanner", "ScannerError"] _THE_END = "\n\0\r\x85\u2028\u2029" _THE_END_SPACE_TAB = " \n\0\t\r\x85\...
self.index = index
Given the following code snippet before the placeholder: <|code_start|> self.name = getattr(self.stream, "name", "<file>") self.eof = False self.raw_buffer = None self.determine_encoding() def peek(self, index=0): # type: (int) -> Text try: ...
self.line += 1
Given snippet: <|code_start|> self.determine_encoding() def peek(self, index=0): # type: (int) -> Text try: return self.buffer[self.pointer + index] except IndexError: self.update(index + 1) return self.buffer[self.pointer + index] def pre...
self.column += 1
Predict the next line for this snippet: <|code_start|># reader.forward(length=1) - move the current position to `length` # characters. # reader.index - the number of the current character. # reader.line, stream.column - the line and the column of the current # character. if False: # MYPY # from s...
self.encoding,
Next line prediction: <|code_start|> self.name, self.index, self.line, self.column, self.buffer, self.pointer ) else: return FileMark(self.name, self.index, self.line, self.column) def determine_encoding(self): # type: () -> None while not self.eof and...
u"\U00010000-\U0010FFFF"
Next line prediction: <|code_start|> # type: () -> None self.name = None # type: Any self.stream_pointer = 0 self.eof = True self.buffer = "" self.pointer = 0 self.raw_buffer = None # type: Any self.raw_decode = None self.encoding = None # type: ...
self.buffer = val + u"\0" # type: ignore
Here is a snippet: <|code_start|> class Reader(object): # Reader: # - determines the data encoding and converts it to a unicode string, # - checks if characters are in allowed range, # - adds '\0' to the end. # Reader accepts # - a `str` object (PY2) / a `bytes` object (PY3), # - a `unic...
self.pointer = 0
Next line prediction: <|code_start|> if self.pointer + length + 1 >= len(self.buffer): self.update(length + 1) while length != 0: ch = self.buffer[self.pointer] self.pointer += 1 self.index += 1 if ch in u"\n\x85\u2028\u2029" or ( ...
def get_mark(self):
Given the code snippet: <|code_start|> self.pointer += 1 self.index += 1 if ch in u"\n\x85\u2028\u2029" or ( ch == u"\r" and self.buffer[self.pointer] != u"\n" ): self.line += 1 self.column = 0 elif ch != u"\uFEFF...
self.name, self.index, self.line, self.column, self.buffer, self.pointer
Using the snippet: <|code_start|> elif ch != u"\uFEFF": self.column += 1 length -= 1 def forward(self, length=1): # type: (int) -> None if self.pointer + length + 1 >= len(self.buffer): self.update(length + 1) while length != 0: ...
while not self.eof and (self.raw_buffer is None or len(self.raw_buffer) < 2):
Given snippet: <|code_start|> def expect_flow_sequence_item(self): # type: () -> None if isinstance(self.event, SequenceEndEvent): self.indent = self.indents.pop() popped = self.flow_context.pop() assert popped == "[" if self.canonical: ...
single
Next line prediction: <|code_start|> self.allow_space_break = None # Emitter is a state machine with a stack of states to handle nested # structures. self.states = [] # type: List[Any] self.state = self.expect_stream_start # type: Any # Current event and the event queu...
self.line = 0
Using the snippet: <|code_start|> allow_block_plain=allow_block_plain, allow_single_quoted=allow_single_quoted, allow_double_quoted=allow_double_quoted, allow_block=allow_block, ) # Writers. def flush_stream(self): # type: () -> None if ha...
data = u" " + indicator
Given the code snippet: <|code_start|> start = end + 1 if ( 0 < end < len(text) - 1 and (ch == u" " or start >= end) and self.column + (end - start) > self.best_width and split ): data = text[start...
hints = u""
Given the following code snippet before the placeholder: <|code_start|> flow_indicators = True block_indicators = True if ch in u"?:": # ToDo if self.serializer.use_version == (1, 1): flow_indicators = True ...
if (
Predict the next line after this snippet: <|code_start|> start = end if ch is not None: spaces = ch == u" " breaks = ch in u"\n\x85\u2028\u2029" end += 1 def write_comment(self, comment, pre=False): # type: (Any, bool) -> None ...
value = " " * nr_spaces + value
Given snippet: <|code_start|> self.write_indent() else: data = text[start:end] self.column += len(data) if bool(self.encoding): data = data.encode(self.encoding) ...
end += 1
Continue the code snippet: <|code_start|> def write_version_directive(self, version_text): # type: (Any) -> None data = u"%%YAML %s" % version_text if self.encoding: data = data.encode(self.encoding) self.stream.write(data) self.write_line_break() def write_ta...
ch = None
Given the code snippet: <|code_start|> self.state = self.expect_document_start else: raise EmitterError("expected DocumentEndEvent, but got %s" % (self.event,)) def expect_document_root(self): # type: () -> None self.states.append(self.expect_document_end) sel...
):
Predict the next line after this snippet: <|code_start|> start += 5 break tail = "" end = self.pointer while ( end < len(self.buffer) and self.buffer[end] not in u"\0\r\n\x85\u2028\u2029" ): end += 1 if end - self.pointer...
self.line + 1,
Based on the snippet: <|code_start|> def __new__(cls, value, anchor=None): # type: (Text, Any) -> Any return ScalarString.__new__(cls, value, anchor=anchor) class DoubleQuotedScalarString(ScalarString): __slots__ = () style = '"' def __new__(cls, value, anchor=None): # type: (...
def walk_tree(base, map=None):
Given snippet: <|code_start|> return type(self)((text_type.replace(self, old, new, maxreplace))) @property def anchor(self): # type: () -> Any if not hasattr(self, Anchor.attrib): setattr(self, Anchor.attrib, Anchor()) return getattr(self, Anchor.attrib) def yaml...
return ScalarString.__new__(cls, value, anchor=anchor)
Using the snippet: <|code_start|> # type: () -> Any if not hasattr(self, Anchor.attrib): setattr(self, Anchor.attrib, Anchor()) return getattr(self, Anchor.attrib) def yaml_anchor(self, any=False): # type: (bool) -> Any if not hasattr(self, Anchor.attrib): ...
self._e_sign, # type: ignore
Predict the next line for this snippet: <|code_start|> self.end_mark = end_mark self.comment = comment self.anchor = anchor def __repr__(self): # type: () -> str value = self.value # if isinstance(value, list): # if len(value) == 0: # value...
if self.comment:
Next line prediction: <|code_start|> # to distinguish key from None def NoComment(): # type: () -> None pass class Format(object): __slots__ = ("_flow_style",) attrib = format_attrib def __init__(self): # type: () -> None self._flow_style = None # type: Any def set_flow_styl...
return default
Next line prediction: <|code_start|> def __init__(self): # type: () -> None self._flow_style = None # type: Any def set_flow_style(self): # type: () -> None self._flow_style = True def set_block_style(self): # type: () -> None self._flow_style = False d...
self.data = None # type: Optional[Dict[Any, Any]]
Given the following code snippet before the placeholder: <|code_start|> if self._flow_style is None: return default return self._flow_style class LineCol(object): attrib = line_col_attrib def __init__(self): # type: () -> None self.line = None self.col = Non...
if self.data is None:
Here is a snippet: <|code_start|>class Format(object): __slots__ = ("_flow_style",) attrib = format_attrib def __init__(self): # type: () -> None self._flow_style = None # type: Any def set_flow_style(self): # type: () -> None self._flow_style = True def set_block...
def __init__(self):
Given the following code snippet before the placeholder: <|code_start|> def __init__(self): # type: () -> None self.line = None self.col = None self.data = None # type: Optional[Dict[Any, Any]] def add_kv_line_col(self, key, data): # type: (Any, Any) -> None if s...
return None
Based on the snippet: <|code_start|> """if default (the flow_style) is None, the flow style tacked on to the object explicitly will be taken. If that is None as well the default flow style rules the format down the line, or the type of the constituent values (simple -> flow, map/list -> b...
return self._kv(k, 2, 3)
Predict the next line after this snippet: <|code_start|> class OrganizationTestCase(TestCase): def test_str(self): organization = Organization(name='My organization') <|code_end|> using the current file's imports: from django.test import TestCase from depot.models import Depot, Item, Organization and a...
self.assertEqual(organization.__str__(), 'My organization')
Predict the next line for this snippet: <|code_start|> class LoginTestCase(ClientTestCase): def test_login_form(self): response = self.as_guest.get('/login/') self.assertSuccess(response, 'login/login.html') def test_login_with_correct_password(self): response = self.as_guest.post('/l...
response = self.as_guest.post('/login/', {