Instruction
stringlengths
362
7.83k
output_code
stringlengths
1
945
Predict the next line for this snippet: <|code_start|># -*- coding: utf-8 -*- """ Copyright (C) 2017 IBM Corporation 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/...
class BuiltinChecker(Checker):
Given the code snippet: <|code_start|># -*- coding: utf-8 -*- """ Copyright (C) 2017 IBM Corporation 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 Unl...
self.loader = BuiltinLoader()
Predict the next line after this snippet: <|code_start|># -*- coding: utf-8 -*- """ Copyright (C) 2017 IBM Corporation 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/license...
self.reporter = ProblemReporter()
Based on the snippet: <|code_start|> Licensed under the Apache License, Version 2.0 (the “License”); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software d...
controller._run_checker(checker, False, path)
Next line prediction: <|code_start|># -*- coding: utf-8 -*- """ Copyright (C) 2017 IBM Corporation 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 Unles...
class ApiMpiChecker(Checker):
Here is a snippet: <|code_start|># -*- coding: utf-8 -*- """ Copyright (C) 2017 IBM Corporation Licensed under the Apache License, Version 2.0 (the “License”); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless r...
class ApiDfpChecker(Checker):
Using the snippet: <|code_start|># -*- coding: utf-8 -*- """ Copyright (C) 2017 IBM Corporation Licensed under the Apache License, Version 2.0 (the “License”); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless r...
class PerformanceDegradationChecker(Checker):
Given the code snippet: <|code_start|> """ Copyright (C) 2017 IBM Corporation Licensed under the Apache License, Version 2.0 (the “License”); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicab...
self.hint = core.get_ifdef_regex("x86", "\\|")
Next line prediction: <|code_start|># -*- coding: utf-8 -*- """ Copyright (C) 2017 IBM Corporation 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 Unles...
class HtmChecker(Checker):
Using the snippet: <|code_start|># -*- coding: utf-8 -*- """ Copyright (C) 2017 IBM Corporation Licensed under the Apache License, Version 2.0 (the “License”); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless r...
self.htm_functions = HtmLoader().get_functions()
Based on the snippet: <|code_start|># -*- coding: utf-8 -*- """ Copyright (C) 2017 IBM Corporation 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 Unles...
class AsmChecker(Checker):
Next line prediction: <|code_start|>#! /usr/bin/env python # -*- coding: utf-8 -*- """ Copyright (C) 2017 IBM Corporation 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/lice...
quickfix_loader = QuickfixLoader()
Based on the snippet: <|code_start|> Licensed under the Apache License, Version 2.0 (the “License”); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software d...
lines = core.execute_stdout(command)[1]
Given the code snippet: <|code_start|># -*- coding: utf-8 -*- """ Copyright (C) 2017 IBM Corporation 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 Unl...
class ApiMklChecker(Checker):
Using the snippet: <|code_start|># -*- coding: utf-8 -*- """ Copyright (C) 2017 IBM Corporation Licensed under the Apache License, Version 2.0 (the “License”); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless r...
class LongDoubleChecker(Checker):
Predict the next line after this snippet: <|code_start|># -*- coding: utf-8 -*- """ Copyright (C) 2017 IBM Corporation 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/license...
class ApiIppChecker(Checker):
Given the following code snippet before the placeholder: <|code_start|># -*- coding: utf-8 -*- """ Copyright (C) 2017 IBM Corporation 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.apa...
self.problems = ProblemReporter.get_problems()
Using the snippet: <|code_start|># -*- coding: utf-8 -*- """ Copyright (C) 2017 IBM Corporation Licensed under the Apache License, Version 2.0 (the “License”); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless r...
class SyscallChecker(Checker):
Here is a snippet: <|code_start|>Copyright (C) 2017 IBM Corporation Licensed under the Apache License, Version 2.0 (the “License”); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or ...
self.syscalls_names = SyscallsLoader().get_names()
Predict the next line after this snippet: <|code_start|># -*- coding: utf-8 -*- """ Copyright (C) 2017 IBM Corporation 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/license...
class CharChecker(Checker):
Here is a snippet: <|code_start|> def get_pattern_hint(self): return self.hint def get_problem_msg(self): return self.problem_msg def get_problem_type(self): return self.problem_type def check_node(self, node): kind = node.kind if kind != CursorKind.BINARY_OPER...
raw_node = core.get_raw_node(node)
Given the code snippet: <|code_start|># -*- coding: utf-8 -*- """ Copyright (C) 2017 IBM Corporation 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 Unl...
class PthreadChecker(Checker):
Given the code snippet: <|code_start|>#! /usr/bin/env python # -*- coding: utf-8 -*- """ Copyright (C) 2017 IBM Corporation 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/lic...
asm_replacer = AssemblyReplacer()
Continue the code snippet: <|code_start|># coding: utf-8 def configure(app): @app.context_processor def inject(): return dict( <|code_end|> . Use current file imports: from lingobarter.core.models.config import Config and context (classes, functions, or code) from other files: # Path: lingobarter...
Config=Config,
Using the snippet: <|code_start|> @classmethod def get(cls, group, name=None, default=None): try: instance = cls.objects.get(group=group) except: return None if not name: ret = instance.values if group == 'settings': ret = ...
class Lingobarter(Dated, Slugged, db.DynamicDocument):
Here is a snippet: <|code_start|> @classmethod def get(cls, group, name=None, default=None): try: instance = cls.objects.get(group=group) except: return None if not name: ret = instance.values if group == 'settings': ret = ...
class Lingobarter(Dated, Slugged, db.DynamicDocument):
Next line prediction: <|code_start|> blueprint = getattr(mods[fname], object_name) app.logger.info("registering blueprint: %s" % blueprint.name) app.register_blueprint(blueprint) # register socket.io events module_events = ".".join([module_root, events_file]) ...
cmds = CommandsCollector(modules_path, base_module_name)
Given the following code snippet before the placeholder: <|code_start|># coding: utf-8 class LanguageResource(Resource): def get(self): languages = {} for lang in Language.objects: languages[lang.name] = { 'id': str(lang.id), "name": lang.name, ...
return render_json(message="Successfully fetch all languages", status=200, **languages)
Predict the next line for this snippet: <|code_start|> logger = logging.getLogger() def create_app_min(config=None, test=False): app = LingobarterApp('lingobarter') app.config.load_lingobarter_config(config=config, test=test) return app def get_site_url(): try: # why import models module ins...
db.init_app(app)
Given snippet: <|code_start|> class ChannelIndex(indexes.SearchIndex, indexes.Indexable): text = indexes.EdgeNgramField(document=True) name = indexes.CharField(model_attr='name') status = indexes.CharField(model_attr='status') def get_model(self): <|code_end|> , continue by predicting the next line. C...
return Channel
Predict the next line after this snippet: <|code_start|> class ChannelDetailView(DetailView): #A view for when users look for a single Channel model = Channel #Tells the DetailView to use the Channel model template_name = "view_channel.html" context_object = "channel" #Sets the name in the template co...
class ChannelListView(LoginRequiredMixin, TemplateView):
Given snippet: <|code_start|> class ChannelDetailView(DetailView): #A view for when users look for a single Channel model = Channel #Tells the DetailView to use the Channel model template_name = "view_channel.html" context_object = "channel" #Sets the name in the template context #Sets the field ...
form_class = ChannelForm
Predict the next line for this snippet: <|code_start|> try: except: VIDEO_BUCKET_NAME = "bitvid-video" # Create your views here. @login_required def upload(request): if request.method == "GET": <|code_end|> with the help of current file imports: from django.shortcuts import render from django.http import H...
chans = Channel.objects.filter(members__in=[request.user])
Next line prediction: <|code_start|># -*- coding: utf-8 -*- # # This file is part of Invenio. # Copyright (C) 2015-2019 CERN. # # Invenio is free software; you can redistribute it and/or modify it # under the terms of the MIT License; see LICENSE file for more details. """Storage module tests.""" def test_make_pat...
assert make_path(base, myid, f, 1, 1) == \
Predict the next line after this snippet: <|code_start|> ensure_readable = ensure_state( lambda o: o.readable, FileInstanceUnreadableError) """Ensure file is readable.""" ensure_writable = ensure_state( lambda o: o.writable, ValueError, 'File is not writable.') """Ensure file is writeable.""" ensure_...
BucketLockedError)
Continue the code snippet: <|code_start|>"""Ensure file is readable.""" ensure_writable = ensure_state( lambda o: o.writable, ValueError, 'File is not writable.') """Ensure file is writeable.""" ensure_completed = ensure_state( lambda o: o.completed, MultipartNotCompleted) """Ensure file is completed....
FileInstanceAlreadySetError)
Continue the code snippet: <|code_start|> class BucketError(object): """Represents a bucket level error. .. note:: This is not an actual exception. """ def __init__(self, message): self.res = dict(message=message) def to_dict(self): return self.res class ObjectVersionError(obje...
FileInstanceUnreadableError)
Given the code snippet: <|code_start|> def delete(self): """Delete a multipart object.""" # Update bucket size. self.bucket.size -= self.size # Remove parts Part.query_by_multipart(self).delete() # Remove self self.query.filter_by(upload_id=self.upload_id).dele...
raise FileSizeError(description=desc)
Here is a snippet: <|code_start|> many object versions. * **Locations** - A bucket belongs to a specific location. Locations can be used to represent e.g. different storage systems. * **Multipart Objects** - Identified by UUIDs and belongs to a specific bucket and key. * **Part object** - Identified by their...
raise InvalidKeyError()
Next line prediction: <|code_start|> def __init__(self, message): self.res = dict(message=message) def to_dict(self): return self.res ensure_readable = ensure_state( lambda o: o.readable, FileInstanceUnreadableError) """Ensure file is readable.""" ensure_writable = ensure_state( ...
InvalidOperationError,
Predict the next line for this snippet: <|code_start|>class ObjectVersionError(object): """Represents an object version level error. .. note:: This is not an actual exception. """ def __init__(self, message): self.res = dict(message=message) def to_dict(self): return self.res en...
MultipartAlreadyCompleted)
Continue the code snippet: <|code_start|> self.file.update_checksum(**kwargs) with db.session.begin_nested(): obj = ObjectVersion.create( self.bucket, self.key, _file_id=self.file_id, version_id=version_id ) ...
raise MultipartInvalidChunkSize()
Continue the code snippet: <|code_start|> @validates('key') def validate_key(self, key, key_): """Validate key.""" return validate_key(key_) @staticmethod def is_valid_chunksize(chunk_size): """Check if size is valid.""" min_csize = current_app.config['FILES_REST_MULTIPA...
raise MultipartInvalidPartNumber()
Given the following code snippet before the placeholder: <|code_start|> self.key, _file_id=self.file_id, version_id=version_id ) self.delete() return obj def delete(self): """Delete a multipart object.""" # Update bucket...
raise MultipartInvalidSize()
Predict the next line for this snippet: <|code_start|> @staticmethod def is_valid_chunksize(chunk_size): """Check if size is valid.""" min_csize = current_app.config['FILES_REST_MULTIPART_CHUNKSIZE_MIN'] max_csize = current_app.config['FILES_REST_MULTIPART_CHUNKSIZE_MAX'] return c...
raise MultipartMissingParts()
Based on the snippet: <|code_start|> def to_dict(self): return self.res class ObjectVersionError(object): """Represents an object version level error. .. note:: This is not an actual exception. """ def __init__(self, message): self.res = dict(message=message) def to_dict(sel...
MultipartNotCompleted)
Predict the next line after this snippet: <|code_start|> """Lock state of bucket. Modifications are not allowed on a locked bucket. """ deleted = db.Column(db.Boolean(name='deleted'), default=False, nullable=False) """Delete state of bucket.""" l...
lim for lim in current_files_rest.file_size_limiters(
Continue the code snippet: <|code_start|> file = db.relationship(FileInstance, backref='objects') """Relationship to file instance.""" __table_args__ = ( db.UniqueConstraint('bucket_id', 'version_id', 'key'), ) @validates('key') def validate_key(self, key, key_): """Validate key...
return self._mimetype if self._mimetype else guess_mimetype(self.key)
Based on the snippet: <|code_start|># -*- coding: utf-8 -*- # # This file is part of Invenio. # Copyright (C) 2019 CERN. # # Invenio is free software; you can redistribute it and/or modify it # under the terms of the MIT License; see LICENSE file for more details. """Test serializer.""" def test_serialize_pretty(a...
assert json_serializer(data=data, context=context).data == \
Based on the snippet: <|code_start|># -*- coding: utf-8 -*- # # This file is part of Invenio. # Copyright (C) 2019 CERN. # # Invenio is free software; you can redistribute it and/or modify it # under the terms of the MIT License; see LICENSE file for more details. """Test serializer.""" def test_serialize_pretty(a...
serializer_mapping['TestSchema'] = TestSchema
Using the snippet: <|code_start|>def bucket(): """Manage buckets.""" @bucket.command() @with_appcontext def touch(): """Create new bucket.""" bucket = Bucket.create() db.session.commit() click.secho(str(bucket), fg='green') @bucket.command() @click.argument('source', type=click.Path(exists=True,...
default_location = Location.get_default()
Given the following code snippet before the placeholder: <|code_start|># -*- coding: utf-8 -*- # # This file is part of Invenio. # Copyright (C) 2016-2019 CERN. # # Invenio is free software; you can redistribute it and/or modify it # under the terms of the MIT License; see LICENSE file for more details. """Test CLI."...
result = runner.invoke(cmd, [
Predict the next line after this snippet: <|code_start|> Factories that reads ``request.stream`` directly must be first in the list, otherwise Werkzeug's form-data parser will read the stream. """ FILES_REST_MULTIPART_MAX_PARTS = 10000 """Maximum number of parts when uploading files with multipart uploads.""" FI...
create_file_streaming_redirect_response
Continue the code snippet: <|code_start|># -*- coding: utf-8 -*- # # This file is part of Invenio. # Copyright (C) 2015-2019 CERN. # # Invenio is free software; you can redistribute it and/or modify it # under the terms of the MIT License; see LICENSE file for more details. """Module tests.""" def test_version(): ...
ext = InvenioFilesREST(app)
Next line prediction: <|code_start|># -*- coding: utf-8 -*- # # This file is part of Invenio. # Copyright (C) 2015-2019 CERN. # # Invenio is free software; you can redistribute it and/or modify it # under the terms of the MIT License; see LICENSE file for more details. """Form data parser customization. Flask and Wer...
request_class = Request
Here is a snippet: <|code_start|># -*- coding: utf-8 -*- # # This file is part of Invenio. # Copyright (C) 2016-2019 CERN. # # Invenio is free software; you can redistribute it and/or modify it # under the terms of the MIT License; see LICENSE file for more details. """Test file signals.""" def test_signals(app, c...
file_deleted.connect(delete_listener, weak=False)
Continue the code snippet: <|code_start|># -*- coding: utf-8 -*- # # This file is part of Invenio. # Copyright (C) 2016-2019 CERN. # # Invenio is free software; you can redistribute it and/or modify it # under the terms of the MIT License; see LICENSE file for more details. """Test file signals.""" def test_signal...
file_uploaded.connect(upload_listener, weak=False)
Next line prediction: <|code_start|>"""example URL Configuration The `urlpatterns` list routes URLs to views. For more information please see: https://docs.djangoproject.com/en/1.10/topics/http/urls/ Examples: Function views 1. Add an import: from my_app import views 2. Add a URL to urlpatterns: url(r'^$...
url(r'^logs/(?P<job_pk>[0-9]+)/$', ExampleJobLogView.as_view(), name='logs'),
Next line prediction: <|code_start|>"""example URL Configuration The `urlpatterns` list routes URLs to views. For more information please see: https://docs.djangoproject.com/en/1.10/topics/http/urls/ Examples: Function views 1. Add an import: from my_app import views 2. Add a URL to urlpatterns: url(r'^$...
url(r'^example/$', ExampleJobStatusView.as_view(), name='example'),
Continue the code snippet: <|code_start|>"""example URL Configuration The `urlpatterns` list routes URLs to views. For more information please see: https://docs.djangoproject.com/en/1.10/topics/http/urls/ Examples: Function views 1. Add an import: from my_app import views 2. Add a URL to urlpatterns: url...
url(r'^$', IndexView.as_view(), name='index'),
Next line prediction: <|code_start|>"""example URL Configuration The `urlpatterns` list routes URLs to views. For more information please see: https://docs.djangoproject.com/en/1.10/topics/http/urls/ Examples: Function views 1. Add an import: from my_app import views 2. Add a URL to urlpatterns: url(r'^$...
url(r'^jobs/$', JobList.as_view(), name='job-list'),
Based on the snippet: <|code_start|>"""example URL Configuration The `urlpatterns` list routes URLs to views. For more information please see: https://docs.djangoproject.com/en/1.10/topics/http/urls/ Examples: Function views 1. Add an import: from my_app import views 2. Add a URL to urlpatterns: url(r'^$...
url(r'^servers/(?P<pk>[0-9]+)/$', ServerDetail.as_view(), name='server-detail'),
Based on the snippet: <|code_start|>"""example URL Configuration The `urlpatterns` list routes URLs to views. For more information please see: https://docs.djangoproject.com/en/1.10/topics/http/urls/ Examples: Function views 1. Add an import: from my_app import views 2. Add a URL to urlpatterns: url(r'^$...
url(r'^servers/$', ServerList.as_view(), name='server-list'),
Continue the code snippet: <|code_start|>"""Provide default route mappings for serializers.""" # -*- coding: utf-8 -*- router = DefaultRouter() router.register(r'servers', ServerViewSet) router.register(r'jobs', JobViewSet) <|code_end|> . Use current file imports: from rest_framework.routers import DefaultRouter fr...
router.register(r'logs', LogViewSet)
Predict the next line for this snippet: <|code_start|>"""Provide default route mappings for serializers.""" # -*- coding: utf-8 -*- router = DefaultRouter() router.register(r'servers', ServerViewSet) router.register(r'jobs', JobViewSet) router.register(r'logs', LogViewSet) router.register(r'results', ResultViewSet) ...
url(r'^job-user-status/$', JobUserStatus.as_view()),
Given snippet: <|code_start|>"""Provide default route mappings for serializers.""" # -*- coding: utf-8 -*- router = DefaultRouter() router.register(r'servers', ServerViewSet) router.register(r'jobs', JobViewSet) router.register(r'logs', LogViewSet) <|code_end|> , continue by predicting the next line. Consider curren...
router.register(r'results', ResultViewSet)
Predict the next line for this snippet: <|code_start|> )) class JobLogConsumer(AsyncWebsocketConsumer): async def connect(self): ''' Creates group, add to the valid channels Connects and sends to the browser the log ''' job_pk = self.scope['url_route']['kwargs']['jo...
job = Job.objects.get(pk=job_pk)
Given the code snippet: <|code_start|># from channels.routing import route # from .consumers import ( # ws_job_status_connect, ws_job_status_disconnect, # ws_job_log_connect, ws_job_log_disconnect, # ) # channel_routing = [ # route('websocket.connect', ws_job_status_connect, path=r'^/job-user/$'), #...
path('ws/job-user/', JobUserConsumer),
Continue the code snippet: <|code_start|># from channels.routing import route # from .consumers import ( # ws_job_status_connect, ws_job_status_disconnect, # ws_job_log_connect, ws_job_log_disconnect, # ) # channel_routing = [ # route('websocket.connect', ws_job_status_connect, path=r'^/job-user/$')...
path('ws/job-log/<int:job_pk>/', JobLogConsumer),
Continue the code snippet: <|code_start|> class GameInfoController(BaseController): def __init__(self, core): self.core = core self.window = None <|code_end|> . Use current file imports: import xbmcgui from resources.lib.controller.basecontroller import BaseController, route from resources.lib.vi...
@route(name='details')
Given the code snippet: <|code_start|> class GameInfoController(BaseController): def __init__(self, core): self.core = core self.window = None @route(name='details') def show_game_info_action(self, host, game): <|code_end|> , generate the next line using the imports in this file: import x...
self.window = GameInfo(self, host, game)
Continue the code snippet: <|code_start|> 'btn_mode', 'btn_south', 'btn_east', 'btn_west', 'btn_north', 'btn_tl', 'btn_tr', 'btn_tl2', 'btn_tr2' ] class StoppableInputHandler(StoppableThread): def __init__(self, input_queue, input_map, dialog, input_number): self.input_q...
while self.input_map.status is not InputMap.STATUS_DONE:
Predict the next line for this snippet: <|code_start|> input_no = [ 'abs_x', 'reverse_x', 'abs_y', 'reverse_y', 'abs_rx', 'reverse_rx', 'abs_ry', 'reverse_ry', 'abs_dpad_x', 'reverse_dpad_x', 'abs_dpad_y', 'reverse_dpad_y', 'btn_thumbl', 'btn_thumbr', 'btn_sel...
class StoppableInputHandler(StoppableThread):
Continue the code snippet: <|code_start|> class ConnectionManager(object): def __init__(self, request_service, pairing_manager): self.request_service = request_service self.pairing_manager = pairing_manager def pair(self, dialog): message = '' server_info = self.request_service...
server_info) == AbstractPairingManager.STATE_PAIRED:
Here is a snippet: <|code_start|> class GameContextMenuController(BaseController): def __init__(self): self.window = None <|code_end|> . Write the next line using the current file imports: from resources.lib.controller.basecontroller import BaseController, route from resources.lib.views.gamecontextmenu i...
@route(name='menu')
Using the snippet: <|code_start|> class GameContextMenuController(BaseController): def __init__(self): self.window = None @route(name='menu') def show_context_action(self, host, list_item, game): <|code_end|> , determine the next line of code. You have imports: from resources.lib.controller.basec...
self.window = GameContextMenu(self, host, list_item, game)
Predict the next line for this snippet: <|code_start|> buf = array.array('B', [0]) ioctl(js_dev, 0x80016a11, buf) self.num_axes = buf[0] print self.num_axes buf = array.array('B', [0]) ioctl(js_dev, 0x80016a12, buf) self.num_buttons = buf[0] print self.nu...
if self.input_map.status == InputMap.STATUS_PENDING:
Here is a snippet: <|code_start|> self.core.string('name'), 'Getting game list failed. ' + 'This usually means your host wasn\'t paired properly.', '', 20000 ) return if not silent: progress_dialo...
if game_version_storage.get('version') == Game.version:
Given the following code snippet before the placeholder: <|code_start|> list_item.setProperty('state', str(host[0].state)) return def onAction(self, action): if action == xbmcgui.ACTION_NAV_BACK: self.close() focus_item_id = self.getFocusId() if focus_item_...
window = HostContextMenu(host, self.controller)
Based on the snippet: <|code_start|> class DiscoveryAgent(object): service_type = '_nvstream._tcp.local.' def __init__(self): self.available_hosts = {} self.zeroconf = None self.browser = None def service_state_change(self, zeroconf, service_type, name, state_change): if ...
self.available_hosts[name] = MdnsComputer.from_service_info(info)
Next line prediction: <|code_start|> class FeatureBroker: def __init__(self, allow_replace=False): self.providers = {} self.tagged_features = {} self.tags = {} self.initialized = {} self.allow_replace = allow_replace def _parse_config(self): if 'xbmcaddon' in ...
feature = Component.from_dict(_service, **service_definitions['services'][_service])
Using the snippet: <|code_start|> class FeatureBroker: def __init__(self, allow_replace=False): self.providers = {} self.tagged_features = {} self.tags = {} self.initialized = {} self.allow_replace = allow_replace def _parse_config(self): if 'xbmcaddon' in sys....
tag = Tag.from_dict(**tag)
Given the code snippet: <|code_start|> def get_game_information(self, nvapp): request_name = nvapp.title.replace(" ", "+").replace(":", "") response = self._gather_information(nvapp, request_name) response.name = nvapp.title return response def return_paths(self): return...
return ApiResponse()
Given snippet: <|code_start|> if not os.path.isfile(file_path): if not os.path.exists(os.path.dirname(file_path)): os.makedirs(os.path.dirname(file_path)) curl = subprocess.Popen(['curl', '-XGET', self.api_url % game], stdout=subprocess.PIPE) with open(file_pat...
image = Fanart()
Given snippet: <|code_start|>""" Holds all cross-controller routes, read from routing.yml """ class Router(object): def __init__(self): self.routes = {} self._routes_cache = {} self.routing = {} self.main_route = None def _parse_config(self): if 'xbmcaddon' in sys.mod...
route_object = Route.from_dict(_route_definition, **routing['routing'][_route_definition])
Next line prediction: <|code_start|> def register(self, cls): route = self.routing[cls.__name__] routes_cache = {} for key, value in self._routes_cache.iteritems(): xbmc.log('[script.luna.router]: Added Route: %s_%s -> %s' % (route.prefix, key, value)) routes_cache["%s...
instance = RequiredFeature(route.service[1:]).request()
Continue the code snippet: <|code_start|> class CacheController(BaseController): def __init__(self, core, scraper_chain): self.core = core self.base_path = core.storage_path self.scraper_chain = scraper_chain <|code_end|> . Use current file imports: from resources.lib.controller.basecontr...
@route("reset")
Given the following code snippet before the placeholder: <|code_start|> class NvHTTPScraper(AbstractScraper): def __init__(self, core, request_service): AbstractScraper.__init__(self, core) self.cover_cache = self._set_up_path(os.path.join(self.base_path, 'art/poster/')) self.request_servi...
response = ApiResponse()
Based on the snippet: <|code_start|> class StoppableJSHandler(StoppableThread): def __init__(self, input_wrapper, input_map): self.input = input_wrapper self.input.build_controller_map() self.js_dev = None self.map = input_map StoppableThread.__init__(self) def stop(sel...
if self.map.status == InputMap.STATUS_DONE:
Predict the next line after this snippet: <|code_start|> class TestConfigHelper(unittest.TestCase): def setUp(self): path = os.path.join(os.path.expanduser('~'), 'LunaTestTemp/') if not os.path.exists(path): os.makedirs(path) self.addon_path = path self.bin_path = os.path...
config = RequiredFeature('config-helper').request()
Predict the next line after this snippet: <|code_start|> data = AdvancedPairingManager._pad(data) cipher = AES.new(buffer(key)) return cipher.decrypt(buffer(data)) @staticmethod def _concat_bytes(a, b): c = bytearray(len(a) + len(b)) c[:] = a c[len(a):len(a) + len...
hash_algo = Sha256PairingHash()
Using the snippet: <|code_start|> return cipher.decrypt(buffer(data)) @staticmethod def _concat_bytes(a, b): c = bytearray(len(a) + len(b)) c[:] = a c[len(a):len(a) + len(b)] = b return c @staticmethod def _verify_signature(data, signature, cert): pubkey ...
hash_algo = Sha1PairingHash()
Predict the next line for this snippet: <|code_start|> class DeviceWrapper: def __init__(self): self.devices = [] self.init_devices() def init_devices(self): input_bus = '/proc/bus/input/devices' if not os.path.exists(input_bus): message = 'Input bus (%s) could no...
device = InputDevice()
Using the snippet: <|code_start|> return 'OMDB' def get_game_information(self, nvapp): request_name = nvapp.title.replace(" ", "+").replace(":", "") response = self._gather_information(nvapp, request_name) response.name = nvapp.title return response def return_paths(self...
return ApiResponse()
Here is a snippet: <|code_start|> self.settings_hash = self._get_settings_hash() self.settings_dict = {} def _get_settings_hash(self): settings_file = open(self.settings_path, 'rb') hasher = hashlib.sha256() blocksize = 65536 buf = settings_file.read(blocksize) ...
cat = Category(cat_label_id, cat_label, cat_prio)
Continue the code snippet: <|code_start|> def get_settings(self): if self.settings_hash == self._get_settings_hash() and len(self.settings_dict) > 0: self.update_values() return self.settings_dict else: self._reload_settings() cat_prio = 1 ...
_setting = Setting(setting_id, setting_label, setting_prio, **setting_args)
Given the code snippet: <|code_start|> if self.year is None: self.year = other.year if self.genre is None: self.genre = sorted(other.genre, key=str.lower) elif other.genre is not None: self.genre = sorted(list(set(self.genre) | set(other.genre)), key=str.lower...
return Fanart(alt, alt)
Here is a snippet: <|code_start|> file_path = update.file_path with open(file_path, 'wb') as asset: asset.write(urllib2.urlopen(update.asset_url).read()) asset.close() zip_file = zipfile.ZipFile(file_path) zip_file.extractall(self.core.internal_path, self._get_memb...
update = Update()
Next line prediction: <|code_start|> return None if not pre_updates_enabled: self.parse_release_information(response) else: for release in response: self.logger.info(release) if re.match(self.regexp, r...
window = UpdateInfo(self, update, 'Update to Luna %s' % self.update_version)
Given snippet: <|code_start|> def init_devices(self): cards_file = '/proc/asound/cards' with open(cards_file) as f: cards = f.readlines() f.close() for card in cards: match = re.match(self.CARDS_REGEX, card) if match: curr_idx ...
device = AudioDevice()