示例#1
0
 def refactor(self):
     '''Perform refactorings.'''
     proj = self.proj
     if not proj:
         g.es_print('rope not found')
         return
     m = proj.get_resource(self.path('leoAtFile.py'))
     s = m.read()
     # Important: get an offset in actual code.
     s = simplify.real_code(s)
     tag1 = 'atFile'
     tag2 = g.pep8_class_name(tag1)
     offset = s.find(tag1)
     if offset > -1:
         changes = refactor.rename.Rename(proj, m, offset).get_changes(tag2)
         g.trace(changes.get_description())
     else:
         g.trace('not found', tag1)
示例#2
0
 def refactor(self):
     '''Perform refactorings.'''
     proj = self.proj
     if not proj:
         g.es_print('rope not found')
         return
     m = proj.get_resource(self.path('leoAtFile.py'))
     s = m.read()
     # Important: get an offset in actual code.
     s = simplify.real_code(s)
     tag1 = 'atFile'
     tag2 = g.pep8_class_name(tag1)
     offset = s.find(tag1)
     if offset > -1:
         changes = refactor.rename.Rename(proj, m, offset).get_changes(tag2)
         g.trace(changes.get_description())
     else:
         g.trace('not found', tag1)
示例#3
0
 def test_joining_implicit_continuations(self):
     code = '(\n)\n'
     self.assertEquals('( )\n', simplify.real_code(code))
示例#4
0
 def test_joining_explicit_continuations(self):
     code = '1 + \\\n 2\n'
     self.assertEquals('1 +    2\n', simplify.real_code(code))
示例#5
0
 def test_replacing_semicolons(self):
     code = 'a = 1;b = 2\n'
     self.assertEquals('a = 1\nb = 2\n', simplify.real_code(code))
示例#6
0
 def test_removing_comments(self):
     code = '# c\n'
     self.assertEquals('   \n', simplify.real_code(code))
示例#7
0
 def test_removing_strings_containing_comments(self):
     code = '"#c"\n'
     self.assertEquals('"  "\n', simplify.real_code(code))
示例#8
0
 def test_trivial_case(self):
     self.assertEquals('', simplify.real_code(''))
示例#9
0
 def test_blanking_strs(self):
     code = 's = "..."\n'
     self.assertEquals('s = "   "\n', simplify.real_code(code))
示例#10
0
 def test_changing_to_double_quotes2(self):
     code = 's = """\n"""\n'
     self.assertEqual('s = "     "\n', simplify.real_code(code))
示例#11
0
 def test_removing_comments(self):
     code = "# c\n"
     self.assertEqual("   \n", simplify.real_code(code))
示例#12
0
 def test_empty_strs(self):
     code = 's = ""\n'
     self.assertEqual(code, simplify.real_code(code))
示例#13
0
 def test_blanking_strs(self):
     code = 's = "..."\n'
     self.assertEqual('s = "   "\n', simplify.real_code(code))
示例#14
0
 def test_replacing_semicolons(self):
     code = 'a = 1;b = 2\n'
     self.assertEquals('a = 1\nb = 2\n', simplify.real_code(code))
示例#15
0
 def test_replacing_tabs(self):
     code = '1\t+\t2\n'
     self.assertEquals('1 + 2\n', simplify.real_code(code))
示例#16
0
 def test_joining_explicit_continuations(self):
     code = '1 + \\\n 2\n'
     self.assertEquals('1 +    2\n', simplify.real_code(code))
示例#17
0
 def test_simplifying_uppercase_f_string_containing_quotes(self):
     code = """s = Fr"..'{hello}'.."\n"""
     self.assertEqual("""s = Fr"..'{hello}'.."\n""",
                      simplify.real_code(code))
示例#18
0
 def test_removing_comments_that_contain_strings(self):
     code = '# "c"\n'
     self.assertEqual("     \n", simplify.real_code(code))
示例#19
0
 def test_trivial_case(self):
     self.assertEqual("", simplify.real_code(""))
示例#20
0
 def test_removing_strings_containing_comments(self):
     code = '"#c"\n'
     self.assertEqual('"  "\n', simplify.real_code(code))
示例#21
0
 def test_empty_strs(self):
     code = 's = ""\n'
     self.assertEquals(code, simplify.real_code(code))
示例#22
0
 def test_joining_implicit_continuations(self):
     code = "(\n)\n"
     self.assertEqual("( )\n", simplify.real_code(code))
示例#23
0
 def test_changing_to_double_quotes2(self):
     code = 's = """\n"""\n'
     self.assertEquals('s = "     "\n', simplify.real_code(code))
示例#24
0
 def test_joining_explicit_continuations(self):
     code = "1 + \\\n 2\n"
     self.assertEqual("1 +    2\n", simplify.real_code(code))
示例#25
0
 def test_removing_comments_that_contain_strings(self):
     code = '# "c"\n'
     self.assertEquals('     \n', simplify.real_code(code))
示例#26
0
 def test_replacing_tabs(self):
     code = "1\t+\t2\n"
     self.assertEqual("1 + 2\n", simplify.real_code(code))
示例#27
0
 def test_joining_implicit_continuations(self):
     code = '(\n)\n'
     self.assertEquals('( )\n', simplify.real_code(code))
示例#28
0
 def test_trivial_case(self):
     self.assertEquals('', simplify.real_code(''))
示例#29
0
 def test_replacing_tabs(self):
     code = '1\t+\t2\n'
     self.assertEquals('1 + 2\n', simplify.real_code(code))
示例#30
0
 def test_simplifying_f_string(self):
     code = 's = f"..{hello}.."\n'
     self.assertEqual('s = f"..{hello}.."\n', simplify.real_code(code))
示例#31
0
 def test_replacing_semicolons(self):
     code = "a = 1;b = 2\n"
     self.assertEqual("a = 1\nb = 2\n", simplify.real_code(code))
示例#32
0
 def test_removing_comments(self):
     code = '# c\n'
     self.assertEquals('   \n', simplify.real_code(code))