Created
February 14, 2013 15:26
-
-
Save puterleat/4953529 to your computer and use it in GitHub Desktop.
sublime text 2 plugin to run selection in Stata
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
import subprocess | |
import os | |
import sublime | |
import sublime_plugin | |
class RunInStataCommand(sublime_plugin.TextCommand): | |
def run(self, edit): | |
CURR, _ = os.path.split(self.view.file_name()) | |
sel = self.view.sel() | |
text = [self.view.substr(i) for i in sel] | |
text = [i.split("//")[0] for i in text] #kill comments | |
text = '\n'.join(text) | |
tmpdofile = os.path.join(CURR, '.tostata.do') | |
with open(tmpdofile, 'w') as f: | |
f.write(text) | |
subprocess.check_call(["open", tmpdofile]) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment