Instruction
stringlengths
362
7.83k
output_code
stringlengths
1
945
Based on the snippet: <|code_start|># the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. # # This program 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...
url(r'^statistics/export/$', 'export_highchart_svg', name='export-highchart'),
Given the following code snippet before the placeholder: <|code_start|># -*- coding: utf-8 -*- # # Atizo - The Open Innovation Platform # http://www.atizo.com/ # # Copyright (c) 2008-2010 Atizo AG. All rights reserved. # # This program is free software; you can redistribute it and/or modify # it under the terms of the ...
admin.site.add_action(admin_export_as_csv)
Here is a snippet: <|code_start|># GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA # SELECTION_NAME = _(u'- Bitte w...
return ''
Based on the snippet: <|code_start|> ('auth', {'secret': b'secret'}, b'AUTH\n' + struct.pack('>l', 6) + b'secret'), ('subscribe', {'topic_name': 'test_topic', 'channel_name': 'test_channel'}, b'SUB test_topic test_channel\n'), ('finish', {'message_id': 'test'}, ...
('multipublish',
Given snippet: <|code_start|># -*- coding: utf-8 -*- from __future__ import absolute_import class CompressionSocket(object): def __init__(self, socket): self._socket = socket self._bootstrapped = None def __getattr__(self, name): return getattr(self._socket, name) <|code_end|> , cont...
def bootstrap(self, data):
Predict the next line after this snippet: <|code_start|> try: self.socket = socket.create_connection( address=(self.address, self.port), timeout=self.timeout, ) except socket.error as error: six.raise_from(NSQSocketError(*error.args), ...
return data
Using the snippet: <|code_start|> if not packet: self.close() self.buffer += packet data = self.buffer[:size] self.buffer = self.buffer[size:] return data def send(self, data): self.ensure_connection() with self.lock: tr...
self.buffer = b''
Based on the snippet: <|code_start|># html_theme = 'sphinx_rtd_theme' # Theme options are theme-specific and customize the look and feel of a theme # further. For a list of options available for each theme, see the # documentation. # # html_theme_options = {} # Add any paths that contain custom static files (such as...
htmlhelp_basename = 'gnsqdoc'
Given the code snippet: <|code_start|># -*- coding: utf-8 -*- from __future__ import absolute_import USERAGENT = 'gnsq/{}'.format(__version__) def _encode(value): if isinstance(value, bytes): return value return value.encode('utf-8') def _encode_dict(value): if value is None: <|code_end|> , ...
return None
Given the code snippet: <|code_start|># -*- coding: utf-8 -*- from __future__ import absolute_import USERAGENT = 'gnsq/{}'.format(__version__) def _encode(value): if isinstance(value, bytes): return value return value.encode('utf-8') def _encode_dict(value): if value is None: <|code_end|> , ...
return None
Here is a snippet: <|code_start|># -*- coding: utf-8 -*- from __future__ import absolute_import class SnappySocket(CompressionSocket): def __init__(self, socket): self._decompressor = snappy.StreamDecompressor() <|code_end|> . Write the next line using the current file imports: import snappy from .compre...
self._compressor = snappy.StreamCompressor()
Based on the snippet: <|code_start|># -*- coding: utf-8 -*- from __future__ import absolute_import class DefalteSocket(CompressionSocket): def __init__(self, socket, level): wbits = -zlib.MAX_WBITS self._decompressor = zlib.decompressobj(wbits) self._compressor = zlib.compressobj(level, zl...
super(DefalteSocket, self).__init__(socket)
Continue the code snippet: <|code_start|> @pytest.mark.parametrize('name,good', [ ('valid_name', True), ('invalid name with space', False), ('invalid_name_due_to_length_this_is_' + (4 * 'really_') + 'long', False), ('test-with_period.', True), ('test#ephemeral', True), ('test:ephemeral', False...
def test_assert_topic():
Continue the code snippet: <|code_start|> nsq.assert_valid_topic_name('invalid name with space') def test_assert_channel(): assert nsq.assert_valid_channel_name('channel') is None with pytest.raises(ValueError): nsq.assert_valid_channel_name('invalid name with space') def test_invalid_comman...
timer.failure()
Based on the snippet: <|code_start|> def time(s): return datetime.strptime(s, '%Y-%m-%dT%H:%M:%S+0000') def post_text(item): return item.get('message', u'') + item.get('description', u'') def list_posts(access_token): latest_created_time = FacebookPost.objects\ <|code_end|> , predict the immediate next ...
.filter(access_token=access_token)\
Predict the next line for this snippet: <|code_start|> config = web.config view = web.config.view class front_page: def GET(self): pref = user_pref.reset() facets = items.get_facets_from_cache('', pref) <|code_end|> with the help of current file imports: import web import fsphinx from cloudmini...
return view.layout(view.front_page(facets, pref))
Next line prediction: <|code_start|> query = i.query_inactive + ' ' + query # redirect to a pretty url url = fsphinx.QueryToPrettyUrl(query) raise web.redirect('/search/' + url + '?' + i.params) class search_url: def GET(self, path): # get variables including the user pr...
return config.visu[visu_type].render(facet, animate=True)
Predict the next line after this snippet: <|code_start|># coding=utf-8 from __future__ import unicode_literals code_apply = 'apply(hello, args, kwargs)' code_basestring = 'basestring' code_buffer = "buffer('hello', 1, 3)" code_callable = "callable('hello')" code_dict = """ d.keys() d.iteritems() d.viewvalues() """...
def test():
Given the following code snippet before the placeholder: <|code_start|> class FixHasKey(fixer_base.BaseFix): BM_compatible = True PATTERN = """ anchor=power< before=any+ trailer< '.' 'has_key' > trailer< '(' ( not(arglist | argument<any '=' any>) arg=any ...
>
Given the code snippet: <|code_start|>2) Cases like this will not be converted: m = d.has_key if m(k): ... Only *calls* to has_key() are converted. While it is possible to convert the above to something like m = d.__contains__ if m(k): ... this is currently not done. """ # ...
)
Next line prediction: <|code_start|>d.viewkeys() -> d.keys() d.viewitems() -> d.items() d.viewvalues() -> d.values() Except in certain very specific contexts: the iter() can be dropped when the context is list(), sorted(), iter() or for...in; the list() can be dropped when the context is list() or sorted() (but not it...
tail=any*
Predict the next line after this snippet: <|code_start|> d.viewkeys() -> d.keys() d.viewitems() -> d.items() d.viewvalues() -> d.values() Except in certain very specific contexts: the iter() can be dropped when the context is list(), sorted(), iter() or for...in; the list() can be dropped when the context is list() or...
parens=trailer< '(' ')' >
Given the code snippet: <|code_start|>d.iterkeys() -> iter(d.keys()) d.iteritems() -> iter(d.items()) d.itervalues() -> iter(d.values()) d.viewkeys() -> d.keys() d.viewitems() -> d.items() d.viewvalues() -> d.values() Except in certain very specific contexts: the iter() can be dropped when the context is list(), sort...
power< head=any+
Here is a snippet: <|code_start|># Copyright 2007 Google, Inc. All Rights Reserved. # Licensed to PSF under a Contributor Agreement. """Fixer that changes xrange(...) into range(...).""" # Local imports class FixXrange(fixer_base.BaseFix): BM_compatible = True PATTERN = """ power< <|code_end|...
(name='xrange') trailer< '(' args=any ')' >
Given the code snippet: <|code_start|>except NameError: unicode = str def encode_ascii(value): if sys.version_info < (3,): return value.encode("ascii") else: return value def invocation(s): def dec(f): f.invocation = s return f return dec class FixOperator(fixer...
trailer< '.' %(methods)s > trailer< %(obj)s > >
Next line prediction: <|code_start|> def encode_ascii(value): if sys.version_info < (3,): return value.encode("ascii") else: return value def invocation(s): def dec(f): f.invocation = s return f return dec class FixOperator(fixer_base.BaseFix): BM_compatible = Tr...
power< %(methods)s trailer< %(obj)s > >
Given the code snippet: <|code_start|> def encode_ascii(value): if sys.version_info < (3,): return value.encode("ascii") else: return value def invocation(s): def dec(f): f.invocation = s return f return dec class FixOperator(fixer_base.BaseFix): BM_compatible = ...
power< %(methods)s trailer< %(obj)s > >
Based on the snippet: <|code_start|> try: unicode except NameError: unicode = str def encode_ascii(value): if sys.version_info < (3,): return value.encode("ascii") else: return value def invocation(s): def dec(f): f.invocation = s return f return dec class...
|'repeat'|'irepeat')
Here is a snippet: <|code_start|> try: unicode except NameError: unicode = str def encode_ascii(value): if sys.version_info < (3,): return value.encode("ascii") else: return value def invocation(s): def dec(f): f.invocation = s return f return dec class Fi...
|'repeat'|'irepeat')
Here is a snippet: <|code_start|> finally: sys.stdin = save expected = ["def parrot(): pass\n\n", "def cheese(): pass\n\n", "<stdin>", False] self.assertEqual(results, expected) def check_file_refactoring(self, test_file, fixers=_2TO3_FIXER...
return
Given the following code snippet before the placeholder: <|code_start|> def test_refactor_dir(self): def check(structure, expected): def mock_refactor_file(self, f, *args): got.append(f) save_func = refactor.RefactoringTool.refactor_file refactor.Refactori...
os.path.join("a_dir", "stuff.py")]
Here is a snippet: <|code_start|> self.assertEqual(run(inp), fs(("generators", "print_function"))) invalid = ("from", "from 4", "from x", "from x 5", "from x im", "from x import", "from x imp...
PATTERN = "'name'"
Based on the snippet: <|code_start|># Local imports MAPPING = {"sys": {"maxint" : "maxsize"}, } LOOKUP = {} try: unicode except NameError: unicode = str def alternates(members): return "(" + "|".join(map(repr, members)) + ")" def build_pattern(): #bare = set() for module, replace i...
( attr_name=%r | import_as_name< attr_name=%r 'as' any >) >
Next line prediction: <|code_start|># Local imports MAPPING = {"sys": {"maxint" : "maxsize"}, } LOOKUP = {} try: unicode except NameError: unicode = str def alternates(members): return "(" + "|".join(map(repr, members)) + ")" def build_pattern(): #bare = set() for module, replace i...
( attr_name=%r | import_as_name< attr_name=%r 'as' any >) >
Given snippet: <|code_start|>"""Fix bound method attributes (method.im_? -> method.__?__). """ # Author: Christian Heimes # Local imports try: unicode except NameError: unicode = str MAP = { "im_func" : "__func__", "im_self" : "__self__", "im_class" : "__self__.__class__" } class FixMethod...
power< any+ trailer< '.' attr=('im_func' | 'im_self' | 'im_class') > any* >
Using the snippet: <|code_start|> a = "operator .mul(x, n)" self.check(b, a) b = "operator. repeat(x, n)" a = "operator. mul(x, n)" self.check(b, a) def test_operator_irepeat(self): b = "operator.irepeat(x, n)" a = "operator.imul(x, n)" self.check(b...
def test_bare_operator_isSequenceType(self):
Using the snippet: <|code_start|> b = """ try: pass except Exception, a().foo: pass""" a = """ try: pass except Exception as xxx_todo_changeme: a().foo = xxx_todo_changeme pass...
self.check(b, a)
Given the code snippet: <|code_start|> s = """print()""" self.unchanged(s) s = """print('')""" self.unchanged(s) def test_1(self): b = """print 1, 1+1, 1+1+1""" a = """print(1, 1+1, 1+1+1)""" self.check(b, a) def test_2(self): b = """print 1, 2""...
self.check(b, a)
Given snippet: <|code_start|>- "except E, T:" where T is not a name, tuple or list: except E as t: T = t This is done because the target of an "except" clause must be a name. - "except E, T:" where T is a tuple or list literal: except E as t: T = t.args """ # Author: ...
['else' ':' (simple_stmt | suite)]
Continue the code snippet: <|code_start|> except E as T: - "except E, T:" where T is not a name, tuple or list: except E as t: T = t This is done because the target of an "except" clause must be a name. - "except E, T:" where T is a tuple or list literal: except E as t: ...
try_stmt< 'try' ':' (simple_stmt | suite)
Given snippet: <|code_start|> except E as T: - "except E, T:" where T is not a name, tuple or list: except E as t: T = t This is done because the target of an "except" clause must be a name. - "except E, T:" where T is a tuple or list literal: except E as t: T = t...
cleanup=(except_clause ':' (simple_stmt | suite))+
Next line prediction: <|code_start|> except E as t: T = t This is done because the target of an "except" clause must be a name. - "except E, T:" where T is a tuple or list literal: except E as t: T = t.args """ # Author: Collin Winter # Local imports def find_excepts...
['finally' ':' (simple_stmt | suite)]) >
Continue the code snippet: <|code_start|> - "except E, T:" where T is not a name, tuple or list: except E as t: T = t This is done because the target of an "except" clause must be a name. - "except E, T:" where T is a tuple or list literal: except E as t: T = t.args "...
tail=(['except' ':' (simple_stmt | suite)]
Given the following code snippet before the placeholder: <|code_start|>- "except E, T:" where T is not a name, tuple or list: except E as t: T = t This is done because the target of an "except" clause must be a name. - "except E, T:" where T is a tuple or list literal: except E a...
['else' ':' (simple_stmt | suite)]
Predict the next line after this snippet: <|code_start|> class TestDriver(support.TestCase): def test_formfeed(self): s = """print 1\n\x0Cprint 2\n""" t = driver.parse_string(s) self.assertEqual(t.children[0].children[0].type, syms.print_stmt) self.assertEqual(t.children[1].children...
def test_2x_style_3(self):
Next line prediction: <|code_start|> # Local imports class TestDriver(support.TestCase): def test_formfeed(self): s = """print 1\n\x0Cprint 2\n""" t = driver.parse_string(s) self.assertEqual(t.children[0].children[0].type, syms.print_stmt) self.assertEqual(t.children[1].children[0...
def test_2x_style_2(self):
Given snippet: <|code_start|> lambda (x, y): x + y -> lambda t: t[0] + t[1] # The parens are a syntax error in Python 3 lambda (x): x + y -> lambda x: x + y """ # Author: Collin Winter # Local imports try: unicode except NameError: unicode = str def is_docstring(stmt): return isinstance(stm...
lambdef< 'lambda' args=vfpdef< '(' inner=any ')' >
Using the snippet: <|code_start|> ... It will also support lambdas: lambda (x, y): x + y -> lambda t: t[0] + t[1] # The parens are a syntax error in Python 3 lambda (x): x + y -> lambda x: x + y """ # Author: Collin Winter # Local imports try: unicode except NameError: unicode = str def i...
funcdef< 'def' any parameters< '(' args=any ')' >
Here is a snippet: <|code_start|> # The parens are a syntax error in Python 3 lambda (x): x + y -> lambda x: x + y """ # Author: Collin Winter # Local imports try: unicode except NameError: unicode = str def is_docstring(stmt): return isinstance(stmt, pytree.Node) and \ stmt.children[...
>
Given the code snippet: <|code_start|> # The parens are a syntax error in Python 3 lambda (x): x + y -> lambda x: x + y """ # Author: Collin Winter # Local imports try: unicode except NameError: unicode = str def is_docstring(stmt): return isinstance(stmt, pytree.Node) and \ stmt.chi...
':' body=any
Given the code snippet: <|code_start|> # The parens are a syntax error in Python 3 lambda (x): x + y -> lambda x: x + y """ # Author: Collin Winter # Local imports try: unicode except NameError: unicode = str def is_docstring(stmt): return isinstance(stmt, pytree.Node) and \ stmt.chil...
>
Continue the code snippet: <|code_start|> # The parens are a syntax error in Python 3 lambda (x): x + y -> lambda x: x + y """ # Author: Collin Winter # Local imports try: unicode except NameError: unicode = str def is_docstring(stmt): return isinstance(stmt, pytree.Node) and \ stmt....
':' body=any
Predict the next line after this snippet: <|code_start|> if remove_prefix: name = name[4:] fix_names.append(name[:-3]) return fix_names class _EveryNode(Exception): pass def _get_head_types(pat): """ Accepts a pytree Pattern Node and returns a set of the pa...
for p in pat.content:
Next line prediction: <|code_start|> if remove_prefix: name = name[4:] fix_names.append(name[:-3]) return fix_names class _EveryNode(Exception): pass def _get_head_types(pat): """ Accepts a pytree Pattern Node and returns a set of the pattern types which wi...
for p in pat.content:
Here is a snippet: <|code_start|> of the pattern types which will match first. """ if isinstance(pat, (pytree.NodePattern, pytree.LeafPattern)): # NodePatters must either have no type and no content # or a type and content -- so they don't get any farther # Always return leafs ...
every = []
Based on the snippet: <|code_start|># coding=utf-8 from __future__ import print_function from __future__ import unicode_literals try: unicode except NameError: unicode = str def to_warn_str(node): lines = [text.strip() for text in unicode(node).split('\n')] for i, line in enumerate(lines): ...
if line.startswith('#'):
Next line prediction: <|code_start|> del lines[i] elif line[-1] != ':': lines[i] = line + ';' return ''.join(lines).strip() class WarnRefactoringTool(refactor.MultiprocessRefactoringTool): def __init__(self, fixer_names, options=None, explicit=None): super(W...
warning=warning)))
Predict the next line for this snippet: <|code_start|># coding=utf-8 from __future__ import print_function from __future__ import unicode_literals try: unicode except NameError: unicode = str def to_warn_str(node): lines = [text.strip() for text in unicode(node).split('\n')] for i, line in enume...
if line:
Given snippet: <|code_start|>""" Convert use of sys.exitfunc to use the atexit module. """ # Author: Benjamin Peterson class FixExitfunc(fixer_base.BaseFix): keep_line_order = True BM_compatible = True PATTERN = """ ( sys_import=import_name<'import' ...
dotted_as_names< (any ',')* 'sys' (',' any)* >
Predict the next line after this snippet: <|code_start|>""" Convert use of sys.exitfunc to use the atexit module. """ # Author: Benjamin Peterson class FixExitfunc(fixer_base.BaseFix): keep_line_order = True BM_compatible = True PATTERN = """ ( sys_import=import_name<'im...
power< 'sys' trailer< '.' 'exitfunc' > >
Using the snippet: <|code_start|>""" Convert use of sys.exitfunc to use the atexit module. """ # Author: Benjamin Peterson class FixExitfunc(fixer_base.BaseFix): keep_line_order = True BM_compatible = True PATTERN = """ <|code_end|> , determine the next line of code. You have imports: from py3kwarn2to...
(
Predict the next line after this snippet: <|code_start|>""" Convert use of sys.exitfunc to use the atexit module. """ # Author: Benjamin Peterson class FixExitfunc(fixer_base.BaseFix): keep_line_order = True BM_compatible = True PATTERN = """ ( sys_import=import_name<'im...
|
Based on the snippet: <|code_start|>""" Convert use of sys.exitfunc to use the atexit module. """ # Author: Benjamin Peterson class FixExitfunc(fixer_base.BaseFix): keep_line_order = True BM_compatible = True PATTERN = """ ( sys_import=import_name<'import' ...
expr_stmt<
Using the snippet: <|code_start|>""" Convert use of sys.exitfunc to use the atexit module. """ # Author: Benjamin Peterson class FixExitfunc(fixer_base.BaseFix): keep_line_order = True BM_compatible = True PATTERN = """ ( sys_import=import_name<'import' ...
dotted_as_names< (any ',')* 'sys' (',' any)* >
Next line prediction: <|code_start|>""" Convert use of sys.exitfunc to use the atexit module. """ # Author: Benjamin Peterson class FixExitfunc(fixer_base.BaseFix): keep_line_order = True BM_compatible = True PATTERN = """ ( sys_import=import_name<'import' ...
>
Given the code snippet: <|code_start|>""" Convert use of sys.exitfunc to use the atexit module. """ # Author: Benjamin Peterson class FixExitfunc(fixer_base.BaseFix): keep_line_order = True BM_compatible = True PATTERN = """ ( sys_import=import_name<'import' <|code_end|>...
('sys'
Next line prediction: <|code_start|># Copyright 2006 Google, Inc. All Rights Reserved. # Licensed to PSF under a Contributor Agreement. """Fixer for exec. This converts usages of the exec statement into calls to a built-in exec() function. exec code in ns1, ns2 -> exec(code, ns1, ns2) """ # Local imports class Fi...
exec_stmt< 'exec' (not atom<'(' [any] ')'>) a=any >
Using the snippet: <|code_start|># Copyright 2006 Google, Inc. All Rights Reserved. # Licensed to PSF under a Contributor Agreement. """Fixer for exec. This converts usages of the exec statement into calls to a built-in exec() function. exec code in ns1, ns2 -> exec(code, ns1, ns2) """ # Local imports class FixEx...
exec_stmt< 'exec' a=any 'in' b=any [',' c=any] >
Given the following code snippet before the placeholder: <|code_start|># Copyright 2006 Google, Inc. All Rights Reserved. # Licensed to PSF under a Contributor Agreement. """Fixer for exec. This converts usages of the exec statement into calls to a built-in exec() function. exec code in ns1, ns2 -> exec(code, ns1, n...
exec_stmt< 'exec' (not atom<'(' [any] ')'>) a=any >
Continue the code snippet: <|code_start|># Copyright 2008 Armin Ronacher. # Licensed to PSF under a Contributor Agreement. """Fixer for reduce(). Makes sure reduce() is imported from the functools module if reduce is used in that module. """ class FixReduce(fixer_base.BaseFix): BM_compatible = True order ...
')' >
Here is a snippet: <|code_start|># Copyright 2008 Armin Ronacher. # Licensed to PSF under a Contributor Agreement. """Fixer for reduce(). Makes sure reduce() is imported from the functools module if reduce is used in that module. """ class FixReduce(fixer_base.BaseFix): BM_compatible = True order = "pre" ...
(not(argument<any '=' any>) any ','
Given the following code snippet before the placeholder: <|code_start|> class MinNode(object): """This class serves as an intermediate representation of the pattern tree during the conversion to sets of leaf-to-root subpatterns""" def __init__(self, type=None, name=None): self.type = type ...
node.alternatives = []
Continue the code snippet: <|code_start|> self.group = [] def __repr__(self): return str(self.type) + ' ' + str(self.name) def leaf_to_root(self): """Internal method. Returns a characteristic path of the pattern tree. This method must be run for all leaves until the line...
node.group = []
Given the following code snippet before the placeholder: <|code_start|> def __init__(self, type=None, name=None): self.type = type self.name = name self.children = [] self.leaf = False self.parent = None self.alternatives = [] self.group = [] def __repr__...
subp = None
Continue the code snippet: <|code_start|> remove_trailing_newline(simple_node) yield (node, i, simple_node) def fixup_indent(suite): """ If an INDENT is followed by a thing with a prefix then nuke the prefix Otherwise we get in trouble when removing __metaclass__ at ...
classdef<any*>
Next line prediction: <|code_start|> remove_trailing_newline(simple_node) yield (node, i, simple_node) def fixup_indent(suite): """ If an INDENT is followed by a thing with a prefix then nuke the prefix Otherwise we get in trouble when removing __metaclass__ at suite...
classdef<any*>
Using the snippet: <|code_start|> remove_trailing_newline(simple_node) yield (node, i, simple_node) def fixup_indent(suite): """ If an INDENT is followed by a thing with a prefix then nuke the prefix Otherwise we get in trouble when removing __metaclass__ at suite st...
classdef<any*>
Here is a snippet: <|code_start|>"""Fixer for __nonzero__ -> __bool__ methods.""" # Author: Collin Winter # Local imports class FixNonzero(fixer_base.BaseFix): BM_compatible = True PATTERN = """ <|code_end|> . Write the next line using the current file imports: from .. import fixer_base from ..fixer_util imp...
classdef< 'class' any+ ':'
Predict the next line for this snippet: <|code_start|>"""Fixer that changes raw_input(...) into input(...).""" # Author: Andre Roberge class FixRawInput(fixer_base.BaseFix): BM_compatible = True PATTERN = """ <|code_end|> with the help of current file imports: from .. import fixer_base from ..fixer_util im...
power< name='raw_input' trailer< '(' [any] ')' > any* >
Predict the next line after this snippet: <|code_start|>"""Fixer that changes raw_input(...) into input(...).""" # Author: Andre Roberge class FixRawInput(fixer_base.BaseFix): BM_compatible = True PATTERN = """ <|code_end|> using the current file's imports: from .. import fixer_base from ..fixer_util impor...
power< name='raw_input' trailer< '(' [any] ')' > any* >
Given snippet: <|code_start|>""" Fixer for imports of itertools.(imap|ifilter|izip|ifilterfalse) """ # Local imports class FixItertoolsImports(fixer_base.BaseFix): BM_compatible = True PATTERN = """ <|code_end|> , continue by predicting the next line. Consider current file imports: from py3kwarn2to3 import ...
import_from< 'from' 'itertools' 'import' imports=any >
Predict the next line for this snippet: <|code_start|>""" Fixer for imports of itertools.(imap|ifilter|izip|ifilterfalse) """ # Local imports class FixItertoolsImports(fixer_base.BaseFix): BM_compatible = True PATTERN = """ <|code_end|> with the help of current file imports: from py3kwarn2to3 import fixer_...
import_from< 'from' 'itertools' 'import' imports=any >
Next line prediction: <|code_start|>""" Fixer for imports of itertools.(imap|ifilter|izip|ifilterfalse) """ # Local imports class FixItertoolsImports(fixer_base.BaseFix): BM_compatible = True PATTERN = """ <|code_end|> . Use current file imports: (from py3kwarn2to3 import fixer_base from py3kwarn2to3.fixer_...
import_from< 'from' 'itertools' 'import' imports=any >
Here is a snippet: <|code_start|>""" Fixer for imports of itertools.(imap|ifilter|izip|ifilterfalse) """ # Local imports class FixItertoolsImports(fixer_base.BaseFix): BM_compatible = True PATTERN = """ <|code_end|> . Write the next line using the current file imports: from py3kwarn2to3 import fixer_base fr...
import_from< 'from' 'itertools' 'import' imports=any >
Given the code snippet: <|code_start|># Copyright 2007 Google, Inc. All Rights Reserved. # Licensed to PSF under a Contributor Agreement. """Fixer for callable(). This converts callable(obj) into isinstance(obj, collections.Callable), adding a collections import if needed.""" # Local imports class FixCallable(fixer...
( not(arglist | argument<any '=' any>) func=any
Predict the next line for this snippet: <|code_start|># Copyright 2007 Google, Inc. All Rights Reserved. # Licensed to PSF under a Contributor Agreement. """Fixer for callable(). This converts callable(obj) into isinstance(obj, collections.Callable), adding a collections import if needed.""" # Local imports class F...
after=any*
Given the code snippet: <|code_start|># Copyright 2007 Google, Inc. All Rights Reserved. # Licensed to PSF under a Contributor Agreement. """Fixer for callable(). This converts callable(obj) into isinstance(obj, collections.Callable), adding a collections import if needed.""" # Local imports class FixCallable(fixer...
power< 'callable'
Next line prediction: <|code_start|># Copyright 2007 Google, Inc. All Rights Reserved. # Licensed to PSF under a Contributor Agreement. """Fixer for callable(). This converts callable(obj) into isinstance(obj, collections.Callable), adding a collections import if needed.""" # Local imports class FixCallable(fixer_b...
power< 'callable'
Continue the code snippet: <|code_start|># Copyright 2007 Google, Inc. All Rights Reserved. # Licensed to PSF under a Contributor Agreement. """Fixer for callable(). This converts callable(obj) into isinstance(obj, collections.Callable), adding a collections import if needed.""" # Local imports class FixCallable(fi...
PATTERN = """
Using the snippet: <|code_start|># Copyright 2007 Google, Inc. All Rights Reserved. # Licensed to PSF under a Contributor Agreement. """Fixer for callable(). This converts callable(obj) into isinstance(obj, collections.Callable), adding a collections import if needed.""" # Local imports class FixCallable(fixer_base...
PATTERN = """
Next line prediction: <|code_start|># Copyright 2006 Google, Inc. All Rights Reserved. # Licensed to PSF under a Contributor Agreement. """Fixer for print. Change: 'print' into 'print()' 'print ...' into 'print(...)' 'print ... ,' into 'print(..., end=" ")' 'print >>x, ...' into 'prin...
simple_stmt< any* bare='print' any* > | print_stmt
Given snippet: <|code_start|># Copyright 2006 Google, Inc. All Rights Reserved. # Licensed to PSF under a Contributor Agreement. """Fixer for print. Change: 'print' into 'print()' 'print ...' into 'print(...)' 'print ... ,' into 'print(..., end=" ")' 'print >>x, ...' into 'print(..., ...
simple_stmt< any* bare='print' any* > | print_stmt
Given snippet: <|code_start|># Copyright 2006 Google, Inc. All Rights Reserved. # Licensed to PSF under a Contributor Agreement. """Fixer for print. Change: 'print' into 'print()' 'print ...' into 'print(...)' 'print ... ,' into 'print(..., end=" ")' 'print >>x, ...' into 'print(..., ...
simple_stmt< any* bare='print' any* > | print_stmt
Here is a snippet: <|code_start|># Copyright 2006 Google, Inc. All Rights Reserved. # Licensed to PSF under a Contributor Agreement. """Fixer for print. Change: 'print' into 'print()' 'print ...' into 'print(...)' 'print ... ,' into 'print(..., end=" ")' 'print >>x, ...' into 'print(....
simple_stmt< any* bare='print' any* > | print_stmt
Given the code snippet: <|code_start|> be added using the add_fixer method""" def __init__(self): self.match = set() self.root = BMNode() self.nodes = [self.root] self.fixers = [] self.logger = logging.getLogger("RefactoringTool") def add_fixer(self, fixer): ...
match_nodes = []
Here is a snippet: <|code_start|> class FixParrot(BaseFix): """ Change functions named 'parrot' to 'cheese'. """ PATTERN = """funcdef < 'def' name='parrot' any* >""" <|code_end|> . Write the next line using the current file imports: from py3kwarn2to3.fixer_base import BaseFix from py3kwarn2to3.fixer_...
def transform(self, node, results):
Here is a snippet: <|code_start|> class FixParrot(BaseFix): """ Change functions named 'parrot' to 'cheese'. """ PATTERN = """funcdef < 'def' name='parrot' any* >""" <|code_end|> . Write the next line using the current file imports: from py3kwarn2to3.fixer_base import BaseFix from py3kwarn2to3.fixer_...
def transform(self, node, results):
Next line prediction: <|code_start|>in iter(<>), list(<>), tuple(<>), sorted(<>), ...join(<>), or for V in <>:. NOTE: This is still not correct if the original code was depending on 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...
power<
Here is a snippet: <|code_start|> # Local imports class FixFilter(fixer_base.ConditionalFix): BM_compatible = True PATTERN = """ filter_lambda=power< 'filter' trailer< '(' arglist< lambdef< 'lambda' (fp=NAME | vfpdef< '(' fp=...
>
Here is a snippet: <|code_start|>NOTE: This is still not correct if the original code was depending on 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.Cond...
>