Instruction
stringlengths
362
7.83k
output_code
stringlengths
1
945
Given the code snippet: <|code_start|> req_transaction_uuid = NullCharField(max_length=40) request_token = NullCharField(max_length=200) transaction_id = NullCharField(max_length=64) # Timestamps date_modified = models.DateTimeField(_("Date Modified"), auto_now=True) date_created = models.DateTi...
return DECISION_REVIEW
Using the snippet: <|code_start|> if self.reason_code in (100,): return DECISION_ACCEPT # Review if self.reason_code in (201, 480): return DECISION_REVIEW # Rejections if self.reason_code in ( 110, 200, 202, ...
return DECISION_DECLINE
Continue the code snippet: <|code_start|> if self.reason_code in (201, 480): return DECISION_REVIEW # Rejections if self.reason_code in ( 110, 200, 202, 203, 204, 205, 207, 208, ...
return DECISION_ERROR
Continue the code snippet: <|code_start|> return None # '!netboy key [' + name + '] does not exist' except Exception: raise NetBoy.Exception('netboy exception: ' + name) def __setattr__(self, name, value): # type: (str, Any) -> None self[name]...
if type(v) == CurlLoop.CurlException:
Given the code snippet: <|code_start|> return self[name] except KeyError: # raise NetBoy.Exception('netboy key error: ' + name) return None # '!netboy key [' + name + '] does not exist' except Exception: raise NetBoy.Exception('netb...
ress = run(net_boy(real_payload, self.share), loop=loop)
Given the code snippet: <|code_start|>class NetBoy: class Exception(Exception): pass class Dict(typing.Dict[str, typing.Any]): def __getattr__(self, name): # type: (str) -> Any try: return self[name] except KeyError: # raise Ne...
def run(self, payload=None, loop=None):
Given the code snippet: <|code_start|> f = FALSY(static_dir='demo/with_wsgi/static') \ .swagger('demo/with_wsgi/spec.yml', ui=True, ui_language='zh-cn', theme='normal') \ .wsgi(flask_app, PRE_FLASK) \ <|code_end|> , generate the next line using the imports in this file: from demo.with_wsgi.ops.flask import fla...
.wsgi(tornado_app, PRE_TORNADO)
Predict the next line after this snippet: <|code_start|> f = FALSY(static_dir='demo/with_wsgi/static') \ .swagger('demo/with_wsgi/spec.yml', ui=True, ui_language='zh-cn', theme='normal') \ .wsgi(flask_app, PRE_FLASK) \ <|code_end|> using the current file's imports: from demo.with_wsgi.ops.flask import flask_a...
.wsgi(tornado_app, PRE_TORNADO)
Continue the code snippet: <|code_start|> 'spider': 'pycurl', 'state': 'error', 'error_code': e.code, 'error_desc': e.desc, } except Exception as e: return { 'url': c._raw_url, ...
result = curl_result(c)
Given snippet: <|code_start|> class ColoredRecord(object): class __dict(collections.defaultdict): def __missing__(self, name): try: return parse_colors(name) except Exception: raise KeyError("{} is not a valid record attribute " ...
'black': fore('black'),
Predict the next line after this snippet: <|code_start|> raise KeyError("{} is not a valid record attribute " "or color sequence".format(name)) def __init__(self, record): self.__dict__ = self.__dict() self.__dict__.update(record.__dict__) self....
'black_': back('black'),
Using the snippet: <|code_start|> 'blue': fore('blue'), 'magenta': fore('magenta'), 'cyan': fore('cyan'), 'lgray': fore('lightgray'), 'gray': fore('darkgray'), 'lred': fore('lightred'), 'lgreen': fore('lightgreen'), 'lyellow': fore('lightyellow'), 'lblue': fore('lightblue'), 'lmag...
'bold': style('bold'),
Here is a snippet: <|code_start|> 'lblue': fore('lightblue'), 'lmagenta': fore('lightmagenta'), 'lcyan': fore('lightcyan'), 'white': fore('white'), 'black_': back('black'), 'red_': back('red'), 'green_': back('green'), 'yellow_': back('yellow'), 'blue_': back('blue'), 'magenta_':...
'reset': reset(),
Continue the code snippet: <|code_start|> 'lmagenta': fore('lightmagenta'), 'lcyan': fore('lightcyan'), 'white': fore('white'), 'black_': back('black'), 'red_': back('red'), 'green_': back('green'), 'yellow_': back('yellow'), 'blue_': back('blue'), 'magenta_': back('magenta'), 'c...
'rstyle': rastyle(),
Given the code snippet: <|code_start|> 'lcyan': fore('lightcyan'), 'white': fore('white'), 'black_': back('black'), 'red_': back('red'), 'green_': back('green'), 'yellow_': back('yellow'), 'blue_': back('blue'), 'magenta_': back('magenta'), 'cyan_': back('cyan'), 'lgray_': back('...
'rafore': rafore(),
Given the code snippet: <|code_start|> 'white': fore('white'), 'black_': back('black'), 'red_': back('red'), 'green_': back('green'), 'yellow_': back('yellow'), 'blue_': back('blue'), 'magenta_': back('magenta'), 'cyan_': back('cyan'), 'lgray_': back('lightgray'), 'gray_': back('...
'raback': raback(),
Predict the next line after this snippet: <|code_start|> self.load_methods(method, method_content, path, swagger_spec) def load_methods(self, method, method_content, path, swagger_spec): uri_fields, uri_regex = compile_uri_template( '/' + method.lower() + swagger_spec['basePath'] + p...
return load(name)
Predict the next line for this snippet: <|code_start|> def json_check(value): try: if type(value) == str: try: value = json.loads(value) except json.decoder.JSONDecodeError as e: value = ast.literal_eval(value) return value except Except...
self.log = JLog().bind()
Next line prediction: <|code_start|> argmap = { 'name': fields.Str(required=False), } <|code_end|> . Use current file imports: (import json from marshmallow import fields from falsy.utils.marshmallow import validate) and context including class names, function names, or small code snippets from other files:...
@validate(argmap)
Given snippet: <|code_start|> def exception_handler(context): print('context:', context) def run(coro, loop=None): async def main_task(): <|code_end|> , continue by predicting the next line. Consider current file imports: import asyncio as aio import json import uvloop from contextlib import suppress from...
pycurl_task = aio.ensure_future(curl_loop())
Using the snippet: <|code_start|> highlights = None logfile = '/tmp/falsy.log' file_level = console_level = 'DEBUG' handlers = ['file', 'console'] extra_loggers = None config = { 'version': 1, 'disable_existing_loggers': False, ...
'()': TraceFilter,
Next line prediction: <|code_start|> handlers = ['file', 'console'] extra_loggers = None config = { 'version': 1, 'disable_existing_loggers': False, 'formatters': { 'file': { 'fmt': '%(asctime)s.%(msecs)03d %(levelnam...
'()': HighlightFilter,
Here is a snippet: <|code_start|> class JLog: def __init__(self, name='falsy'): self.logger = None self.logname = name def setup(self, config=None): if config is not None: highlights = config.get('highlights') logfile = config.get('logfile', '/tmp/falsy.log') ...
'()': JLogColoredFormatter,
Predict the next line after this snippet: <|code_start|> def error(self, msg, *args, **kwargs): return self.logger.error(msg, *args, **kwargs) def critical(self, msg, *args, **kwargs): return self.logger.critical(msg, *args, **kwargs) def warning_trace(self, msg, *args, **kwargs): ...
blue() + filename, yellow() + str(s.lineno),
Based on the snippet: <|code_start|> def error(self, msg, *args, **kwargs): return self.logger.error(msg, *args, **kwargs) def critical(self, msg, *args, **kwargs): return self.logger.critical(msg, *args, **kwargs) def warning_trace(self, msg, *args, **kwargs): self.trace(kwargs) ...
blue() + filename, yellow() + str(s.lineno),
Next line prediction: <|code_start|> def error(self, msg, *args, **kwargs): return self.logger.error(msg, *args, **kwargs) def critical(self, msg, *args, **kwargs): return self.logger.critical(msg, *args, **kwargs) def warning_trace(self, msg, *args, **kwargs): self.trace(kwargs) ...
'|' + '-' * (i * 4) + cyan() + s.name + ':' + red() + s.line)
Predict the next line after this snippet: <|code_start|> def error(self, msg, *args, **kwargs): return self.logger.error(msg, *args, **kwargs) def critical(self, msg, *args, **kwargs): return self.logger.critical(msg, *args, **kwargs) def warning_trace(self, msg, *args, **kwargs): s...
'|' + '-' * (i * 4) + cyan() + s.name + ':' + red() + s.line)
Predict the next line for this snippet: <|code_start|> return self.logger.critical(msg, *args, **kwargs) def warning_trace(self, msg, *args, **kwargs): self.trace(kwargs) return self.logger.critical(msg, *args, **kwargs) def critical_trace(self, msg, *args, **kwargs): self.trace...
'trace': magenta() + str(exc_type) + ' ' + bold() + magenta() + str(exc_value) + '\n\t' + lines}
Predict the next line after this snippet: <|code_start|> return self.logger.critical(msg, *args, **kwargs) def warning_trace(self, msg, *args, **kwargs): self.trace(kwargs) return self.logger.critical(msg, *args, **kwargs) def critical_trace(self, msg, *args, **kwargs): self.tra...
'trace': magenta() + str(exc_type) + ' ' + bold() + magenta() + str(exc_value) + '\n\t' + lines}
Based on the snippet: <|code_start|> # Lowercase name here. name = name.lower() # Now we can actually record the header name and value. if name in headers['content'][count]: headers['content'][count][name].append(value) else: headers['content'][count][name...
c.setopt(pycurl.HEADERFUNCTION, load(headerfunction))
Continue the code snippet: <|code_start|> class TraceFilter(logging.Filter): def filter(self, record): if 'trace' not in dir(record): record.trace = '' else: record.trace = '\n\t' + record.trace return True class HighlightFilter(logging.Filter): def __init__(s...
magenta() + 'highlight' + rmagenta() + ': ' + \
Next line prediction: <|code_start|> class TraceFilter(logging.Filter): def filter(self, record): if 'trace' not in dir(record): record.trace = '' else: record.trace = '\n\t' + record.trace return True class HighlightFilter(logging.Filter): def __init__(self, ...
magenta() + 'highlight' + rmagenta() + ': ' + \
Using the snippet: <|code_start|> class TraceFilter(logging.Filter): def filter(self, record): if 'trace' not in dir(record): record.trace = '' else: record.trace = '\n\t' + record.trace return True class HighlightFilter(logging.Filter): def __init__(self, hig...
record.msg.replace(e, cc(e, fore='yellow', back='red'))
Here is a snippet: <|code_start|> logging.basicConfig(level=logging.INFO) log = logging.getLogger(__name__) class CommonWSGIMiddleware(object): def __init__(self, falcon_api, app, url_prefix='wsgi'): self.falcon_api = falcon_api self.app = app self.url_prefix = url_prefix.lstrip('/') <|c...
self.log = JLog().bind()
Predict the next line for this snippet: <|code_start|> route_args = { '/get/v1/hello': { 'name': fields.Str(required=False), }, '/post/v1/hello': { 'name': fields.Str(validate=lambda p: len(p) >= 4) } } def mmcheck(req, resp, **kwargs): <|code_end|> with the help of current file impo...
mm_check(route_args, req, **kwargs)
Predict the next line after this snippet: <|code_start|> if __name__ == "__main__": payload = [ # { # "url": "http://172.30.0.77:8003/v1/validate", # "postfields": { # "token": "eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJleHAiOjE0OTE4ODg2ODQsImNvZGVfaWQiOiJjYWYwZTZlOC0w...
boy=NetBoy(payload, share=True)
Continue the code snippet: <|code_start|> if __name__ == "__main__": payload = [ # { # "url": "http://172.30.0.77:8003/v1/validate", # "postfields": { # "token": "eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJleHAiOjE0OTE4ODg2ODQsImNvZGVfaWQiOiJjYWYwZTZlOC0wYTEzLTExZTctOTV...
ress = boy.run()
Based on the snippet: <|code_start|># Single curl request: def post_it(payload): if type(payload) is list: payload = payload[0] c = pycurl.Curl() data_buf = BytesIO() # header_buf = BytesIO() headers = {'count': 0, 'content': [{}]} try: <|code_end|> , predict the immediate next line...
setup_curl_for_post(c, payload, data_buf, headers) # header_buf)
Given the following code snippet before the placeholder: <|code_start|> # from ymon.loader.task import loads if __name__ == '__main__': payload = { 'tasks': [ {"args": "haha", "ids": ["demo.celery.task.tasks.test2"], "on_error": "demo.celery.task.tasks.on_chord_error"}, ], '...
res = task.loads(payload).delay()
Based on the snippet: <|code_start|> try: except Exception as e: raise Exception('celery import failed') def load(id, args, error_handler=None): if args and error_handler: <|code_end|> , predict the immediate next line with the help of imports: from falsy.loader import func from celery import chain, chor...
return func.load(id).s(args).on_error(func.load(error_handler).s())
Predict the next line after this snippet: <|code_start|> async def get_boy(payload): targets = [] for p in payload: <|code_end|> using the current file's imports: from falsy.netboy.request import get_request, post_request import asyncio as aio and any relevant context from other files: # Path: falsy/netbo...
targets.append(get_request(p))
Given the code snippet: <|code_start|> async def get_boy(payload): targets = [] for p in payload: targets.append(get_request(p)) res = await aio.gather( *targets, return_exceptions=True ) return res async def post_boy(payload): targets = [] for p in payload: <|code_end|> ,...
targets.append(post_request(p))
Predict the next line for this snippet: <|code_start|> class CustomException(Exception): pass def handle_custom(req, resp, e): resp.body = json.dumps({'error': 'custom error catched'}) resp.content_type = 'application/json' <|code_end|> with the help of current file imports: import json from falsy.f...
f = FALSY(static_path='test', static_dir='demo/catch/static')
Predict the next line after this snippet: <|code_start|> "text": document.body.innerText, }); ''' req['params'] = {"expression": eval_func} ws.send(json.dumps(req)) resp = self.recv4result(ws) return resp def crawl_info(self, data, payload, begin_time): ...
post_func = func.load(post_func)
Based on the snippet: <|code_start|> ret = self.crawl_info(error_data, payload, begin_time) return ret else: sleep(payload.get('retry_sleep', 3)) payload['sockettimeout'] = int(payload.get('sockettimeout') or self._socket_timeout) + payload.get(...
resp = get_it(payload)
Here is a snippet: <|code_start|> class redirect_exceptions(ContextDecorator): def __init__(self, **kwargs): self.__dict__.update(kwargs) def __enter__(self): return self def __exit__(self, e_type, e_value, e_trace): if e_type is None or e_value is None: return ...
propagate = func.load(to)(e_type, e_value, e_trace)
Predict the next line after this snippet: <|code_start|>from __future__ import absolute_import urlpatterns = ( url(r'^authorize/$', views.AuthorizationView.as_view(), name="authorize"), url(r'^token/$', views.TokenView.as_view(), name="token"), url(r'^revoke_token/$', views.RevokeTokenView.as_view(), ...
CoffeestatsApplicationRegistration.as_view(), name="register"),
Given snippet: <|code_start|>from __future__ import absolute_import urlpatterns = ( url(r'^authorize/$', views.AuthorizationView.as_view(), name="authorize"), url(r'^token/$', views.TokenView.as_view(), name="token"), url(r'^revoke_token/$', views.RevokeTokenView.as_view(), name="revoke-token"), ...
url(r'^applications/(?P<pk>\d+)/$', CoffeestatsApplicationDetail.as_view(),
Given snippet: <|code_start|> class CaffeineViewSet(viewsets.ReadOnlyModelViewSet): """ API endpoint that allows caffeine entries to be viewed. """ queryset = Caffeine.objects.all().order_by('-date') <|code_end|> , continue by predicting the next line. Consider current file imports: from django.contr...
serializer_class = CaffeineSerializer
Given the code snippet: <|code_start|> class CaffeineViewSet(viewsets.ReadOnlyModelViewSet): """ API endpoint that allows caffeine entries to be viewed. """ queryset = Caffeine.objects.all().order_by('-date') serializer_class = CaffeineSerializer class UserViewSet(viewsets.ReadOnlyModelViewSet):...
serializer_class = UserCaffeineSerializer
Given the following code snippet before the placeholder: <|code_start|> class CaffeineViewSet(viewsets.ReadOnlyModelViewSet): """ API endpoint that allows caffeine entries to be viewed. """ queryset = Caffeine.objects.all().order_by('-date') serializer_class = CaffeineSerializer class UserViewSe...
serializer_class = UserSerializer
Continue the code snippet: <|code_start|> class CaffeineViewSet(viewsets.ReadOnlyModelViewSet): """ API endpoint that allows caffeine entries to be viewed. """ queryset = Caffeine.objects.all().order_by('-date') serializer_class = CaffeineSerializer class UserViewSet(viewsets.ReadOnlyModelViewSe...
IsOwnerOrReadOnly,)
Based on the snippet: <|code_start|> class CaffeineViewSet(viewsets.ReadOnlyModelViewSet): """ API endpoint that allows caffeine entries to be viewed. """ queryset = Caffeine.objects.all().order_by('-date') serializer_class = CaffeineSerializer class UserViewSet(viewsets.ReadOnlyModelViewSet): ...
IsOwnCaffeineOrReadOnly,
Given the code snippet: <|code_start|> password1 = forms.CharField(required=False) password2 = forms.CharField(required=False) password_set = False email_action = None class Meta: model = User fields = ['email', 'first_name', 'last_name', 'location'] def clean_password2(self): ...
self.instance, ACTION_TYPES.change_email,
Next line prediction: <|code_start|> """ password1 = forms.CharField(required=False) password2 = forms.CharField(required=False) password_set = False email_action = None class Meta: model = User fields = ['email', 'first_name', 'last_name', 'location'] def clean_password2(s...
self.email_action = Action.objects.create_action(
Given snippet: <|code_start|> model = User fields = ['timezone'] error_messages = { 'timezone': { 'required': EMPTY_TIMEZONE_ERROR, }, } def __init__(self, *args, **kwargs): super(SelectTimeZoneForm, self).__init__(*args, **kwargs) ...
model = Caffeine
Here is a snippet: <|code_start|>""" DUPLICATE_USER_ERROR = _("A user with that username already exists.") DUPLICATE_EMAIL_ERROR = _( "This email address is already in use. " "Please supply a different email address." ) PASSWORD_MISMATCH_ERROR = _('Passwords must match!') INVALID_TIMEZONE_ERROR = _("Invalid ...
existing = User.objects.filter(
Given the following code snippet before the placeholder: <|code_start|> return self.initial['password'] class CaffeineUserAdmin(UserAdmin): """ Custom admin page for users. """ form = UserChangeForm add_form = UserCreationForm list_display = ('username', 'email', 'first_name', 'last_na...
admin.site.register(Action)
Given the code snippet: <|code_start|> class CaffeineUserAdmin(UserAdmin): """ Custom admin page for users. """ form = UserChangeForm add_form = UserCreationForm list_display = ('username', 'email', 'first_name', 'last_name', 'is_staff') list_filter = ('is_staff',) fieldsets = ( ...
admin.site.register(Caffeine)
Continue the code snippet: <|code_start|>""" Django admin classes for the caffeine app. """ PASSWORD_MISMATCH_ERROR = _("Passwords don't match") class UserCreationForm(forms.ModelForm): """ A form for creating new users. Includes all the required fields, plus a repeated password. """ password...
model = User
Given snippet: <|code_start|>""" Custom authentication backend for coffeestats. """ logger = logging.getLogger(__name__) class LegacyCoffeestatsAuth(object): """ Authentication backend for passwords generated by the original coffeestats PHP implementation. """ def authenticate(self, userna...
user = User.objects.get(username=username)
Given the following code snippet before the placeholder: <|code_start|> class ManagedROMArchiveTests(unittest.TestCase): def setUp(self): self.tempdir = tempfile.mkdtemp() self.temppath = os.path.join(self.tempdir, "tempfile") self.mock_user = mock() self.mock_user.user_id = 1234 def tearDown(sel...
archive = ManagedROMArchive(missing_path)
Predict the next line for this snippet: <|code_start|># encoding: utf-8 """ local_provider_tests.py Created by Scott on 2014-08-18. Copyright (c) 2014 Scott Rice. All rights reserved. """ class LocalProviderTests(unittest.TestCase): def setUp(self): <|code_end|> with the help of current file imports: from moc...
self.provider = LocalProvider()
Based on the snippet: <|code_start|># encoding: utf-8 """ consolegrid_provider_tests.py Created by Scott on 2014-08-18. Copyright (c) 2014 Scott Rice. All rights reserved. """ # I need to do this instead of importing the class explicitly so that I can # override the urllib2 function. # TODO: Use dependency injection...
self.provider = consolegrid_provider.ConsoleGridProvider()
Using the snippet: <|code_start|> class EmulatorsTests(unittest.TestCase): @parameterized.expand([ ("C:/emu.exe", "C:"), ("C:/Path/to/emulator.exe", "C:/Path/to"), ("/emu", "/"), ("/path/to/emulator", "/path/to"), ]) def test_emulator_startdir(self, location, expected): emu = model.Emulato...
self.assertEqual(emulators.emulator_startdir(emu), expected)
Given the following code snippet before the placeholder: <|code_start|> class EmulatorsTests(unittest.TestCase): @parameterized.expand([ ("C:/emu.exe", "C:"), ("C:/Path/to/emulator.exe", "C:/Path/to"), ("/emu", "/"), ("/path/to/emulator", "/path/to"), ]) def test_emulator_startdir(self, locati...
emu = model.Emulator("Mednafen", location, "%l %r")
Next line prediction: <|code_start|> class BackupsTests(unittest.TestCase): def setUp(self): self.steam_fixture = fixtures.SteamFixture() self.user_fixture = fixtures.UserFixture(self.steam_fixture) @parameterized.expand([ (None, None), <|code_end|> . Use current file imports: (import os impor...
("", backups.default_backups_directory()),
Based on the snippet: <|code_start|># encoding: utf-8 class TaskEngine(object): def __init__(self, steam): self.steam = steam <|code_end|> , predict the immediate next line with the help of imports: import os from pysteam import paths as steam_paths from pysteam import shortcuts from pysteam import steam a...
logger.debug("Initializing Ice")
Given the following code snippet before the placeholder: <|code_start|> class ConsoleAdapterTests(unittest.TestCase): def test_verify(self): emu = mock() <|code_end|> , predict the next line using imports from the current file: import unittest from mockito import * from nose_parameterized import parameteriz...
adapter = console_adapter.ConsoleBackedObjectAdapter([])
Here is a snippet: <|code_start|> class ConsoleAdapterTests(unittest.TestCase): def test_verify(self): emu = mock() adapter = console_adapter.ConsoleBackedObjectAdapter([]) <|code_end|> . Write the next line using the current file imports: import unittest from mockito import * from nose_parameterized im...
valid = model.Console("Nintendo", "NES", "", "", "", "", "", emu)
Based on the snippet: <|code_start|> class ROMParser(object): regexes = [ # Regex that matches the entire string up until it hits the first '[', # ']', '(', ')', or '.' # DOESN'T WORK FOR GAMES WITH ()s IN THEIR NAME ur"(?P<name>[^\(\)\[\]]*).*", ] def __init__(self): <|code_end|> , predict th...
logger.debug("Creating ROM parser with regexes: %s" % self.regexes)
Using the snippet: <|code_start|> # }, # ... # } # # Will produce an output like this # [Section Name] # key=value # key=value # # [Section Name 2] # key2=value # key2=value f = open(path, "w") for section_name in sections_dict.keys(): f.write("[%s]\n" % ...
cfbs = ConfigFileBackingStore(self.tempfile)
Next line prediction: <|code_start|> class EnvironmentCheckerTests(unittest.TestCase): def setUp(self): self.tempdir = tempfile.mkdtemp() def tearDown(self): shutil.rmtree(self.tempdir) def testRequireDirectoryExistsSucceedsWhenDirectoryExists(self): try: <|code_end|> . Use current file imports: ...
with EnvironmentChecker(RealFilesystem()) as env_checker:
Next line prediction: <|code_start|> class EnvironmentCheckerTests(unittest.TestCase): def setUp(self): self.tempdir = tempfile.mkdtemp() def tearDown(self): shutil.rmtree(self.tempdir) def testRequireDirectoryExistsSucceedsWhenDirectoryExists(self): try: <|code_end|> . Use current file imports: ...
with EnvironmentChecker(RealFilesystem()) as env_checker:
Predict the next line for this snippet: <|code_start|> class EmulatorAdapterTests(unittest.TestCase): def setUp(self): fs = filesystem.RealFilesystem() <|code_end|> with the help of current file imports: import os import tempfile import unittest from mockito import * from nose_parameterized import parameter...
self.adapter = emulator_adapter.EmulatorBackedObjectAdapter(fs)
Continue the code snippet: <|code_start|> class EmulatorAdapterTests(unittest.TestCase): def setUp(self): fs = filesystem.RealFilesystem() self.adapter = emulator_adapter.EmulatorBackedObjectAdapter(fs) def test_verify_returns_false_when_location_is_none(self): <|code_end|> . Use current file imports: ...
emu = model.Emulator("Mednafen", None, "%l %r")
Predict the next line after this snippet: <|code_start|> class SettingsTests(unittest.TestCase): def setUp(self): pass @parameterized.expand([ ("local", [LocalProvider]), <|code_end|> using the current file's imports: import os import shutil import tempfile import unittest from mockito import * fr...
("consolegrid", [ConsoleGridProvider]),
Predict the next line for this snippet: <|code_start|> class SettingsTests(unittest.TestCase): def setUp(self): pass @parameterized.expand([ <|code_end|> with the help of current file imports: import os import shutil import tempfile import unittest from mockito import * from nose_parameterized import ...
("local", [LocalProvider]),
Given snippet: <|code_start|> class SettingsTests(unittest.TestCase): def setUp(self): pass @parameterized.expand([ ("local", [LocalProvider]), ("consolegrid", [ConsoleGridProvider]), ("local, consolegrid", [LocalProvider, ConsoleGridProvider]), ("consOLEGRId , LOcaL ", [ConsoleGrid...
result = settings.image_provider(config)
Predict the next line after this snippet: <|code_start|> class ConsoleGridProvider(grid_image_provider.GridImageProvider): @staticmethod def api_url(): return "http://consolegrid.com/api/top_picture" @staticmethod def is_enabled(): # TODO: Return True/False based on the current network status r...
logger.debug(
Using the snippet: <|code_start|> class ROMsTests(unittest.TestCase): def setUp(self): pass @parameterized.expand([ (None, paths.default_roms_directory()), ("", paths.default_roms_directory()), ('/roms/', '/roms/'), ]) def test_roms_directory(self, config_directory, expected): config...
console = model.Console(
Based on the snippet: <|code_start|> class ROMsTests(unittest.TestCase): def setUp(self): pass @parameterized.expand([ <|code_end|> , predict the immediate next line with the help of imports: import os import shutil import tempfile import unittest from mockito import * from nose_parameterized import pa...
(None, paths.default_roms_directory()),
Predict the next line for this snippet: <|code_start|> class ROMsTests(unittest.TestCase): def setUp(self): pass @parameterized.expand([ (None, paths.default_roms_directory()), ("", paths.default_roms_directory()), ('/roms/', '/roms/'), ]) def test_roms_directory(self, config_directory, ...
self.assertEqual(roms.roms_directory(config), expected)
Predict the next line for this snippet: <|code_start|>#!/usr/bin/env python # encoding: utf-8 # TODO(#368); This shouldn't be necessary as part of the app. We shouldn't be # relying on log messages as our UI class LogAppStateTask(object): def __call__(self, app_settings, users, dry_run): for emulator in app_se...
logger.info("Detected Emulator: %s" % emulator.name)
Predict the next line after this snippet: <|code_start|> def _create_default_directories(self): """This method creates all of the directories that Steam normally creates for a user.""" # Assert that the userdata directory is there assert(os.path.exists(self.steam_fixture.get_steam().userdata_directory)...
"mednafen": model.Emulator(
Here is a snippet: <|code_start|> consoles = DataFixture({ "nes": model.Console( fullname = 'Nintendo Entertainment System', shortname = 'NES', extensions = 'nes', custom_roms_directory = '', prefix = '[NES]', icon = '/consoles/icons/nes.png', images_directory = '/consoles/grid/nes/', ...
fullname = roms.ICE_FLAG_TAG,
Given the code snippet: <|code_start|>#!/usr/bin/env python # encoding: utf-8 """ local_provider.py Created by Scott on 2013-12-26. Copyright (c) 2013 Scott Rice. All rights reserved. """ class LocalProvider(grid_image_provider.GridImageProvider): def valid_extensions(self): return ['.png', '.jpg', '.jpeg',...
logger.debug(
Continue the code snippet: <|code_start|># encoding: utf-8 """ local_provider_tests.py Created by Scott on 2014-08-18. Copyright (c) 2014 Scott Rice. All rights reserved. """ class CombinedProviderTests(unittest.TestCase): def test_is_enabled_returns_false_when_no_providers_are_enabled(self): provider1 = mo...
combined_provider = CombinedProvider(provider1, provider2)
Predict the next line after this snippet: <|code_start|> class FilesystemTests(unittest.TestCase): def setUp(self): self.tempdir = tempfile.mkdtemp() <|code_end|> using the current file's imports: import os import shutil import sys import tempfile import unittest from nose_parameterized import parameterize...
self.filesystem = filesystem.RealFilesystem()
Predict the next line for this snippet: <|code_start|> def new(self, backing_store, identifier): fullname = identifier shortname = backing_store.get(identifier, 'nickname', fullname) extensions = backing_store.get(identifier, 'extensions', "") custom_roms_directory ...
logger.debug("No emulator provided for console `%s`" % console.fullname)
Predict the next line for this snippet: <|code_start|> class ConsoleBackedObjectAdapter(object): def __init__(self, emulators): self.emulators = emulators def new(self, backing_store, identifier): fullname = identifier shortname = backing_store.get(identifier, 'nickname', fu...
return model.Console(
Given the code snippet: <|code_start|> class ROMFinderTests(unittest.TestCase): def setUp(self): self.mock_config = mock() self.mock_filesystem = mock() self.mock_parser = mock() self.rom_finder = rom_finder.ROMFinder( self.mock_filesystem, self.mock_parser, ) def _dum...
return model.Console("Nintendo", "NES", extensions, roms_directory, "", "", "", emu)
Predict the next line after this snippet: <|code_start|> class ROMFinderTests(unittest.TestCase): def setUp(self): self.mock_config = mock() self.mock_filesystem = mock() self.mock_parser = mock() <|code_end|> using the current file's imports: import os import shutil import tempfile import...
self.rom_finder = rom_finder.ROMFinder(
Given snippet: <|code_start|> class SteamGridUpdaterTests(unittest.TestCase): def setUp(self): self.steam_fixture = fixtures.SteamFixture() self.user_fixture = fixtures.UserFixture(self.steam_fixture) self.mock_provider = mock() self.updater = steam_grid_updater.SteamGridUpdater( self.m...
rom = model.ROM(name = 'Game1', path = '/Path/to/game1', console = fixtures.consoles.flagged)
Based on the snippet: <|code_start|> class SteamGridUpdaterTests(unittest.TestCase): def setUp(self): self.steam_fixture = fixtures.SteamFixture() self.user_fixture = fixtures.UserFixture(self.steam_fixture) self.mock_provider = mock() self.updater = steam_grid_updater.SteamGridUpdater( ...
shortcut = roms.rom_to_shortcut(rom)
Using the snippet: <|code_start|> class SteamGridUpdaterTests(unittest.TestCase): def setUp(self): self.steam_fixture = fixtures.SteamFixture() self.user_fixture = fixtures.UserFixture(self.steam_fixture) self.mock_provider = mock() <|code_end|> , determine the next line of code. You have imports: ...
self.updater = steam_grid_updater.SteamGridUpdater(
Continue the code snippet: <|code_start|>""" backed_object_manager_tests.py Created by Scott on 2014-08-20. Copyright (c) 2014 Scott Rice. All rights reserved. """ # The fact that this class exists should probably signal that my current API # isn't perfect... class BackedObjectBackedObjectAdapter(object): def __...
return BackedObject(backing_store, identifier)
Predict the next line for this snippet: <|code_start|>Created by Scott on 2014-08-20. Copyright (c) 2014 Scott Rice. All rights reserved. """ # The fact that this class exists should probably signal that my current API # isn't perfect... class BackedObjectBackedObjectAdapter(object): def __init__(self): # Ver...
self.manager = BackedObjectManager(self.backing_store, self.adapter)
Given the code snippet: <|code_start|>backed_object_manager_tests.py Created by Scott on 2014-08-20. Copyright (c) 2014 Scott Rice. All rights reserved. """ # The fact that this class exists should probably signal that my current API # isn't perfect... class BackedObjectBackedObjectAdapter(object): def __init__(...
self.backing_store = ConfigFileBackingStore(self.tempfile)
Based on the snippet: <|code_start|>#!/usr/bin/env python # encoding: utf-8 class UpdateGridImagesTask(object): def __init__(self, rom_finder): self.rom_finder = rom_finder def __call__(self, app_settings, users, dry_run): roms = self.rom_finder.roms_for_consoles( app_settings.config, app_se...
provider = settings.image_provider(app_settings.config)