Python lib2to3.fixer_util.find_indentation() Examples
The following are 30
code examples of lib2to3.fixer_util.find_indentation().
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example.
You may also want to check out all available functions/classes of the module
lib2to3.fixer_util
, or try the search function
.
Example #1
Source File: test_util.py From CTFCrackTools-V2 with GNU General Public License v3.0 | 5 votes |
def test_nothing(self): fi = fixer_util.find_indentation node = parse("node()") self.assertEqual(fi(node), u"") node = parse("") self.assertEqual(fi(node), u"")
Example #2
Source File: test_util.py From datafari with Apache License 2.0 | 5 votes |
def test_nothing(self): fi = fixer_util.find_indentation node = parse("node()") self.assertEqual(fi(node), u"") node = parse("") self.assertEqual(fi(node), u"")
Example #3
Source File: test_util.py From datafari with Apache License 2.0 | 5 votes |
def test_simple(self): fi = fixer_util.find_indentation node = parse("def f():\n x()") self.assertEqual(fi(node), u"") self.assertEqual(fi(node.children[0].children[4].children[2]), u" ") node = parse("def f():\n x()\n y()") self.assertEqual(fi(node.children[0].children[4].children[4]), u" ")
Example #4
Source File: test_util.py From Project-New-Reign---Nemesis-Main with GNU General Public License v3.0 | 5 votes |
def test_nothing(self): fi = fixer_util.find_indentation node = parse("node()") self.assertEqual(fi(node), "") node = parse("") self.assertEqual(fi(node), "")
Example #5
Source File: test_util.py From Project-New-Reign---Nemesis-Main with GNU General Public License v3.0 | 5 votes |
def test_simple(self): fi = fixer_util.find_indentation node = parse("def f():\n x()") self.assertEqual(fi(node), "") self.assertEqual(fi(node.children[0].children[4].children[2]), " ") node = parse("def f():\n x()\n y()") self.assertEqual(fi(node.children[0].children[4].children[4]), " ")
Example #6
Source File: test_util.py From odoo13-x64 with GNU General Public License v3.0 | 5 votes |
def test_nothing(self): fi = fixer_util.find_indentation node = parse("node()") self.assertEqual(fi(node), "") node = parse("") self.assertEqual(fi(node), "")
Example #7
Source File: test_util.py From odoo13-x64 with GNU General Public License v3.0 | 5 votes |
def test_simple(self): fi = fixer_util.find_indentation node = parse("def f():\n x()") self.assertEqual(fi(node), "") self.assertEqual(fi(node.children[0].children[4].children[2]), " ") node = parse("def f():\n x()\n y()") self.assertEqual(fi(node.children[0].children[4].children[4]), " ")
Example #8
Source File: test_util.py From CTFCrackTools-V2 with GNU General Public License v3.0 | 5 votes |
def test_nothing(self): fi = fixer_util.find_indentation node = parse("node()") self.assertEqual(fi(node), u"") node = parse("") self.assertEqual(fi(node), u"")
Example #9
Source File: test_util.py From CTFCrackTools-V2 with GNU General Public License v3.0 | 5 votes |
def test_simple(self): fi = fixer_util.find_indentation node = parse("def f():\n x()") self.assertEqual(fi(node), u"") self.assertEqual(fi(node.children[0].children[4].children[2]), u" ") node = parse("def f():\n x()\n y()") self.assertEqual(fi(node.children[0].children[4].children[4]), u" ")
Example #10
Source File: fix_annotate.py From pyannotate with Apache License 2.0 | 5 votes |
def add_py2_annot(self, argtypes, restype, node, results): children = results['suite'][0].children # Insert '# type: {annot}' comment. # For reference, see lib2to3/fixes/fix_tuple_params.py in stdlib. if len(children) >= 1 and children[0].type != token.NEWLINE: # one liner function if children[0].prefix.strip() == '': children[0].prefix = '' children.insert(0, Leaf(token.NEWLINE, '\n')) children.insert( 1, Leaf(token.INDENT, find_indentation(node) + ' ')) children.append(Leaf(token.DEDENT, '')) if len(children) >= 2 and children[1].type == token.INDENT: degen_str = '(...) -> %s' % restype short_str = '(%s) -> %s' % (', '.join(argtypes), restype) if (len(short_str) > 64 or len(argtypes) > 5) and len(short_str) > len(degen_str): self.insert_long_form(node, results, argtypes) annot_str = degen_str else: annot_str = short_str children[1].prefix = '%s# type: %s\n%s' % (children[1].value, annot_str, children[1].prefix) children[1].changed() else: self.log_message("%s:%d: cannot insert annotation for one-line function" % (self.filename, node.get_lineno()))
Example #11
Source File: test_util.py From CTFCrackTools-V2 with GNU General Public License v3.0 | 5 votes |
def test_simple(self): fi = fixer_util.find_indentation node = parse("def f():\n x()") self.assertEqual(fi(node), u"") self.assertEqual(fi(node.children[0].children[4].children[2]), u" ") node = parse("def f():\n x()\n y()") self.assertEqual(fi(node.children[0].children[4].children[4]), u" ")
Example #12
Source File: test_util.py From android_universal with MIT License | 5 votes |
def test_nothing(self): fi = fixer_util.find_indentation node = parse("node()") self.assertEqual(fi(node), "") node = parse("") self.assertEqual(fi(node), "")
Example #13
Source File: test_util.py From android_universal with MIT License | 5 votes |
def test_simple(self): fi = fixer_util.find_indentation node = parse("def f():\n x()") self.assertEqual(fi(node), "") self.assertEqual(fi(node.children[0].children[4].children[2]), " ") node = parse("def f():\n x()\n y()") self.assertEqual(fi(node.children[0].children[4].children[4]), " ")
Example #14
Source File: test_util.py From CTFCrackTools with GNU General Public License v3.0 | 5 votes |
def test_nothing(self): fi = fixer_util.find_indentation node = parse("node()") self.assertEqual(fi(node), u"") node = parse("") self.assertEqual(fi(node), u"")
Example #15
Source File: test_util.py From CTFCrackTools with GNU General Public License v3.0 | 5 votes |
def test_simple(self): fi = fixer_util.find_indentation node = parse("def f():\n x()") self.assertEqual(fi(node), u"") self.assertEqual(fi(node.children[0].children[4].children[2]), u" ") node = parse("def f():\n x()\n y()") self.assertEqual(fi(node.children[0].children[4].children[4]), u" ")
Example #16
Source File: test_util.py From CTFCrackTools with GNU General Public License v3.0 | 5 votes |
def test_nothing(self): fi = fixer_util.find_indentation node = parse("node()") self.assertEqual(fi(node), u"") node = parse("") self.assertEqual(fi(node), u"")
Example #17
Source File: test_util.py From CTFCrackTools with GNU General Public License v3.0 | 5 votes |
def test_simple(self): fi = fixer_util.find_indentation node = parse("def f():\n x()") self.assertEqual(fi(node), u"") self.assertEqual(fi(node.children[0].children[4].children[2]), u" ") node = parse("def f():\n x()\n y()") self.assertEqual(fi(node.children[0].children[4].children[4]), u" ")
Example #18
Source File: test_util.py From oss-ftp with MIT License | 5 votes |
def test_simple(self): fi = fixer_util.find_indentation node = parse("def f():\n x()") self.assertEqual(fi(node), u"") self.assertEqual(fi(node.children[0].children[4].children[2]), u" ") node = parse("def f():\n x()\n y()") self.assertEqual(fi(node.children[0].children[4].children[4]), u" ")
Example #19
Source File: test_util.py From misp42splunk with GNU Lesser General Public License v3.0 | 5 votes |
def test_simple(self): fi = fixer_util.find_indentation node = parse("def f():\n x()") self.assertEqual(fi(node), "") self.assertEqual(fi(node.children[0].children[4].children[2]), " ") node = parse("def f():\n x()\n y()") self.assertEqual(fi(node.children[0].children[4].children[4]), " ")
Example #20
Source File: test_util.py From misp42splunk with GNU Lesser General Public License v3.0 | 5 votes |
def test_nothing(self): fi = fixer_util.find_indentation node = parse("node()") self.assertEqual(fi(node), u"") node = parse("") self.assertEqual(fi(node), u"")
Example #21
Source File: test_util.py From misp42splunk with GNU Lesser General Public License v3.0 | 5 votes |
def test_simple(self): fi = fixer_util.find_indentation node = parse("def f():\n x()") self.assertEqual(fi(node), u"") self.assertEqual(fi(node.children[0].children[4].children[2]), u" ") node = parse("def f():\n x()\n y()") self.assertEqual(fi(node.children[0].children[4].children[4]), u" ")
Example #22
Source File: test_util.py From ironpython2 with Apache License 2.0 | 5 votes |
def test_nothing(self): fi = fixer_util.find_indentation node = parse("node()") self.assertEqual(fi(node), u"") node = parse("") self.assertEqual(fi(node), u"")
Example #23
Source File: test_util.py From ironpython2 with Apache License 2.0 | 5 votes |
def test_simple(self): fi = fixer_util.find_indentation node = parse("def f():\n x()") self.assertEqual(fi(node), u"") self.assertEqual(fi(node.children[0].children[4].children[2]), u" ") node = parse("def f():\n x()\n y()") self.assertEqual(fi(node.children[0].children[4].children[4]), u" ")
Example #24
Source File: test_util.py From Computable with MIT License | 5 votes |
def test_nothing(self): fi = fixer_util.find_indentation node = parse("node()") self.assertEqual(fi(node), u"") node = parse("") self.assertEqual(fi(node), u"")
Example #25
Source File: test_util.py From Computable with MIT License | 5 votes |
def test_simple(self): fi = fixer_util.find_indentation node = parse("def f():\n x()") self.assertEqual(fi(node), u"") self.assertEqual(fi(node.children[0].children[4].children[2]), u" ") node = parse("def f():\n x()\n y()") self.assertEqual(fi(node.children[0].children[4].children[4]), u" ")
Example #26
Source File: test_util.py From oss-ftp with MIT License | 5 votes |
def test_nothing(self): fi = fixer_util.find_indentation node = parse("node()") self.assertEqual(fi(node), u"") node = parse("") self.assertEqual(fi(node), u"")
Example #27
Source File: test_util.py From misp42splunk with GNU Lesser General Public License v3.0 | 5 votes |
def test_nothing(self): fi = fixer_util.find_indentation node = parse("node()") self.assertEqual(fi(node), "") node = parse("") self.assertEqual(fi(node), "")
Example #28
Source File: test_util.py From Fluid-Designer with GNU General Public License v3.0 | 5 votes |
def test_nothing(self): fi = fixer_util.find_indentation node = parse("node()") self.assertEqual(fi(node), "") node = parse("") self.assertEqual(fi(node), "")
Example #29
Source File: test_util.py From Fluid-Designer with GNU General Public License v3.0 | 5 votes |
def test_simple(self): fi = fixer_util.find_indentation node = parse("def f():\n x()") self.assertEqual(fi(node), "") self.assertEqual(fi(node.children[0].children[4].children[2]), " ") node = parse("def f():\n x()\n y()") self.assertEqual(fi(node.children[0].children[4].children[4]), " ")
Example #30
Source File: test_util.py From Imogen with MIT License | 5 votes |
def test_nothing(self): fi = fixer_util.find_indentation node = parse("node()") self.assertEqual(fi(node), "") node = parse("") self.assertEqual(fi(node), "")