import sublime
import sublime_plugin
import re

class LevureAppNotify(sublime_plugin.EventListener):
    def on_post_save(self, view):
        # 1. Get script only stack name. line 1: script "Name" [done]
        # 2. Get project key from project settings
        # 3. Send notification over socket with project key and script name
        # 4. Get response from LiveCode IDE

        if view.settings().get('syntax') == 'Packages/LiveCode/LiveCode.sublime-syntax':
            stack_name = None

            # \A matches beginning of file
            region = view.find('\Ascript "([-a-zA-Z0-9_\s\?!]+)"', 0, sublime.IGNORECASE)
            if region.a >= 0:
                stack_name = re.search('"([-a-zA-Z0-9_\s\?!]+)"', view.substr(region)).group(1)

            print('stack name and filename', stack_name, view.file_name())

Add python file that is triggered when saving a file
[WIP] Add python file that is triggered when saving a file
