Skip to content

Instantly share code, notes, and snippets.

@aronbeal
Last active December 21, 2015 11:19
Show Gist options
  • Save aronbeal/6297927 to your computer and use it in GitHub Desktop.
Save aronbeal/6297927 to your computer and use it in GitHub Desktop.
Modifications to phing.py in Sublime Text Phing Plugin by nLight to get it to work in ST3
#encoding:utf-8
import re
import sublime, sublime_plugin
import xml.etree.ElementTree as ET
class PhingCommand(sublime_plugin.WindowCommand):
def run(self):
if(len(self.window.folders()) == 0):
print("No folders found.")
return
self.project_root = self.window.folders()[0]
buildfile = open("%s/build.xml" % self.project_root, 'r')
file_content = buildfile.read()
root = ET.fromstring(file_content)
elements = root.findall(".//target")
self.targets = list(map( lambda target: [target.attrib['name'], (target.attrib['description'] if 'description' in target.attrib else "No description given")], elements ))
self.targets.sort()
self.window.show_quick_panel(self.targets, self.on_target)
def on_target(self, index):
if index != -1:
self.window.run_command("exec", {
"cmd": ['phing', '-logger', 'phing.listener.DefaultLogger', self.targets[index][0]],
"working_dir": self.project_root
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment