# Path: lib/utils/debug.py
# def Debug(classification, text):
#     if 'all' in print_classifications or classification in print_classifications:
#         print("ArcticTypescript: %s: %s" % (classification.ljust(8), text))
#     if classification not in possible_classifications:
#         print("ArcticTypescript: debug: got unknown debug message classification: %s. " \
#             "Consider adding this to possible_classifications" % classification)
#     sys.stdout.flush()
# 
# Path: lib/utils/pathutils.py
# def add_usr_local_bin_to_path_on_osx():
# def find_tsconfigdir(rootdir):
# def expand_variables(path, project=None, use_cache=False):
# def get_tss_path():
# def get_expandglob_path():
# def default_node_path(node_path, project=None):
# def default_tsc_path(tsc_path=None, project=None):
# def search_node_modules(rootdir):
# 
# Path: lib/utils/osutils.py
# def get_kwargs(stderr=True):
#     if os.name == 'nt':
#         startupinfo = subprocess.STARTUPINFO()
#         startupinfo.dwFlags |= subprocess.STARTF_USESHOWWINDOW
#         if stderr:
#             #errorlog = open(os.devnull, 'w')
#             return {'stderr':subprocess.DEVNULL, 'startupinfo': startupinfo}
#         return {'startupinfo': startupinfo}
#     else:
#         return {}
# 
# Path: lib/utils/pathutils.py
# def default_tsc_path(tsc_path=None, project=None):
#     if tsc_path is not None and tsc_path:
#         tsc_path = expand_variables(tsc_path, project)
#         return tsc_path
# 
#     # search node_modules
#     if project:
#         node_modules_dir = search_node_modules(project.tsconfigdir)
#         if node_modules_dir:
#             tsc_path = os.path.join(node_modules_dir, ".bin", "tsc")
#             if file_exists(tsc_path):
#                 return os.path.normcase(tsc_path)
# 
#     # use ArcticTypescript's tsc
#     return os.path.join(package_path, 'bin', 'node_modules', 'typescript', 'bin', 'tsc')
# 
# def default_node_path(node_path, project=None):
#     if node_path == 'none':
#         Debug('notify', 'The setting node_path is set to "none". That is depreciated. Remove the setting.')
#         node_path = None
# 
#     if node_path == "" or node_path is None:
#         if sys.platform == "linux":
#             return "nodejs"
#         elif sys.platform == "nt":
#             return "node"
#         elif sys.platform == "darwin":
#             return "/usr/local/bin/node"
#         else:
#             return "node"
#     else:
#         return expand_variables(node_path, project)
# 
# def expand_variables(path, project=None, use_cache=False):
#     variables = {}
#     if project is not None:
#         variables.update(project.extract_variables(use_cache))
#     return replace_variables(path, variables)
# 
# Path: lib/display/Panel.py
# PANEL = Panel()


from subprocess import Popen, PIPE
from threading import Thread
    from queue import Queue
    from Queue import Queue
from ..utils import package_path, Debug
from ..utils.osutils import get_kwargs
from ..utils.pathutils import default_tsc_path, default_node_path, expand_variables
from ..display.Panel import PANEL
import sublime
import os
import json
        self.triggered_for_file = triggered_for_file
        self.window_for_panel = window_for_panel
        self.project = project
        self.p = None
        self.cancel_build = False
        Thread.__init__(self)

    def run(self):
        if self.p is not None:
            Debug('error', "Only use Compiler Object once!")

        self.cwd = os.path.abspath(self.project.tsconfigdir)
        node_path, compile_cmd = self._make_commandline()
        self.kwargs = get_kwargs()

        self._prepare_pre_and_post_commands()

        PANEL.clear(self.window_for_panel)

        if self.post_pre_authorized:
            for pre_cmd in self.pre_processing_commands:
                pre_cmd = expand_variables(str(pre_cmd), self.project, use_cache=True)
                self._run_command(pre_cmd, shell=True)

        self._run_command(compile_cmd)

        self.project.show_compiled_file()

        if self.post_pre_authorized:
            for post_cmd in self.post_processing_commands:

# Path: lib/utils/debug.py
# def Debug(classification, text):
#     if 'all' in print_classifications or classification in print_classifications:
#         print("ArcticTypescript: %s: %s" % (classification.ljust(8), text))
#     if classification not in possible_classifications:
#         print("ArcticTypescript: debug: got unknown debug message classification: %s. " \
#             "Consider adding this to possible_classifications" % classification)
#     sys.stdout.flush()
# 
# Path: lib/utils/pathutils.py
# def add_usr_local_bin_to_path_on_osx():
# def find_tsconfigdir(rootdir):
# def expand_variables(path, project=None, use_cache=False):
# def get_tss_path():
# def get_expandglob_path():
# def default_node_path(node_path, project=None):
# def default_tsc_path(tsc_path=None, project=None):
# def search_node_modules(rootdir):
# 
# Path: lib/utils/osutils.py
# def get_kwargs(stderr=True):
#     if os.name == 'nt':
#         startupinfo = subprocess.STARTUPINFO()
#         startupinfo.dwFlags |= subprocess.STARTF_USESHOWWINDOW
#         if stderr:
#             #errorlog = open(os.devnull, 'w')
#             return {'stderr':subprocess.DEVNULL, 'startupinfo': startupinfo}
#         return {'startupinfo': startupinfo}
#     else:
#         return {}
# 
# Path: lib/utils/pathutils.py
# def default_tsc_path(tsc_path=None, project=None):
#     if tsc_path is not None and tsc_path:
#         tsc_path = expand_variables(tsc_path, project)
#         return tsc_path
# 
#     # search node_modules
#     if project:
#         node_modules_dir = search_node_modules(project.tsconfigdir)
#         if node_modules_dir:
#             tsc_path = os.path.join(node_modules_dir, ".bin", "tsc")
#             if file_exists(tsc_path):
#                 return os.path.normcase(tsc_path)
# 
#     # use ArcticTypescript's tsc
#     return os.path.join(package_path, 'bin', 'node_modules', 'typescript', 'bin', 'tsc')
# 
# def default_node_path(node_path, project=None):
#     if node_path == 'none':
#         Debug('notify', 'The setting node_path is set to "none". That is depreciated. Remove the setting.')
#         node_path = None
# 
#     if node_path == "" or node_path is None:
#         if sys.platform == "linux":
#             return "nodejs"
#         elif sys.platform == "nt":
#             return "node"
#         elif sys.platform == "darwin":
#             return "/usr/local/bin/node"
#         else:
#             return "node"
#     else:
#         return expand_variables(node_path, project)
# 
# def expand_variables(path, project=None, use_cache=False):
#     variables = {}
#     if project is not None:
#         variables.update(project.extract_variables(use_cache))
#     return replace_variables(path, variables)
# 
# Path: lib/display/Panel.py
# PANEL = Panel()


# Path: lib/commands/Compiler.py
from subprocess import Popen, PIPE
from threading import Thread
    from queue import Queue
    from Queue import Queue
from ..utils import package_path, Debug
from ..utils.osutils import get_kwargs
from ..utils.pathutils import default_tsc_path, default_node_path, expand_variables
from ..display.Panel import PANEL
import sublime
import os
import json

        self.triggered_for_file = triggered_for_file
        self.window_for_panel = window_for_panel
        self.project = project
        self.p = None
        self.cancel_build = False
        Thread.__init__(self)

    def run(self):
        if self.p is not None:
            Debug('error', "Only use Compiler Object once!")

        self.cwd = os.path.abspath(self.project.tsconfigdir)
        node_path, compile_cmd = self._make_commandline()
        self.kwargs = get_kwargs()

        self._prepare_pre_and_post_commands()

        PANEL.clear(self.window_for_panel)

        if self.post_pre_authorized:
            for pre_cmd in self.pre_processing_commands:
                pre_cmd = expand_variables(str(pre_cmd), self.project, use_cache=True)
                self._run_command(pre_cmd, shell=True)

        self._run_command(compile_cmd)

        self.project.show_compiled_file()

        if self.post_pre_authorized:
            for post_cmd in self.post_processing_commands:

                post_cmd = expand_variables(str(post_cmd), self.project, use_cache=True)