Commit 1161ec14 authored by Eckhart Arnold's avatar Eckhart Arnold
Browse files

cython compatibility

parent e1092e1b
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -9,7 +9,7 @@ cdef class Node:
    cdef public object _result
    cdef public tuple children
    cdef public str tag_name
    cdef object _xml_attr
    cdef public object _xml_attr

    # cpdef equals(self, other, ignore_attr_order)
    # cpdef get(self,  index_or_tagname, surrogate)
+0 −3
Original line number Diff line number Diff line
@@ -36,7 +36,6 @@ from DHParser.error import Error, ErrorCode, linebreaks, line_col
from DHParser.stringview import StringView  # , real_indices
from DHParser.toolkit import re, cython


__all__ = ('WHITESPACE_PTYPE',
           'TOKEN_PTYPE',
           'REGEXP_PTYPE',
@@ -486,8 +485,6 @@ class Node: # (collections.abc.Sized): Base class omitted for cython-compatibil
        existence of any attributes.
        """
        try:
            if self._xml_attr is None:  # cython compatibility
                return False
            return attr in self._xml_attr if bool(attr) else bool(self._xml_attr)
        except (AttributeError, TypeError):
            return False
+9 −20
Original line number Diff line number Diff line
@@ -581,7 +581,6 @@ def swap_attributes(node: Node, other: Node):
    NA = node.has_attr()
    OA = other.has_attr()
    if NA or OA:
        try:
        save = node._xml_attr if NA else None
        if OA:
            node._xml_attr = other._xml_attr
@@ -591,16 +590,6 @@ def swap_attributes(node: Node, other: Node):
            other._xml_attr = save
        elif OA:
            other._xml_attr = None
        except AttributeError:  # cython compatibility
            save = node.attr if NA else None
            if OA:
                node.attr = other.attr
            elif NA:
                node.attr = None
            if NA:
                other.attr = save
            elif OA:
                other.attr = None


def _replace_by(node: Node, child: Node):
+9 −9
Original line number Diff line number Diff line
@@ -15,17 +15,17 @@ setup(
    name='DHParser',
    version=__version__,
    packages=['DHParser', 'DHParser.scripts'],
    ext_modules=cythonize([#'DHParser/stringview.py',
                           #'DHParser/toolkit.py',
                           #'DHParser/preprocess.py',
                           #'DHParser/error.py',
    ext_modules=cythonize(['DHParser/stringview.py',
                           'DHParser/toolkit.py',
                           'DHParser/preprocess.py',
                           'DHParser/error.py',
                           'DHParser/syntaxtree.py',
                           #'DHParser/log.py',
                           #'DHParser/parse.py',
                           #'DHParser/trace.py',
                           'DHParser/log.py',
                           'DHParser/parse.py',
                           'DHParser/trace.py',
                           'DHParser/transform.py',
                           #'DHParser/compile.py',
                           #'DHParser/ebnf.py',
                           'DHParser/compile.py',
                           'DHParser/ebnf.py',
                           ],
                          nthreads=0, annotate=False),
    url='https://gitlab.lrz.de/badw-it/DHParser',