-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathNameCase.py
More file actions
25 lines (20 loc) · 775 Bytes
/
NameCase.py
File metadata and controls
25 lines (20 loc) · 775 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
import sublime
import sublime_plugin
import subprocess
class NameCaseCommand(sublime_plugin.TextCommand):
def run(self, edit):
for region in self.view.sel():
if region.empty():
region = self.view.line(region)
p = subprocess.Popen(
"namecase",
shell = True,
bufsize = -1,
stdout = subprocess.PIPE,
stderr = subprocess.PIPE,
stdin = subprocess.PIPE)
output, error = p.communicate(self.view.substr(region).encode('utf-8'))
if error:
sublime.errorMessage(error.decode('utf-8'))
else:
self.view.replace(edit, region, output.decode('utf-8'))