ctrl+shift+p filters: :st2 :st3 :win :osx :linux
Browse

Py​Refactor

by dnatag ST2/ST3

Python refactoring tool for Sublime Text

Details

  • 2015.09.23.02.09.05
  • github.​com
  • github.​com
  • 4 years ago
  • 2 hours ago
  • 6 years ago

Installs

  • Total 5K
  • Win 2K
  • OS X 2K
  • Linux 1K
Dec 7 Dec 6 Dec 5 Dec 4 Dec 3 Dec 2 Dec 1 Nov 30 Nov 29 Nov 28 Nov 27 Nov 26 Nov 25 Nov 24 Nov 23 Nov 22 Nov 21 Nov 20 Nov 19 Nov 18 Nov 17 Nov 16 Nov 15 Nov 14 Nov 13 Nov 12 Nov 11 Nov 10 Nov 9 Nov 8 Nov 7 Nov 6 Nov 5 Nov 4 Nov 3 Nov 2 Nov 1 Oct 31 Oct 30 Oct 29 Oct 28 Oct 27 Oct 26 Oct 25 Oct 24 Oct 23
Windows 0 2 0 1 1 0 0 0 0 0 1 1 2 0 1 0 0 1 0 1 1 1 0 2 1 0 0 2 1 0 0 0 0 0 1 0 0 2 1 1 3 1 0 0 0 2
OS X 1 1 1 0 2 1 0 0 0 0 0 2 0 0 3 2 2 1 1 0 1 0 1 1 1 1 1 0 0 2 2 0 1 0 0 0 1 0 1 0 0 1 0 2 0 1
Linux 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 1 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 4 2 0 1 0 1 0 0

Readme

Source
raw.​githubusercontent.​com

Python refactoring made easy in Sublime Text 3

Introduction

This plugin is designed to help rope users to refactor python codes. It generates a temporary rope script, which refactors your codes, and then it reloads the refactored codes in Sublime Text. This is a quick and dirty hack and may not work well for very complex codes.

Refactor Methods Implemented

  1. Create a rope project (Ctrl+Shift+N): You must create the rope project first before performing any following refactoring actions.
  2. Undo last refactoring action (Ctrl+Shift+Z)
  3. Redo last refactoring action (Ctrl+Shift+Y)
  4. Rename a field
  5. Rename a module
  6. Transform a module to package with the same name
  7. Change the signiture of a function/method
  8. Extract method
  9. Extract variable
  10. Inline: Inline occurrences of a method/variable/parameter
  11. Change a local variable to field
  12. Introduce parameter to a function
  13. Introduce constructor factory (select a class name to perform the refactoring)
  14. Encapsulate field: Generate a getter/setter for a field and changes its occurrences to use them.
  15. Use function: Try to use a function whenever possible
  16. Move across module
  17. Move attribute
  18. Transform function to method object
  19. Restructure

Installation

Prerequisite: Install the rope package from PyPI.

  1. Automatic installation via Package Control. Search for PyRefactor under Package Control.
  2. Manual installation via github Clone the git repository directly into the Packages folder

    git clone git@github.com:dnatag/PyRefactor.git

Usage Guide

  1. Create a rope project in the project level (Ctrl+Shift+N)
  2. Use Cmd+Shift+P (Ctrl+Shift+P in Linux or Windows) and type Refactor to choose refactoring method
  3. Under Tools Menu and then submenu Refactor to choose proper refactoring method

Licence

You can use this under Simplified BSD License:

Copyright © 2014, Yi Xie All rights reserved.

Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:

Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS “AS IS” AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.