Exemple #1
0
    def read_source(self):
        """Read the source."""

        errors = False
        ext_tbl = self.settings.get("yaml_strip_tabs_from", [])
        filename = self.view.file_name()
        self.strip_tabs = False
        if filename is not None:
            for ext in ext_tbl:
                m = re.match("^(.*)\\." + re.escape(ext) + "$", filename, re.IGNORECASE)
                if m is not None:
                    self.strip_tabs = True
                    break
        try:
            # Ensure view buffer is in a UTF8 format.
            # Wrap string in a file structure so it can be accessed by readPlist
            # Read view buffer as PLIST and dump to Python dict
            if self.binary and self.view.encoding() == 'Hexadecimal':
                self.plist = plist.read_plist_from_hex_view(self.view)
            elif self.binary and filename is not None and os.path.exists(filename):
                self.plist = plist.read_plist_from_file(filename)
            else:
                self.plist = plist.read_plist_from_view(self.view)
        except Exception:
            errors = True
            error_type = 'view2bplist' if self.binary else 'view2plist'
            error_msg(self.errors[error_type], traceback.format_exc())
        return errors
Exemple #2
0
    def read_source(self):
        """Read the source."""

        errors = False
        try:
            # Ensure view buffer is in a UTF8 format.
            # Wrap string in a file structure so it can be accessed by readPlist
            # Read view buffer as PLIST and dump to Python dict
            filename = self.view.file_name()
            if self.binary and self.view.encoding() == 'Hexadecimal':
                self.plist = plist.read_plist_from_hex_view(self.view)
            elif self.binary and filename is not None and os.path.exists(filename):
                self.plist = plist.read_plist_from_file(filename)
            else:
                self.plist = plist.read_plist_from_view(self.view)
        except Exception:
            errors = True
            error_type = 'view2bplist' if self.binary else 'view2plist'
            error_msg(self.errors[error_type], traceback.format_exc())
        return errors