# Path: src/core.py
# def diff_override(window, pkg_info, override,
#                   diff_only=False, force_reuse=False):
#     """
#     Generate a diff for the given package and override in a background thread,
#     """
#     context_lines = oa_setting("diff_context_lines")
#     action = "diff" if diff_only else oa_setting("diff_unchanged")
#     empty_diff_hdr = oa_setting("diff_empty_hdr")
# 
#     if force_reuse:
#         reuse, clear = True, True
#     else:
#         reuse = oa_setting("reuse_views")
#         clear = oa_setting("clear_existing")
# 
#     def _process_diff(thread):
#         diff = thread.diff
#         if diff is None:
#             return log("Unable to diff %s/%s\n\n"
#                         "Error loading file contents of one or both files.\n"
#                         "Check the console for more information",
#                         pkg_info.name, override, dialog=True)
# 
#         if diff.is_empty:
#             log("No changes detected in %s/%s", pkg_info.name, override,
#                  status=True)
# 
#             if action == "open":
#                 return open_override(window, pkg_info.name, override)
# 
#             elif action == "ignore":
#                 return
# 
#         title = "Diff of %s" % override_display(
#             os.path.join(pkg_info.name, override))
# 
#         result = diff.result
#         prefix = diff.hdr if diff.is_empty and empty_diff_hdr else ""
#         content = prefix + "No differences found" if result == "" else result
# 
#         view = output_to_view(window, title, content, reuse, clear,
#                               "Packages/Diff/Diff.tmLanguage")
# 
#         override_group.apply(view, pkg_info.name, override, True)
# 
#     callback = lambda thread: _process_diff(thread)
#     OverrideDiffThread(window, "Diffing Override", callback,
#                        pkg_info=pkg_info, override=override).start()
# 
# def packages_with_overrides(pkg_list, name_list=None):
#     """
#     Collect a list of package names from the given package list for which there
#     is at least a single (simple) override file and which is not in the list of
#     packages to ignore overrides in.
# 
#     Optionally, if name_list is provided, the list of package names will be
#     filtered to only include packages whose name also exists in the name list.
#     """
#     ignored = oa_setting("ignore_overrides_in")
#     items = [name for name, pkg in pkg_list if len(pkg.override_files()) > 0
#                                                and name not in ignored]
# 
#     if name_list is not None:
#         items = list(filter(lambda name: name in name_list, items))
# 
#     return items
# 
# def log(message, *args, status=False, dialog=False):
#     """
#     Simple logging method; writes to the console and optionally also the status
#     message as well.
#     """
#     message = message % args
#     print("OverrideAudit:", message)
#     if status:
#         sublime.status_message(message)
#     if dialog:
#         sublime.message_dialog(message)
# 
# Path: src/core.py
# class PackageListCollectionThread(BackgroundWorkerThread):
#     """
#     Collect the list of packages in a background thread. The collection can
#     optionally filter the list returned to only a set of names given and can
#     also optionally pre-fetch the list of overrides in found packages.
#     """
#     def _process(self):
#         self.pkg_list = PackageList(self.args.get("name_list", None))
#         if self.args.get("get_overrides", False) is True:
#             packages_with_overrides(self.pkg_list)


import sublime
import sublime_plugin
from ..core import diff_override, packages_with_overrides, log
from ..core import PackageListCollectionThread
                                        })

    def _show_pkg_list(self, pkg_list, bulk, exclude_unchanged):
        items = packages_with_overrides(pkg_list)

        if not items:
            log("No unignored packages have overrides",
                 status=True, dialog=True)

        self.window.show_quick_panel(
            items=items,
            on_select=lambda i: self._pkg_pick(pkg_list, items, i, bulk, exclude_unchanged))

    def _loaded(self, thread, package, override, bulk, exclude_unchanged):
        pkg_list = thread.pkg_list

        if package is None:
            self._show_pkg_list(pkg_list, bulk, exclude_unchanged)
        else:
            if package in pkg_list:
                pkg_info = pkg_list[package]
                if override is None:
                    self._show_override_list(pkg_info)
                else:
                    if pkg_info.has_possible_overrides():
                        diff_override(self.window, pkg_info, override)
                    else:
                        log("Package '%s' has no overrides to diff" % package,
                             status=True, dialog=True)
            else:

# Path: src/core.py
# def diff_override(window, pkg_info, override,
#                   diff_only=False, force_reuse=False):
#     """
#     Generate a diff for the given package and override in a background thread,
#     """
#     context_lines = oa_setting("diff_context_lines")
#     action = "diff" if diff_only else oa_setting("diff_unchanged")
#     empty_diff_hdr = oa_setting("diff_empty_hdr")
# 
#     if force_reuse:
#         reuse, clear = True, True
#     else:
#         reuse = oa_setting("reuse_views")
#         clear = oa_setting("clear_existing")
# 
#     def _process_diff(thread):
#         diff = thread.diff
#         if diff is None:
#             return log("Unable to diff %s/%s\n\n"
#                         "Error loading file contents of one or both files.\n"
#                         "Check the console for more information",
#                         pkg_info.name, override, dialog=True)
# 
#         if diff.is_empty:
#             log("No changes detected in %s/%s", pkg_info.name, override,
#                  status=True)
# 
#             if action == "open":
#                 return open_override(window, pkg_info.name, override)
# 
#             elif action == "ignore":
#                 return
# 
#         title = "Diff of %s" % override_display(
#             os.path.join(pkg_info.name, override))
# 
#         result = diff.result
#         prefix = diff.hdr if diff.is_empty and empty_diff_hdr else ""
#         content = prefix + "No differences found" if result == "" else result
# 
#         view = output_to_view(window, title, content, reuse, clear,
#                               "Packages/Diff/Diff.tmLanguage")
# 
#         override_group.apply(view, pkg_info.name, override, True)
# 
#     callback = lambda thread: _process_diff(thread)
#     OverrideDiffThread(window, "Diffing Override", callback,
#                        pkg_info=pkg_info, override=override).start()
# 
# def packages_with_overrides(pkg_list, name_list=None):
#     """
#     Collect a list of package names from the given package list for which there
#     is at least a single (simple) override file and which is not in the list of
#     packages to ignore overrides in.
# 
#     Optionally, if name_list is provided, the list of package names will be
#     filtered to only include packages whose name also exists in the name list.
#     """
#     ignored = oa_setting("ignore_overrides_in")
#     items = [name for name, pkg in pkg_list if len(pkg.override_files()) > 0
#                                                and name not in ignored]
# 
#     if name_list is not None:
#         items = list(filter(lambda name: name in name_list, items))
# 
#     return items
# 
# def log(message, *args, status=False, dialog=False):
#     """
#     Simple logging method; writes to the console and optionally also the status
#     message as well.
#     """
#     message = message % args
#     print("OverrideAudit:", message)
#     if status:
#         sublime.status_message(message)
#     if dialog:
#         sublime.message_dialog(message)
# 
# Path: src/core.py
# class PackageListCollectionThread(BackgroundWorkerThread):
#     """
#     Collect the list of packages in a background thread. The collection can
#     optionally filter the list returned to only a set of names given and can
#     also optionally pre-fetch the list of overrides in found packages.
#     """
#     def _process(self):
#         self.pkg_list = PackageList(self.args.get("name_list", None))
#         if self.args.get("get_overrides", False) is True:
#             packages_with_overrides(self.pkg_list)


# Path: src/commands/diff_single.py
import sublime
import sublime_plugin
from ..core import diff_override, packages_with_overrides, log
from ..core import PackageListCollectionThread

                                        })

    def _show_pkg_list(self, pkg_list, bulk, exclude_unchanged):
        items = packages_with_overrides(pkg_list)

        if not items:
            log("No unignored packages have overrides",
                 status=True, dialog=True)

        self.window.show_quick_panel(
            items=items,
            on_select=lambda i: self._pkg_pick(pkg_list, items, i, bulk, exclude_unchanged))

    def _loaded(self, thread, package, override, bulk, exclude_unchanged):
        pkg_list = thread.pkg_list

        if package is None:
            self._show_pkg_list(pkg_list, bulk, exclude_unchanged)
        else:
            if package in pkg_list:
                pkg_info = pkg_list[package]
                if override is None:
                    self._show_override_list(pkg_info)
                else:
                    if pkg_info.has_possible_overrides():
                        diff_override(self.window, pkg_info, override)
                    else:
                        log("Package '%s' has no overrides to diff" % package,
                             status=True, dialog=True)
            else:

                log("Unable to diff; no package '%s'" % package,