Skip to content

Commit

Permalink
Initial version integrating Chuck Rhode's PythonTidy (see http://pypi…
Browse files Browse the repository at this point in the history
  • Loading branch information
witsch committed Sep 25, 2011
0 parents commit f8753cc
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 0 deletions.
3 changes: 3 additions & 0 deletions Default (Linux).sublime-keymap
@@ -0,0 +1,3 @@
[
{ "keys": ["ctrl+shift+alt+t"], "command": "python_tidy" }
]
3 changes: 3 additions & 0 deletions Default (OSX).sublime-keymap
@@ -0,0 +1,3 @@
[
{ "keys": ["super+ctrl+alt+t"], "command": "python_tidy" }
]
3 changes: 3 additions & 0 deletions Default (Windows).sublime-keymap
@@ -0,0 +1,3 @@
[
{ "keys": ["ctrl+shift+alt+t"], "command": "python_tidy" }
]
19 changes: 19 additions & 0 deletions PythonTidy.py
@@ -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)

0 comments on commit f8753cc

Please sign in to comment.