Instruction stringlengths 362 7.83k | output_code stringlengths 1 945 |
|---|---|
Given the following code snippet before the placeholder: <|code_start|> grammar_def = [
"S ::= E",
"E ::= one addition two",
"one := String,one",
"two := String,two",
"addition := String,addition",
]
productio... | rdp = LL1RecursiveDescentParser(production_set) |
Predict the next line after this snippet: <|code_start|>#!/usr/bin/python
# -*- coding: utf-8 -*-
# This file is part of pydsl.
#
# pydsl 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, either version 3 of the... | class ParsleyGrammar(Grammar): |
Predict the next line for this snippet: <|code_start|>#!/usr/bin/python
# -*- coding: utf-8 -*-
# This file is part of pydsl.
#
# pydsl 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, either version 3 of the L... | repo[key] = checker_factory(repo[key]) |
Given the following code snippet before the placeholder: <|code_start|>#!/usr/bin/python
# -*- coding: utf-8 -*-
#This file is part of pydsl.
#
#pydsl 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, either versi... | class BacktracingErrorRecursiveDescentParser(TopDownParser): |
Here is a snippet: <|code_start|>
__author__ = "Nestor Arocha"
__copyright__ = "Copyright 2008-2014, Nestor Arocha"
__email__ = "nesaro@gmail.com"
LOG = logging.getLogger(__name__)
class BacktracingErrorRecursiveDescentParser(TopDownParser):
"""Recursive descent parser implementation. Backtracing. Null support. ... | return [ParseTree(0, 0, onlysymbol, "")] |
Given the code snippet: <|code_start|>LOG = logging.getLogger(__name__)
class BacktracingErrorRecursiveDescentParser(TopDownParser):
"""Recursive descent parser implementation. Backtracing. Null support. Error support"""
def get_trees(self, data, showerrors = False): # -> list:
""" returns a list of t... | alternativetree = PositionResultList() |
Given the following code snippet before the placeholder: <|code_start|>#!/usr/bin/python
# -*- coding: utf-8 -*-
#This file is part of pydsl.
#
#pydsl 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, either versi... | if not all(check(self._productionset.alphabet, [x]) for x in data): |
Predict the next line for this snippet: <|code_start|># pydsl 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, either version 3 of the License, or
#(at your option) any later version.
#
# pydsl is distributed i... | class ZeroOrMore(Grammar): |
Predict the next line for this snippet: <|code_start|>#!/usr/bin/env python
# -*- coding: utf-8 -*-
#This file is part of pydsl.
#
#pydsl 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, either version 3 of the L... | re1 = RegularExpression('^a$') |
Based on the snippet: <|code_start|>#!/usr/bin/python
#This file is part of pydsl.
#
#pydsl 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, either version 3 of the License, or
#(at your option) any later version... | if not check(definition, first_element): |
Here is a snippet: <|code_start|> )
# Tokens
t_PLUS = r'\+'
t_MINUS = r'-'
t_TIMES = r'\*'
t_DIVIDE = r'/'
t_EQUALS = r'='
t_LPAREN = r'\('
t_RPAREN = r'\)'
t_NAME = r'[a-zA-Z_][a-zA-Z0-9_]*'
def t_NUMBER(t):
r'\d+'
try:
t.value = int(t.value)
except ValueError:
print("In... | raise ParseError("unknown character", t.lexpos) |
Predict the next line after this snippet: <|code_start|># This file is part of pydsl.
#
# pydsl 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, either version 3 of the License, or
#(at your option) any later v... | if not isinstance(element, Symbol): |
Next line prediction: <|code_start|>
def __hash__(self):
return hash(self.leftside) & hash(self.rightside)
#Only stores a ruleset, and methods to ask properties or validity check
class BNFGrammar(Grammar):
def __init__(self, initialsymbol, fulllist, options=None):
Grammar.__init__(self)
... | return [x for x in self.fulllist if isinstance(x, TerminalSymbol)] |
Given snippet: <|code_start|> if fulllist.count(rule) > 1:
raise ValueError("Duplicated rule: " + str(rule))
self.fulllist = tuple(fulllist)
self.options = options or {}
def __hash__(self):
return hash(self.fulllist)
@property
def alphabet(self):
... | if isinstance(symbol, (TerminalSymbol, NullSymbol)): |
Given the following code snippet before the placeholder: <|code_start|> """
Returns a Grammar Definition with the first n terminal symbols
produced by the input symbol
"""
if isinstance(symbol, (TerminalSymbol, NullSymbol)):
return [symbol.gd]
result = []
... | result.append(EndSymbol()) |
Based on the snippet: <|code_start|> for element in rightside:
if not isinstance(element, Symbol):
raise TypeError
self.leftside = tuple(leftside)
self.rightside = tuple(rightside)
def __str__(self):
leftstr = " ".join([x for x in self.leftside])
r... | class BNFGrammar(Grammar): |
Given snippet: <|code_start|> return False
if not list_eq(self.leftside, other.leftside):
return False
if not list_eq(self.rightside, other.rightside):
return False
except AttributeError:
return False
return True
def... | return Choice([x.gd for x in self.terminal_symbols]) |
Here is a snippet: <|code_start|>#!/usr/bin/env python
# -*- coding: utf-8 -*-
#This file is part of pydsl.
#
#pydsl 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, either version 3 of the License, or
#(at your ... | self.assertSetEqual(self.grammardef.first, set([String("S")])) |
Given the code snippet: <|code_start|> def testCheck(self):
"""Test checker instantiation and call"""
grammardef = PLYGrammar(example_ply)
checker = PLYChecker(grammardef)
self.assertTrue(checker.check("O"))
self.assertTrue(checker.check(["O"]))
self.assertFalse(checke... | number_three = checker_factory(String("3")) |
Next line prediction: <|code_start|> def testCheck(self):
"""Test checker instantiation and call"""
grammardef = PLYGrammar(example_ply)
checker = PLYChecker(grammardef)
self.assertTrue(checker.check("O"))
self.assertTrue(checker.check(["O"]))
self.assertFalse(checker.... | number_three = checker_factory(String("3")) |
Here is a snippet: <|code_start|> fc = {"number_three":number_three}
grammardef = JsonSchema(schema)
checker = JsonSchemaChecker(grammardef, fc) # Adds a format checker
self.assertFalse(checker.check({"foo" : 1, "bar" : "123456"}))
self.assertTrue(checker.check({"foo" : 1, "bar" :... | sequence = Sequence((String("a"), String("b"), String("c"))) |
Predict the next line after this snippet: <|code_start|> lexer = lexer_factory(alphabet, base_alphabet)
totallen = len(inputdata)
maxl = totallen
minl = 1
if fixed_start:
max_start = 1
else:
max_start = totallen
result = []
for i in range(max_start):
for j in range... | checker = checker_factory(grammar) |
Based on the snippet: <|code_start|>__email__ = "nesaro@gmail.com"
LOG = logging.getLogger(__name__)
def filter_subsets(lst):
to_remove = set()
for i, j, _, _ in lst:
for x, y, _, _ in lst:
if (x < i and y >= j) or (x <= i and y > j):
to_remove.add((i,j))
b... | lexer = lexer_factory(alphabet, base_alphabet) |
Based on the snippet: <|code_start|>def extract_alphabet(alphabet, inputdata, fixed_start = False):
"""
Receives a sequence and an alphabet,
returns a list of PositionTokens with all of the parts of the sequence that
are a subset of the alphabet
"""
if not inputdata:
return []
base... | return [PositionToken(content, gd, left, right) for (left, right, content, gd) in result] |
Given the code snippet: <|code_start|>#!/usr/bin/python
# -*- coding: utf-8 -*-
#This file is part of pydsl.
#
#pydsl 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, either version 3 of the License, or
#(at your... | alphabet = Choice([String(x) for x in "abcde1"]) |
Predict the next line for this snippet: <|code_start|>#!/usr/bin/python
# -*- coding: utf-8 -*-
#This file is part of pydsl.
#
#pydsl 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, either version 3 of the Licen... | alphabet = Choice([String(x) for x in "abcde1"]) |
Based on the snippet: <|code_start|>#This file is part of pydsl.
#
#pydsl 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, either version 3 of the License, or
#(at your option) any later version.
#
#pydsl is dist... | return [x for x in self.grammarlist if check(x,data)] |
Continue the code snippet: <|code_start|>__email__ = "nesaro@gmail.com"
@unittest.skip
class TestGrammarDefinitionPLY(unittest.TestCase):
def setUp(self):
self.grammardef = PLYGrammar(plye)
@unittest.skip
def testEnumerate(self):
self.grammardef.enum()
@unittest.skip
def testFir... | self.grammardef = String('abc') |
Predict the next line after this snippet: <|code_start|> self.grammardef.first
@unittest.skip
def testMin(self):
self.grammardef.minsize
@unittest.skip
def testMax(self):
self.grammardef.maxsize
def testAlphabet(self):
self.assertListEqual(self.grammardef.alphabet, ... | self.assertSetEqual(self.grammardef.alphabet, ascii_encoding) |
Based on the snippet: <|code_start|>class Parser(object):
"""Expands an input based on grammar rules
At this time, all parsers are tree based"""
def __init__(self, productionset):
self._productionset = productionset
def get_trees(self, word): # -> list:
""" returns a ParseTree list with ... | self._lexer = lexer_factory(bnfgrammar.alphabet, ascii_encoding) |
Given the following code snippet before the placeholder: <|code_start|>class Parser(object):
"""Expands an input based on grammar rules
At this time, all parsers are tree based"""
def __init__(self, productionset):
self._productionset = productionset
def get_trees(self, word): # -> list:
... | self._lexer = lexer_factory(bnfgrammar.alphabet, ascii_encoding) |
Given snippet: <|code_start|>#it under the terms of the GNU General Public License as published by
#the Free Software Foundation, either version 3 of the License, or
#(at your option) any later version.
#
#pydsl is distributed in the hope that it will be useful,
#but WITHOUT ANY WARRANTY; without even the implied warra... | return TerminalSymbol(String(content)) |
Here is a snippet: <|code_start|>__copyright__ = "Copyright 2008-2014, Nestor Arocha"
__email__ = "nesaro@gmail.com"
LOG = logging.getLogger(__name__)
""" pydsl Grammar definition file parser """
def __generateStringSymbol(rightside):
head, tail = rightside.split(",", 1)
if head != "String":
raise Ty... | symboldict[leftside] = NonTerminalSymbol(leftside) |
Here is a snippet: <|code_start|> #FIXME supports only one symbol
symboldict[leftside] = NonTerminalSymbol(leftside)
rightside = sidesarray[1]
alternatives = [alt.rstrip() for alt in rightside.split("|")]
result = []
n = 0
for alternative in alternatives:
symbollist = alternative.spli... | newsymbol = NullSymbol() |
Predict the next line for this snippet: <|code_start|> raise TypeError
content = tail
if len(tail) > 2 and tail[1][0] == "'" and tail[1][-1] == "'":
content = tail[1][1:-1]
return TerminalSymbol(String(content))
def __generateWordSymbol(rightside, repository):
args = rightside.split(",")... | result.append(Production([symboldict[leftside]], symbolinstancelist)) |
Using the snippet: <|code_start|>#!/usr/bin/python
# -*- coding: utf-8 -*-
#This file is part of pydsl.
#
#pydsl 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, either version 3 of the License, or
#(at your opti... | binary_alphabet = Choice([String('0'), String('1')]) |
Given the code snippet: <|code_start|>#!/usr/bin/python
# -*- coding: utf-8 -*-
#This file is part of pydsl.
#
#pydsl 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, either version 3 of the License, or
#(at your... | parsley_grammar = ParsleyGrammar("""digit = anything:x ?(x in '01') |
Continue the code snippet: <|code_start|>#!/usr/bin/python
# -*- coding: utf-8 -*-
#This file is part of pydsl.
#
#pydsl 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, either version 3 of the License, or
#(at y... | binary_number = OneOrMore(binary_alphabet) |
Next line prediction: <|code_start|>#!/usr/bin/python
# -*- coding: utf-8 -*-
#This file is part of pydsl.
#
#pydsl 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, either version 3 of the License, or
#(at your o... | binary_alphabet = Choice([String('0'), String('1')]) |
Predict the next line for this snippet: <|code_start|># -*- coding: utf-8 -*-
#This file is part of pydsl.
#
#pydsl 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, either version 3 of the License, or
#(at your o... | binary_addition = ParsleyTranslator(parsley_grammar) |
Next line prediction: <|code_start|>
customers = Blueprint('customers', __name__)
#############################################
# Customers
#############################################
@customers.route("/customers", methods=['GET'])
@login_required
def customers_list():
<|code_end|>
. Use current file imports:
(fro... | customers = Customers.query.order_by(Customers.name).all() |
Given snippet: <|code_start|>
customers = Blueprint('customers', __name__)
#############################################
# Customers
#############################################
@customers.route("/customers", methods=['GET'])
@login_required
def customers_list():
customers = Customers.query.order_by(Customers.na... | jobs = Jobs.query.all() |
Given snippet: <|code_start|>
customers = Blueprint('customers', __name__)
#############################################
# Customers
#############################################
@customers.route("/customers", methods=['GET'])
@login_required
def customers_list():
customers = Customers.query.order_by(Customers.na... | hashfiles = Hashfiles.query.all() |
Using the snippet: <|code_start|> customers = Customers.query.order_by(Customers.name).all()
jobs = Jobs.query.all()
hashfiles = Hashfiles.query.all()
return render_template('customers.html', title='Cusomters', customers=customers, jobs=jobs, hashfiles=hashfiles)
@customers.route("/customers/add", metho... | hashfile_hashes = HashfileHashes.query.filter_by(hashfile_id = hashfile.id).all() |
Given snippet: <|code_start|> hashfiles = Hashfiles.query.all()
return render_template('customers.html', title='Cusomters', customers=customers, jobs=jobs, hashfiles=hashfiles)
@customers.route("/customers/add", methods=['GET', 'POST'])
@login_required
def customers_add():
form = CustomersForm()
if form... | hashes = Hashes.query.filter_by(id=hashfile_hash.id, cracked=0).all() |
Predict the next line for this snippet: <|code_start|> form = CustomersForm()
if form.validate_on_submit():
customer = Customers(name=form.name.data)
db.session.add(customer)
db.session.commit()
flash(f'Customer created!', 'success')
return redirect(url_for('customers.cust... | HashNotifications.query.filter_by(hash_id=hashfile_hash.hash_id).delete() |
Given the code snippet: <|code_start|>
customers = Blueprint('customers', __name__)
#############################################
# Customers
#############################################
@customers.route("/customers", methods=['GET'])
@login_required
def customers_list():
customers = Customers.query.order_by(Cus... | form = CustomersForm() |
Predict the next line for this snippet: <|code_start|>
customers = Blueprint('customers', __name__)
#############################################
# Customers
#############################################
@customers.route("/customers", methods=['GET'])
@login_required
def customers_list():
customers = Customers.qu... | db.session.add(customer) |
Next line prediction: <|code_start|>
searches = Blueprint('searches', __name__)
@searches.route("/search", methods=['GET', 'POST'])
@login_required
def searches_list():
customers = Customers.query.all()
hashfiles = Hashfiles.query.all()
<|code_end|>
. Use current file imports:
(from flask import Blueprint, re... | searchForm = SearchForm() |
Using the snippet: <|code_start|>
searches = Blueprint('searches', __name__)
@searches.route("/search", methods=['GET', 'POST'])
@login_required
def searches_list():
<|code_end|>
, determine the next line of code. You have imports:
from flask import Blueprint, render_template, redirect, url_for, request, flash
from f... | customers = Customers.query.all() |
Predict the next line for this snippet: <|code_start|>
searches = Blueprint('searches', __name__)
@searches.route("/search", methods=['GET', 'POST'])
@login_required
def searches_list():
customers = Customers.query.all()
<|code_end|>
with the help of current file imports:
from flask import Blueprint, render_temp... | hashfiles = Hashfiles.query.all() |
Given the code snippet: <|code_start|>
searches = Blueprint('searches', __name__)
@searches.route("/search", methods=['GET', 'POST'])
@login_required
def searches_list():
customers = Customers.query.all()
hashfiles = Hashfiles.query.all()
searchForm = SearchForm()
# TODO
# We should be able to incl... | results = db.session.query(Hashes, HashfileHashes).join(HashfileHashes, Hashes.id==HashfileHashes.hash_id).filter(Hashes.ciphertext==searchForm.query.data).all() |
Based on the snippet: <|code_start|>
searches = Blueprint('searches', __name__)
@searches.route("/search", methods=['GET', 'POST'])
@login_required
def searches_list():
customers = Customers.query.all()
hashfiles = Hashfiles.query.all()
searchForm = SearchForm()
# TODO
# We should be able to includ... | results = db.session.query(Hashes, HashfileHashes).join(HashfileHashes, Hashes.id==HashfileHashes.hash_id).filter(Hashes.ciphertext==searchForm.query.data).all() |
Continue the code snippet: <|code_start|>
searches = Blueprint('searches', __name__)
@searches.route("/search", methods=['GET', 'POST'])
@login_required
def searches_list():
customers = Customers.query.all()
hashfiles = Hashfiles.query.all()
searchForm = SearchForm()
# TODO
# We should be able to i... | results = db.session.query(Hashes, HashfileHashes).join(HashfileHashes, Hashes.id==HashfileHashes.hash_id).filter(Hashes.ciphertext==searchForm.query.data).all() |
Continue the code snippet: <|code_start|>
class JobsForm(FlaskForm):
name = StringField('Job Name', validators=[DataRequired()])
customer_id = StringField('Customer ID (unused)', validators=[DataRequired()])
customer_name = StringField('Customer Name (unused)')
submit = SubmitField('Next')
def val... | job = Jobs.query.filter_by(name = name.data).first() |
Continue the code snippet: <|code_start|>
hashfiles = Blueprint('hashfiles', __name__)
@hashfiles.route("/hashfiles", methods=['GET', 'POST'])
@login_required
def hashfiles_list():
<|code_end|>
. Use current file imports:
from flask import Blueprint, render_template, url_for, redirect, flash
from flask_login import ... | hashfiles = Hashfiles.query.all() |
Predict the next line after this snippet: <|code_start|>
hashfiles = Blueprint('hashfiles', __name__)
@hashfiles.route("/hashfiles", methods=['GET', 'POST'])
@login_required
def hashfiles_list():
hashfiles = Hashfiles.query.all()
<|code_end|>
using the current file's imports:
from flask import Blueprint, render... | customers = Customers.query.order_by(Customers.name).all() |
Given snippet: <|code_start|>
hashfiles = Blueprint('hashfiles', __name__)
@hashfiles.route("/hashfiles", methods=['GET', 'POST'])
@login_required
def hashfiles_list():
hashfiles = Hashfiles.query.all()
customers = Customers.query.order_by(Customers.name).all()
<|code_end|>
, continue by predicting the next l... | jobs = Jobs.query.all() |
Next line prediction: <|code_start|>
hashfiles = Blueprint('hashfiles', __name__)
@hashfiles.route("/hashfiles", methods=['GET', 'POST'])
@login_required
def hashfiles_list():
hashfiles = Hashfiles.query.all()
customers = Customers.query.order_by(Customers.name).all()
jobs = Jobs.query.all()
cracked_... | cracked_cnt = db.session.query(Hashes).join(HashfileHashes, Hashes.id==HashfileHashes.hash_id).filter(Hashes.cracked == '1').filter(HashfileHashes.hashfile_id==hashfile.id).count() |
Here is a snippet: <|code_start|> cracked_cnt = db.session.query(Hashes).join(HashfileHashes, Hashes.id==HashfileHashes.hash_id).filter(Hashes.cracked == '1').filter(HashfileHashes.hashfile_id==hashfile.id).count()
hash_cnt = db.session.query(Hashes).join(HashfileHashes, Hashes.id==HashfileHashes.hash_id... | HashNotifications.query.filter_by(hash_id=hashfile_hash.hash_id).delete() |
Here is a snippet: <|code_start|>
hashfiles = Blueprint('hashfiles', __name__)
@hashfiles.route("/hashfiles", methods=['GET', 'POST'])
@login_required
def hashfiles_list():
hashfiles = Hashfiles.query.all()
customers = Customers.query.order_by(Customers.name).all()
jobs = Jobs.query.all()
cracked_rat... | cracked_cnt = db.session.query(Hashes).join(HashfileHashes, Hashes.id==HashfileHashes.hash_id).filter(Hashes.cracked == '1').filter(HashfileHashes.hashfile_id==hashfile.id).count() |
Given the code snippet: <|code_start|>
hashfiles = Blueprint('hashfiles', __name__)
@hashfiles.route("/hashfiles", methods=['GET', 'POST'])
@login_required
def hashfiles_list():
hashfiles = Hashfiles.query.all()
customers = Customers.query.order_by(Customers.name).all()
jobs = Jobs.query.all()
cracke... | cracked_cnt = db.session.query(Hashes).join(HashfileHashes, Hashes.id==HashfileHashes.hash_id).filter(Hashes.cracked == '1').filter(HashfileHashes.hashfile_id==hashfile.id).count() |
Given snippet: <|code_start|>
settings = Blueprint('settings', __name__)
#############################################
# Settings
#############################################
@settings.route("/settings", methods=['GET', 'POST'])
@login_required
def settings_list():
if current_user.admin:
<|code_end|>
, continue... | HashviewForm = HashviewSettingsForm() |
Based on the snippet: <|code_start|>
settings = Blueprint('settings', __name__)
#############################################
# Settings
#############################################
@settings.route("/settings", methods=['GET', 'POST'])
@login_required
def settings_list():
if current_user.admin:
Hashview... | settings = Settings.query.first() |
Here is a snippet: <|code_start|>
settings = Blueprint('settings', __name__)
#############################################
# Settings
#############################################
@settings.route("/settings", methods=['GET', 'POST'])
@login_required
def settings_list():
if current_user.admin:
HashviewFor... | db.session.commit() |
Given the code snippet: <|code_start|>
task_groups = Blueprint('task_groups', __name__)
@task_groups.route("/task_groups", methods=['GET', 'POST'])
@login_required
def task_groups_list():
task_groups = TaskGroups.query.all()
tasks = Tasks.query.all()
users = Users.query.all()
return render_template('t... | taskGroupsForm = TaskGroupsForm() |
Given snippet: <|code_start|>
task_groups = Blueprint('task_groups', __name__)
@task_groups.route("/task_groups", methods=['GET', 'POST'])
@login_required
def task_groups_list():
task_groups = TaskGroups.query.all()
<|code_end|>
, continue by predicting the next line. Consider current file imports:
from flask imp... | tasks = Tasks.query.all() |
Continue the code snippet: <|code_start|>
task_groups = Blueprint('task_groups', __name__)
@task_groups.route("/task_groups", methods=['GET', 'POST'])
@login_required
def task_groups_list():
<|code_end|>
. Use current file imports:
from flask import Blueprint, render_template, redirect, url_for, flash, abort
from fla... | task_groups = TaskGroups.query.all() |
Predict the next line after this snippet: <|code_start|>
task_groups = Blueprint('task_groups', __name__)
@task_groups.route("/task_groups", methods=['GET', 'POST'])
@login_required
def task_groups_list():
task_groups = TaskGroups.query.all()
tasks = Tasks.query.all()
<|code_end|>
using the current file's imp... | users = Users.query.all() |
Given the following code snippet before the placeholder: <|code_start|>
task_groups = Blueprint('task_groups', __name__)
@task_groups.route("/task_groups", methods=['GET', 'POST'])
@login_required
def task_groups_list():
task_groups = TaskGroups.query.all()
tasks = Tasks.query.all()
users = Users.query.all... | db.session.add(task_group) |
Using the snippet: <|code_start|>#!/usr/bin/python3
parser = argparse.ArgumentParser()
parser.add_argument("--debug", action="store_true", help="increase output verbosity")
args = parser.parse_args()
<|code_end|>
, determine the next line of code. You have imports:
import argparse
import logging
import builtins
... | app = create_app() |
Based on the snippet: <|code_start|>
@login_manager.user_loader
def load_user(user_id):
return Users.query.get(int(user_id))
<|code_end|>
, predict the immediate next line with the help of imports:
from datetime import datetime
from operator import index
from hashview import db, login_manager
from flask_login i... | class Users(db.Model, UserMixin): |
Predict the next line after this snippet: <|code_start|>
@login_manager.user_loader
def load_user(user_id):
return Users.query.get(int(user_id))
class Users(db.Model, UserMixin):
id = db.Column(db.Integer, primary_key=True)
first_name = db.Column(db.String(20), nullable=False)
last_name = db.Column(d... | s = Serializer(Config.SECRET_KEY, expires_sec) |
Predict the next line after this snippet: <|code_start|>
class TaskGroupsForm(FlaskForm):
name = StringField('Name', validators=([DataRequired()]))
submit = SubmitField('Create')
def validate_task(self, name):
<|code_end|>
using the current file's imports:
from flask_wtf import FlaskForm
from wtforms ... | task = Tasks.query.filter_by(name = name.data).first() |
Continue the code snippet: <|code_start|>
class CustomersForm(FlaskForm):
name = StringField('Customer Name', validators=[DataRequired()])
def validate_name(self, name):
<|code_end|>
. Use current file imports:
from flask_wtf import FlaskForm
from wtforms import StringField
from wtforms.validators import Data... | customer = Customers.query.filter_by(name = name.data).first() |
Next line prediction: <|code_start|>
notifications = Blueprint('notifications', __name__)
@notifications.route("/notifications", methods=['GET', 'POST'])
@login_required
def notifications_list():
<|code_end|>
. Use current file imports:
(from flask import Blueprint, render_template, redirect, flash, url_for
from fl... | job_notifications = JobNotifications.query.filter_by(owner_id=current_user.id).all() |
Predict the next line after this snippet: <|code_start|>
notifications = Blueprint('notifications', __name__)
@notifications.route("/notifications", methods=['GET', 'POST'])
@login_required
def notifications_list():
job_notifications = JobNotifications.query.filter_by(owner_id=current_user.id).all()
<|code_end|>... | hash_notifications = HashNotifications.query.filter_by(owner_id=current_user.id).all() |
Using the snippet: <|code_start|>
notifications = Blueprint('notifications', __name__)
@notifications.route("/notifications", methods=['GET', 'POST'])
@login_required
def notifications_list():
job_notifications = JobNotifications.query.filter_by(owner_id=current_user.id).all()
hash_notifications = HashNotifi... | jobs = Jobs.query.all() |
Given the code snippet: <|code_start|>
notifications = Blueprint('notifications', __name__)
@notifications.route("/notifications", methods=['GET', 'POST'])
@login_required
def notifications_list():
job_notifications = JobNotifications.query.filter_by(owner_id=current_user.id).all()
hash_notifications = HashN... | hashes = db.session.query(Hashes).join(HashNotifications, Hashes.id == HashNotifications.hash_id).all() |
Based on the snippet: <|code_start|>
notifications = Blueprint('notifications', __name__)
@notifications.route("/notifications", methods=['GET', 'POST'])
@login_required
def notifications_list():
job_notifications = JobNotifications.query.filter_by(owner_id=current_user.id).all()
hash_notifications = HashNot... | hashfiles = Hashfiles.query.all() |
Based on the snippet: <|code_start|>
notifications = Blueprint('notifications', __name__)
@notifications.route("/notifications", methods=['GET', 'POST'])
@login_required
def notifications_list():
job_notifications = JobNotifications.query.filter_by(owner_id=current_user.id).all()
hash_notifications = HashNot... | hashes = db.session.query(Hashes).join(HashNotifications, Hashes.id == HashNotifications.hash_id).all() |
Predict the next line for this snippet: <|code_start|>
agents = Blueprint('agents', __name__)
@agents.route("/agents", methods=['GET', 'POST'])
@login_required
def agents_list():
if current_user.admin:
<|code_end|>
with the help of current file imports:
from flask import Blueprint, render_template, abort, flash,... | agentsForm = AgentsForm() |
Given the code snippet: <|code_start|>
agents = Blueprint('agents', __name__)
@agents.route("/agents", methods=['GET', 'POST'])
@login_required
def agents_list():
if current_user.admin:
agentsForm = AgentsForm()
if agentsForm.validate_on_submit():
agent_name = agentsForm.name.data
... | agent = Agents.get(agent_id) |
Here is a snippet: <|code_start|> agent.status = 'Authorized'
db.session.commit()
flash('Agent Authorized', 'success')
return redirect(url_for('agents.agents_list'))
else:
abort(403)
@agents.route("/agents/<int:agent_id>/deauthorize", methods=['GET'])
@login_required
def age... | jobtasks = JobTasks.query.filter_by(agent_id = agent_id).count() |
Given the following code snippet before the placeholder: <|code_start|> flash('Agent was working. The active task was not stopped and you will not receive the results.', 'warning')
agent.status = 'Pending'
db.session.commit()
flash('Agent Deauthorized', 'success')
return red... | version = getHashviewVersion() |
Here is a snippet: <|code_start|>
agents = Blueprint('agents', __name__)
@agents.route("/agents", methods=['GET', 'POST'])
@login_required
def agents_list():
if current_user.admin:
agentsForm = AgentsForm()
if agentsForm.validate_on_submit():
agent_name = agentsForm.name.data
... | db.session.commit() |
Given the following code snippet before the placeholder: <|code_start|>
wordlists = Blueprint('wordlists', __name__)
@wordlists.route("/wordlists", methods=['GET'])
@login_required
def wordlists_list():
static_wordlists = Wordlists.query.filter_by(type='static').all()
dynamic_wordlists = Wordlists.query.filter... | form = WordlistsForm() |
Next line prediction: <|code_start|>
wordlists = Blueprint('wordlists', __name__)
@wordlists.route("/wordlists", methods=['GET'])
@login_required
def wordlists_list():
static_wordlists = Wordlists.query.filter_by(type='static').all()
dynamic_wordlists = Wordlists.query.filter_by(type='dynamic').all()
wordl... | tasks = Tasks.query.all() |
Here is a snippet: <|code_start|>
wordlists = Blueprint('wordlists', __name__)
@wordlists.route("/wordlists", methods=['GET'])
@login_required
def wordlists_list():
<|code_end|>
. Write the next line using the current file imports:
from flask import Blueprint, render_template, redirect, url_for, flash
from flask_logi... | static_wordlists = Wordlists.query.filter_by(type='static').all() |
Given the following code snippet before the placeholder: <|code_start|>
wordlists = Blueprint('wordlists', __name__)
@wordlists.route("/wordlists", methods=['GET'])
@login_required
def wordlists_list():
static_wordlists = Wordlists.query.filter_by(type='static').all()
dynamic_wordlists = Wordlists.query.filter... | users = Users.query.all() |
Given the code snippet: <|code_start|>
class UsersForm(FlaskForm):
first_name = StringField('First Name', validators=[DataRequired(), Length(min=1, max=20)])
last_name = StringField('Last Name', validators=[DataRequired(), Length(min=1, max=20)])
email = StringField('Email', validators=[DataRequired(), Emai... | user = Users.query.filter_by(email_address = email.data).first() |
Predict the next line for this snippet: <|code_start|>
def get_wordlists():
return Wordlists.query
def get_rules():
<|code_end|>
with the help of current file imports:
from flask_wtf import FlaskForm
from wtforms import StringField, SubmitField, SelectField
from wtforms.validators import DataRequired, Validation... | return Rules.query |
Given the following code snippet before the placeholder: <|code_start|>
def get_wordlists():
return Wordlists.query
def get_rules():
return Rules.query
class TasksForm(FlaskForm):
name = StringField('Name', validators=([DataRequired()]))
hc_attackmode = SelectField('Attack Mode', choices=[('', '--SELE... | task = Tasks.query.filter_by(name = name.data).first() |
Here is a snippet: <|code_start|>
rules = Blueprint('rules', __name__)
#############################################
# Rules
#############################################
@rules.route("/rules", methods=['GET'])
@login_required
def rules_list():
<|code_end|>
. Write the next line using the current file imports:
impo... | rules = Rules.query.all() |
Using the snippet: <|code_start|>
rules = Blueprint('rules', __name__)
#############################################
# Rules
#############################################
@rules.route("/rules", methods=['GET'])
@login_required
def rules_list():
rules = Rules.query.all()
<|code_end|>
, determine the next line of ... | tasks = Tasks.query.all() |
Given snippet: <|code_start|>
rules = Blueprint('rules', __name__)
#############################################
# Rules
#############################################
@rules.route("/rules", methods=['GET'])
@login_required
def rules_list():
rules = Rules.query.all()
tasks = Tasks.query.all()
<|code_end|>
, c... | jobs = Jobs.query.all() |
Predict the next line for this snippet: <|code_start|>
rules = Blueprint('rules', __name__)
#############################################
# Rules
#############################################
@rules.route("/rules", methods=['GET'])
@login_required
def rules_list():
rules = Rules.query.all()
tasks = Tasks.que... | jobtasks = JobTasks.query.all() |
Using the snippet: <|code_start|>
rules = Blueprint('rules', __name__)
#############################################
# Rules
#############################################
@rules.route("/rules", methods=['GET'])
@login_required
def rules_list():
rules = Rules.query.all()
tasks = Tasks.query.all()
jobs = J... | users = Users.query.all() |
Here is a snippet: <|code_start|>
# TODO
# This whole things is a mess
# Each graph should be its own route
analytics = Blueprint('analytics', __name__)
@analytics.route('/analytics', methods=['GET'])
@login_required
def get_analytics():
if request.args.get("customer_id"):
customer_id = request.args["c... | results = db.session.query(Customers, Hashfiles).join(Hashfiles, Customers.id==Hashfiles.customer_id).order_by(Customers.name) |
Continue the code snippet: <|code_start|>
analytics = Blueprint('analytics', __name__)
@analytics.route('/analytics', methods=['GET'])
@login_required
def get_analytics():
if request.args.get("customer_id"):
customer_id = request.args["customer_id"]
else:
customer_id = None
if request.ar... | fig1_cracked_cnt = db.session.query(Hashes, HashfileHashes).join(HashfileHashes, Hashes.id==HashfileHashes.hash_id).filter(Hashes.cracked == '1').filter(HashfileHashes.hashfile_id==hashfile_id).count() |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.