Instruction
stringlengths
362
7.83k
output_code
stringlengths
1
945
Given the code snippet: <|code_start|> joint_coord = joint_coord.astype(int) cv2.circle(disp_img, tuple(joint_coord), radius=3, color=[255,0,0], thickness = 10) if pred is not None: if correct[i]: color=[0,255,0] else: ...
fr = int(name.split('/')[-1].split('.')[-2])
Next line prediction: <|code_start|> # upsampling flow = torch.squeeze(flow).data.cpu().numpy() flow = np.concatenate( [cv2.resize(flow[0],(input_size[1],input_size[0]))[:,:,np.newaxis], cv2.resize(flow[1],(input_size[1],input_size[0]))[:,:,np.newaxis]],-1) flow[:,:,0] *= imgL...
disp_img = rgb_img.copy()
Given the following code snippet before the placeholder: <|code_start|> size = 150 else: size = len(all_anno) for i in range(size): if args.append_render=='no':break # render flow between mesh 1 and 2 if args.freeze: print(i) refimg = all_anno[0][0]...
refmesh = all_mesh[i]
Given snippet: <|code_start|> elif os.path.exists(file_name): print ("BADJA SEGMENTATION file path: {0} is missing".format(seg_name)) else: print ("BADJA IMAGE file path: {0} is missing".format(file_name)) ...
rgb_h, rgb_w, _ = rgb_img.shape
Given the code snippet: <|code_start|>#from IPython import embed class DistModel(BaseModel): def name(self): return self.model_name <|code_end|> , generate the next line using the imports in this file: import numpy as np import torch import os import os.path as osp import itertools import fractions impor...
def initialize(self, model='net-lin', net='alex', model_path=None, colorspace='Lab', use_gpu=True, printNet=False, spatial=False, spatial_shape=None, spatial_order=1, spatial_factor=None, is_train=False, lr=.0001, beta1=0.5):
Here is a snippet: <|code_start|> def optimize_parameters(self): pass def get_current_visuals(self): return self.input def get_current_errors(self): return {} def save(self, label): pass # helper saving function that can be used by subclasses def save_network(...
def get_image_paths(self):
Given the code snippet: <|code_start|>@user_passes_test(lambda u: u.is_superuser) def script_runner_index(request): munger_builder_list = MungerBuilder.objects.order_by('id') context = {'munger_builder_list': munger_builder_list} return render(request, 'script_runner/script_runner_index.html', context) @us...
context = {'script_string': highlighted, 'mb_id': munger_builder_id}
Using the snippet: <|code_start|> INDEX_REDIRECT = HttpResponseRedirect('/script_builder/munger_builder_index') @user_passes_test(lambda u: u.is_superuser) def script_runner_index(request): munger_builder_list = MungerBuilder.objects.order_by('id') context = {'munger_builder_list': munger_builder_list} re...
print(mb.munger_template)
Here is a snippet: <|code_start|> INDEX_REDIRECT = HttpResponseRedirect('/script_builder/munger_builder_index') @user_passes_test(lambda u: u.is_superuser) def script_runner_index(request): munger_builder_list = MungerBuilder.objects.order_by('id') context = {'munger_builder_list': munger_builder_list} ...
return StreamingHttpResponse(
Next line prediction: <|code_start|> logger = get_task_logger(__name__) @shared_task def run_munger(munger_builder_id=1): <|code_end|> . Use current file imports: (import os import scripts.run_munger import scripts.build_munger from django.http import HttpResponse from django.conf import settings from celery impo...
return [log_entry for log_entry in scripts.run_munger.main(munger_builder_id)]
Next line prediction: <|code_start|> sys.path.append(os.path.dirname(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))) def main(munger_builder_id=1): mb = MungerBuilder.objects.get(pk=munger_builder_id) jinja_env = Environment(trim_blocks=True, lstrip_blocks=True, loader=PackageLoader('s...
)
Predict the next line after this snippet: <|code_start|> # Read data from singups with orders CSV from Looker and load into pandas DataFrame # input_file = glob(os.path.abspath(mb.input_path))[0] input_file = os.path.join(settings.BASE_DIR, 'static', mb.input_path) print_run_status(run_start_time, 'Read...
)
Given the code snippet: <|code_start|>class MungerBuilderAPIView(MungerPermissions, mixins.CreateModelMixin, mixins.RetrieveModelMixin, mixins.UpdateModelMixin, mixins.DestroyModelMixin, ...
return self.destroy(request, *args, **kwargs)
Given snippet: <|code_start|> return self.create(request, *args, **kwargs) else: error_string = 'Cannot Create more {} - Delete some to make space'.format( self.__class__.__name__ ) return Response(error_string, status=status.HTTP_403_FORBIDDEN) ...
USER_OBJECT_LIMIT = 10
Predict the next line for this snippet: <|code_start|> if 'pk' in kwargs: return self.retrieve(request, *args, **kwargs) else: return self.list(request, *args, **kwargs) def put(self, request, *args, **kwargs): return self.update(request, *args, **kwargs) def pos...
filter_backends = (filters.DjangoObjectPermissionsFilter,)
Given the code snippet: <|code_start|> if request.method == 'POST': user_form = UserRegistrationForm(data=request.POST) # If the two forms are valid... if user_form.is_valid(): new_user = user_form.save() assign_perm('script_builder.add_mungerbuilder', new_user) ...
else:
Next line prediction: <|code_start|> class MungerTestCase(TestCase): def setUp(self): self.field_type_dict = { 'column': 'column', 'index': 'index', 'count': 'len', 'sum': 'np.sum', 'mean': 'np.mean', 'median': 'np.median', } ...
test_field_dict = {
Continue the code snippet: <|code_start|> class MungerTestCase(TestCase): def setUp(self): self.field_type_dict = { 'column': 'column', 'index': 'index', 'count': 'len', 'sum': 'np.sum', 'mean': 'np.mean', 'median': 'np.median', ...
)
Predict the next line for this snippet: <|code_start|> class MungerTestCase(TestCase): def setUp(self): self.field_type_dict = { 'column': 'column', 'index': 'index', 'count': 'len', 'sum': 'np.sum', 'mean': 'np.mean', 'median': 'np.me...
'region': ['column'],
Based on the snippet: <|code_start|> input_dir = os.path.dirname(self.input_path) return os.path.join(input_dir, '{0}-output.csv'.format(self.safe_file_name)) def __str__(self): return self.munger_name class DataField(models.Model, PermissionedModel): class Meta: permis...
return self.new_name and self.new_name != self.current_name
Predict the next line for this snippet: <|code_start|>def main(): """ Generate the organization enum """ print datetime.now(), "Start" parms = get_parms() # Organization query = """ SELECT (MIN (?xlabel) AS ?short) ?vivo WHERE { ?vivo rdf:type foaf:Organization . ...
}
Continue the code snippet: <|code_start|>#!/usr/bin/env/python """ make_enum.py -- make enumerations for orgs """ __author__ = "Michael Conlon" __copyright__ = "Copyright 2017 (c) Michael Conlon" __license__ = "BSD 3-Clause license" __version__ = "0.2" def main(): """ Generate the organization enum ...
{
Continue the code snippet: <|code_start|> 2. pubs in the source keyed by doi There are three cases - pub in VIVO and in source => add to update data with uri - pub in VIVO, not in source => nothing to do - pub not in VIVO, is in source => Add to update data with blank uri (to be assigned during upda...
?uri a vivo:InformationResource .
Next line prediction: <|code_start|> There are two inputs: 1. pubs in VIVO keyed by doi 2. pubs in the source keyed by doi There are three cases - pub in VIVO and in source => add to update data with uri - pub in VIVO, not in source => nothing to do - pub not in VIVO, is in source => Add to update ...
SELECT
Based on the snippet: <|code_start|>There are three cases - pub in VIVO and in source => add to update data with uri - pub in VIVO, not in source => nothing to do - pub not in VIVO, is in source => Add to update data with blank uri (to be assigned during update) """ __author__ = "Michael Conlon" __copy...
}
Predict the next line for this snippet: <|code_start|> There are three cases - pub in VIVO and in source => add to update data with uri - pub in VIVO, not in source => nothing to do - pub not in VIVO, is in source => Add to update data with blank uri (to be assigned during update) """ __author__ = "Mic...
?uri bibo:doi ?doi .
Given the code snippet: <|code_start|> SELECT (MIN (?xshort) AS ?short) ?vivo WHERE { ?vivo vivo:orcidId ?xshort . } GROUP BY ?vivo ORDER BY ?short """ create_enum("orcid_enum.txt", query, parms) # journals via issn query = """ SELECT (MIN (?xlabel) AS ?short) ?...
WHERE
Next line prediction: <|code_start|>def main(): """ Generate the enums for publications """ print datetime.now(), "Start" parms = get_parms() # person via Orcid query = """ SELECT (MIN (?xshort) AS ?short) ?vivo WHERE { ?vivo vivo:orcidId ?xshort . } GROUP B...
GROUP BY ?vivo
Here is a snippet: <|code_start|> try: except ImportError: # pragma: noqa _session_factory = None def _column_keys(query): return [(column.primary_key, column.key) for column in query._primary_entity.entity_zero.columns] @add_metaclass(abc.ABCMeta) <|code_end|> . Write the next line using the current file ...
class SQLResource(object):
Based on the snippet: <|code_start|> class ViewWriter(object): def __init__(self, view): self._view_lock = threading.Lock() self._newline = True self.view = view def set_view(self, view): with self._view_lock: self.view = view self._newline = ...
text = text.replace("\n", "\n%s" % timestamp, newlines)
Predict the next line for this snippet: <|code_start|>#!/usr/bin/env python """Generates a response""" # Semantics constants KNOWN_ACTIONS = set(ACTION_ALIASES.values()) # Response constants DUNNO = "Sorry, I don't know how to%s." GOTIT = "Got it. I'll%s." MISUNDERSTAND = "Sorry, I didn't understand that at all." d...
good_commands.append(c)
Using the snippet: <|code_start|> if self.type == 'all': return self.type if self.number == 0: return 'no' if self.number == 1: return 'the' else: return str(self.number) else: if self.numb...
def merge(self, other):
Predict the next line after this snippet: <|code_start|> if cd != None: self.number = cd if cd.isdigit() else text2int(cd) def readable(self): if self.definite: if self.type == 'all': return self.type if self.number == 0: return 'no...
def fill_cardinal(self, cd):
Based on the snippet: <|code_start|> Fiducial.TYPE_HOSTAGE: "icon-hostage", Fiducial.TYPE_BADGUY: "icon-badguy", Fiducial.TYPE_USER1: "icon-user1", Fiducial.TYPE_USER2: "icon-user2"} def SerializeAction(event, argument): """Serialize an action message.""" validAc...
new_obj['data'] = dict()
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; without ...
response = self.query(structure)
Given the code snippet: <|code_start|> return '\n'.join(responses) return None def fill_commands(self, commands): """Fills in underspecified fields based on current knowledge""" for c in commands: if isinstance(c, Command): if self.last_object:...
if c.theme:
Here is a snippet: <|code_start|> def query(self, query): """"Override this in subclasses""" return None def assimilate(self, assertion, source): """Override this in subclasses""" pass class MapFact(Fact): """Spatial map of the environment""" def __init__(self): ...
return None
Here is a snippet: <|code_start|> def __init__(self): pass def query(self, query): """"Override this in subclasses""" return None def assimilate(self, assertion, source): """Override this in subclasses""" pass class MapFact(Fact): """Spatial map of the environme...
if location in self.env_map:
Given the code snippet: <|code_start|> | rp(lam, unit='kev') : Returns real part (unit='kev'|'angs') | ip(lam, unit='kev') : Returns imaginary part (always 0.0) | cm(lam, unit='kev') : Complex index of refraction of dtype='complex' | plot(lam, unit='kev') : Plots Re(m-1) """ def __init__(self, rh...
if np.size(lam) > 1:
Using the snippet: <|code_start|># coding=utf-8 # Copyright 2022 The Meta-Dataset Authors. # # 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 #...
dataset_spec.
Given the code snippet: <|code_start|> def totalize(self, discount=Decimal(0), surcharge=Decimal(0), taxcode=TaxType.NONE): log.info('totalize(discount=%r, surcharge=%r, taxcode=%r)' % ( discount, surcharge, taxcode)) if discount and surcharge: raise TypeErro...
retval = self._driver.coupon_cancel()
Given snippet: <|code_start|> try: self.setup() self._setup_complete = True except Exception: log.error(''.join(traceback.format_exception(*sys.exc_info()))) self._setup_complete = False def setup_complete(self): return self._setup_complete ...
def coupon_is_customer_identified(self):
Based on the snippet: <|code_start|> if discount and surcharge: raise TypeError("discount and surcharge can not be used together") if surcharge and taxcode == TaxType.NONE: raise ValueError("to specify a surcharge you need specify its " "tax code") ...
return retval
Given the code snippet: <|code_start|> 'customer_address=%r, customer_id=%r)' % ( customer_name, customer_address, customer_id)) self._driver.coupon_identify_customer( self._format_text(customer_name), self._format_text(customer_address), ...
if self._has_been_totalized:
Based on the snippet: <|code_start|># USA. # # Author(s): Johan Dahlin <jdahlin@async.com.br> # Henrique Romano <henrique@async.com.br> # _ = stoqdrivers_gettext log = logging.getLogger('stoqdrivers.fiscalprinter') # # FiscalPrinter interface # class FiscalPrinter(BasePrinter): def __init...
except Exception:
Given 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 GNU ...
**kwargs)
Next line prediction: <|code_start|> raise AlreadyTotalized("the coupon is already totalized, you " "can't add more items") if discount and surcharge: raise TypeError("discount and surcharge can not be used together") elif unit != UnitType.CUSTOM...
if discount and surcharge:
Next line prediction: <|code_start|> if surcharge < 0: raise ValueError('Surcharge cannot be negative') if discount < 0: raise ValueError('Discount cannot be negative') return self._driver.coupon_add_item( self._format_text(item_code), self._format_text(item_...
if not self._has_been_totalized:
Next line prediction: <|code_start|> items_quantity=Decimal("1.0"), unit=UnitType.EMPTY, discount=Decimal("0.0"), surcharge=Decimal("0.0"), unit_desc=""): log.info("add_item(code=%r, description=%r, price=%r, " "taxcode=%r, quantity=%r, unit=%r,...
return self._driver.coupon_add_item(
Predict the next line after this snippet: <|code_start|>## (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 PURPOSE. See the ## GNU General Public Li...
def setDTR(self, value):
Continue the code snippet: <|code_start|> class EthernetPort: def __init__(self, address, port): self.address = address self.port = port self._get_or_create_connection() def _get_or_create_connection(self): self.device = active_device or self._create_connection() def _creat...
self._create_connection()
Given the code snippet: <|code_start|> def fileno(self): return self._port.fileno() def writeline(self, data): self.write(self.CMD_PREFIX + data + self.CMD_SUFFIX) return self.readline() def write(self, data): # pyserial is expecting bytes but we work with str in stoqdriver...
a += 1
Next line prediction: <|code_start|> def _get_or_create_connection(self): self.device = active_device or self._create_connection() def _create_connection(self): global active_device try: active_device = self.device = socket.create_connection( (self.address, se...
except (ConnectionResetError, socket.timeout):
Predict the next line for this snippet: <|code_start|> # Most serial printers allow connecting a cash drawer to them. You can then # open the drawer, and also check its status. Some models, for instance, # the Radiant drawers, use inverted logic to describe whether they are # open, specified by this attr...
data = self._port.read(n_bytes)
Here is a snippet: <|code_start|> def __init__(self, device, baudrate=9600): # WARNING: Never change these default options, some drivers are based # on this to work. Maybe we should change this and make all the driver # specify its options, but right now I think that's ok, since these ...
active_device = self.device = socket.create_connection(
Given snippet: <|code_start|> start = 0 for tag in re.finditer(b'<\w+>', data): # Text before the tag text = data[start: tag.start()] if text: self._driver.print_inline(text) start = tag.end() tag = tag.group()[1:-1].decode() #...
else:
Based on the snippet: <|code_start|> 'cp863': ESC + '\x74\x04', # Canadian-French 'cp865': ESC + '\x74\x05', # Nordic 'latin1': ESC + '\x74\x06', # Simplified Kanji, Hirakana 'cp737': ESC + '\x74\x07', # Simplified Kanji 'cp862': ESC + '\x74\x08', # Simplified Kanji '...
GRAPHICS_CMD = {
Predict the next line for this snippet: <|code_start|> # Based on python-escpos's escpos.escpos.Escpos: # # https://github.com/python-escpos/python-escpos/blob/master/src/escpos/escpos.py ESC = '\x1b' # Escape GS = '\x1d' # Group Separator class EscPosMixin(object): FONT_REGULAR = ESC + 'M0' FONT_CONDENSE...
BARCODE_FONT_CONDENSED = GS + 'f' + '\x01' # Font Condensed for HRI barcode chars
Continue the code snippet: <|code_start|>## the Free Software Foundation; either version 2 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...
TXT_BOLD_ON = ESC + 'E\x01' # Bold font ON
Given the following code snippet before the placeholder: <|code_start|> LINE_FEED = '\x0a' LINE_FEED_RESET = ESC + '2' LINE_FEED_SET = ESC + '3' BARCODE_HEIGHT = GS + 'h' # Barcode Height [1-255] BARCODE_WIDTH = GS + 'w' # Barcode Width [2-6] BARCODE_FONT_REGULAR = GS + 'f' + '\x00' # Font ...
'cp852': ESC + '\x74\x13', # Latin 2
Using the snippet: <|code_start|>class DR700(SerialBase): supported = True model_name = "Daruma DR 700" max_characters = 57 def __init__(self, port, consts=None): SerialBase.__init__(self, port) self.set_condensed() self.descentralize() self.unset_bold() self.u...
self.write(NORMAL_MODE)
Given the following code snippet before the placeholder: <|code_start|> def unset_bold(self): self.write(UNSET_BOLD) def set_condensed(self): self.write(CONDENSED_MODE) def unset_condensed(self): self.write(NORMAL_MODE) def set_double_height(self): self.write(DOUBLE_HEI...
def print_qrcode(self, code):
Predict the next line after this snippet: <|code_start|>class Package: SIZE = 22 def __init__(self, raw_data): self.code = None self.price_per_kg = None self.total_price = None self.weight = None self._parse(raw_data) def _parse(self, data): if not data: ...
self._package = None
Using the snippet: <|code_start|> model_name = "Micheletti P15" def __init__(self, device, consts=None): SerialBase.__init__(self, device) self._package = None def _get_package(self): # PESO, PRECO, TOTAL # b'\x02 0800 99999 79999\x03' reply = self.writeline('') ...
print("PRICE BY KG:", data.price_per_kg)
Continue the code snippet: <|code_start|> @implementer(IScale) class MicP15(SerialBase): CMD_PREFIX = "\x05" EOL_DELIMIT = chr(ETX) model_name = "Micheletti P15" def __init__(self, device, consts=None): SerialBase.__init__(self, device) self._package = None def _get_package(self):...
if __name__ == "__main__":
Using the snippet: <|code_start|> self.price_per_kg = None self.total_price = None self.weight = None self._parse(raw_data) def _parse(self, data): if not data: return elif ord(data[0]) != STX or len(data) != self.SIZE: raise InvalidReply("Rece...
reply = self.writeline('')
Based on the snippet: <|code_start|> def __init__(self, device, consts=None): SerialBase.__init__(self, device) self._package = None def _get_package(self): # PESO, PRECO, TOTAL # b'\x02 0800 99999 79999\x03' reply = self.writeline('') # The sum is just becaus...
print("CODE:", data.code)
Based on the snippet: <|code_start|># # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, # USA. # # Author(s): Johan Dahlin <jdahlin@async.com.br> # def...
action="store",
Based on the snippet: <|code_start|># You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, # USA. # # Author(s): Johan Dahlin <jdahlin@async.com.br> # def m...
dest="port",
Given the following code snippet before the placeholder: <|code_start|>## Copyright (C) 2016 Stoq Tecnologia <http://stoq.link> ## All rights reserved ## ## 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 F...
class UsbBase(object):
Given the following code snippet before the placeholder: <|code_start|># Author(s): Henrique Romano <henrique@async.com.br> # @implementer(IBarcodeReader) class BaseBarcodeReader(SerialBase): # Should be defined in subclasses model_name = None def __init__(self, port, consts=None): SerialBa...
raise TypeError("The driver %s %s doesn't implements a "
Given the following code snippet before the placeholder: <|code_start|># it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # bu...
return self.readline()
Next line prediction: <|code_start|>## Copyright (C) 2016 Async Open Source <http://www.async.com.br> ## All rights reserved ## ## This program is free software; you can redistribute it and/or modify ## it under the terms of the GNU Lesser General Public License as published by ## the Free Software Foundation; either v...
def cut_paper(self):
Given snippet: <|code_start|>## Copyright (C) 2016 Async Open Source <http://www.async.com.br> ## All rights reserved ## ## This program is free software; you can redistribute it and/or modify ## it under the terms of the GNU Lesser General Public License as published by ## the Free Software Foundation; either version ...
def cut_paper(self):
Given snippet: <|code_start|># vi:si:et:sw=4:sts=4:ts=4 ## ## Copyright (C) 2016 Async Open Source <http://www.async.com.br> ## All rights reserved ## ## This program is free software; you can redistribute it and/or modify ## it under the terms of the GNU Lesser General Public License as published by ## the Free Softw...
model_name = "Bematech MP4200 TH"
Here is a snippet: <|code_start|> backend.barrier() nsec = timer.median nbytes = x.nbytes + y.nbytes + A_d._matrix_d.nbytes gbps = nbytes / nsec * 1e-9 frac = gbps / args.stream * 100 nthreads = backend.get_max_threads() name = backend.__class__.__name__ print("csrmm %s, %d threa...
minosf, maxosf = 1.25, 1.5
Given the code snippet: <|code_start|> XYZ = np.prod(x.shape[:3]) nsec = timer.median / args.trials nflops = 5 * XYZ * np.log2(XYZ) nbytes = 4 * x.nbytes roofline = args.stream*1e9 * (nflops / nbytes) frac = (nflops / nsec) / roofline * 100 nthreads = backend.get_max_threads() name = bac...
y_d = backend.copy_array(y)
Continue the code snippet: <|code_start|>#!/usr/bin/env python from __future__ import absolute_import from __future__ import unicode_literals from __future__ import print_function from __future__ import division __all__ = ['evaluations', 'svm_load_model', 'svm_predict', 'svm_read_problem', 'svm_save_mode...
def svm_read_problem(data_file_name):
Using the snippet: <|code_start|> # Module pattern.graph.commonsense implements a semantic network of commonsense. # It contains a Concept class (Node subclass), Relation class (Edge subclass), # and a Commonsense class (Graph subclass). # It contains about 10,000 manually annotated relations between mundane concepts, ...
print(g["spoon"].properties) # hot
Next line prediction: <|code_start|> "three" : 3, "thirteen" : 13, "fifty" : 50, "four" : 4, "fourteen" : 14, "sixty" : 60, "five" : 5, "fifteen" : 15, "seventy" : 70, "six" : 6, "sixteen" : 16, "eighty" : 80, "seven" : 7, "seventeen" : 17, "ninety" : 90, "eight" : 8, "eighteen" ...
"septemdec",
Given the code snippet: <|code_start|># -*- coding: utf-8 -*- router = Router() def func_a(): pass func_b = copy_func(func_a, 'func_b') func_c = copy_func(func_a, 'func_c') func_d = copy_func(func_a, 'func_d') func_e = copy_func(func_a, 'func_e') func_f = copy_func(func_a, 'func_f') func_g = copy_func(func_a, 'func_...
router.register('/a', func_a, methods=['GET', 'POST'])
Based on the snippet: <|code_start|>router.register('/e/(?P<id>\d+)', func_e, methods=['POST']) router.register('/f/(?P<id>\d+)/(?P<code>\w+)', func_f, methods=['GET']) # /<int:id> router.register('/g/<id>', func_g, methods=['GET', 'POST']) router.register('/h/<int:id>', func_h, methods=['GET', 'PUT']) router.register(...
('/j/a/b/c/', 'func_j', {'PUT', 'POST'}, {'path': 'a/b/c/'}),
Next line prediction: <|code_start|># -*- coding: utf-8 -*- class Request: def __init__(self, environ): self.environ = environ <|code_end|> . Use current file imports: (import cgi import io import json from http.cookies import SimpleCookie from .constants import HTTP_STATUS_CODES from .utils import ( ...
@property
Given snippet: <|code_start|># -*- coding: utf-8 -*- class Request: def __init__(self, environ): self.environ = environ <|code_end|> , continue by predicting the next line. Consider current file imports: import cgi import io import json from http.cookies import SimpleCookie from .constants import HTTP...
@property
Predict the next line after this snippet: <|code_start|># -*- coding: utf-8 -*- class Request: def __init__(self, environ): self.environ = environ <|code_end|> using the current file's imports: import cgi import io import json from http.cookies import SimpleCookie from .constants import HTTP_STATUS_C...
@property
Given snippet: <|code_start|># -*- coding: utf-8 -*- class Request: def __init__(self, environ): self.environ = environ @property <|code_end|> , continue by predicting the next line. Consider current file imports: import cgi import io import json from http.cookies import SimpleCookie from .constan...
def method(self):
Based on the snippet: <|code_start|># -*- coding: utf-8 -*- class Request: def __init__(self, environ): self.environ = environ <|code_end|> , predict the immediate next line with the help of imports: import cgi import io import json from http.cookies import SimpleCookie from .constants import HTTP_STA...
@property
Using the snippet: <|code_start|>#!/usr/bin/env python # -*- coding: utf-8 -*- class WSGIServer: address_family = socket.AF_INET socket_type = socket.SOCK_STREAM request_queue_size = 5 allow_reuse_address = True default_request_version = 'HTTP/1.1' server_version = 'WSGIServer/0.1' weekda...
monthname = [None,
Predict the next line for this snippet: <|code_start|>#!/usr/bin/env python # -*- coding: utf-8 -*- class WSGIServer: address_family = socket.AF_INET socket_type = socket.SOCK_STREAM request_queue_size = 5 allow_reuse_address = True default_request_version = 'HTTP/1.1' server_version = 'WSGIS...
def server_bind(self, server_address):
Here is a snippet: <|code_start|># -*- coding: utf-8 -*- http_methods = ('get', 'post', 'head', 'options', 'delete', 'put', 'trace', 'patch') class View: decorators = () def dispatch_request(self, request, *args, **kwargs): method = request.method.lower() if method == 'head'...
methods = []
Using the snippet: <|code_start|># -*- coding: utf-8 -*- http_methods = ('get', 'post', 'head', 'options', 'delete', 'put', 'trace', 'patch') class View: decorators = () def dispatch_request(self, request, *args, **kwargs): method = request.method.lower() if method == 'head'...
view = decorator(view)
Given the code snippet: <|code_start|># -*- coding: utf-8 -*- app = Bustard() @app.route('/set/<value>') def set_session(request, value): request.session['name'] = value return 'hello {}'.format(value) @app.route('/') def get_session(request): <|code_end|> , generate the next line using the imports in this...
value = request.session.get('name', '')
Using the snippet: <|code_start|># -*- coding: utf-8 -*- app = Bustard() @app.route('/') def helloword(request): return 'hello world' if __name__ == '__main__': <|code_end|> , determine the next line of code. You have imports: from bustard.app import Bustard and context (class names, function names, or code) ...
app.run()
Given the following code snippet before the placeholder: <|code_start|># -*- coding: utf-8 -*- pg_uri = os.environ.get( 'BUSTARD_TEST_PG_URI', 'postgresql://dbuser:password@localhost/exampledb' ) @pytest.yield_fixture def model(): yield orm.Model orm.MetaData.tables = {} orm.MetaData.indexes = ...
('DateTimeField', 'timestamp'),
Here is a snippet: <|code_start|> headers['foo'] = ['v1', 'v2'] assert headers['foo'] == 'v2' assert headers.get_all('Foo') == ['v1', 'v2'] @pytest.mark.parametrize('url, code', [ ('http://a.com', None), ('/a/b/c', 301), ]) def test_redirect(url, code): kwargs = {'url': url} if...
(200, '200 OK'),
Given snippet: <|code_start|> headers.set('Name', 'v') assert headers.get_all('Name') == ['v'] headers['a'] = 'b' assert headers['a'] == 'b' assert headers.get_all('a') == ['b'] def test_value_list(self): headers = Headers() headers.add('name', ['value', 'v2'...
kwargs = {'url': url}
Predict the next line for this snippet: <|code_start|># -*- coding: utf-8 -*- class TestHeaders: def test_normal(self): headers = Headers({'User-Agent': 'firefox/34'}) assert headers['User-Agent'] == 'firefox/34' assert headers['user-agent'] == headers['User-Agent'] headers.add(...
headers.add('name', ['value', 'v2'])
Predict the next line for this snippet: <|code_start|>class Template: TOKEN_VARIABLE_START = '{{' TOKEN_VARIABLE_END = '}}' TOKEN_TAG_START = '{%' TOKEN_TAG_END = '%}' TOKEN_COMMENT_START = '{#' TOKEN_COMMENT_END = '#}' FUNC_WHITELIST = TEMPLATE_BUILTIN_FUNC_WHITELIST def __init__(self,...
{token_variable_start} .+? {token_variable_end}
Predict the next line for this snippet: <|code_start|> auto_escape=True ): self.re_tokens = re.compile(r'''(?x)( (?:{token_variable_start} .+? {token_variable_end}) |(?:{token_tag_start} .+? {token_tag_end}) |(?:{token_comment_start}.*?{token_comment_end}...
{token_tag_start}.*?{token_tag_end}
Predict the next line after this snippet: <|code_start|># -*- coding: utf-8 -*- class HTTPException(Exception): def __init__(self, response): self.response = response class NotFound(HTTPException): <|code_end|> using the current file's imports: from .constants import NOTFOUND_HTML from .http import Re...
def __init__(self):