Instruction
stringlengths
362
7.83k
output_code
stringlengths
1
945
Predict the next line for this snippet: <|code_start|> social_auth = Blueprint('social', __name__) @social_auth.route('/login/<string:backend>/', methods=['GET', 'POST']) @strategy('social.complete') def auth(backend): return do_auth(g.strategy) @social_auth.route('/complete/<string:backend>/', methods=['GET'...
@social_auth.route('/disconnect/<string:backend>/<string:association_id>/',
Given the following code snippet before the placeholder: <|code_start|> social_auth = Blueprint('social', __name__) @social_auth.route('/login/<string:backend>/', methods=['GET', 'POST']) @strategy('social.complete') def auth(backend): return do_auth(g.strategy) @social_auth.route('/complete/<string:backend>/...
@social_auth.route('/disconnect/<string:backend>/<string:association_id>/',
Next line prediction: <|code_start|> social_auth = Blueprint('social', __name__) @social_auth.route('/login/<string:backend>/', methods=['GET', 'POST']) @strategy('social.complete') def auth(backend): return do_auth(g.strategy) @social_auth.route('/complete/<string:backend>/', methods=['GET', 'POST']) @strate...
@social_auth.route('/disconnect/<string:backend>/<string:association_id>/',
Predict the next line for this snippet: <|code_start|> return True @classmethod def changed(cls, user): """The given user instance is ready to be saved""" raise NotImplementedError('Implement in subclass') @classmethod def get_username(cls, user): """Return the usern...
raise NotImplementedError('Implement in subclass')
Given snippet: <|code_start|># coding=utf-8 sys.path.append('..') manager = Manager(app) manager.add_command('runserver', Server()) manager.add_command('shell', Shell(make_context=lambda: { 'app': app, 'db': db, 'models': models, 'user': User, 'auth': UserSocialAuth <|code_end|> , continue by pre...
}))
Here is a snippet: <|code_start|># coding=utf-8 sys.path.append('..') manager = Manager(app) manager.add_command('runserver', Server()) manager.add_command('shell', Shell(make_context=lambda: { 'app': app, 'db': db, <|code_end|> . Write the next line using the current file imports: import sys from flask_scr...
'models': models,
Predict the next line for this snippet: <|code_start|> def backends(): """Load Social Auth current user data to context under the key 'backends'. Will return the output of social.backends.utils.user_backends_data.""" id = session.get('user_id', None) provider = session.get('social_auth_last_login_back...
}
Continue the code snippet: <|code_start|> DEFAULTS = { 'STORAGE': 'social.apps.flask_app.models.FlaskStorage', 'STRATEGY': 'social.strategies.flask_strategy.FlaskStrategy' } def get_helper(name, do_import=False): config = current_app.config.get(setting_name(name), DE...
storage = get_helper('STORAGE')
Based on the snippet: <|code_start|> 'STRATEGY': 'social.strategies.flask_strategy.FlaskStrategy' } def get_helper(name, do_import=False): config = current_app.config.get(setting_name(name), DEFAULTS.get(name, None)) return do_import and module_member(config) or config ...
def login_required(fn):
Using the snippet: <|code_start|> chart_header = start_date.strftime('%b %d %Y') + " - " + end_date.strftime('%b %d %Y') budget_data = {} # budget data for primary chart cat_data = {} # category data for drill down for budget in budgets: subcat = {} #This will hold the dril...
return context
Next line prediction: <|code_start|> class AccountsOverview(View): def get_context(self, *args, **kwargs): transfer_form = TransferForm(prefix='transfer_form') filter_form = FilterForm(prefix='filter_form') accounts = Account.objects.all().order_by('name') ## CODE FOR CHART DATA #...
start_date = kwargs['startdate']
Given the following code snippet before the placeholder: <|code_start|> ###Handle special fields### if key == "budget":# If the transaction is applied towards a budget: #The transaction will hit the monthly budget for the month the transaction is posted in ...
if transaction_form.cleaned_data['direction'] == 'O': #Check the direction of money flow and update the balance of the account
Based on the snippet: <|code_start|> end_date = 0 if (action == 'add_transaction'): transaction_form = AddTransactionForm(request.POST, prefix='transaction_form') if transaction_form.is_valid(): transaction_data = {'account': accountobj} for key, v...
if value == "O": #If money is going OUT it is a debit
Using the snippet: <|code_start|> context = {'transactions': transactions, 'account': accountobj, 'transaction_form': transaction_form, 'filter_form': filter_form, 'balances': balances} return context def get(self, request, account): start_date = 0 end_date = 0 return rend...
year = date.year
Given snippet: <|code_start|> if budget_data['duration'] == 'M': newmonthlybudget = MonthlyBudget.objects.create(budget=newbudget, month=budget_data['starting_month'], planned=budget_data['amount'], actual=0.00) else: start = budget_data['starting_m...
return render(request, 'budget/monthlybudget.html', context)
Given snippet: <|code_start|> class MonthlyBudgetOverview(View): def get(self, request): budget_form = AddMonthlyBudget(prefix='budget_form') filter_form = FilterForm(prefix='filter_form') now = datetime.datetime.now() monthlybudgets = MonthlyBudget.objects.filter(month__year=now.y...
Sum('amount'))
Given the following code snippet before the placeholder: <|code_start|> class MonthlyBudgetOverview(View): def get(self, request): budget_form = AddMonthlyBudget(prefix='budget_form') filter_form = FilterForm(prefix='filter_form') now = datetime.datetime.now() monthlybudgets = Mont...
def post(self, request):
Given snippet: <|code_start|> now = datetime.datetime.now() action = self.request.POST['action'] monthlybudgets = MonthlyBudget.objects.filter(month__year=now.year, month__month=now.month) header = now.strftime('%B') + " " + str(now.year) planned_total = MonthlyBudget.objects.filt...
while start_month < 13:
Using the snippet: <|code_start|> register = template.Library() DOUBLE_RENDER = getattr(settings, 'DOUBLE_RENDER', False) #class RateUrlsNode(template.Node): # def __init__(self, object, up_name, down_name, form_name=None): # self.object, self.up_name, self.down_name = object, up_name, down_name # s...
obj = template.Variable(self.object).resolve(context)
Here is a snippet: <|code_start|> register = template.Library() DOUBLE_RENDER = getattr(settings, 'DOUBLE_RENDER', False) #class RateUrlsNode(template.Node): # def __init__(self, object, up_name, down_name, form_name=None): # self.object, self.up_name, self.down_name = object, up_name, down_name # ...
self.form_name = form_name
Based on the snippet: <|code_start|> # ratings - specific settings ANONYMOUS_KARMA = getattr(settings, 'ANONYMOUS_KARMA', 1) INITIAL_USER_KARMA = getattr(settings, 'ANONYMOUS_KARMA', 4) MINIMAL_ANONYMOUS_IP_DELAY = getattr(settings, 'MINIMAL_ANONYMOUS_IP_DELAY', 1800) RATINGS_COOKIE_NAME = getattr(settings, 'RATINGS_...
class UserKarma(models.Model):
Using the snippet: <|code_start|> def test_karma_gets_created_for_appropriate_total_rate(self): TotalRate.objects.create(amount=100, **self.kw) UserKarma.objects.total_rate_to_karma() self.assert_equals(1, UserKarma.objects.count()) k = UserKarma.objects.all()[0] self.assert_...
f = lambda u:u
Continue the code snippet: <|code_start|> def test_raises_error_on_double_registration_with_different_weights(self): f = lambda u:u karma.sources.register(User, f, 100) self.assert_raises(ImproperlyConfigured, karma.sources.register, User, f, 10) def test_raises_error_on_double_registra...
]),
Next line prediction: <|code_start|> def test_karma_doesnt_get_created_when_no_applicable_ratings(self): UserKarma.objects.total_rate_to_karma() self.assert_equals(0, UserKarma.objects.count()) def test_karma_gets_created_with_weight_for_appropriate_total_rate(self): karma.sources.regist...
self.assert_equals(self.user, k.user)
Given snippet: <|code_start|> for ct in self.objs: objs.append((TotalRate.objects.get_for_object(ct), TotalRate.objects.get_normalized_rating(ct, top))) self.assert_equals([(ct.pk*10, (ct.pk-1)) for ct in self.objs], objs) def test_distribution_in_same_sized_universum(self): objs...
class TestRating(SimpleRateTestCase):
Continue the code snippet: <|code_start|> def test_distribution_in_same_sized_universum(self): objs = [] top = len(self.objs) * 10 for ct in self.objs: objs.append((TotalRate.objects.get_for_object(ct), TotalRate.objects.get_normalized_rating(ct, top))) self.assert_equals(...
def test_rating_shows_in_get_for_model(self):
Next line prediction: <|code_start|> class RatingOptions(admin.ModelAdmin): list_filter = ('time', 'target_ct',) list_display = ('__unicode__', 'time', 'amount', 'user',) <|code_end|> . Use current file imports: (from django.contrib import admin from django_ratings.models import Rating, TotalRate, ModelWeigh...
class TotalRateOptions(admin.ModelAdmin):
Given the code snippet: <|code_start|> class TestAggregation(SimpleRateTestCase): def test_totalrate_from_aggregation(self): now = date.today() for i in range(1,4): Agg.objects.create(people=i, amount=4-i, time=now, period='d', detract=0, **self.kw) Agg.objects.agg_to_totalrate...
def test_aggregation_from_aggegates(self):
Predict the next line after this snippet: <|code_start|> before = now - timedelta(days=40) Agg.objects.create(people=2, amount=4, time=before, **self.kw) Agg.objects.create(people=1, amount=8, time=before, **self.kw) Agg.objects.move_agg_to_agg(now, 'month') expected = [ ...
]
Based on the snippet: <|code_start|> (now.replace(day=1), 12, 3 ), ] self.assert_equals(2, Agg.objects.count()) self.assert_equals(expected, [(a.time, a.people, a.amount) for a in Agg.objects.order_by('time')]) def test_aggregation_from_ratings_works_for_days(self):...
yesterday = now - timedelta(days=1)
Given the code snippet: <|code_start|> now = datetime.now() Rating.objects.create(amount=1, time=now, **self.kw) Rating.objects.create(amount=2, time=now, **self.kw) yesterday = now - timedelta(days=1) Rating.objects.create(amount=4, time=yesterday, **self.kw) Rating.obje...
(now.date(), 2, 3 ),
Next line prediction: <|code_start|> class SimpleRateTestCase(DatabaseTestCase): def setUp(self): super(SimpleRateTestCase, self).setUp() self.obj = ContentType.objects.get_for_model(ContentType) self.kw = { 'target_ct': ContentType.objects.get_for_model(self.obj), ...
for ct in self.objs:
Given the code snippet: <|code_start|> class TestAssets(unittest.TestCase): def setUp(self): self.assets = VersionedAssets() self.assets['jquery.js'][Version('1.7.1')] = 'jquery-1.7.1.js' self.assets['jquery.js'][Version('1.8.3')] = 'jquery-1.8.3.js' self.assets['jquery.some.js'][...
'requires': 'jquery.js>=1.8.3',
Predict the next line for this snippet: <|code_start|> ) def test_asset_unversioned(self): bundle = self.assets.require('jquery.js') assert bundle.contents == ('jquery-1.8.3.js',) def test_asset_versioned(self): bundle = self.assets.require('jquery.js==1.7.1') assert bun...
def test_version_copies(self):
Given snippet: <|code_start|> class TestAssets(unittest.TestCase): def setUp(self): self.assets = VersionedAssets() self.assets['jquery.js'][Version('1.7.1')] = 'jquery-1.7.1.js' self.assets['jquery.js'][Version('1.8.3')] = 'jquery-1.8.3.js' self.assets['jquery.some.js'][Version('...
'provides': 'jquery.js',
Given the code snippet: <|code_start|> self.assets = VersionedAssets() self.assets['jquery.js'][Version('1.7.1')] = 'jquery-1.7.1.js' self.assets['jquery.js'][Version('1.8.3')] = 'jquery-1.8.3.js' self.assets['jquery.some.js'][Version('1.8.3')] = { 'provides': 'jquery.js', ...
bundle = self.assets.require('jquery.js>=1.8.0')
Next line prediction: <|code_start|> # List of patterns, relative to source directory, that match files and # directories to ignore when looking for source files. exclude_patterns = ['_build'] # The reST default role (used for this markup: `text`) to use for all documents. # default_role = None # If true, '()' will b...
html_theme = 'alabaster'
Given the code snippet: <|code_start|>| Computer | $1600 | | Phone | $12 | | Pipe | $1 | | Function name | Description | | ------------- | ------------------------------ | | `help()` | Display the help window. | | `destroy()` | **Destroy your computer!** | ''' sample...
<p>An <a href="https://www.example.com/" rel="nofollow">inline link</a></p>
Continue the code snippet: <|code_start|>app1.config['SQLALCHEMY_TRACK_MODIFICATIONS'] = False db.init_app(app1) app2 = Flask(__name__) app2.config['SQLALCHEMY_DATABASE_URI'] = 'sqlite://' app2.config['SQLALCHEMY_TRACK_MODIFICATIONS'] = False db.init_app(app2) @app1.route('/<doc>') @NamedDocument.is_url_for('view', ...
@app1.route('/<doc>/with/<other>')
Using the snippet: <|code_start|> @app1.route('/<container>/<doc>/edit') @ScopedNamedDocument.is_url_for( 'edit', _external=True, container=('parent', 'id'), doc='name' ) def sdoc_edit(container, doc): return f'edit {container} {doc}' @app1.route('/<doc>/app_only') @NamedDocument.is_url_for('app_only', _app=a...
class TestUrlForBase(unittest.TestCase):
Predict the next line after this snippet: <|code_start|> @app1.route('/<doc>/edit') @NamedDocument.is_url_for('edit', doc='name') def doc_edit(doc): return f'edit {doc}' @app1.route('/<doc>/upper') @NamedDocument.is_url_for('upper', doc=lambda d: d.name.upper()) def doc_upper(doc): return f'upper {doc}' # T...
'edit', _external=True, container=('parent', 'id'), doc='name'
Given the following code snippet before the placeholder: <|code_start|>) def sdoc_edit(container, doc): return f'edit {container} {doc}' @app1.route('/<doc>/app_only') @NamedDocument.is_url_for('app_only', _app=app1, doc='name') def doc_app_only(doc): return f'app_only {doc}' @app1.route('/<doc>/app1') @Nam...
self.ctx = self.app.test_request_context()
Predict the next line after this snippet: <|code_start|> .. cmdoption:: -C, --numc Number of controllers to start, to handle simultaneous requests. Each controller requires one AMQP connection. Default is 2. .. cmdoption:: --sup-interval Supervisor schedule Interval in seconds. Default is 5. """ ...
-- ******* ---- . instancedir: %(instance_dir)s
Next line prediction: <|code_start|> Custom instance directory (default is :file:`instances/``) Must be writeable by the user cyme-branch runs as. .. cmdoption:: -C, --numc Number of controllers to start, to handle simultaneous requests. Each controller requires one AMQP connection. Default is 2. ...
- ** ---------- . presence: interval=%(presence.interval)s
Predict the next line after this snippet: <|code_start|> model = knn.KNNRegressor(k=5, distance_func=distance.euclidean) model.fit(X_train, y_train) predictions = model.predict(X_test) print("regression mse", mean_squared_error(y_test, predictions)) def classification(): X, y = make_classification...
classification()
Using the snippet: <|code_start|>try: except ImportError: def regression(): # Generate a random regression problem X, y = make_regression( <|code_end|> , determine the next line of code. You have imports: from sklearn.model_selection import train_test_split from sklearn.cross_validation import train...
n_samples=500, n_features=5, n_informative=5, n_targets=1, noise=0.05, random_state=1111, bias=0.5
Based on the snippet: <|code_start|> try: except ImportError: logging.basicConfig(level=logging.DEBUG) def classification(): # Generate a random binary classification problem. <|code_end|> , predict the immediate next line with the help of imports: import logging from sklearn.datasets import make_classificati...
X, y = make_classification(
Predict the next line after this snippet: <|code_start|> try: except ImportError: logging.basicConfig(level=logging.DEBUG) def classification(): # Generate a random binary classification problem. X, y = make_classification( <|code_end|> using the current file's imports: import logging from sklearn.datase...
n_samples=350, n_features=15, n_informative=10, random_state=1111, n_classes=2, class_sep=1.0, n_redundant=0
Here is a snippet: <|code_start|> try: except ImportError: logging.basicConfig(level=logging.DEBUG) def classification(): # Generate a random binary classification problem. X, y = make_classification( n_samples=350, n_features=15, n_informative=10, random_state=1111, n_classes=2, class_sep=1.0, n_r...
X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.1, random_state=1111)
Here is a snippet: <|code_start|> def classification(): # Generate a random binary classification problem. X, y = make_classification( n_samples=1000, n_features=10, n_informative=10, random_state=1111, n_classes=2, class_sep=2.5, n_redundant=0 ) <|code_end|> . Write the next line using the curren...
X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.1, random_state=1111)
Given snippet: <|code_start|># coding=utf-8 try: except ImportError: @pytest.fixture def dataset(): # Generate a random binary classification problem. return make_classification( n_samples=1000, n_features=100, n_informative=75, random_state=1111, n_classes=2, class_sep=2.5 ) # TODO: fix @pyte...
predictions = model.predict(X_test_reduced)[:, 1]
Predict the next line after this snippet: <|code_start|># coding=utf-8 try: except ImportError: @pytest.fixture def dataset(): # Generate a random binary classification problem. <|code_end|> using the current file's imports: import pytest from sklearn.datasets import make_classification from sklearn.metrics i...
return make_classification(
Next line prediction: <|code_start|> logging.basicConfig(level=logging.DEBUG) def print_curve(rbm): def moving_average(a, n=25): ret = np.cumsum(a, dtype=float) ret[n:] = ret[n:] - ret[:-n] return ret[n - 1:] / n plt.plot(moving_average(rbm.errors)) plt.show() X = np.random.u...
print_curve(rbm)
Here is a snippet: <|code_start|>from __future__ import division def test_data_validation(): with pytest.raises(ValueError): check_data([], 1) with pytest.raises(ValueError): check_data([1, 2, 3], [3, 2]) a, b = check_data([1, 2, 3], [3, 2, 1]) assert np.all(a == np.array([1, 2, 3...
def metric(name):
Here is a snippet: <|code_start|> with pytest.raises(ValueError): check_data([1, 2, 3], [3, 2]) a, b = check_data([1, 2, 3], [3, 2, 1]) assert np.all(a == np.array([1, 2, 3])) assert np.all(b == np.array([3, 2, 1])) def metric(name): return validate_input(get_metric(name)) def test_cla...
assert f([1, 2, 3], [3, 2, 1]) == 4 / 3
Given snippet: <|code_start|> assert np.all(a == np.array([1, 2, 3])) assert np.all(b == np.array([3, 2, 1])) def metric(name): return validate_input(get_metric(name)) def test_classification_error(): f = metric("classification_error") assert f([1, 2, 3, 4], [1, 2, 3, 4]) == 0 assert f([1, 2,...
assert f([3], [1]) == [4]
Predict the next line for this snippet: <|code_start|> def kmeans_example(plot=False): X, y = make_blobs(centers=4, n_samples=500, n_features=2, shuffle=True, random_state=42) clusters = len(np.unique(y)) k = KMeans(K=clusters, max_iters=150, init="++") <|code_end|> with the help of current file imports:...
k.fit(X)
Predict the next line after this snippet: <|code_start|>try: except ImportError: # Change to DEBUG to see convergence logging.basicConfig(level=logging.ERROR) def regression(): # Generate a random regression problem X, y = make_regression( n_samples=10000, n_features=100, n_informative=75, n_targets...
predictions = model.predict(X_test)
Based on the snippet: <|code_start|> def regression(): # Generate a random regression problem X, y = make_regression( n_samples=10000, n_features=100, n_informative=75, n_targets=1, noise=0.05, random_state=1111, bias=0.5 ) X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.2...
classification()
Predict the next line after this snippet: <|code_start|> try: except ImportError: # Change to DEBUG to see convergence logging.basicConfig(level=logging.ERROR) def regression(): # Generate a random regression problem <|code_end|> using the current file's imports: import logging from sklearn.model_selectio...
X, y = make_regression(
Using the snippet: <|code_start|> try: except ImportError: logging.basicConfig(level=logging.DEBUG) def classification(): # Generate a random binary classification problem. X, y = make_classification( n_samples=500, n_features=10, n_informative=10, random_state=1111, n_classes=2, class_sep=2.5, n_r...
print("classification, accuracy score: %s" % accuracy_score(y_test, predictions))
Here is a snippet: <|code_start|>try: except ImportError: logging.basicConfig(level=logging.DEBUG) def classification(): # Generate a random binary classification problem. X, y = make_classification( n_samples=500, n_features=10, n_informative=10, random_state=1111, n_classes=2, class_sep=2.5, n_red...
X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.1, random_state=1111)
Predict the next line for this snippet: <|code_start|> try: except ImportError: logging.basicConfig(level=logging.DEBUG) <|code_end|> with the help of current file imports: import logging import numpy as np from sklearn.datasets import make_classification from sklearn.datasets import make_regression from sklearn...
def classification():
Using the snippet: <|code_start|># -*- coding: utf-8 -*- def test_bp_add(debugger): src_file = "src/test_breakpoint_basic.cpp" line = 5 debugger.load_binary(os.path.join(TEST_SRC_DIR, "test_breakpoint_basic")) assert debugger.breakpoint_manager.add_breakpoint(src_file, line) assert not debugger...
def test_bp_remove(debugger):
Continue the code snippet: <|code_start|> def is_data_available(fd, timeout=0.05): return len(select.select([fd], [], [], timeout)[0]) != 0 def __init__(self, width=-1, height=-1): Gtk.ScrolledWindow.__init__(self) self.set_hexpand(True) self.set_vexpand(True) self.set_s...
cursor_rectangle.y)
Continue the code snippet: <|code_start|> self.write(text) def _read_data(self, debugger, stream_attr, data_tag): stream_file = getattr(debugger.io_manager, stream_attr) if Console.is_data_available(stream_file): data = stream_file.readline() if len(data) > 0: ...
args=[debugger])
Predict the next line for this snippet: <|code_start|># # This file is part of Devi. # # Devi is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, version 3 of the License, or # (at your option) any ...
self.pack_start(self.entry_value, False, False, 0)
Predict the next line after this snippet: <|code_start|># Devi is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should ...
return self.entry_value.get_text()
Continue the code snippet: <|code_start|># -*- coding: utf-8 -*- # # Copyright (C) 2015-2016 Jakub Beranek # # This file is part of Devi. # # Devi is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation,...
def __init__(self, color=None, bold=False, italic=False, font_family=None):
Continue the code snippet: <|code_start|># -*- coding: utf-8 -*- TEST_FILE = "test_frame" TEST_LINE = 6 def test_frame_list(debugger): def test_frame_list_cb(): assert len(debugger.thread_manager.get_frames()) == 2 setup_debugger(debugger, TEST_FILE, TEST_LINE, test_frame_list_cb) <|code_end|> ....
def test_frame_properties(debugger):
Next line prediction: <|code_start|># -*- coding: utf-8 -*- def test_stop_no_launch(debugger): debugger.load_binary(os.path.join(TEST_SRC_DIR, "test_breakpoint_basic")) debugger.quit_program() def test_load_file(debugger): assert debugger.load_binary(os.path.join(TEST_SRC_DIR, ...
assert debugger.file_manager.get_main_source_file() == os.path.join(
Next line prediction: <|code_start|># -*- coding: utf-8 -*- def test_stop_no_launch(debugger): debugger.load_binary(os.path.join(TEST_SRC_DIR, "test_breakpoint_basic")) debugger.quit_program() <|code_end|> . Use current file imports: (import os from debugger.enums import DebuggerState from tests.conftest...
def test_load_file(debugger):
Continue the code snippet: <|code_start|> def _open_file(self, attribute, mode, file_path): setattr(self, attribute, open(file_path, mode, buffering=0)) def _close_file(self, attribute): try: if getattr(self, attribute): getattr(self, a...
map(lambda thread: thread.join(), self.file_threads)
Here is a snippet: <|code_start|># -*- coding: utf-8 -*- # # Copyright (C) 2015-2016 Jakub Beranek # # This file is part of Devi. # # Devi is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, version...
self.file_paths = []
Given the following code snippet before the placeholder: <|code_start|># -*- coding: utf-8 -*- TEST_FILE = "test_type" TEST_LINE = 51 def check_type(debugger, variable_name, type_name, type_category, basic_type_category=BasicTypeCategory.Invalid): type = debugger.variable_manager.get_type(variabl...
assert type_name(type.name)
Given the following code snippet before the placeholder: <|code_start|> assert type_name(type.name) assert type.type_category == type_category assert type.basic_type_category == basic_type_category return type def test_types(debugger): def test_types_cb(): check_type(debugger, "varInt...
assert type.child_type.name == "int"
Predict the next line after this snippet: <|code_start|># -*- coding: utf-8 -*- TEST_FILE = "test_type" TEST_LINE = 51 def check_type(debugger, variable_name, type_name, type_category, basic_type_category=BasicTypeCategory.Invalid): type = debugger.variable_manager.get_type(variable_name) if...
elif hasattr(type_name, "__call__"):
Based on the snippet: <|code_start|> class ValueEntry(Gtk.Frame): @require_gui_thread def __init__(self, title, text): Gtk.Frame.__init__(self) self.set_label(title) self.set_label_align(0.0, 0.0) self.box = Gtk.Box.new(Gtk.Orientation.HORIZONTAL, 0) self.box.set_margi...
def set_value(self, value):
Predict the next line after this snippet: <|code_start|># # This file is part of Devi. # # Devi is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, version 3 of the License, or # (at your option) an...
self.box.set_margin_bottom(5)
Continue the code snippet: <|code_start|># Devi is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, version 3 of the License, or # (at your option) any later version. # # Devi is distributed in the ...
self.exec_pixbuf = GdkPixbuf.Pixbuf.new_from_file(execution_img_path)
Given snippet: <|code_start|># You should have received a copy of the GNU General Public License # along with Devi. If not, see <http://www.gnu.org/licenses/>. # class BreakpointChangeType(Enum): Create = 1 Delete = 2 class BreakpointRenderer(GtkSource.GutterRendererPixbuf): def __init__(self...
GtkSource.GutterRendererPixbuf.do_draw(self, cr, background_area,
Here is a snippet: <|code_start|># class BreakpointChangeType(Enum): Create = 1 Delete = 2 class BreakpointRenderer(GtkSource.GutterRendererPixbuf): def __init__(self, source_window, breakpoint_img_path, execution_img_path, **properties): super(BreakpointRenderer, self).__in...
start, end, state)
Given the following code snippet before the placeholder: <|code_start|># (at your option) any later version. # # Devi is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU G...
self.set_padding(5, -1)
Predict the next line for this snippet: <|code_start|> enumB = debugger.variable_manager.get_variable("enumB") assert enumB.value == "EnumB::B" setup_debugger(debugger, TEST_FILE, TEST_LINE, test_enum_cb) def test_union(debugger): def test_union_cb(): uniA = debugger.variable_manager.g...
assert debugger.variable_manager.get_variable("a").value == "8"
Next line prediction: <|code_start|>def check_variable(debugger, expression, value=None, size=None): variable = debugger.variable_manager.get_variable(expression) assert variable.path == expression if value is not None: assert variable.value == value if size: if isinstance(size, Itera...
check_variable(debugger, "strA.x", "5", int_size)
Based on the snippet: <|code_start|> toolbar_builder.connect_signals(signals) self.toolbar_builder = toolbar_builder self.toolbar = toolbar_builder.get_object("toolbar") self.debugger = debugger self.debugger.on_process_state_changed.subscribe( self._handle_process_s...
self._change_state("stop", True)
Predict the next line after this snippet: <|code_start|> self._state_stopped() elif state == ProcessState.Running: self._state_running() def _handle_debugger_state_change(self, state, old_value): if (state.is_set(DebuggerState.BinaryLoaded) and not state.is_se...
self.debugger.quit_program()
Predict the next line after this snippet: <|code_start|># # You should have received a copy of the GNU General Public License # along with Devi. If not, see <http://www.gnu.org/licenses/>. # class ToolbarManager(object): def __init__(self, toolbar_builder, debugger): signals = { "tool...
self.grp_halt_control = ["stop", "pause"]
Given snippet: <|code_start|> self.parent_thread = None self.on_signal = EventBroadcaster() self.msg_queue = Queue.Queue() self.child_pid = None self.last_signal = None def run(self): assert not self.parent_thread self.parent_thread = threading.Thread(target=...
return False
Given snippet: <|code_start|> def _parent(self): try: while True: pid, status = os.waitpid(self.child_pid, os.WNOHANG) if pid != 0: self._handle_child_status(status) try: command = self.msg_queue.get(True, 0...
os.WTERMSIG(status),
Given the following code snippet before the placeholder: <|code_start|> file = os.path.abspath(address.file.fullpath) breakpoints.append(Breakpoint(bp.id, file, line)) return breakpoints def toggle_breakpoint(self, location, line): bp = self.find_breakpoint(location,...
if bp.location == location and bp.line == line:
Based on the snippet: <|code_start|># # Devi is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a co...
return breakpoints
Predict the next line for this snippet: <|code_start|> class LldbBreakpointManager(debugger_api.BreakpointManager): def __init__(self, debugger): super(LldbBreakpointManager, self).__init__(debugger) def get_breakpoints(self): bps = [self.debugger.target.GetBreakpointAtIndex(i) ...
location = os.path.abspath(location)
Given the code snippet: <|code_start|> cont=False) def test_thread_switch(debugger): def test_thread_switch_cb(): selected = select_other_thread(debugger) thread_info = debugger.thread_manager.get_thread_info() assert thread_info.selected_thread.id == selected.id ...
def test_thread_frame(debugger):
Next line prediction: <|code_start|> def add_breakpoint(self, file, line): file = os.path.abspath(file) assert self.debugger.program_info.has_location(file, line) for bp in self.breakpoints: # assumes different (file, line) maps to # different addresses if bp.locati...
assert ptrace.ptrace_set_instruction(pid, address, inst)
Here is a snippet: <|code_start|> gdb.INLINE_FRAME] def handle_malloc(self, stop_event): frame = gdb.newest_frame() frame_name = frame.name() if not self.is_valid_memory_frame(frame): return args = self.gdb_helper.get...
frame = gdb.newest_frame()
Given the code snippet: <|code_start|>def test_step_over(debugger): state = AsyncState() def test_step_over_cb(): if state.state == 0: state.inc() debugger.exec_step_over() else: assert debugger.file_manager.get_current_location() ==\ make_loc...
def test_step_out(debugger):
Here is a snippet: <|code_start|> setup_debugger(debugger, TEST_FILE, 11, test_step_in_cb, cont=False) def test_step_out(debugger): state = AsyncState() def test_step_out_cb(): if state.state == 0: state.inc() debugger.exec_step_out() else: location = d...
debugger.quit_program()
Given the following code snippet before the placeholder: <|code_start|># # Copyright (C) 2015-2016 Jakub Beranek # # This file is part of Devi. # # Devi is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Found...
def parse_breakpoints(self, data):
Given snippet: <|code_start|># Copyright (C) 2015-2016 Jakub Beranek # # This file is part of Devi. # # Devi is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, version 3 of the License, or # (at...
return [self._instantiate_breakpoint(bp)