import sublime, sublime_plugin class BongoModule(sublime_plugin.TextCommand): def run(self, edit): # Replace <Panel> self.view.replace(edit, self.view.find(r'<Panel', 0), '<BongoModule') self.view.replace(edit, self.view.find(r'</Panel', 0), '</BongoModule') # Find device name a = self.view.find(r'Device ID="1".*?Name="', 0).end() b = self.view.find(r'Device ID="1".*?Name=".*?"', 0).end() c = sublime.Region(a,b-1) name = self.view.substr(c) # Find widget a = self.view.find(r'<Popup Name="', 0).end() b = self.view.find(r'<Popup Name=".*?"', 0).end() c = sublime.Region(a,b-1) widget = self.view.substr(c) # find end file end = self.view.find(r'</BongoModule>', 0).begin() subdevice = '<SubDevices><SubDevice Device="' + widget + '" Function="" Location="" Name="' + name + '" RemoteType="0" Type="E1"><Widgets><Widget Name="' + widget + '"/></Widgets></SubDevice></SubDevices>' self.view.insert(edit, end, subdevice)
Run
Reset
Share
Import
Link
Embed
Language▼
English
中文
Python Fiddle
Python Cloud IDE
Follow @python_fiddle
Browser Version Not Supported
Due to Python Fiddle's reliance on advanced JavaScript techniques, older browsers might have problems running it correctly. Please download the latest version of your favourite browser.
Chrome 10+
Firefox 4+
Safari 5+
IE 10+
Let me try anyway!
url:
Go
Python Snippet
Stackoverflow Question