# Path: plugins/lib/view_utils.py
# def coorded_substr(view, reg1=None, reg2=None, rel=None):
#     """Returns the string of two coordinate pairs forming a region.
# 
#     The pairs are supporsed to be indexable and have a length of 2.
#     Tuples are preferred.
# 
#     Defaults to the whole buffer.
# 
#         For examples, see `coorded_region`.
#     """
#     return view.substr(coorded_region(view, reg1, reg2))
# 
# def base_scope(view):
#     """Returns the view's base scope.
#     """
#     return view.scope_name(0).split(' ', 1)[0]
# 
# def get_text(view):
#     """Returns the whole string of a buffer. Alias for `coorded_substr(view)`.
#     """
#     return coorded_substr(view)


import re
import os
import json
import yaml
import plistlib
import sublime
from sublime_lib import OutputPanel
from ..view_utils import coorded_substr, base_scope, get_text
    from xml.parsers.expat import ExpatError, ErrorString
    from . import plist_parser
            from xml.sax._exceptions import SAXReaderNotAvailable
            # except BaseException as e:
            #     # Whatever could happen here ...
            #     self.output.print(self.debug_base % (self.file_path, str(e), 0, 0))
            else:
                return data
        else:
            # falling back to plist_parser
            try:
                data = plist_parser.parse_string(text)
            except plist_parser.PropertyListParseError as e:
                self.output.print(self.debug_base % (self.file_path, str(e), 0, 0))
            except SAXReaderNotAvailable:
                # https://github.com/SublimeText/AAAPackageDev/issues/48
                self.output.print("Unable to parse Property List because of missing XML "
                                  "parsers in your Python environment.\n"
                                  "Please use Sublime Text 3 or reinstall Python 2.6 "
                                  "on your system.")
            else:
                return data


class YAMLLoader(LoaderProto):
    name    = "YAML"
    ext     = "yaml"
    comment = "#"
    scope   = "source.yaml"
    debug_base = "Error parsing YAML: %s"
    file_regex = r'^ +in "(.*?)", line (\d+), column (\d+)'

    def parse(self, *args, **kwargs):

# Path: plugins/lib/view_utils.py
# def coorded_substr(view, reg1=None, reg2=None, rel=None):
#     """Returns the string of two coordinate pairs forming a region.
# 
#     The pairs are supporsed to be indexable and have a length of 2.
#     Tuples are preferred.
# 
#     Defaults to the whole buffer.
# 
#         For examples, see `coorded_region`.
#     """
#     return view.substr(coorded_region(view, reg1, reg2))
# 
# def base_scope(view):
#     """Returns the view's base scope.
#     """
#     return view.scope_name(0).split(' ', 1)[0]
# 
# def get_text(view):
#     """Returns the whole string of a buffer. Alias for `coorded_substr(view)`.
#     """
#     return coorded_substr(view)


# Path: plugins/lib/fileconv/loaders.py
import re
import os
import json
import yaml
import plistlib
import sublime
from sublime_lib import OutputPanel
from ..view_utils import coorded_substr, base_scope, get_text
    from xml.parsers.expat import ExpatError, ErrorString
    from . import plist_parser
            from xml.sax._exceptions import SAXReaderNotAvailable

            # except BaseException as e:
            #     # Whatever could happen here ...
            #     self.output.print(self.debug_base % (self.file_path, str(e), 0, 0))
            else:
                return data
        else:
            # falling back to plist_parser
            try:
                data = plist_parser.parse_string(text)
            except plist_parser.PropertyListParseError as e:
                self.output.print(self.debug_base % (self.file_path, str(e), 0, 0))
            except SAXReaderNotAvailable:
                # https://github.com/SublimeText/AAAPackageDev/issues/48
                self.output.print("Unable to parse Property List because of missing XML "
                                  "parsers in your Python environment.\n"
                                  "Please use Sublime Text 3 or reinstall Python 2.6 "
                                  "on your system.")
            else:
                return data


class YAMLLoader(LoaderProto):
    name    = "YAML"
    ext     = "yaml"
    comment = "#"
    scope   = "source.yaml"
    debug_base = "Error parsing YAML: %s"
    file_regex = r'^ +in "(.*?)", line (\d+), column (\d+)'

    def parse(self, *args, **kwargs):

        text = get_text(self.view)