def parse(self, source):

        self._graph = None

        try:

            # Compressed?

            try:

                # UTF-8?

                try:

                    source = source.encode('utf-8')

                except __HOLE__:

                    pass

                source = gzip.GzipFile(fileobj=StringIO.StringIO(source), mode='rb').read()

            except IOError:

                pass

            xml.sax.parseString(source, self)

            # Delete 'OPERATOR' from tail nodes

            tail_nodes = [node for node, degree in self._graph.out_degree().items() if degree == 0]

            for node in tail_nodes:

                del self._graph.node[node]['OPERATOR']

        except xml.sax._exceptions.SAXParseException:

            pass

        return self._graph
dataset/ETHPy150Open ikotler/pythonect/pythonect/internal/parsers/dia.py/_DiaParser.parse