Instruction
stringlengths
362
7.83k
output_code
stringlengths
1
945
Given the code snippet: <|code_start|> self.subscription.disposable = d d.disposable = self.parent.source.subscribeSafe(self) return self.subscription def onNext(self, value): self.observer.onNext(value) def onError(self, exception): if isinstance(exception, self.parent.exception...
class WrapObserver(Observer):
Here is a snippet: <|code_start|> def onError(self, exception): self.observer.onError(exception) self.dispose() def onCompleted(self): self.observer.onCompleted() self.dispose() class SkipTime(Producer): def __init__(self, source, duration, scheduler): self.source = source se...
self.open = Atomic(False)
Given the following code snippet before the placeholder: <|code_start|> self.dispose() class SkipTime(Producer): def __init__(self, source, duration, scheduler): self.source = source self.duration = duration self.scheduler = scheduler def omega(self, duration): if duration < self.duration: ...
return CompositeDisposable(t, d)
Given snippet: <|code_start|> self.selector = selector self.sources = sources self.defaultSource = defaultSource def eval(self): res = self.sources.get(self.selector()) if res != None: return res else: self.defaultSource def run(self, observer, cancel, setSink): sink = self...
return Disposable.empty()
Given the code snippet: <|code_start|> class Latest(PushToPullAdapter): def __init__(self, source): super(Latest, self).__init__(source) def run(self, subscription): return self.Sink(subscription) class Sink(rx.linq.sink.PushToPullSink): def __init__(self, subscription): super(Latest.Sink, se...
self.kind = Notification.KIND_NEXT
Given snippet: <|code_start|> def run(self): self.first = True self.hasResult = False self.result = None return self.parent.scheduler.scheduleWithState( self.parent.initialState, self.invokeRec ) def invokeRec(self, scheduler, state): time = 0 if self....
return Disposable.empty()
Continue the code snippet: <|code_start|> class Next(PushToPullAdapter): def __init__(self, source): super(Next, self).__init__(source) def run(self, subscription): return self.Sink(subscription) class Sink(rx.linq.sink.PushToPullSink): def __init__(self, subscription): super(Next.Sink, self)...
self.kind = Notification.KIND_NEXT
Predict the next line after this snippet: <|code_start|> class If(Producer): def __init__(self, condition, thenSource, elseSource): self.condition = condition self.thenSource = thenSource self.elseSource = elseSource def eval(self): if self.condition(): return self.thenSource else: ...
return Disposable.empty()
Predict the next line for this snippet: <|code_start|> class AddRef(Producer): def __init__(self, source, refCount): self.source = source self.refCount = refCount def run(self, observer, cancel, setSink): <|code_end|> with the help of current file imports: from rx.disposable import CompositeDisposable f...
d = CompositeDisposable(self.refCount.getDisposable(), cancel)
Predict the next line after this snippet: <|code_start|> class TakeTime(Producer): def __init__(self, source, duration, scheduler): self.source = source self.duration = duration self.scheduler = scheduler def omega(self, duration): if self.duration <= duration: return self else: ret...
return CompositeDisposable(t, d)
Given snippet: <|code_start|> def run_tests(test_files): print('Will run the following tests \n\t%s' % "\n\t".join(test_files)) results = list() for test_file in test_files: test_name = os.path.splitext(test_file)[0] test_module = imp.load_source(test_name, test_file) if hasattr(te...
banner = 'V4L %s test of device %s (%s)' %(test_name, v4l_get_name(), device_path)
Given the following code snippet before the placeholder: <|code_start|> test_files.append(os.path.join(root, f)) return test_files def run_tests(test_files): print('Will run the following tests \n\t%s' % "\n\t".join(test_files)) results = list() for test_file in test_files: test...
for device in v4l_get_devices():
Given snippet: <|code_start|>def run_tests(test_files): print('Will run the following tests \n\t%s' % "\n\t".join(test_files)) results = list() for test_file in test_files: test_name = os.path.splitext(test_file)[0] test_module = imp.load_source(test_name, test_file) if hasattr(tes...
v4l_set_current_device(device_path)
Continue the code snippet: <|code_start|> TESTS_DIR = 'tests' def scan_test_folder(folder=TESTS_DIR): test_files = list() for root, dirs, files in os.walk(folder): for f in files: if f.endswith('.py'): test_files.append(os.path.join(root, f)) return test_files def run_...
info = "%s[Pass]%s" %(Colors.GREEN, Colors.DEFAULT)
Continue the code snippet: <|code_start|>#!/usr/bin/env python # -*- coding: utf-8 -*- # Copyright 2015, Florent Thiery cmd_pattern = "gst-launch-1.0 v4l2src device=%s num-buffers=1 ! fakesink -v | grep v4l2src0" def run(): try: <|code_end|> . Use current file imports: import os from utils.process import get_s...
caps = get_stdout(cmd_pattern %v4l_get_current_device(), shell=True).split('caps = ')[1].strip().replace('\\', '')
Continue the code snippet: <|code_start|>#!/usr/bin/env python # -*- coding: utf-8 -*- # Copyright 2015, Florent Thiery cmd_pattern = "gst-launch-1.0 v4l2src device=%s num-buffers=1 ! fakesink -v | grep v4l2src0" def run(): try: <|code_end|> . Use current file imports: import os from utils.process import get_s...
caps = get_stdout(cmd_pattern %v4l_get_current_device(), shell=True).split('caps = ')[1].strip().replace('\\', '')
Predict the next line after this snippet: <|code_start|>#!/usr/bin/env python # -*- coding: utf-8 -*- # Copyright 2015, Florent Thiery #http://www.raspberrypi-spy.co.uk/2012/09/checking-your-raspberry-pi-board-version/ RPI_REV = { '0002': 'Model B', '0003': 'Model B', '0004': 'Model B', '0005': 'Mode...
rev = get_stdout('grep Revision /proc/cpuinfo', shell=True).split(': ')[1].strip()
Using the snippet: <|code_start|> if self.ENABLE_QUALITY_ANALYSIS: quality, min_quality, quality_log = self.get_quality_score(caps, framerate, output_files) quality_results.append(q...
write_timestamped_results(info)
Using the snippet: <|code_start|> write_timestamped_results(info) return (success, info) def get_quality_score(self, raw_caps, framerate, files): print('Running quality analysis with %s' % self.QUALITY_METHOD) muxed_raw_file = os.path.join(self.OUTPUT_FOLDER, self.RAW_REF_FILE) ...
write_results('\n'.join(warnings), fname)
Using the snippet: <|code_start|> else: sink = "fakesink sync=%s" % self.ENABLE_LIVE encoders = list() encoders_short = list() for i in range(1, channel_cou...
took = run_gst_cmd(cmd)
Given snippet: <|code_start|> realtime_duration = num_buffers/framerate fps = int(round(framerate*(realtime_duration / took))) # Assuming that encoders should not be late by mor...
rc, stdout, stderr = run_cmd(cmd)
Based on the snippet: <|code_start|> encoders = list() encoders_short = list() for i in range(1, channel_count + 1): if self.ENABLE_QUALITY_ANALYSIS: ...
print_red('<<< Heat test failed: %s' %plugin_string)
Continue the code snippet: <|code_start|> info += '\nEncoder\tSample\tfps\tdeviation' if self.ENABLE_QUALITY_ANALYSIS: info += "\tq\tminq\tqlog" return info def parse_pattern(self, pattern_string): name, w, h, f = pattern_string.split('=')[1].split('-') return nam...
if is_plugin_present(plugin[0]):
Given the code snippet: <|code_start|> ['x264enc', 'x264enc speed-preset=ultrafast bitrate={bitrate_kb} tune=zerolatency key-int-max={keyframes}'], ] PLUGINS_INTEL = [] PLUGINS_PI = [] PLUGINS_JETSON = [] PLUGINS_NV = [] # List of bitrates in kbit/s BITRATES_K = [ 20000, ...
info = "Gstreamer %s: %s Encoding benchmark (mean fps over %s passes), GPU: %s CPU: %s (live mode: %s)" %(get_gst_version(), self.COLORSPACE, self.PASS_COUNT, hw.gpu(), hw.cpu(), self.ENABLE_LIVE)
Given the following code snippet before the placeholder: <|code_start|>#!/usr/bin/env python # -*- coding: utf-8 -*- # Copyright 2015, Florent Thiery def read_file(path): with open(path, 'r') as f: data = f.read() return data def check_temp_path(path='/tmp'): path = os.path.dirname(path) if ...
d = get_stdout('df %s | tail -n 1' % path, shell=True)
Predict the next line for this snippet: <|code_start|>#!/usr/bin/env python # -*- coding: utf-8 -*- # Copyright 2015, Florent Thiery cmd_pattern = "gst-launch-1.0 v4l2src device=%s num-buffers=1 ! fakesink" MAX_TIME_S = 1 def _run(): run_cmd(cmd_pattern %v4l_get_current_device()) def run(): <|code_end|> with...
took = time_took(_run)
Given the following code snippet before the placeholder: <|code_start|>#!/usr/bin/env python # -*- coding: utf-8 -*- # Copyright 2015, Florent Thiery cmd_pattern = "gst-launch-1.0 v4l2src device=%s num-buffers=1 ! fakesink" MAX_TIME_S = 1 def _run(): <|code_end|> , predict the next line using imports from the curr...
run_cmd(cmd_pattern %v4l_get_current_device())
Here is a snippet: <|code_start|>#!/usr/bin/env python # -*- coding: utf-8 -*- # Copyright 2015, Florent Thiery cmd_pattern = "gst-launch-1.0 v4l2src device=%s num-buffers=1 ! fakesink" MAX_TIME_S = 1 def _run(): <|code_end|> . Write the next line using the current file imports: import os from utils.time import t...
run_cmd(cmd_pattern %v4l_get_current_device())
Predict the next line for this snippet: <|code_start|>#!/usr/bin/env python # -*- coding: utf-8 -*- # Copyright 2015, Florent Thiery cmd_pattern = "gst-launch-1.0 v4l2src device=%s num-buffers=1 ! fakesink" def run(): input('Please make sure that input is NOT connected') print('Running test') <|code_end|>...
result, info = check_cmd(cmd_pattern %v4l_get_current_device())
Given snippet: <|code_start|>#!/usr/bin/env python # -*- coding: utf-8 -*- # Copyright 2015, Florent Thiery cmd_pattern = "gst-launch-1.0 v4l2src device=%s num-buffers=1 ! fakesink" def run(): input('Please make sure that input is NOT connected') print('Running test') <|code_end|> , continue by predicting...
result, info = check_cmd(cmd_pattern %v4l_get_current_device())
Predict the next line for this snippet: <|code_start|>#!/usr/bin/env python # -*- coding: utf-8 -*- # Copyright 2015, Florent Thiery COLORSPACES_BPP = { 'I420': 12, 'YUY2': 16, 'UYVY': 16, 'RGB': 24, 'RGBA': 32, 'NV12': 12, } TMP_BUF_FILE = 'tmp.raw' def get_buffer_size_bytes(colorspace, wi...
memsize = get_free_space_bytes(os.path.dirname(os.path.abspath(raw_buf_file)))
Continue the code snippet: <|code_start|># Copyright 2015, Florent Thiery COLORSPACES_BPP = { 'I420': 12, 'YUY2': 16, 'UYVY': 16, 'RGB': 24, 'RGBA': 32, 'NV12': 12, } TMP_BUF_FILE = 'tmp.raw' def get_buffer_size_bytes(colorspace, width, height): bpp = COLORSPACES_BPP[colorspace] ret...
if not check_temp_path(raw_buf_file):
Given the code snippet: <|code_start|> memsize = get_free_space_bytes(os.path.dirname(os.path.abspath(tmp_location))) # assumption: 20 Mbits/s file, build 1s blocks #blocksize = int(20*1000*1000/8) # FIXME: why is gst-launch-1.0 filesrc location=samples/1080p.mp4 num-buffers=60 blocksize=2500000 ! decode...
run_cmd(cmd)
Here is a snippet: <|code_start|> 'UYVY', 'RGB', 'RGBA' ] def get_test_banner(): info = "glimagesink benchmark, GPU: %s CPU: %s" %(hw.gpu(), hw.cpu()) info += "\nTest\tFramerate" return info def run(): # Ensure that we are not limited by vblank os.environ['vblank_mode'] = '0' info ...
took = run_gst_cmd(cmd)
Given the code snippet: <|code_start|> 'RGBA' ] def get_test_banner(): info = "glimagesink benchmark, GPU: %s CPU: %s" %(hw.gpu(), hw.cpu()) info += "\nTest\tFramerate" return info def run(): # Ensure that we are not limited by vblank os.environ['vblank_mode'] = '0' info = get_test_banner(...
print_red('test %s failed' %testname)
Using the snippet: <|code_start|>#!/usr/bin/env python # -*- coding: utf-8 -*- # Copyright 2015, Florent Thiery framerates = [60, 30, 25] resolutions = [ (3840, 2160), (1920, 1200), (1920, 1080), (1280, 720), (1024, 768), ] cmd_pattern = 'gst-launch-1.0 v4l2src num-buffers=1 device=%s ! "video/...
run_cmd(cmd)
Next line prediction: <|code_start|>#!/usr/bin/env python # -*- coding: utf-8 -*- # Copyright 2015, Florent Thiery framerates = [60, 30, 25] resolutions = [ (3840, 2160), (1920, 1200), (1920, 1080), (1280, 720), (1024, 768), ] cmd_pattern = 'gst-launch-1.0 v4l2src num-buffers=1 device=%s ! "vid...
cmd = cmd_pattern %(v4l_get_current_device(), r[0], r[1], f)
Given the code snippet: <|code_start|>#!/usr/bin/env python # -*- coding: utf-8 -*- # Copyright 2015, Florent Thiery cmd_pattern = "gst-launch-1.0 v4l2src device=%s num-buffers=10 ! fakesink silent=false -v | grep chain" def run(): failed = False for i in range(10): success, msg = _run() if ...
data = get_stdout(cmd_pattern %v4l_get_current_device(), shell=True).strip().split('\n')
Based on the snippet: <|code_start|>#!/usr/bin/env python # -*- coding: utf-8 -*- # Copyright 2015, Florent Thiery cmd_pattern = "gst-launch-1.0 v4l2src device=%s num-buffers=10 ! fakesink silent=false -v | grep chain" def run(): failed = False for i in range(10): success, msg = _run() if no...
data = get_stdout(cmd_pattern %v4l_get_current_device(), shell=True).strip().split('\n')
Next line prediction: <|code_start|># -*- coding: utf-8 -*- from __future__ import unicode_literals try: except ImportError: # pragma: no cover # Python < 2.7 logger = logging.getLogger('staticgen') class StaticgenPool(object): def __init__(self): self._discovered = False self.modules ...
if not settings.STATICGEN_FAIL_SILENTLY:
Here is a snippet: <|code_start|># -*- coding: utf-8 -*- from __future__ import unicode_literals try: except ImportError: # pragma: no cover # Python < 2.7 logger = logging.getLogger('staticgen') class StaticgenPool(object): def __init__(self): self._discovered = False self.modules = {...
raise StaticgenError(message)
Predict the next line for this snippet: <|code_start|> class TestStaticgenStorage(TestCase): @mock_s3 def _upload(self, storage, folder): # setUp connection = connect_s3() connection.create_bucket(settings.AWS_STORAGE_BUCKET_NAME) # upload a file file_name = 's3dumm...
self._upload(StaticgenDefaultFilesStorage(), settings.AWS_S3_DEFAULT_FILES_LOCATION)
Continue the code snippet: <|code_start|> class TestStaticgenStorage(TestCase): @mock_s3 def _upload(self, storage, folder): # setUp connection = connect_s3() connection.create_bucket(settings.AWS_STORAGE_BUCKET_NAME) # upload a file file_name = 's3dummyfile.txt' ...
self._upload(StaticgenStaticFilesStorage(), settings.AWS_S3_STATIC_FILES_LOCATION)
Next line prediction: <|code_start|>#!/usr/bin/env python # -*- coding: utf-8 -*- from __future__ import unicode_literals class TestCommands(TestCase): @mock_s3 def test_publish(self): # setUp connection = connect_s3() connection.create_bucket(settings.AWS_STORAGE_BUCKET_NAME) ...
self.assertEqual(Page.objects.published().count(), 16)
Given the code snippet: <|code_start|># -*- coding: utf-8 -*- from __future__ import unicode_literals logger = logging.getLogger('staticgen') class StaticgenView(object): is_paginated = False def __init__(self, *args, **kwargs): super(StaticgenView, self).__init__(*args, **kwargs) self.c...
if not settings.STATICGEN_FAIL_SILENTLY:
Predict the next line after this snippet: <|code_start|># -*- coding: utf-8 -*- from __future__ import unicode_literals logger = logging.getLogger('staticgen') class StaticgenView(object): is_paginated = False def __init__(self, *args, **kwargs): super(StaticgenView, self).__init__(*args, **kwar...
raise StaticgenError(message)
Given the code snippet: <|code_start|># -*- coding: utf-8 -*- from __future__ import unicode_literals logger = logging.getLogger('staticgen') class StaticgenView(object): is_paginated = False def __init__(self, *args, **kwargs): super(StaticgenView, self).__init__(*args, **kwargs) <|code_end|> ,...
self.client = Client(SERVER_NAME=get_static_site_domain())
Predict the next line for this snippet: <|code_start|>#!/usr/bin/env python # -*- coding: utf-8 -*- from __future__ import unicode_literals class TestStaticgenPageAdmin(TestCase): def setUp(self): for id in range(1, 6): path = '/page{0}/'.format(id) page = Page.objects.create( ...
LogEntry.objects.log_action(change_message, page_id=id)
Using the snippet: <|code_start|>#!/usr/bin/env python # -*- coding: utf-8 -*- from __future__ import unicode_literals class TestStaticgenPageAdmin(TestCase): def setUp(self): for id in range(1, 6): path = '/page{0}/'.format(id) <|code_end|> , determine the next line of code. You have impo...
page = Page.objects.create(
Predict the next line for this snippet: <|code_start|>logger = logging.getLogger('staticgen') class UrlRegistry(object): def __init__(self): self.visited = set() self.to_visit = set() def enqueue(self, url): if url and url not in self.visited: self.to_visit.add(url) ...
if not settings.STATICGEN_FAIL_SILENTLY:
Given snippet: <|code_start|> class UrlRegistry(object): def __init__(self): self.visited = set() self.to_visit = set() def enqueue(self, url): if url and url not in self.visited: self.to_visit.add(url) def __iter__(self): while self.to_visit: url ...
raise StaticgenError(message)
Here is a snippet: <|code_start|>except ImportError: # pragma: no cover # Python 2.X logger = logging.getLogger('staticgen') class UrlRegistry(object): def __init__(self): self.visited = set() self.to_visit = set() def enqueue(self, url): if url and url not in self.visited: ...
self.client = Client(SERVER_NAME=get_static_site_domain())
Based on the snippet: <|code_start|> from __future__ import unicode_literals class ExampleStaticView(StaticgenView): def items(self): return ( 'homepage', 'error_page', 'redirect_home', 'django.contrib.sitemaps.views.sitemap', ) class ExampleLis...
staticgen_pool.register(ExampleStaticView)
Continue the code snippet: <|code_start|># -*- coding: utf-8 -*- from __future__ import unicode_literals class ExampleStaticView(StaticgenView): def items(self): return ( 'homepage', 'error_page', 'redirect_home', 'django.contrib.sitemaps.views.sitemap',...
return Post.objects.all()
Given the code snippet: <|code_start|># -*- coding: utf-8 -*- from __future__ import unicode_literals class ExampleSitemap(Sitemap): changefreq = 'never' priority = 0.5 def items(self): <|code_end|> , generate the next line using the imports in this file: from django.contrib.sitemaps import Sitemap f...
return Post.objects.all()
Next line prediction: <|code_start|># -*- coding: utf-8 -*- from __future__ import unicode_literals class IndexView(TemplateView): template_name = 'example/home.html' class ErrorView(TemplateView): template_name = 'example/error.html' class PostListView(ListView): <|code_end|> . Use current file imports...
model = Post
Given snippet: <|code_start|># -*- coding: utf-8 -*- from __future__ import unicode_literals class PostAdmin(admin.ModelAdmin): pass <|code_end|> , continue by predicting the next line. Consider current file imports: from django.contrib import admin from .models import Post and context: # Path: example/mo...
admin.site.register(Post, PostAdmin)
Given snippet: <|code_start|># -*- coding: utf-8 -*- from __future__ import unicode_literals class TestStaticgenContextProcessors(TestCase): def test_request_with_custom_header(self): request = Mock() request.META = {'HTTP_X_STATICGEN_PUBLISHER': True} <|code_end|> , continue by predicting t...
context = staticgen_publisher(request)
Next line prediction: <|code_start|> from __future__ import unicode_literals try: except ImportError: # pragma: no cover # Python 2.X logger = logging.getLogger('staticgen') class PageQuerySet(models.QuerySet): def changed(self): return self.filter(publisher_state=self.model.PUBLISHER_STATE_CHA...
def on_site(self, site_id=settings.SITE_ID):
Here is a snippet: <|code_start|> return self.get_queryset().pending() def pending_and_changed(self): return self.get_queryset().pending_and_changed() def published(self): return self.get_queryset().published() def deleted(self): return self.get_queryset().deleted() de...
urls.extend(staticgen_pool.get_urls())
Next line prediction: <|code_start|> return self.get_queryset().changed() def pending(self): return self.get_queryset().pending() def pending_and_changed(self): return self.get_queryset().pending_and_changed() def published(self): return self.get_queryset().published() ...
crawler = StaticgenCrawler()
Given the code snippet: <|code_start|># -*- coding: utf-8 -*- from __future__ import unicode_literals class Command(BaseCommand): help = 'Publish/update all registered pages to Amazon S3 via a Celery task.' def handle(self, *args, **options): <|code_end|> , generate the next line using the imports in thi...
publish_pages.delay()
Predict the next line for this snippet: <|code_start|># -*- coding: utf-8 -*- from __future__ import unicode_literals admin.autodiscover() sitemaps = { 'posts': ExampleSitemap } urlpatterns = patterns( '', url(r'^sitemap\.xml$', sitemap, <|code_end|> with the help of current file imports: from dja...
{'sitemaps': override_sitemaps_domain(sitemaps)},
Next line prediction: <|code_start|># -*- coding: utf-8 -*- from __future__ import unicode_literals admin.autodiscover() sitemaps = { 'posts': ExampleSitemap } urlpatterns = patterns( '', url(r'^sitemap\.xml$', sitemap, {'sitemaps': override_sitemaps_domain(sitemaps)}, name='django.c...
url(r'^error\.html$', ErrorView.as_view(), name='error_page'),
Predict the next line for this snippet: <|code_start|># -*- coding: utf-8 -*- from __future__ import unicode_literals admin.autodiscover() sitemaps = { 'posts': ExampleSitemap } urlpatterns = patterns( '', url(r'^sitemap\.xml$', sitemap, {'sitemaps': override_sitemaps_domain(sitemaps)}, ...
url(r'^$', IndexView.as_view(), name='homepage'),
Predict the next line for this snippet: <|code_start|># -*- coding: utf-8 -*- from __future__ import unicode_literals admin.autodiscover() sitemaps = { 'posts': ExampleSitemap } urlpatterns = patterns( '', url(r'^sitemap\.xml$', sitemap, {'sitemaps': override_sitemaps_domain(sitemaps)}, ...
url(r'^posts/(?P<pk>[-\w]+)/$', PostDetailView.as_view(), name='post_detail'),
Next line prediction: <|code_start|># -*- coding: utf-8 -*- from __future__ import unicode_literals admin.autodiscover() sitemaps = { 'posts': ExampleSitemap } urlpatterns = patterns( '', url(r'^sitemap\.xml$', sitemap, {'sitemaps': override_sitemaps_domain(sitemaps)}, name='django.c...
url(r'^posts/$', PostListView.as_view(), name='post_list'),
Based on the snippet: <|code_start|># -*- coding: utf-8 -*- from __future__ import unicode_literals admin.autodiscover() sitemaps = { 'posts': ExampleSitemap } urlpatterns = patterns( '', url(r'^sitemap\.xml$', sitemap, {'sitemaps': override_sitemaps_domain(sitemaps)}, name='django.c...
url(r'^redirect/$', RedirectToHomeView.as_view(), name='redirect_home'),
Predict the next line for this snippet: <|code_start|># -*- coding: utf-8 -*- from __future__ import unicode_literals admin.autodiscover() sitemaps = { <|code_end|> with the help of current file imports: from django.conf.urls import patterns, url, include from django.contrib import admin from django.contrib.si...
'posts': ExampleSitemap
Next line prediction: <|code_start|># -*- coding: utf-8 -*- from __future__ import unicode_literals class TestStaticgenRoutablePageTemplateTag(TestCase): def setUp(self): self.rf = RequestFactory() self.request = self.rf.get(reverse('post_list')) self.context = {'request': self.request...
self.assertEqual(routable_pageurl(self.context, 2), '/posts/page/2/')
Predict the next line after this snippet: <|code_start|># -*- coding: utf-8 -*- from __future__ import unicode_literals class TestStaticgenSitemapsDomainOverride(TestCase): def test_domain_override(self): <|code_end|> using the current file's imports: from django.test import TestCase from example.sitemaps i...
sitemaps = override_sitemaps_domain({'test': ExampleSitemap})
Based on the snippet: <|code_start|># -*- coding: utf-8 -*- from __future__ import unicode_literals class TestStaticgenSitemapsDomainOverride(TestCase): def test_domain_override(self): sitemaps = override_sitemaps_domain({'test': ExampleSitemap}) sitemap = sitemaps['test'] if callable(...
domain = 'http://{domain}'.format(domain=get_static_site_domain())
Given the following code snippet before the placeholder: <|code_start|># -*- coding: utf-8 -*- from __future__ import unicode_literals class TestStaticgenSitemapsDomainOverride(TestCase): def test_domain_override(self): <|code_end|> , predict the next line using imports from the current file: from django.tes...
sitemaps = override_sitemaps_domain({'test': ExampleSitemap})
Using the snippet: <|code_start|># -*- coding: utf-8 -*- from __future__ import unicode_literals class TestStaticgenCrawler(TestCase): def setUp(self): self.crawler = StaticgenCrawler() @override_settings(STATICGEN_SITEMAP_URL='sitemap.xml') def test_get_sitemap_url_from_settings(self): ...
self.assertRaises(StaticgenError, self.crawler.get_sitemap_url)
Given the code snippet: <|code_start|># -*- coding: utf-8 -*- from __future__ import unicode_literals class TestStaticgenCrawler(TestCase): def setUp(self): <|code_end|> , generate the next line using the imports in this file: from django.conf import settings from django.test import TestCase, override_settin...
self.crawler = StaticgenCrawler()
Using the snippet: <|code_start|> # Python 2.X logger = logging.getLogger('staticgen') class StaticgenPublisher(object): model = Page def __init__(self): self.client = None self.connection = None self.bucket = None self.updated_paths = [] self.deleted_paths = [] ...
settings.AWS_ACCESS_KEY_ID,
Predict the next line after this snippet: <|code_start|># -*- coding: utf-8 -*- from __future__ import unicode_literals try: except ImportError: # pragma: no cover # Python 2.X logger = logging.getLogger('staticgen') class StaticgenPublisher(object): model = Page def __init__(self): self....
self.client = Client(SERVER_NAME=get_static_site_domain())
Predict the next line for this snippet: <|code_start|> queryset = queryset.changed() elif pending and changed: queryset = queryset.pending_and_changed() return queryset def get_output_path(self, path): if path.endswith('/'): path = os.path.join(path, 'ind...
LogEntry.objects.log_action(
Using the snippet: <|code_start|># -*- coding: utf-8 -*- from __future__ import unicode_literals try: except ImportError: # pragma: no cover # Python 2.X logger = logging.getLogger('staticgen') class StaticgenPublisher(object): <|code_end|> , determine the next line of code. You have imports: import logg...
model = Page
Here is a snippet: <|code_start|> self.deleted_paths.append((page.path, output_path)) if to_delete: key_chunks = [] for i in range(0, len(to_delete), 100): key_chunks.append(to_delete[i:i+100]) for chunk in key_chunks: bucket.delete...
publishing_complete.send(
Predict the next line after this snippet: <|code_start|>#!/usr/bin/env python # -*- coding: utf-8 -*- from __future__ import unicode_literals class TestStaticgenLogEntryManager(TestCase): change_message = 'Something changed' def setUp(self): self.page = Page.objects.create(path='/', site_id=settin...
self.log_entry = LogEntry.objects.log_action(self.change_message, page_id=self.page.id)
Given the code snippet: <|code_start|>#!/usr/bin/env python # -*- coding: utf-8 -*- from __future__ import unicode_literals class TestStaticgenLogEntryManager(TestCase): change_message = 'Something changed' def setUp(self): <|code_end|> , generate the next line using the imports in this file: from django...
self.page = Page.objects.create(path='/', site_id=settings.SITE_ID)
Predict the next line after this snippet: <|code_start|># -*- coding: utf-8 -*- from __future__ import unicode_literals class TestStaticgenHelpers(TestCase): @mock_s3 @override_settings(STATICGEN_STATIC_SITE_DOMAIN=None) def test_request_with_custom_header(self): # setUp connection = c...
static_domain = get_static_site_domain()
Next line prediction: <|code_start|>#!/usr/bin/env python # -*- coding: utf-8 -*- from __future__ import unicode_literals class TestCeleryTasks(TestCase): def test_sync_pages(self): # this should should add 16 pages to database sync_pages() <|code_end|> . Use current file imports: (from djan...
self.assertEqual(Page.objects.all().count(), 16)
Here is a snippet: <|code_start|> @mock_s3 def test_publish_changed(self): # setUp connection = connect_s3() connection.create_bucket(settings.AWS_STORAGE_BUCKET_NAME) Page.objects.sync() # adds 16 pages to database # mark 5 pages as changed. page_ids = Page.ob...
publish_pages()
Given the code snippet: <|code_start|>#!/usr/bin/env python # -*- coding: utf-8 -*- from __future__ import unicode_literals class TestCeleryTasks(TestCase): def test_sync_pages(self): # this should should add 16 pages to database sync_pages() self.assertEqual(Page.objects.all().count(...
publish_pending()
Given the code snippet: <|code_start|>#!/usr/bin/env python # -*- coding: utf-8 -*- from __future__ import unicode_literals class TestCeleryTasks(TestCase): def test_sync_pages(self): # this should should add 16 pages to database <|code_end|> , generate the next line using the imports in this file: ...
sync_pages()
Continue the code snippet: <|code_start|> connection = connect_s3() connection.create_bucket(settings.AWS_STORAGE_BUCKET_NAME) Page.objects.sync() # there should be 16 pending publish pages in the database self.assertEqual(Page.objects.pending().count(), 16) # actual te...
publish_changed()
Predict the next line after this snippet: <|code_start|>#!/usr/bin/env python # -*- coding: utf-8 -*- from __future__ import unicode_literals class TestStaticgenViews(TestCase): def test_base_staticgen_view_items(self): # base StaticgenView() - this should return empty list. staticgen_view =...
self.assertRaises(StaticgenError, staticgen_view.log_error, message)
Given snippet: <|code_start|>#!/usr/bin/env python # -*- coding: utf-8 -*- from __future__ import unicode_literals class TestStaticgenViews(TestCase): def test_base_staticgen_view_items(self): # base StaticgenView() - this should return empty list. <|code_end|> , continue by predicting the next line...
staticgen_view = StaticgenView()
Predict the next line after this snippet: <|code_start|> # base StaticgenView() - this should return empty list. staticgen_view = StaticgenView() self.assertEqual(len(staticgen_view.items()), 0) @patch('staticgen.staticgen_views.logger') def test_base_staticgen_log_error_logging(self, lo...
module = ExampleDetailView()
Predict the next line after this snippet: <|code_start|> class TestStaticgenViews(TestCase): def test_base_staticgen_view_items(self): # base StaticgenView() - this should return empty list. staticgen_view = StaticgenView() self.assertEqual(len(staticgen_view.items()), 0) @patch('stat...
module = ExampleListView()
Next line prediction: <|code_start|> from __future__ import unicode_literals class TestStaticgenViews(TestCase): def test_base_staticgen_view_items(self): # base StaticgenView() - this should return empty list. staticgen_view = StaticgenView() self.assertEqual(len(staticgen_view.items...
module = ExampleStaticView()
Using the snippet: <|code_start|>#!/usr/bin/env python # -*- coding: utf-8 -*- from __future__ import unicode_literals class TestStaticgenPool(TestCase): def setUp(self): self.staticgen_pool = StaticgenPool() @override_settings(STATICGEN_FAIL_SILENTLY=False) def test_register(self): ...
self.assertRaises(StaticgenError, self.staticgen_pool.register, ExampleStaticView)
Based on the snippet: <|code_start|>#!/usr/bin/env python # -*- coding: utf-8 -*- from __future__ import unicode_literals class TestStaticgenPool(TestCase): def setUp(self): <|code_end|> , predict the immediate next line with the help of imports: from django.test import TestCase, override_settings from stat...
self.staticgen_pool = StaticgenPool()
Next line prediction: <|code_start|>#!/usr/bin/env python # -*- coding: utf-8 -*- from __future__ import unicode_literals class TestStaticgenPool(TestCase): def setUp(self): self.staticgen_pool = StaticgenPool() @override_settings(STATICGEN_FAIL_SILENTLY=False) def test_register(self): <|cod...
self.staticgen_pool.register(ExampleStaticView)
Based on the snippet: <|code_start|># -*- coding: utf-8 -*- from __future__ import unicode_literals def staticgen_publisher(request): context = {} is_publishing = request.META.get('HTTP_X_STATICGEN_PUBLISHER', False) context['STATICGEN_IS_PUBLISHING'] = is_publishing current_site = Site.objects.g...
base_url = get_static_site_domain()
Using the snippet: <|code_start|> def test_get_body_gm(): with pytest.raises(ValueError): body = get_body_gm('no_name_body') body_gm = get_body_gm('moon') <|code_end|> , determine the next line of code. You have imports: import pytest from pygeoid.constants.solar_system_gm import get_body_gm, gm_moo...
assert gm_moon == body_gm
Next line prediction: <|code_start|> def common_precompute(lat, lon, r, r0, lmax): lat = np.atleast_2d(lat) lon = np.atleast_2d(lon) r = np.atleast_2d(r) degrees = np.arange(lmax + 1) m = np.atleast_2d(lon[0]).T * degrees cosin = np.array([np.cos(m), np.sin(m)]) if np.allclose(r[:, 0, N...
p = lplm(lmax, x)
Given snippet: <|code_start|>def in_coeff_potential(x, q, lmax, degrees): p = lplm(lmax, x) q = np.power(q, degrees) l_coeff = np.tile(q, (lmax + 1, 1)).T in_coeff = l_coeff * p return in_coeff def sum_potential(in_coeff, cosin, cilm): cosm_sinm_sum = cilm[0] * cosin[0] + cilm[1] * cosin[1]...
_, p_d1 = lplm_d1(lmax, x)