• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Python move.create_move函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中rope.refactor.move.create_move函数的典型用法代码示例。如果您正苦于以下问题:Python create_move函数的具体用法?Python create_move怎么用?Python create_move使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了create_move函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。

示例1: test_moving_a_global_when_it_is_used_after_a_multiline_str

 def test_moving_a_global_when_it_is_used_after_a_multiline_str(self):
     code = 'def f():\n    pass\ns = """\\\n"""\nr = f()\n'
     self.mod1.write(code)
     mover = move.create_move(self.project, self.mod1, code.index("f()") + 1)
     self.project.do(mover.get_changes(self.mod2))
     expected = 'import mod2\ns = """\\\n"""\nr = mod2.f()\n'
     self.assertEquals(expected, self.mod1.read())
开发者ID:chiamingyen,项目名称:kmol2016,代码行数:7,代码来源:movetest.py


示例2: test_moving_methods_and_nonexistent_attributes

 def test_moving_methods_and_nonexistent_attributes(self):
     code = 'class A(object):\n' \
            '    def a_method(self):\n        return 1\n'
     self.mod1.write(code)
     mover = move.create_move(self.project, self.mod1,
                              code.index('a_method'))
     mover.get_changes('x', 'new_method')
开发者ID:Kha,项目名称:rope,代码行数:7,代码来源:movetest.py


示例3: test_moving_methods_getting_new_method_for_constant_methods

 def test_moving_methods_getting_new_method_for_constant_methods(self):
     code = 'class A(object):\n    def a_method(self):\n        return 1\n'
     self.mod1.write(code)
     mover = move.create_move(self.project, self.mod1,
                              code.index('a_method'))
     self.assertEquals('def new_method(self):\n    return 1\n',
                       mover.get_new_method('new_method'))
开发者ID:Kha,项目名称:rope,代码行数:7,代码来源:movetest.py


示例4: test_moving_module_and_star_imports

 def test_moving_module_and_star_imports(self):
     self.mod1.write('a_var = 1')
     self.mod2.write('from mod1 import *\na = a_var\n')
     mover = move.create_move(self.project, self.mod1)
     mover.get_changes(self.pkg).do()
     self.assertEquals('from pkg.mod1 import *\na = a_var\n',
                       self.mod2.read())
开发者ID:Kha,项目名称:rope,代码行数:7,代码来源:movetest.py


示例5: test_unknown_attribute_type

 def test_unknown_attribute_type(self):
     code = 'class A(object):\n    attr = 1\n' \
            '    def a_method(self):\n        return 1\n'
     self.mod1.write(code)
     mover = move.create_move(self.project, self.mod1,
                              code.index('a_method'))
     mover.get_changes('attr', 'new_method')
开发者ID:Kha,项目名称:rope,代码行数:7,代码来源:movetest.py


示例6: test_moving_module_refactoring_and_nonexistent_destinations

 def test_moving_module_refactoring_and_nonexistent_destinations(self):
     self.mod4.write('a_var = 1')
     self.mod2.write('from pkg import mod4\n'
                     'import os\n\n\nprint(mod4.a_var)\n')
     with self.assertRaises(exceptions.RefactoringError):
         mover = move.create_move(self.project, self.mod4)
         mover.get_changes(None).do()
开发者ID:JacekPliszka,项目名称:rope,代码行数:7,代码来源:movetest.py


示例7: test_moving_methods_gettin_new_method_with_keyword_arguments

 def test_moving_methods_gettin_new_method_with_keyword_arguments(self):
     code = 'class A(object):\n    attr = 1\n' \
            '    def a_method(self, p=None):\n        return p\n'
     self.mod1.write(code)
     mover = move.create_move(self.project, self.mod1,
                              code.index('a_method'))
     self.assertEquals('def new_method(self, p=None):\n    return p\n',
                       mover.get_new_method('new_method'))
开发者ID:Kha,项目名称:rope,代码行数:8,代码来源:movetest.py


示例8: test_moving_methods_getting_new_method_renaming_main_object

 def test_moving_methods_getting_new_method_renaming_main_object(self):
     code = 'class A(object):\n    attr = 1\n' \
            '    def a_method(self):\n        return self.attr\n'
     self.mod1.write(code)
     mover = move.create_move(self.project, self.mod1,
                              code.index('a_method'))
     self.assertEquals('def new_method(self, host):\n    return host.attr\n',
                       mover.get_new_method('new_method'))
开发者ID:Kha,项目名称:rope,代码行数:8,代码来源:movetest.py


示例9: test_moving_methods_getting_new_method_passing_simple_paremters

 def test_moving_methods_getting_new_method_passing_simple_paremters(self):
     code = 'class A(object):\n' \
            '    def a_method(self, p):\n        return p\n'
     self.mod1.write(code)
     mover = move.create_move(self.project, self.mod1,
                              code.index('a_method'))
     self.assertEquals('def new_method(self, p):\n    return p\n',
                       mover.get_new_method('new_method'))
开发者ID:Kha,项目名称:rope,代码行数:8,代码来源:movetest.py


示例10: test_moving_module_and_not_removing_blanks_after_imports

 def test_moving_module_and_not_removing_blanks_after_imports(self):
     self.mod4.write('a_var = 1')
     self.mod2.write('from pkg import mod4\n'
                     'import os\n\n\nprint(mod4.a_var)\n')
     mover = move.create_move(self.project, self.mod4)
     mover.get_changes(self.project.root).do()
     self.assertEquals('import os\nimport mod4\n\n\n'
                       'print(mod4.a_var)\n', self.mod2.read())
开发者ID:Kha,项目名称:rope,代码行数:8,代码来源:movetest.py


示例11: test_unknown_attribute_type

 def test_unknown_attribute_type(self):
     code = 'class A(object):\n    attr = 1\n' \
            '    def a_method(self):\n        return 1\n'
     self.mod1.write(code)
     with self.assertRaises(exceptions.RefactoringError):
         mover = move.create_move(self.project, self.mod1,
                                  code.index('a_method'))
         mover.get_changes('attr', 'new_method')
开发者ID:JacekPliszka,项目名称:rope,代码行数:8,代码来源:movetest.py


示例12: test_moving_resources_using_move_module_refactoring

 def test_moving_resources_using_move_module_refactoring(self):
     self.mod1.write("a_var = 1")
     self.mod2.write("import mod1\nmy_var = mod1.a_var\n")
     mover = move.create_move(self.project, self.mod1)
     mover.get_changes(self.pkg).do()
     expected = "import pkg.mod1\nmy_var = pkg.mod1.a_var\n"
     self.assertEquals(expected, self.mod2.read())
     self.assertTrue(self.pkg.get_child("mod1.py") is not None)
开发者ID:chiamingyen,项目名称:kmol2016,代码行数:8,代码来源:movetest.py


示例13: test_moving_resources_using_move_module_for_init_dot_py

 def test_moving_resources_using_move_module_for_init_dot_py(self):
     self.mod1.write("import pkg\nmy_pkg = pkg")
     pkg2 = testutils.create_package(self.project, "pkg2")
     init = self.pkg.get_child("__init__.py")
     mover = move.create_move(self.project, init)
     mover.get_changes(pkg2).do()
     self.assertEquals("import pkg2.pkg\nmy_pkg = pkg2.pkg", self.mod1.read())
     self.assertTrue(pkg2.get_child("pkg") is not None)
开发者ID:chiamingyen,项目名称:kmol2016,代码行数:8,代码来源:movetest.py


示例14: test_moving_resources_using_move_module_for_packages

 def test_moving_resources_using_move_module_for_packages(self):
     self.mod1.write("import pkg\nmy_pkg = pkg")
     pkg2 = testutils.create_package(self.project, "pkg2")
     mover = move.create_move(self.project, self.pkg)
     mover.get_changes(pkg2).do()
     expected = "import pkg2.pkg\nmy_pkg = pkg2.pkg"
     self.assertEquals(expected, self.mod1.read())
     self.assertTrue(pkg2.get_child("pkg") is not None)
开发者ID:chiamingyen,项目名称:kmol2016,代码行数:8,代码来源:movetest.py


示例15: test_moving_methods_and_nonexistent_attributes

 def test_moving_methods_and_nonexistent_attributes(self):
     code = 'class A(object):\n' \
            '    def a_method(self):\n        return 1\n'
     self.mod1.write(code)
     with self.assertRaises(exceptions.RefactoringError):
         mover = move.create_move(self.project, self.mod1,
                                  code.index('a_method'))
         mover.get_changes('x', 'new_method')
开发者ID:JacekPliszka,项目名称:rope,代码行数:8,代码来源:movetest.py


示例16: test_moving_globals_to_a_module_with_only_docstrings

 def test_moving_globals_to_a_module_with_only_docstrings(self):
     self.mod1.write("import sys\n\n\ndef f():\n    print(sys.version)\n")
     self.mod2.write('"""doc\n\nMore docs ...\n\n"""\n')
     mover = move.create_move(self.project, self.mod1, self.mod1.read().index("f()") + 1)
     self.project.do(mover.get_changes(self.mod2))
     self.assertEquals(
         '"""doc\n\nMore docs ...\n\n"""\n' "import sys\n\n\ndef f():\n    print(sys.version)\n", self.mod2.read()
     )
开发者ID:chiamingyen,项目名称:kmol2016,代码行数:8,代码来源:movetest.py


示例17: test_moving_to_a_module_with_encoding_cookie

 def test_moving_to_a_module_with_encoding_cookie(self):
     code1 = "# -*- coding: utf-8 -*-"
     self.mod1.write(code1)
     code2 = "def f(): pass\n"
     self.mod2.write(code2)
     mover = move.create_move(self.project, self.mod2, code2.index("f()") + 1)
     self.project.do(mover.get_changes(self.mod1))
     expected = "%s\n%s" % (code1, code2)
     self.assertEquals(expected, self.mod1.read())
开发者ID:chiamingyen,项目名称:kmol2016,代码行数:9,代码来源:movetest.py


示例18: test_moving_methods_gettin_new_method_with_many_kinds_arguments

 def test_moving_methods_gettin_new_method_with_many_kinds_arguments(self):
     code = (
         "class A(object):\n    attr = 1\n"
         "    def a_method(self, p1, *args, **kwds):\n"
         "        return self.attr\n"
     )
     self.mod1.write(code)
     mover = move.create_move(self.project, self.mod1, code.index("a_method"))
     expected = "def new_method(self, host, p1, *args, **kwds):\n" "    return host.attr\n"
     self.assertEquals(expected, mover.get_new_method("new_method"))
开发者ID:chiamingyen,项目名称:kmol2016,代码行数:10,代码来源:movetest.py


示例19: get_refactor

    def get_refactor(ctx):
        """ Function description.

        :return Rename:

        """
        _, offset = env.get_offset_params()
        if offset == 0:
            offset = None
        return move.create_move(ctx.project, ctx.resource, offset)
开发者ID:anto-daniel,项目名称:python-vim,代码行数:10,代码来源:rope.py


示例20: test_moving_methods_getting_getting_changes_for_goal_class3

 def test_moving_methods_getting_getting_changes_for_goal_class3(self):
     self.mod2.write("class B(object):\n    pass\n")
     code = (
         "import mod2\n\n"
         "class A(object):\n"
         "    attr = mod2.B()\n"
         "    def a_method(self):\n"
         "        return 1\n"
     )
     self.mod1.write(code)
     mover = move.create_move(self.project, self.mod1, code.index("a_method"))
     mover.get_changes("attr", "new_method").do()
     expected = "class B(object):\n\n" "    def new_method(self):\n" "        return 1\n"
     self.assertEquals(expected, self.mod2.read())
开发者ID:chiamingyen,项目名称:kmol2016,代码行数:14,代码来源:movetest.py



注:本文中的rope.refactor.move.create_move函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python core.Observable类代码示例发布时间:2022-05-27
下一篇:
Python codeassist.starting_offset函数代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap