diff --git a/pya2l/classes.py b/pya2l/classes.py index cc03c59..3eeb43b 100644 --- a/pya2l/classes.py +++ b/pya2l/classes.py @@ -1,5 +1,4 @@ #!/usr/bin/env python -# -*- coding: utf-8 -*- __copyright__ = """ pySART - Simplified AUTOSAR-Toolkit for Python. @@ -25,8 +24,6 @@ from collections import namedtuple -import six - from pya2l.utils import SingletonBase @@ -36,11 +33,11 @@ def camel_case(name, upper_first=True): result.append(splitty[0]) if len(splitty) > 1: for part in splitty[1:]: - xxx = "{0}{1}".format(part[0].upper(), part[1:]) + xxx = f"{part[0].upper()}{part[1:]}" result.append(xxx) result = "".join(result) if upper_first: - result = "{}{}".format(result[0].upper(), result[1:]) + result = f"{result[0].upper()}{result[1:]}" return result @@ -165,8 +162,7 @@ def getClass(metacls, name): return result -@six.add_metaclass(KeywordType) -class Keyword(object): +class Keyword(metaclass=KeywordType): multiple = False block = False @@ -180,7 +176,7 @@ def attributeNames(cls): return [attr[1] for attr in cls.attrs if MULTIPLE not in attr] def __str__(self): - return "< %s @%0X >" % (self.__class__.__name__, id(self)) + return f"< {self.__class__.__name__} @{id(self):0X} >" @classmethod def class_name(cls): @@ -2073,7 +2069,7 @@ class RootElement(Keyword): } -class A2LElement(object): +class A2LElement: def __str__(self): result = [] result.append("%s {" % self.__class__.__name__) diff --git a/pya2l/parserlib.py b/pya2l/parserlib.py index 401d2ab..91dfa94 100644 --- a/pya2l/parserlib.py +++ b/pya2l/parserlib.py @@ -1,5 +1,4 @@ #!/usr/bin/env python -# -*- coding: utf-8 -*- __copyright__ = """ pySART - Simplified AUTOSAR-Toolkit for Python. @@ -27,20 +26,22 @@ __author__ = "Christoph Schueler" __version__ = "0.1.0" -from collections import namedtuple import importlib import sys - -import antlr4 -from antlr4.error.ErrorListener import ErrorListener -from antlr4.atn.ParserATNSimulator import ParserATNSimulator +from collections import namedtuple from pya2l import model +# import antlr4 +# from antlr4.error.ErrorListener import ErrorListener +# from antlr4.atn.ParserATNSimulator import ParserATNSimulator + + ResultType = namedtuple("ResultType", "db listener_result") +''' class MyErrorListener(ErrorListener): """ """ @@ -58,6 +59,7 @@ def syntaxError(self, recognizer, offendingSymbol, line, column, msg, e): ) else: print("line " + str(line) + ":" + str(column) + " " + msg, file=sys.stderr) +''' class ParserWrapper: @@ -82,8 +84,8 @@ def __init__( self.listener = listener def _load(self, name): - className = "{0}{1}".format(self.grammarName, name) - moduleName = "pya2l.{0}".format(className) + className = f"{self.grammarName}{name}" + moduleName = f"pya2l.{className}" module = importlib.import_module(moduleName) klass = getattr(module, className) return ( diff --git a/pya2l/parsers.py b/pya2l/parsers.py index aa68fdf..df24302 100644 --- a/pya2l/parsers.py +++ b/pya2l/parsers.py @@ -1,5 +1,4 @@ #!/usr/bin/env python -# -*- coding: utf-8 -*- __copyright__ = """ pySART - Simplified AUTOSAR-Toolkit for Python. @@ -26,10 +25,13 @@ """ __author__ = "Christoph Schueler" -from pya2l.aml.listener import AMLListener -from pya2l.parserlib import ParserWrapper from pya2l.a2lparser import A2LParser -from pya2l.if_data_parser import IfDataParser + +# from pya2l.aml.listener import AMLListener +from pya2l.parserlib import ParserWrapper + + +# from pya2l.if_data_parser import IfDataParser def aml(debug: bool = False, prepro_result=None):