Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Initial version integrating Chuck Rhode's PythonTidy (see http://pypi…
- Loading branch information
0 parents
commit f8753cc
Showing
4 changed files
with
28 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
[ | ||
{ "keys": ["ctrl+shift+alt+t"], "command": "python_tidy" } | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
[ | ||
{ "keys": ["super+ctrl+alt+t"], "command": "python_tidy" } | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
[ | ||
{ "keys": ["ctrl+shift+alt+t"], "command": "python_tidy" } | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
from sublime_plugin import TextCommand | ||
from sublime import Region | ||
from subprocess import Popen, PIPE | ||
from os.path import expanduser, exists | ||
|
||
|
||
cmd = ['pythontidy'] | ||
config = expanduser('~/.pythontidy.xml') | ||
if exists(config): | ||
cmd.extend(['-c', config]) | ||
|
||
|
||
class python_tidy(TextCommand): | ||
def run(self, edit): | ||
view = self.view | ||
region = Region(0L, view.size()) | ||
tidy = Popen(cmd, bufsize=-1, stdin=PIPE, stdout=PIPE, stderr=PIPE) | ||
output, error = tidy.communicate(view.substr(region)) | ||
view.replace(edit, region, output) |