# Path: turbulenz_tools/utils/dependencies.py
# def find_file_in_dirs(filename, dirs, error_on_multiple = False):
#     found = []
#     for d in dirs:
#         fn = join(d, filename)
#         if exists(fn):
#             if error_on_multiple:
#                 if fn not in found:
#                     found.append(fn)
#             else:
#                 return abspath(fn)
#     if error_on_multiple:
#         if len(found) > 1:
#             raise Exception("File '%s' matched several locations: %s" % found)
#         if len(found) == 1:
#             return abspath(found[0])
#     return None
# 
# Path: turbulenz_tools/utils/profiler.py
# class Profiler(object):
# 
#     _profiler_impl = ProfilerDummyImpl()
# 
#     @classmethod
#     def enable(cls):
#         if not isinstance(cls._profiler_impl, ProfilerDummyImpl):
#             raise Exception("Profiler.enable_profiler() called twice")
#         cls._profiler_impl = ProfilerImpl()
# 
#     @classmethod
#     def start(cls, section_name):
#         cls._profiler_impl.start(section_name)
# 
#     @classmethod
#     def stop(cls, section_name):
#         cls._profiler_impl.stop(section_name)
# 
#     @classmethod
#     def get_root_nodes(cls):
#         return cls._profiler_impl.get_root_nodes()
# 
#     @classmethod
#     def dump_data(cls):
#         cls._profiler_impl.dump_data()
# 
# Path: turbulenz_tools/tools/toolsexception.py
# class ToolsException(Exception):
#     pass
# 
# Path: turbulenz_tools/tools/templates.py
# def read_file_utf8(filename):
#     with open(filename, 'rb') as f:
#         text = f.read().decode('utf-8-sig')
# 
#         # This is unpleasant, but it is thorough.  This is the
#         # single-pass equivalent of:
#         # return (in_data.replace('\r\n', '\n').replace('\n\r', '\n'))\
#         #     .replace('\r', '\n');
#         return LF_RE.sub(_sanitize_crlf, text)


from turbulenz_tools.utils.dependencies import find_file_in_dirs
from turbulenz_tools.utils.profiler import Profiler
from turbulenz_tools.tools.toolsexception import ToolsException
from turbulenz_tools.tools.templates import read_file_utf8
from re import compile as re_compile
from logging import getLogger
    from turbulenz_tools.version import SDK_VERSION as engine_version
import os.path
import glob
    parser.add_option("-t", "--templatedir", action="append", dest="templatedirs",
                      default=[], help="template directory (multiple allowed)")

    # Dependency generation
    parser.add_option("-M", "--dependency", action="store_true",
                      dest="dependency", default=False,
                      help="output dependencies")
    parser.add_option("--MF", action="store", dest="dependency_file",
                      help="dependencies output to file")

    # "use strict" options
    parser.add_option("--use-strict", action="store_true", dest="use_strict",
                      default=False, help='enforce "use strict"; statement. '
                      'This adds a single "use strict"; line at the top of the '
                      'JavaScript code.')
    parser.add_option("--include-use-strict", action="store_true",
                      dest="include_use_strict", default=False,
                      help='don\'t strip out "use strict"; statements. '
                      'By default all "use strict"; statements are removed '
                      'from the output file.')

    # Hybrid
    parser.add_option("--hybrid", action="store_true", dest="hybrid",
                      default=False, help="canvas, canvas_dev modes only. "
                      "Start up a plugin as well as a canvas-based "
                      "TurbulenzEngine. The plugin will be available as "
                      "TurbulenzEnginePlugin.")

    # Profiling
    def _enable_profiler(_options, _opt_str, _value, _parser):

# Path: turbulenz_tools/utils/dependencies.py
# def find_file_in_dirs(filename, dirs, error_on_multiple = False):
#     found = []
#     for d in dirs:
#         fn = join(d, filename)
#         if exists(fn):
#             if error_on_multiple:
#                 if fn not in found:
#                     found.append(fn)
#             else:
#                 return abspath(fn)
#     if error_on_multiple:
#         if len(found) > 1:
#             raise Exception("File '%s' matched several locations: %s" % found)
#         if len(found) == 1:
#             return abspath(found[0])
#     return None
# 
# Path: turbulenz_tools/utils/profiler.py
# class Profiler(object):
# 
#     _profiler_impl = ProfilerDummyImpl()
# 
#     @classmethod
#     def enable(cls):
#         if not isinstance(cls._profiler_impl, ProfilerDummyImpl):
#             raise Exception("Profiler.enable_profiler() called twice")
#         cls._profiler_impl = ProfilerImpl()
# 
#     @classmethod
#     def start(cls, section_name):
#         cls._profiler_impl.start(section_name)
# 
#     @classmethod
#     def stop(cls, section_name):
#         cls._profiler_impl.stop(section_name)
# 
#     @classmethod
#     def get_root_nodes(cls):
#         return cls._profiler_impl.get_root_nodes()
# 
#     @classmethod
#     def dump_data(cls):
#         cls._profiler_impl.dump_data()
# 
# Path: turbulenz_tools/tools/toolsexception.py
# class ToolsException(Exception):
#     pass
# 
# Path: turbulenz_tools/tools/templates.py
# def read_file_utf8(filename):
#     with open(filename, 'rb') as f:
#         text = f.read().decode('utf-8-sig')
# 
#         # This is unpleasant, but it is thorough.  This is the
#         # single-pass equivalent of:
#         # return (in_data.replace('\r\n', '\n').replace('\n\r', '\n'))\
#         #     .replace('\r', '\n');
#         return LF_RE.sub(_sanitize_crlf, text)


# Path: turbulenz_tools/tools/appcodegen.py
from turbulenz_tools.utils.dependencies import find_file_in_dirs
from turbulenz_tools.utils.profiler import Profiler
from turbulenz_tools.tools.toolsexception import ToolsException
from turbulenz_tools.tools.templates import read_file_utf8
from re import compile as re_compile
from logging import getLogger
    from turbulenz_tools.version import SDK_VERSION as engine_version
import os.path
import glob

    parser.add_option("-t", "--templatedir", action="append", dest="templatedirs",
                      default=[], help="template directory (multiple allowed)")

    # Dependency generation
    parser.add_option("-M", "--dependency", action="store_true",
                      dest="dependency", default=False,
                      help="output dependencies")
    parser.add_option("--MF", action="store", dest="dependency_file",
                      help="dependencies output to file")

    # "use strict" options
    parser.add_option("--use-strict", action="store_true", dest="use_strict",
                      default=False, help='enforce "use strict"; statement. '
                      'This adds a single "use strict"; line at the top of the '
                      'JavaScript code.')
    parser.add_option("--include-use-strict", action="store_true",
                      dest="include_use_strict", default=False,
                      help='don\'t strip out "use strict"; statements. '
                      'By default all "use strict"; statements are removed '
                      'from the output file.')

    # Hybrid
    parser.add_option("--hybrid", action="store_true", dest="hybrid",
                      default=False, help="canvas, canvas_dev modes only. "
                      "Start up a plugin as well as a canvas-based "
                      "TurbulenzEngine. The plugin will be available as "
                      "TurbulenzEnginePlugin.")

    # Profiling
    def _enable_profiler(_options, _opt_str, _value, _parser):

        Profiler.enable()