Instruction
stringlengths
362
7.83k
output_code
stringlengths
1
945
Predict the next line after this snippet: <|code_start|>filter(F, X) to return a string if X is a string and a tuple if X is a tuple. That would require type inference, which we don't do. Let Python 2.6 figure it out. """ # Local imports class FixFilter(fixer_base.ConditionalFix): BM_compatible = True PATT...
|
Continue the code snippet: <|code_start|> def handle_unmatchable(*args, **kwargs): # return 'unmatchable page', 404 data = get_base_data() return render_template('main/404.html', **data), 404 def page_not_found(e): data = get_base_data() return render_template('main/404.html', **data), 40...
return render_template('blog_admin/403.html', msg=e.description), 403
Given the code snippet: <|code_start|> user.save() return redirect(url_for('accounts.users')) return render_template('accounts/registration.html', form=form) def get_current_user(): user = models.User.objects.get(username=current_user.username) return user class Users(MethodView): de...
data = self.get_context(username, form)
Given snippet: <|code_start|> user.biography = form.biography.data user.homepage_url = form.homepage_url.data or None user.social_networks['weibo']['url'] = form.weibo.data or None user.social_networks['weixin']['url'] = form.weixin.data or None user.social_net...
user.linkedin = user.social_networks['linkedin'].get('url')
Given the code snippet: <|code_start|> class SubmitFormBuilder(WagtailCaptchaFormBuilder if has_recaptcha() else FormBuilder): def get_form_class(self): form_class = super(SubmitFormBuilder, self).get_form_class() form_class.required_css_class = 'required' <|code_end|> , generate the next line usin...
return form_class
Given the following code snippet before the placeholder: <|code_start|> logger = logging.getLogger('core') # Signals for Models. Some for performing specific class tasks, some just for clearing the cache. # Set your own classes PAGE_CLASSES = [WagtailPage] @receiver(pre_save) <|code_end|> , predict the next line ...
def pre_page_save(sender, instance, **kwargs):
Here is a snippet: <|code_start|> #Tests can't use manage.py createcachetable due to temporary database, so use dummy CACHES = DEV_CACHES.copy() TEMPLATES = [ { 'BACKEND': 'django.template.backends.django.DjangoTemplates', 'DIRS': [ normpath(join(DJANGO_ROOT, 'core/templates')), ...
'APP_DIRS': True,
Given snippet: <|code_start|> #Tests can't use manage.py createcachetable due to temporary database, so use dummy CACHES = DEV_CACHES.copy() TEMPLATES = [ { 'BACKEND': 'django.template.backends.django.DjangoTemplates', 'DIRS': [ normpath(join(DJANGO_ROOT, 'core/templates')), ], ...
'context_processors': ['django.template.context_processors.debug'] + CONTEXT_PROCESSORS
Here is a snippet: <|code_start|> class ClientTestCase(WagtailTest): def setUp(self): super(ClientTestCase, self).setUp() def testHomePage(self): home_page = HomePage.objects.all()[0] response = self.client.get(home_page.url) self.assertEqual(response.status_code, 200) ...
core_pagetag_items__isnull=False,
Next line prediction: <|code_start|> class ClientTestCase(WagtailTest): def setUp(self): super(ClientTestCase, self).setUp() def testHomePage(self): home_page = HomePage.objects.all()[0] response = self.client.get(home_page.url) self.assertEqual(response.status_code, 200) ...
self.assertContains(
Predict the next line after this snippet: <|code_start|> class ClientTestCase(WagtailTest): def setUp(self): super(ClientTestCase, self).setUp() <|code_end|> using the current file's imports: from taggit.models import Tag from core.models import HomePage, WagtailSitePage from core.tests.utils import W...
def testHomePage(self):
Continue the code snippet: <|code_start|> class TemplateFiltersTestCase(WagtailTest): def setUp(self): super(TemplateFiltersTestCase, self).setUp() <|code_end|> . Use current file imports: from django.template import Context, Template from core.models import HomePage from core.tests.utils import Wagtai...
def test_content_type(self):
Given snippet: <|code_start|> admin.autodiscover() # Register search signal handlers wagtailsearch_register_signal_handlers() urlpatterns = [ url(r'^django-admin/', include(admin.site.urls)), url(r'^admin/', include(wagtailadmin_urls)), url(r'^search/', include(wagtailsearch_urls)), url(r'^documents...
url(r'^images/', include(wagtailimages_urls)),
Predict the next line for this snippet: <|code_start|> class WagtailCompanyPageTestCase(test_utils.WagtailTest): def test_twitter_handler(self): twitter_user = 'springloadnz' twitter_url = 'https://twitter.com/{}'.format(twitter_user) <|code_end|> with the help of current file imports: import co...
twitter_handle = '@{}'.format(twitter_user)
Using the snippet: <|code_start|> # Hacks to prevent pyroma from screwing up the logging system for everyone else old_config = logging.basicConfig try: logging.basicConfig = lambda **k: None finally: logging.basicConfig = old_config # Hacks so we can get the messages of these tests without running them. HA...
setattr(getattr(ratings, clazz), attr, value)
Given the following code snippet before the placeholder: <|code_start|> # Hacks to prevent pyroma from screwing up the logging system for everyone else old_config = logging.basicConfig try: logging.basicConfig = lambda **k: None finally: logging.basicConfig = old_config # Hacks so we can get the messages o...
('ValidREST', '_message', ''),
Predict the next line after this snippet: <|code_start|> # Hacks to prevent pyroma from screwing up the logging system for everyone else old_config = logging.basicConfig try: logging.basicConfig = lambda **k: None finally: logging.basicConfig = old_config # Hacks so we can get the messages of these tests w...
)
Here is a snippet: <|code_start|> class EradicateIssue(Issue): tool = 'eradicate' pylint_type = 'R' CODE = 'commented' <|code_end|> . Write the next line using the current file imports: from eradicate import Eradicator from .base import PythonTool, Issue, AccessIssue and context from other files: # Path...
DESCRIPTION = 'Commented-out code'
Given the code snippet: <|code_start|> class EradicateIssue(Issue): tool = 'eradicate' pylint_type = 'R' <|code_end|> , generate the next line using the imports in this file: from eradicate import Eradicator from .base import PythonTool, Issue, AccessIssue and context (functions, classes, or occasionally...
CODE = 'commented'
Based on the snippet: <|code_start|> class EradicateIssue(Issue): tool = 'eradicate' pylint_type = 'R' CODE = 'commented' <|code_end|> , predict the immediate next line with the help of imports: from eradicate import Eradicator from .base import PythonTool, Issue, AccessIssue and context (classes, functi...
DESCRIPTION = 'Commented-out code'
Given snippet: <|code_start|> class DetectSecretsIssue(Issue): tool = 'secrets' pylint_type = 'W' PLUGINS = tuple(get_mapping_from_secret_type_to_class().values()) <|code_end|> , continue by predicting the next line. Consider current file imports: from detect_secrets import SecretsCollection from detect_...
DESCRIPTION = 'Possible secret detected: {description}'
Next line prediction: <|code_start|> class DetectSecretsIssue(Issue): tool = 'secrets' pylint_type = 'W' <|code_end|> . Use current file imports: (from detect_secrets import SecretsCollection from detect_secrets.core.potential_secret import PotentialSecret from detect_secrets.core.plugins.util import \ ...
PLUGINS = tuple(get_mapping_from_secret_type_to_class().values())
Here is a snippet: <|code_start|> class VultureIssue(Issue): tool = 'vulture' pylint_type = 'R' class TidyPyVulture(Vulture): ISSUE_TYPES = ( ('unused-class', 'Unused class {entity}', 'unused_classes'), ('unused-function', 'Unused function {entity}', 'unused_funcs'), ('unused-i...
ignore_names = config['options']['ignore-names']
Based on the snippet: <|code_start|> # Unfortunately instead of raising exceptions, this base implementation of # this method writes directly to stdout. This is a copy&paste with that # piece replaced by capturing an issue def scan(self, code, filename=''): self.code = code.splitlines() ...
template.format(entity=str(item)),
Given snippet: <|code_start|> class VultureIssue(Issue): tool = 'vulture' pylint_type = 'R' class TidyPyVulture(Vulture): ISSUE_TYPES = ( ('unused-class', 'Unused class {entity}', 'unused_classes'), ('unused-function', 'Unused function {entity}', 'unused_funcs'), ('unused-impor...
ignore_decorators = ignore_decorators.split(',')
Here is a snippet: <|code_start|> # Unfortunately instead of raising exceptions, this base implementation of # this method writes directly to stdout. This is a copy&paste with that # piece replaced by capturing an issue def scan(self, code, filename=''): self.code = code.splitlines() sel...
template.format(entity=str(item)),
Using the snippet: <|code_start|> class McCabeIssue(Issue): tool = 'mccabe' pylint_type = 'W' <|code_end|> , determine the next line of code. You have imports: from mccabe import PathGraphingAstVisitor from .base import PythonTool, Issue, AccessIssue, ParseIssue from ..util import parse_python_file and c...
CODE = 'complex'
Given the code snippet: <|code_start|> class McCabeIssue(Issue): tool = 'mccabe' pylint_type = 'W' CODE = 'complex' <|code_end|> , generate the next line using the imports in this file: from mccabe import PathGraphingAstVisitor from .base import PythonTool, Issue, AccessIssue, ParseIssue from ..util impor...
DESCRIPTION = '"{entity}" is too complex ({score})'
Given snippet: <|code_start|> class McCabeIssue(Issue): tool = 'mccabe' pylint_type = 'W' CODE = 'complex' <|code_end|> , continue by predicting the next line. Consider current file imports: from mccabe import PathGraphingAstVisitor from .base import PythonTool, Issue, AccessIssue, ParseIssue from ..util ...
DESCRIPTION = '"{entity}" is too complex ({score})'
Continue the code snippet: <|code_start|> TMPL_FILENAME = click.style('{filename}', underline=True) + ' ({num_errors})' TMPL_LOCATION = click.style( '{line:>5}{position_splitter}{character:<3} ', dim=True, ) TMPL_TOOLINFO = click.style('({tool}:{code})', fg='yellow', dim=True) <|code_end|> . Use current f...
TAB = ' ' * 8
Predict the next line after this snippet: <|code_start|> ALWAYS_EXCLUDED_DIRS = compile_masks([ r'^\.hg$', r'^\.git$', r'^\.svn$', r'^CVS$', <|code_end|> using the current file's imports: from pathlib import Path from .util import read_file, compile_masks, matches_masks and any relevant context fr...
r'^\.bzr$',
Given the following code snippet before the placeholder: <|code_start|> ALWAYS_EXCLUDED_DIRS = compile_masks([ r'^\.hg$', r'^\.git$', <|code_end|> , predict the next line using imports from the current file: from pathlib import Path from .util import read_file, compile_masks, matches_masks and context incl...
r'^\.svn$',
Based on the snippet: <|code_start|> HOOK_TEMPLATE = '''#!{executable} # TIDYPY-INSTALLED-HOOK import os.path import sys <|code_end|> , predict the immediate next line with the help of imports: import os.path import stat import subprocess # noqa: bandit:B404 import sys from ..config import get_project_config fro...
from tidypy.plugin import git
Based on the snippet: <|code_start|> class DummyDirective(Directive): has_content = True def run(self, *args, **kwargs): # pylint: disable=unused-argument <|code_end|> , predict the immediate next line with the help of imports: import os from importlib import import_module from shutil import rmtr...
return []
Given snippet: <|code_start|> class DummyDirective(Directive): has_content = True def run(self, *args, **kwargs): # pylint: disable=unused-argument return [] <|code_end|> , continue by predicting the next line. Consider current file imports: import os from importlib import import_module...
def dummy_role(*args, **kwargs):
Here is a snippet: <|code_start|> class DummyDirective(Directive): has_content = True def run(self, *args, **kwargs): # pylint: disable=unused-argument return [] <|code_end|> . Write the next line using the current file imports: import os from importlib import import_module from shutil ...
def dummy_role(*args, **kwargs):
Given the code snippet: <|code_start|> class DummyDirective(Directive): has_content = True def run(self, *args, **kwargs): # pylint: disable=unused-argument return [] def dummy_role(*args, **kwargs): # pylint: disable=unused-argument return [], [] dummy_role.content = True cl...
return 'E'
Using the snippet: <|code_start|> class DummyDirective(Directive): has_content = True def run(self, *args, **kwargs): # pylint: disable=unused-argument return [] def dummy_role(*args, **kwargs): # pylint: disable=unused-argument return [], [] dummy_role.content = True class R...
@property
Next line prediction: <|code_start|> def pytest_addoption(parser): group = parser.getgroup( 'tidypy', 'static analysis of a project with TidyPy', ) group.addoption( <|code_end|> . Use current file imports: (import pytest from ..config import get_project_config from ..core import execute...
'--tidypy',
Next line prediction: <|code_start|> self.output('TidyPy Results:\n') super().execute(collector) class TidyPyPlugin: def __init__(self, config): self.enabled = config.getoption('tidypy') self.project_path = config.getoption('tidypy_project_path') \ or str(config.rootdir)...
terminalreporter,
Here is a snippet: <|code_start|> message, self.filename, line=line_number, character=offset + 1, )) elif code == 'E902': message = text[5:].split(':', 1)[1].lstrip() self._tidypy_issues.append(AccessIssue(messag...
super().__init__(**kwargs)
Continue the code snippet: <|code_start|> class PyCodeStyleIssue(Issue): tool = 'pycodestyle' pylint_type = 'C' def __init__(self, code, message, filename, line, character): if code in ('E101',): line = None super().__init__( code, message, ...
)
Next line prediction: <|code_start|> message, self.filename, line=line_number, character=offset + 1, )) elif code == 'E902': message = text[5:].split(':', 1)[1].lstrip() self._tidypy_issues.append(AccessIssue(mes...
super().__init__(**kwargs)
Predict the next line for this snippet: <|code_start|> class PyCodeStyleIssue(Issue): tool = 'pycodestyle' pylint_type = 'C' def __init__(self, code, message, filename, line, character): if code in ('E101',): line = None super().__init__( <|code_end|> with the help of curren...
code,
Given the code snippet: <|code_start|> class TidyPyReporter(Reporter): def __init__(self, config): super().__init__(None, None) self._tidypy_issues = [] self._config = config def unexpectedError(self, filename, msg): # noqa if msg == 'problem decoding source': issue...
message.__class__.__name__,
Here is a snippet: <|code_start|>class TidyPyReporter(Reporter): def __init__(self, config): super().__init__(None, None) self._tidypy_issues = [] self._config = config def unexpectedError(self, filename, msg): # noqa if msg == 'problem decoding source': issue = Par...
message.message % message.message_args,
Predict the next line for this snippet: <|code_start|> class PyFlakesIssue(Issue): tool = 'pyflakes' class TidyPyReporter(Reporter): def __init__(self, config): super().__init__(None, None) self._tidypy_issues = [] self._config = config def unexpectedError(self, filename, msg): #...
if message.__class__.__name__ in self._config['disabled']:
Given the following code snippet before the placeholder: <|code_start|> def unexpectedError(self, filename, msg): # noqa if msg == 'problem decoding source': issue = ParseIssue else: issue = AccessIssue self._tidypy_issues.append(issue( msg, fi...
def get_issues(self):
Based on the snippet: <|code_start|> class YamlLintIssue(Issue): tool = 'yamllint' def __init__(self, *args, **kwargs): <|code_end|> , predict the immediate next line with the help of imports: import basicserial from yamllint import linter from yamllint.config import YamlLintConfig from .base import Tool,...
super().__init__(*args, **kwargs)
Continue the code snippet: <|code_start|> class YamlLintIssue(Issue): tool = 'yamllint' def __init__(self, *args, **kwargs): <|code_end|> . Use current file imports: import basicserial from yamllint import linter from yamllint.config import YamlLintConfig from .base import Tool, Issue, AccessIssue, Unknow...
super().__init__(*args, **kwargs)
Continue the code snippet: <|code_start|> class FilesysExtender(Extender): @classmethod def can_handle(cls, location): return True @classmethod def retrieve(cls, location, project_path): path = Path(location) if not path.is_absolute(): path = Path(project_path).jo...
content = config_file.read()
Continue the code snippet: <|code_start|> class FilesysExtender(Extender): @classmethod def can_handle(cls, location): return True @classmethod def retrieve(cls, location, project_path): path = Path(location) if not path.is_absolute(): path = Path(project_path).jo...
)
Given the following code snippet before the placeholder: <|code_start|> IGNORE_MSGS = ( 'lists of files in version control and sdist match', ) class CheckManifestIssue(Issue): tool = 'manifest' pylint_type = 'W' class CheckManifestUI(check_manifest.UI): def __init__(self, dirname): <|code_end|> ...
super().__init__()
Next line prediction: <|code_start|> IGNORE_MSGS = ( 'lists of files in version control and sdist match', ) class CheckManifestIssue(Issue): tool = 'manifest' pylint_type = 'W' class CheckManifestUI(check_manifest.UI): def __init__(self, dirname): super().__init__() <|code_end|> . Use cu...
self.dirname = dirname
Next line prediction: <|code_start|> class PbbtReport(ConsoleReport): def __init__(self, config, base_path, pbbt_ui): super().__init__(config, base_path) <|code_end|> . Use current file imports: (import os from pbbt import Test, Field, BaseCase, maybe from ..config import get_project_config from ..core...
self.pbbt_ui = pbbt_ui
Using the snippet: <|code_start|>class PbbtReport(ConsoleReport): def __init__(self, config, base_path, pbbt_ui): super().__init__(config, base_path) self.pbbt_ui = pbbt_ui def output(self, msg, newline=True): self.pbbt_ui.literal(msg or ' ') @Test class TidyPyCase(BaseCase): clas...
report.execute(collector)
Here is a snippet: <|code_start|> class PbbtReport(ConsoleReport): def __init__(self, config, base_path, pbbt_ui): super().__init__(config, base_path) self.pbbt_ui = pbbt_ui def output(self, msg, newline=True): self.pbbt_ui.literal(msg or ' ') @Test class TidyPyCase(BaseCase): ...
)
Using the snippet: <|code_start|> class StructuredReport(Report): def get_structure(self, collector): issues = OrderedDict() for filename, file_issues in collector.get_grouped_issues().items(): issues[self.relative_filename(filename)] = [ OrderedDict(( ...
('code', issue.code),
Predict the next line after this snippet: <|code_start|> ) ) config = configparser.ConfigParser() config.read(hgrc) if not config.has_section('hooks'): config.add_section('hooks') config.set( 'hooks', 'precommit.tidypy', ...
config = configparser.ConfigParser()
Given snippet: <|code_start|> report = ConsoleReport(cfg, repo.root) report.execute(collector) strict = ui.configbool('tidypy', 'strict', default=False) if strict and collector.issue_count() > 0: return 1 return 0 class MercurialHook: def get_hgrc(self, path, ensure_exists=False): ...
hgrc = self.get_hgrc(path, ensure_exists=True)
Given snippet: <|code_start|> strict = ui.configbool('tidypy', 'strict', default=False) if strict and collector.issue_count() > 0: return 1 return 0 class MercurialHook: def get_hgrc(self, path, ensure_exists=False): path = Path(path) if not path.exists(): return ...
raise Exception(
Here is a snippet: <|code_start|> RATING = { 'LOW': 1, 'MEDIUM': 2, 'HIGH': 3, } class TidyPyBanditManager(manager.BanditManager): def __init__(self, *args, **kwargs): # pylint: disable=unused-argument self.config = kwargs.pop('config') super().__init__( bandit_config.Band...
if SKIPPED_PARSE.search(reason):
Given the following code snippet before the placeholder: <|code_start|> RATING = { 'LOW': 1, 'MEDIUM': 2, 'HIGH': 3, } class TidyPyBanditManager(manager.BanditManager): def __init__(self, *args, **kwargs): # pylint: disable=unused-argument self.config = kwargs.pop('config') super().__...
if SKIPPED_PARSE.search(reason):
Continue the code snippet: <|code_start|> class BanditIssue(Issue): tool = 'bandit' pylint_type = 'R' SKIPPED_PARSE = re.compile( r'(exception while scanning file|syntax error while parsing AST from file)' ) SKIPPED_ACCESS = re.compile( r'Permission denied' <|code_end|> . Use current file imports...
)
Next line prediction: <|code_start|> class BanditIssue(Issue): tool = 'bandit' pylint_type = 'R' SKIPPED_PARSE = re.compile( r'(exception while scanning file|syntax error while parsing AST from file)' ) SKIPPED_ACCESS = re.compile( r'Permission denied' ) RATING = { 'LOW': 1, 'MEDIUM': 2, ...
profile={
Given the code snippet: <|code_start|> class DlintIssue(Issue): tool = 'dlint' pylint_type = 'W' # pylint: disable=protected-access def get_linter_msg(linter, msg=None): msg = msg or linter._error_tmpl <|code_end|> , generate the next line using the imports in this file: from dlint import linters fr...
if msg.startswith(linter._code):
Given the following code snippet before the placeholder: <|code_start|> class DlintIssue(Issue): tool = 'dlint' pylint_type = 'W' # pylint: disable=protected-access def get_linter_msg(linter, msg=None): msg = msg or linter._error_tmpl if msg.startswith(linter._code): return msg[len(linter...
return msg
Based on the snippet: <|code_start|> class DlintIssue(Issue): tool = 'dlint' pylint_type = 'W' # pylint: disable=protected-access def get_linter_msg(linter, msg=None): msg = msg or linter._error_tmpl if msg.startswith(linter._code): return msg[len(linter._code) + 1:] <|code_end|> , predic...
return msg
Next line prediction: <|code_start|> class NumberFieldTestCase(unittest.TestCase): def setUp(self): pass def tearDown(self): pass def test_basic_creation_with_default(self): number = 122 field = NumberField(default=number) self.assertEqual(number, field.number) ...
try:
Using the snippet: <|code_start|> class BooleanFieldTestCase(unittest.TestCase): def setUp(self): pass def tearDown(self): <|code_end|> , determine the next line of code. You have imports: import unittest from arangodb.orm.fields import BooleanField and context (class names, function names, or cod...
pass
Using the snippet: <|code_start|> class UuidFieldTestCase(unittest.TestCase): def setUp(self): pass def tearDown(self): pass <|code_end|> , determine the next line of code. You have imports: import unittest from arangodb import six from arangodb.orm.fields import UuidField and context (cl...
def test_state(self):
Given the following code snippet before the placeholder: <|code_start|> class UserTestCase(ExtendedTestCase): def setUp(self): self.database_name = 'testcase_user_123' self.db = Database.create(name=self.database_name) def tearDown(self): Database.remove(name=self.database_name) <|...
def test_get_root(self):
Continue the code snippet: <|code_start|> class UserTestCase(ExtendedTestCase): def setUp(self): self.database_name = 'testcase_user_123' self.db = Database.create(name=self.database_name) def tearDown(self): Database.remove(name=self.database_name) def test_get_root(self): ...
self.assertEqual(root.name, 'root')
Predict the next line for this snippet: <|code_start|> class DocumentTestCase(unittest.TestCase): def setUp(self): pass def tearDown(self): pass def test_document_access_values_by_attribute_getter(self): doc = Document(id='', key='', collection='', api=client.api) # set th...
doc_attr_value = 'foo_bar'
Predict the next line after this snippet: <|code_start|> class EndpointTestCase(unittest.TestCase): def setUp(self): pass def tearDown(self): pass def test_get_all_endpoints(self): endpoints = Endpoint.all() <|code_end|> using the current file's imports: import unittest from ...
self.assertTrue(len(endpoints) > 0)
Here is a snippet: <|code_start|> class DatabaseTestCase(unittest.TestCase): def setUp(self): pass def tearDown(self): pass def test_create_and_delete_database(self): database_name = 'test_foo_123' db = Database.create(name=database_name) self.assertIsNotNone(d...
for db in databases:
Predict the next line for this snippet: <|code_start|> self.assertTrue(True, 'The value is valid') def test_equals(self): choice1 = ChoiceField(choices=[ ('value', 'DESCRIPTION'), ('value2', 'DESCRIPTION 2'), ]) choice1.set('value') choice2 = Choice...
choice.validate()
Here is a snippet: <|code_start|> def setUp(self): pass def tearDown(self): pass def test_basic_creation_with_default(self): date = datetime.date.today() field = DateField(default=date) self.assertEqual(date, field.date) def test_equals(self): date = da...
self.assertTrue(field1 != field2)
Next line prediction: <|code_start|> def create_document_from_result_dict(result_dict, api): collection_name = result_dict['_id'].split('/')[0] doc = Document( id=result_dict['_id'], key=result_dict['_key'], rev=result_dict['_rev'], collection=collection_name, <|code_end|> . Us...
api=api,
Continue the code snippet: <|code_start|> [submitter_id] ))) def is_variant_name(self, variant_name): return bool(list(self.cursor.execute( 'SELECT 1 FROM submissions WHERE variant_name=? LIMIT 1', [variant_name] ))) def max_date(self): return...
condition1_name AS condition_name,
Given snippet: <|code_start|>from __future__ import unicode_literals __author__ = 'luissaguas' def save_upload_file(fname, content, dn, parent=None): content_type = mimetypes.guess_type(fname)[0] file_data = write_file_jrxml(fname, content, dn=dn, content_type=content_type, parent=parent) <|code_end|> , contin...
return file_data
Next line prediction: <|code_start|>no_cache = True def get_context(context): if frappe.local.session['sid'] == 'Guest': return {"message":_("Please login first."), "doc_title":_("Not Permitted")} jasper_report_path = frappe.form_dict.jasper_doc_path if not jasper_report_path: return {"message":_("Switch to De...
childrens = frappe.get_all("Jasper Email Report", filters=[crit], fields=["jasper_report_path", "jasper_email_report_name", "jasper_file_name", "jasper_email_date"], order_by="jasper_email_date ASC", limit_page_length=10)
Given snippet: <|code_start|> def run_local_report_async(self, path, doc, data=None, params=None, pformat="pdf", ncopies=1, for_all_sites=0): try: self.frappe_task = FrappeTask(frappe.local.task_id, None) cresp = self.prepare_report_async(path, doc, data=data, params=params, pformat=pformat, ncopies=ncopies, ...
"&password=" + frappe.conf.db_password
Next line prediction: <|code_start|> res = self.prepareResponse({"reportURI": os.path.relpath(batch.outputPath, batch.jasper_path) + os.sep + batch.reportName + "." + pformat}, batch.sessionId) res["status"] = None res["report_name"] = data.get("report_name") resp.append(res) batch.batchReport.setTaskHa...
values = pram[pram_copy_index].get("value","")
Predict the next line after this snippet: <|code_start|> for m in range(ncopies): if pram_copy_index != -1: values = pram[pram_copy_index].get("value","") pram_copy_name = pram[pram_copy_index].get("name","") if not values or not values[0]: hashmap.put(pram_copy_name, copies[m]) else: hash...
return resp
Given snippet: <|code_start|> size += 1 for report in with_param: name = report.parent if name == r.name: if report.jasper_param_action == "Automatic": break report.pop("parent") report.pop("p_name") report.pop("jasper_param_action") ret[r.name]["params"].ap...
return ret
Next line prediction: <|code_start|> xmldoc = JasperXmlReport(jrxml_os_path) if (self.ext!="properties" and self.ext != "xml"): image_path = xmldoc.get_image_path_from_jrxml(self.fname) self.file_path= self.path_join(self.compiled_path, os.path.normpath(image_path)) elif (self.ext == "xml"): x...
jrxml_path = get_jrxml_path(self.jasper_path, self.dn)
Here is a snippet: <|code_start|> self.dn = frappe.form_dict.docname self.autofilename = None self.ext = check_extension(self.fname) self.jasper_all_sites_report = frappe.db.get_value(self.dt, self.dn, 'jasper_all_sites_report') self.jasper_path = get_jasper_path(self.jasper_all_sites_report) self.compiled_p...
"doctype": "File",
Given the code snippet: <|code_start|> try: f.insert(ignore_permissions=True) if self.ext == "jrxml": self.make_content_jrxml(f.name) except frappe.DuplicateEntryError: return frappe.get_doc("File", f.duplicate_entry) return f def process(self, dn=None): if self.ext != "jrxml": self.process_c...
return f
Based on the snippet: <|code_start|> frappe.msgprint(_("The report %s is not a subreport of %s." % (self.fname[:-6], docs[0].file_name[:-6])),raise_exception=True) elif not (sub[:-7] == self.fname[:-6]): frappe.msgprint(_("The report %s is not a subreport of %s." % (self.fname[:-6], docs[0].file_name[:-...
jasper_compile_jrxml(self.fname, self.file_path, self.compiled_path)
Predict the next line after this snippet: <|code_start|> class WriteFileJrxml(object): def __init__(self, dt, fname, content, parent): self.file_path = None self.dt = dt self.fname = fname self.content = content self.parent = parent self.dn = frappe.form_dict.docname self.autofilename = None self.ext...
file_url = os.sep + self.rel_path.replace('\\','/')
Given snippet: <|code_start|> frappe.msgprint(_("The report %s is not a subreport of %s." % (self.fname[:-6], docs[0].file_name[:-6])),raise_exception=True) if not xmldoc.subreports: frappe.msgprint(_("The report %s is not a subreport of %s." % (self.fname[:-6], docs[0].file_name[:-6])),raise_exception=Tr...
def make_thumbnail(self, file_url, doc, dn):
Given the following code snippet before the placeholder: <|code_start|># Copyright (c) 2013, Luis Fernandes and contributors # For license information, please see license.txt from __future__ import unicode_literals class JasperEmailReport(Document): def validate(self): if not self.jasper_email_report_name: <|code...
raise frappe.PermissionError(_("You are not allowed to add this document."))
Predict the next line for this snippet: <|code_start|> #call from bench frappe --python session or #to be called from terminal: bench frappe --execute jasper_erpnext_report.utils.scheduler.list_all_memcached_keys_v4 def list_all_memcached_keys_v4(value=None): keys = [] memc = MemcachedStats() if value: for m in ...
frappe.cache().delete_value(value[1])
Based on the snippet: <|code_start|> keys = redis.get_keys("jasper:user") for key in keys: if check_if_expire(key): redis.delete_value(key) removed += 1 print _("Was removed {0} user(s) from redis cache".format(removed)) return removed #to be called from terminal: bench frappe --execute jasper_erpnex...
if removed == 0:
Using the snippet: <|code_start|>def clear_all_jasper_user_redis_cache(force=True): removed = 0 if force: clear_all_jasper_from_redis_cache("jasper:user") print _("Was removed by force jasper:user* pattern from redis cache") return 1 else: redis = frappe.cache() keys = redis.get_keys("jasper:user") for k...
else:
Using the snippet: <|code_start|>__author__ = 'luissaguas' #call from bench frappe --python session or #to be called from terminal: bench frappe --execute jasper_erpnext_report.utils.scheduler.list_all_memcached_keys_v4 def list_all_memcached_keys_v4(value=None): keys = [] memc = MemcachedStats() if value: for ...
print (keys)
Using the snippet: <|code_start|> if check_if_expire("report_list_doctype"): frappe.cache().delete_value("jasper:report_list_doctype") removed += 1 return removed #remove the files in compiled directory #from command line remove and don't check expire time #from scheduler remove only if past expire time def cle...
intern_reqid = m.get("reqid")
Next line prediction: <|code_start|> for key in keys: if check_if_expire(key): redis.delete_value(key) removed += 1 print _("Was removed {0} user(s) from redis cache".format(removed)) return removed #to be called from terminal: bench frappe --execute jasper_erpnext_report.utils.scheduler.clear_all_jasp...
print _("No user cache was removed.")
Given the following code snippet before the placeholder: <|code_start|>class JasperBase(object): def __init__(self, doc=None, origin=None): doc = doc or {} if isinstance(doc, Document): self.doc = frappe._dict(doc.as_dict()) else: self.doc = frappe._dict(doc) self.user = frappe.local.session["user"] se...
doc_jasper_server = self.doc.use_jasper_server.lower()