10.12., 9:00 - 11:00: Due to updates GitLab may be unavailable for some minutes between 09:00 and 11:00.

Commit 9c69fd49 authored by Eckhart Arnold's avatar Eckhart Arnold

Python 3.4 compatibility

parent a4f9cbe1
......@@ -24,7 +24,7 @@ try:
import regex as re
except ImportError:
import re
from typing import Any, cast, Tuple, Union
from .typing import Any, cast, Tuple, Union
from DHParser.ebnf import EBNFTransformer, EBNFCompiler, grammar_changed, \
get_ebnf_scanner, get_ebnf_grammar, get_ebnf_transformer, get_ebnf_compiler, \
......
......@@ -23,7 +23,7 @@ try:
import regex as re
except ImportError:
import re
from typing import Callable, Dict, List, Set, Tuple
from .typing import Callable, Dict, List, Set, Tuple
from DHParser.toolkit import load_if_file, escape_re, md5, sane_parser_name
from DHParser.parsers import Grammar, mixin_comment, nil_scanner, Forward, RE, NegativeLookahead, \
......
......@@ -57,7 +57,7 @@ try:
import regex as re
except ImportError:
import re
from typing import Any, Callable, Dict, Iterator, List, Set, Tuple, Union
from .typing import Any, Callable, Dict, Iterator, List, Set, Tuple, Union
from DHParser.toolkit import is_logging, log_dir, logfile_basename, escape_re, sane_parser_name
from DHParser.syntaxtree import WHITESPACE_PTYPE, TOKEN_PTYPE, ZOMBIE_PARSER, ParserBase, \
......@@ -851,7 +851,7 @@ class Sequence(NaryOperator):
return Node(self, results), text_
def __add__(self, other: 'Sequence') -> 'Sequence':
return Sequence(*self.parsers, other)
return Sequence(*(self.parsers + (other,)))
def __radd__(self, other: 'Sequence') -> 'Sequence':
return Sequence(other, *self.parsers)
......@@ -896,7 +896,7 @@ class Alternative(NaryOperator):
return None, text
def __or__(self, other):
return Alternative(*self.parsers, other)
return Alternative(*(self.parsers + (other,)))
def __ror__(self, other):
return Alternative(other, *self.parsers)
......
......@@ -27,7 +27,7 @@ try:
import regex as re
except ImportError:
import re
from typing import AbstractSet, Any, ByteString, Callable, cast, Container, Iterator, List, \
from .typing import AbstractSet, Any, ByteString, Callable, cast, Container, Iterator, List, \
NamedTuple, Sequence, Union, Text, Tuple
from DHParser.toolkit import log_dir, expand_table, line_col, smart_list
......@@ -338,7 +338,7 @@ class Node:
s = '(' + node.tag_name
# s += " '(pos %i)" % node.pos
if src:
s += " '(pos %i %i %i)" % (node.pos, *line_col(src, node.pos))
s += " '(pos %i " % node.pos + " %i %i)" % line_col(src, node.pos)
if node.errors:
s += " '(err '(%s))" % ' '.join(str(err).replace('"', r'\"')
for err in node.errors)
......
......@@ -38,7 +38,7 @@ try:
import regex as re
except ImportError:
import re
from typing import List, Tuple
from .typing import List, Tuple
__all__ = ['logging',
......@@ -169,7 +169,7 @@ def error_messages(source_text, errors) -> List[str]:
a list that contains all error messages in string form. Each
string starts with "line: [Line-No], column: [Column-No]
"""
return ["line: %i, column: %i, error: %s" % (*line_col(source_text, err.pos), err.msg)
return ["line: %i, column: %i" % line_col(source_text, err.pos) + ", error: %s" % err.msg
for err in sorted(list(errors))]
......
This diff is collapsed.
This diff is collapsed.
......@@ -5,3 +5,6 @@ Permission is hereby granted, free of charge, to any person obtaining a copy of
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
IMPORTANT: The module DHParser/typing.py is taken from the Python 3.5 distribution and thus licensed under the Python Software Foundation License!
......@@ -13,6 +13,19 @@ License
DHParser is open source software under the [MIT License](https://opensource.org/licenses/MIT)
**Exception**: The module ``DHParser/typing.py`` was directly taken from the
Python 3.5 source code in order for DHParser to be backwards compatible
with Python 3.4. The module ``DHParser/typing.py`` is licensed under the
[Python Software Foundation License Version 2](https://docs.python.org/3.5/license.html)
Sources
-------
Find the sources on [gitlab.lrz.de/badw-it/DHParser](https://gitlab.lrz.de/badw-it/) .
Get them with:
git clone https://gitlab.lrz.de/badw-it/DHParser
Purpose
......
#!/bin/sh
python setup.py sdist bdist
python3 setup.py sdist bdist
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment