Commit c7d0bc6b authored by Laura Alexandra Sequeira Gouveia's avatar Laura Alexandra Sequeira Gouveia

Merge branch 'master' into CoRA-ZynQ

parents 5d0ec830 34f98001
version: 2
jobs:
build:
machine: true
steps:
- checkout
- restore_cache:
key: docker-{{ checksum "Dockerfile" }}
- run:
command: if [[ -e ~/docker/image.tar ]]; then docker load --input ~/docker/image.tar; else docker build -t dmt . && { mkdir -p ~/docker; docker save dmt > ~/docker/image.tar ; } ; fi
- save_cache:
key: docker-{{ checksum "Dockerfile" }}
paths:
- ~/docker
- run:
command: docker run -it -v $(pwd):/root/tests dmt bash -c 'cd /root/tests ; pip3 uninstall dmt ; pip3 install --upgrade . ; LANG=C LC_ALL=C PATH=$PATH:/asn1scc make'
...@@ -14,3 +14,10 @@ tests-sqlalchemy/test.db ...@@ -14,3 +14,10 @@ tests-sqlalchemy/test.db
tests-sqlalchemy/verifier/LotsOfDataTypes.asn tests-sqlalchemy/verifier/LotsOfDataTypes.asn
tests-sqlalchemy/verifier/asn2dataModel/ tests-sqlalchemy/verifier/asn2dataModel/
.mypy_cache .mypy_cache
env
aclocal.m4
autom4te.cache/
config.log
config.status
setup.py
dmt/commonPy/__init__.py
FROM debian:stretch
RUN bash -c echo -e 'Acquire::http::Pipeline-Depth 0;\nAcquire::http::No-Cache true;\nAcquire::BrokenProxy true;\n' > /etc/apt/apt.conf.d/99badproxies
RUN cat /etc/apt/apt.conf.d/99badproxies
RUN apt-get update
RUN apt-get install -y libxslt-dev libxml2-dev python-psycopg2 mono-runtime libmono-system-data4.0-cil libmono-system-web4.0-cil libfsharp-core4.3-cil
RUN apt-get install -y wget python3-pip
RUN wget -O - -q https://github.com/ttsiodras/asn1scc/releases/download/4.2.0.1.f/asn1scc-bin-4.2.0.1f.tar.bz2 | tar jxvf -
RUN apt-get install -y python-pip
RUN wget -O - -q https://github.com/ttsiodras/DataModellingTools/files/335591/antlr-2.7.7.tar.gz | tar zxvf - ; cd antlr-2.7.7/lib/python ; pip2 install .
RUN pip2 install SQLAlchemy psycopg2
COPY requirements.txt /tmp/
RUN pip3 install -r /tmp/requirements.txt
RUN apt-get install less
RUN apt-get install -y postgresql
COPY setup_testdb.sh /tmp/
RUN /tmp/setup_testdb.sh
...@@ -5,11 +5,19 @@ PY_SRC:=$(filter-out dmt/B_mappers/antlr.main.py dmt/A_mappers/Stubs.py, ${PY_SR ...@@ -5,11 +5,19 @@ PY_SRC:=$(filter-out dmt/B_mappers/antlr.main.py dmt/A_mappers/Stubs.py, ${PY_SR
# the one installed in $HOME/.local via setup.py. # the one installed in $HOME/.local via setup.py.
# #
# To address this, we find where our pip-installed typing lives: # To address this, we find where our pip-installed typing lives:
TYPING_FOLDER:=$(shell pip3 show typing | grep ^Location | sed 's,^.*: ,,') TYPING_FOLDER:=$(shell pip3 show typing 2>/dev/null | grep ^Location | sed 's,^.*: ,,')
export PYTHONPATH=${TYPING_FOLDER} export PYTHONPATH=${TYPING_FOLDER}
# all: flake8 pylint mypy coverage testDB all: tests
all: flake8 mypy coverage testDB
tests: flake8 pylint mypy coverage testDB
configure:
./configure
install: configure
pip3 uninstall -y dmt || exit 0 # Uninstall if there, but don't abort if not installed
pip3 install --user .
flake8: flake8:
@echo Performing syntax checks via flake8... @echo Performing syntax checks via flake8...
...@@ -33,4 +41,4 @@ testDB: ...@@ -33,4 +41,4 @@ testDB:
@echo Performing database tests... @echo Performing database tests...
@$(MAKE) -C tests-sqlalchemy || exit 1 @$(MAKE) -C tests-sqlalchemy || exit 1
.PHONY: flake8 pylint mypy coverage .PHONY: flake8 pylint mypy coverage install configure
# Automake macro to set the revision utils
# Usage: AM_REVISION_UTILS([directory_name]).
# Directory name must be a litteral string and not the result of a
# command.
AC_DEFUN([AM_REVISION_UTILS],
[
# Take the current SVN revision
AC_MSG_CHECKING(whether this is a SCM working copy)
temp_scm_output=`(cd $srcdir; git rev-parse --short HEAD)`
if test x"${temp_scm_output}" = x""; then
# This means we are NOT working on a repository copy, the value of
# SCM_REVISION will not be taken into account.
SCM_REVISION=""
AC_MSG_RESULT(no.)
else
SCM_REVISION="r${temp_scm_output}"
AC_MSG_RESULT(yes: ${SCM_REVISION}.)
fi
AC_SUBST(SCM_REVISION)
# Take the configure full date
AC_MSG_CHECKING(the configuration full date)
temp_config_date=`LANG=C date +"%A %d %B %Y, %H:%M:%S"`
if test x"${temp_config_date}" = x""; then
LAST_CONFIG_DATE=""
AC_MSG_RESULT(empty date.)
else
LAST_CONFIG_DATE="${temp_config_date}"
AC_MSG_RESULT(${LAST_CONFIG_DATE}.)
fi
AC_SUBST(LAST_CONFIG_DATE)
# Take the configure year
AC_MSG_CHECKING(the configuration year)
temp_config_year=`LANG=C date +"%Y"`
if test x"${temp_config_year}" = x""; then
LAST_CONFIG_YEAR="2007"
AC_MSG_RESULT(no year found, fall into default: ${LAST_CONFIG_YEAR}.)
else
LAST_CONFIG_YEAR="${temp_config_year}"
AC_MSG_RESULT(${LAST_CONFIG_YEAR})
fi
AC_SUBST(LAST_CONFIG_YEAR)
])
m4_include([ac-macros/revision_utils.m4])
machine:
post:
- pyenv global 3.4.4 system
dependencies:
cache_directories:
- "~/.apt-cache"
pre:
- sudo rm -rf /var/cache/apt/archives && sudo ln -s ~/.apt-cache /var/cache/apt/archives && mkdir -p ~/.apt-cache/partial
# - sudo apt-get update
- sudo apt-get install libxslt-dev libxml2-dev python-psycopg2
- wget -O - -q https://github.com/ttsiodras/asn1scc/releases/download/4.1b/asn1scc-bin-4.1b.tar.bz2 | tar jxvf -
- wget -O - -q https://github.com/ttsiodras/DataModellingTools/files/335591/antlr-2.7.7.tar.gz | tar zxvf - ; cd antlr-2.7.7/lib/python ; sudo pip2 install .
- sudo apt-get install mono-runtime libmono-system-data4.0-cil libmono-system-web4.0-cil libfsharp-core4.3-cil
override:
- pip3 install -r requirements.txt
test:
override:
- sudo pip2 install SQLAlchemy psycopg2
- PATH=$PATH:$(pwd)/asn1scc make
This diff is collapsed.
AC_INIT([DMT], [2.2], [Thanassis.Tsiodras@esa.int])
AC_CONFIG_MACRO_DIR([ac-macros])
AM_REVISION_UTILS
# Finally create all the generated files
AC_CONFIG_FILES([setup.py dmt/commonPy/__init__.py])
AC_OUTPUT
...@@ -23,12 +23,16 @@ from __future__ import absolute_import ...@@ -23,12 +23,16 @@ from __future__ import absolute_import
import os import os
import re import re
import copy import copy
import sys
import DV_Types # pylint: disable=import-error import DV_Types # pylint: disable=import-error
from ctypes import ( from ctypes import (
cdll, c_void_p, c_ubyte, c_double, c_uint, cdll, c_void_p, c_ubyte, c_double, c_uint,
c_longlong, c_bool, c_int, c_long, c_char c_longlong, c_bool, c_int, c_long, c_char
) )
if sys.version_info > (3,):
long = int
# load the *getset.so in this folder # load the *getset.so in this folder
script_path = os.path.dirname(os.path.realpath(__file__)) script_path = os.path.dirname(os.path.realpath(__file__))
soFileNames = [ soFileNames = [
...@@ -102,12 +106,20 @@ class DataStream(object): ...@@ -102,12 +106,20 @@ class DataStream(object):
def GetPyString(self): def GetPyString(self):
# print "Reading", # print "Reading",
msg = "" if sys.version_info > (3,):
pData = c_void_p(GetBitstreamBuffer(self._bs)) msg = b""
for i in range(0, GetStreamCurrentLength(self._bs)): pData = c_void_p(GetBitstreamBuffer(self._bs))
b = GetBufferByte(pData, i) for i in range(0, GetStreamCurrentLength(self._bs)):
msg += chr(b) b = GetBufferByte(pData, i)
# print b, ",", msg += bytes([b])
# print b, ",",
else:
msg = ""
pData = c_void_p(GetBitstreamBuffer(self._bs))
for i in range(0, GetStreamCurrentLength(self._bs)):
b = GetBufferByte(pData, i)
msg += chr(b)
# print b, ",",
# print "EOF" # print "EOF"
return msg return msg
...@@ -117,10 +129,16 @@ class DataStream(object): ...@@ -117,10 +129,16 @@ class DataStream(object):
self._bs.count = strLength self._bs.count = strLength
pData = c_void_p(GetBitstreamBuffer(self._bs)) pData = c_void_p(GetBitstreamBuffer(self._bs))
# print "Writing", # print "Writing",
for i in range(0, strLength): if sys.version_info > (3,):
b = ord(data[i]) for i in range(0, strLength):
# print b, ",", b = data[i]
SetBufferByte(pData, i, b) # print b, ",",
SetBufferByte(pData, i, b)
else:
for i in range(0, strLength):
b = ord(data[i])
# print b, ",",
SetBufferByte(pData, i, b)
# print "EOF" # print "EOF"
...@@ -354,22 +372,42 @@ grep for the errorcode value inside ASN1SCC generated headers.""" ...@@ -354,22 +372,42 @@ grep for the errorcode value inside ASN1SCC generated headers."""
self.SetLength(strLength, False) self.SetLength(strLength, False)
self._Caccessor += "_iDx" self._Caccessor += "_iDx"
accessPath = self._accessPath accessPath = self._accessPath
for idx in range(0, strLength): if sys.version_info > (3,):
self._params.append(idx) for idx in range(0, strLength):
self._accessPath = accessPath + "[" + str(idx) + "]" self._params.append(idx)
self.Set(ord(src[idx]), reset=False) self._accessPath = accessPath + "[" + str(idx) + "]"
self._params.pop() self.Set(ord(src[idx]), reset=False)
self._params.pop()
else:
for idx in range(0, strLength):
self._params.append(idx)
self._accessPath = accessPath + "[" + str(idx) + "]"
self.Set(ord(src[idx]), reset=False)
self._params.pop()
self.Reset() self.Reset()
def GetPyString(self): def GetPyString(self):
retval = "" if sys.version_info > (3,):
strLength = self.GetLength(False) retval = b""
self._Caccessor += "_iDx" strLength = self.GetLength(False)
accessPath = self._accessPath self._Caccessor += "_iDx"
for idx in range(0, strLength): accessPath = self._accessPath
self._params.append(idx) for idx in range(0, strLength):
self._accessPath = accessPath + "[" + str(idx) + "]" self._params.append(idx)
retval += chr(self.Get(reset=False)) self._accessPath = accessPath + "[" + str(idx) + "]"
self._params.pop() retval += bytes([self.Get(reset=False)])
self.Reset() self._params.pop()
return retval self.Reset()
return retval.decode("utf-8")
else:
retval = ""
strLength = self.GetLength(False)
self._Caccessor += "_iDx"
accessPath = self._accessPath
for idx in range(0, strLength):
self._params.append(idx)
self._accessPath = accessPath + "[" + str(idx) + "]"
retval += chr(self.Get(reset=False))
self._params.pop()
self.Reset()
return retval
...@@ -24,7 +24,7 @@ code generator A.''' ...@@ -24,7 +24,7 @@ code generator A.'''
import os import os
import sys import sys
import distutils.spawn as spawn from distutils import spawn
from typing import List from typing import List
from ..commonPy.utility import panic from ..commonPy.utility import panic
...@@ -47,12 +47,12 @@ def OnStartup(unused_modelingLanguage: str, asnFiles: List[str], outputDir: str, ...@@ -47,12 +47,12 @@ def OnStartup(unused_modelingLanguage: str, asnFiles: List[str], outputDir: str,
if not asn1SccPath: if not asn1SccPath:
panic("ASN1SCC seems to be missing from your system (asn1.exe not found in PATH).\n") # pragma: no cover panic("ASN1SCC seems to be missing from your system (asn1.exe not found in PATH).\n") # pragma: no cover
# allow externally-defined flags when calling the asn1 compiler (e.g. to set word size based on target) # allow externally-defined flags when calling the asn1 compiler (e.g. to set word size based on target)
extraFlags = os.getenv ("ASN1SCC_FLAGS") or "" extraFlags = os.getenv("ASN1SCC_FLAGS") or ""
os.system( os.system(
("mono " if sys.platform.startswith('linux') else "") + ("mono " if sys.platform.startswith('linux') else "") +
"\"{}\" -typePrefix asn1Scc -Ada {} -uPER -o \"".format(asn1SccPath, extraFlags) + "\"{}\" -typePrefix asn1Scc -equal -Ada {} -o \"".format(asn1SccPath, extraFlags) +
outputDir + "\" \"" + "\" \"".join(asnFiles) + "\"") outputDir + "\" \"" + "\" \"".join(asnFiles) + "\"")
os.system("rm -f \"" + outputDir + "\"/*.adb") # os.system("rm -f \"" + outputDir + "\"/*.adb")
def OnBasic(unused_nodeTypename: str, unused_node: AsnBasicNode, unused_leafTypeDict: AST_Leaftypes) -> None: def OnBasic(unused_nodeTypename: str, unused_node: AsnBasicNode, unused_leafTypeDict: AST_Leaftypes) -> None:
......
...@@ -24,7 +24,7 @@ code generator A.''' ...@@ -24,7 +24,7 @@ code generator A.'''
import os import os
import sys import sys
import distutils.spawn as spawn from distutils import spawn
from typing import List from typing import List
from ..commonPy.utility import panic from ..commonPy.utility import panic
...@@ -49,12 +49,12 @@ def OnStartup(unused_modelingLanguage: str, asnFiles: List[str], outputDir: str, ...@@ -49,12 +49,12 @@ def OnStartup(unused_modelingLanguage: str, asnFiles: List[str], outputDir: str,
("mono " if sys.platform.startswith('linux') else "") + ("mono " if sys.platform.startswith('linux') else "") +
"\"{}\" -typePrefix asn1Scc -c -uPER -o \"".format(asn1SccPath) + "\"{}\" -typePrefix asn1Scc -c -uPER -o \"".format(asn1SccPath) +
outputDir + "\" \"" + "\" \"".join(asnFiles) + "\"") outputDir + "\" \"" + "\" \"".join(asnFiles) + "\"")
cmd = 'rm -f ' # cmd = 'rm -f '
for i in ['real.c', 'asn1crt.c', 'acn.c']: # for i in ['real.c', 'asn1crt.c', 'acn.c']:
cmd += ' "' + outputDir + '"/' + i # cmd += ' "' + outputDir + '"/' + i
os.system(cmd) # os.system(cmd)
for tmp in asnFiles: # for tmp in asnFiles:
os.system("rm -f \"" + outputDir + os.sep + os.path.basename(os.path.splitext(tmp)[0]) + ".c\"") # os.system("rm -f \"" + outputDir + os.sep + os.path.basename(os.path.splitext(tmp)[0]) + ".c\"")
def OnBasic(unused_nodeTypename: str, unused_node: AsnBasicNode, unused_leafTypeDict: AST_Leaftypes) -> None: def OnBasic(unused_nodeTypename: str, unused_node: AsnBasicNode, unused_leafTypeDict: AST_Leaftypes) -> None:
......
...@@ -31,7 +31,7 @@ enums_dump = "\n ".join( ...@@ -31,7 +31,7 @@ enums_dump = "\n ".join(
) )
enums_dump += "\n ".join( enums_dump += "\n ".join(
'printf("%s = %d\\n");' % (name.strip(), int(val)) 'printf("{} = {}\\n");'.format(name.strip(), val.replace('LL', ''))
for name, val in enums for name, val in enums
) )
uniq = os.getpid() uniq = os.getpid()
......
...@@ -102,7 +102,7 @@ def OnStartup(unused_modelingLanguage: str, asnFile: str, outputDir: str, badTyp ...@@ -102,7 +102,7 @@ def OnStartup(unused_modelingLanguage: str, asnFile: str, outputDir: str, badTyp
g_outputGetSetC.write('}\n\n') g_outputGetSetC.write('}\n\n')
g_outputGetSetC.write('void ResetStream(BitStream *pStrm) {\n') g_outputGetSetC.write('void ResetStream(BitStream *pStrm) {\n')
g_outputGetSetC.write(' assert(pStrm);\n') g_outputGetSetC.write(' assert(pStrm);\n')
g_outputGetSetC.write(' assert(pStrm->count > 0);\n') g_outputGetSetC.write(' assert(pStrm->count >= 0);\n')
g_outputGetSetC.write(' pStrm->currentByte = 0;\n') g_outputGetSetC.write(' pStrm->currentByte = 0;\n')
g_outputGetSetC.write(' pStrm->currentBit = 0;\n') g_outputGetSetC.write(' pStrm->currentBit = 0;\n')
g_outputGetSetC.write('}\n\n') g_outputGetSetC.write('}\n\n')
...@@ -131,12 +131,14 @@ def OnStartup(unused_modelingLanguage: str, asnFile: str, outputDir: str, badTyp ...@@ -131,12 +131,14 @@ def OnStartup(unused_modelingLanguage: str, asnFile: str, outputDir: str, badTyp
# mono_exe = "mono " if sys.platform.startswith('linux') else "" # mono_exe = "mono " if sys.platform.startswith('linux') else ""
mono_exe = "mono" mono_exe = "mono"
makefile_text = '''\ makefile_text = '''\
export MAKEFLAGS="-j $(grep -c ^processor /proc/cpuinfo)"
ASN1SCC:=$(shell which asn1.exe) ASN1SCC:=$(shell which asn1.exe)
ASN2DATAMODEL:=asn2dataModel ASN2DATAMODEL:=asn2dataModel
GRAMMAR := %(origGrammarBase)s GRAMMAR := %(origGrammarBase)s
BASEGRAMMAR := %(base)s BASEGRAMMAR := %(base)s
BDIR:= . BDIR:= .
OBJ := $(BDIR)/$(GRAMMAR).o $(BDIR)/asn1crt.o $(BDIR)/real.o $(BDIR)/acn.o $(BDIR)/$(BASEGRAMMAR)_getset.o OBJ := $(BDIR)/$(GRAMMAR).o $(BDIR)/asn1crt.o $(BDIR)/asn1crt_encoding.o $(BDIR)/asn1crt_encoding_uper.o $(BDIR)/asn1crt_encoding_acn.o $(BDIR)/$(BASEGRAMMAR)_getset.o
all: $(BDIR)/$(BASEGRAMMAR)_getset.so $(BDIR)/DV.py all: $(BDIR)/$(BASEGRAMMAR)_getset.so $(BDIR)/DV.py
...@@ -144,22 +146,39 @@ $(BDIR)/$(GRAMMAR)_getset.c: $(GRAMMAR).asn ...@@ -144,22 +146,39 @@ $(BDIR)/$(GRAMMAR)_getset.c: $(GRAMMAR).asn
%(tab)smkdir -p $(BDIR) %(tab)smkdir -p $(BDIR)
%(tab)s$(ASN2DATAMODEL) -toPython -o $(BDIR) $< %(tab)s$(ASN2DATAMODEL) -toPython -o $(BDIR) $<
$(BDIR)/asn1crt.c $(BDIR)/$(GRAMMAR).c $(BDIR)/real.c $(BDIR)/acn.c $(BDIR)/$(GRAMMAR).h $(BDIR)/asn1crt.h: $(GRAMMAR).asn # Create the ACN file if it is missing
%(tab)sif [ ! -f "$(GRAMMAR).acn" ] ; then %(mono)s $(ASN1SCC) -ACND -o $(BDIR) $< ; fi $(BDIR)/$(GRAMMAR).acn:
%(tab)smono $(ASN1SCC) -ACND -o $(BDIR) $(GRAMMAR).asn
# The hell of multiple outputs (see https://www.gnu.org/software/automake/manual/html_node/Multiple-Outputs.html )
$(BDIR)/asn1crt.c: $(GRAMMAR).asn $(GRAMMAR).acn
%(tab)s%(mono)s $(ASN1SCC) -ACN -c -uPER -equal -o $(BDIR) $< $(GRAMMAR).acn %(tab)s%(mono)s $(ASN1SCC) -ACN -c -uPER -equal -o $(BDIR) $< $(GRAMMAR).acn
$(BDIR)/DV.py: $(GRAMMAR).asn # The hell of multiple outputs (see https://www.gnu.org/software/automake/manual/html_node/Multiple-Outputs.html )
$(BDIR)/$(GRAMMAR).c $(BDIR)/asn1crt_encoding.c $(BDIR)/asn1crt_encoding_uper.c $(BDIR)/asn1crt_encoding_acn.c $(BDIR)/$(GRAMMAR).h $(BDIR)/asn1crt.h: $(BDIR)/asn1crt.c
## Recover from the removal of any of these
%(tab)s@for i in $@; do \
%(tab)s if test -f "$$i" ; then :; \
%(tab)s else \
%(tab)s%(tab)srm -f $< ; \
%(tab)s%(tab)s$(MAKE) $< ; \
%(tab)s fi ; \
%(tab)sdone
$(BDIR)/$(GRAMMAR).c $(BDIR)/asn1crt_encoding.c $(BDIR)/asn1crt_encoding_uper.c $(BDIR)/asn1crt_encoding_acn.c $(BDIR)/$(GRAMMAR).h $(BDIR)/asn1crt.h:
$(BDIR)/DV.py: $(GRAMMAR).asn $(BDIR)/$(GRAMMAR).h
%(tab)sgrep 'REQUIRED_BYTES_FOR_.*ENCODING' $(BDIR)/$(GRAMMAR).h | awk '{print $$2 " = " $$3}' > $@ %(tab)sgrep 'REQUIRED_BYTES_FOR_.*ENCODING' $(BDIR)/$(GRAMMAR).h | awk '{print $$2 " = " $$3}' > $@
%(tab)spython learn_CHOICE_enums.py %(base)s >> $@ %(tab)spython learn_CHOICE_enums.py %(base)s >> $@ || rm $@
$(BDIR)/%%.o: $(BDIR)/%%.c $(BDIR)/%%.o: $(BDIR)/%%.c $(BDIR)/$(GRAMMAR).h
%(tab)sgcc -g -fPIC -c `python-config --includes` -o $@ $< %(tab)sgcc -g -fPIC -c `python-config --includes` -o $@ $<
$(BDIR)/$(BASEGRAMMAR)_getset.so: ${OBJ} $(BDIR)/$(BASEGRAMMAR)_getset.so: ${OBJ}
%(tab)sgcc -g -fPIC -shared `python-config --ldflags` -o $@ $^ %(tab)sgcc -g -fPIC -shared `python-config --ldflags` -o $@ $^
clean: clean:
%(tab)srm -f $(BDIR)/asn1crt.? $(BDIR)/real.? $(BDIR)/$(GRAMMAR).? $(BDIR)/acn.? %(tab)srm -f $(BDIR)/asn1crt* $(BDIR)/$(GRAMMAR).?
%(tab)srm -f $(BDIR)/DV.py $(BDIR)/*.pyc $(BDIR)/$(BASEGRAMMAR)_getset.? $(BDIR)/$(BASEGRAMMAR)_getset.so %(tab)srm -f $(BDIR)/DV.py $(BDIR)/*.pyc $(BDIR)/$(BASEGRAMMAR)_getset.? $(BDIR)/$(BASEGRAMMAR)_getset.so
%(tab)srm -f $(BDIR)/$(GRAMMAR)_asn.py %(tab)srm -f $(BDIR)/$(GRAMMAR)_asn.py
''' '''
......
...@@ -29,7 +29,7 @@ import os ...@@ -29,7 +29,7 @@ import os
import sys import sys
import re import re
import distutils.spawn as spawn from distutils import spawn
from typing import List, Union, Set # NOQA from typing import List, Union, Set # NOQA
from ..commonPy import asnParser from ..commonPy import asnParser
......
...@@ -88,7 +88,7 @@ def FixupNestedStringsAndEnumerated() -> None: ...@@ -88,7 +88,7 @@ def FixupNestedStringsAndEnumerated() -> None:
node = names[nodeTypename] node = names[nodeTypename]
if isinstance(node, (AsnSequence, AsnChoice, AsnSet)): if isinstance(node, (AsnSequence, AsnChoice, AsnSet)):
for child in node._members: for child in node._members:
if isinstance(child[1], AsnString) or isinstance(child[1], AsnEnumerated): if isinstance(child[1], (AsnString, AsnEnumerated)):
newName = nodeTypename + "_" + child[0] # pragma: no cover newName = nodeTypename + "_" + child[0] # pragma: no cover
while newName in names: # pragma: no cover while newName in names: # pragma: no cover
newName += "_t" # pragma: no cover newName += "_t" # pragma: no cover
...@@ -158,7 +158,7 @@ def RenderElements(controlString: str) -> None: ...@@ -158,7 +158,7 @@ def RenderElements(controlString: str) -> None:
else: else:
# This is a bug in pylint - scheduled to be fixed in next release, by: # This is a bug in pylint - scheduled to be fixed in next release, by:
# https://github.com/PyCQA/pylint/commit/6d31776454b5e308e4b869a1893b39083dca3146 # https://github.com/PyCQA/pylint/commit/6d31776454b5e308e4b869a1893b39083dca3146
newElement = g_doc.createElement(finalElementName) # pylint: disable=redefined-variable-type newElement = g_doc.createElement(finalElementName)
if attributes: if attributes:
for atr in attributes: for atr in attributes:
# This is a bug in pylint - scheduled to be fixed in next release, by: # This is a bug in pylint - scheduled to be fixed in next release, by:
...@@ -168,7 +168,7 @@ def RenderElements(controlString: str) -> None: ...@@ -168,7 +168,7 @@ def RenderElements(controlString: str) -> None:
parent = createdElements[under] parent = createdElements[under]
parent.appendChild(newElement) parent.appendChild(newElement)
createdElements[finalElementName] = newElement createdElements[finalElementName] = newElement
parent = newElement # pylint: disable=redefined-variable-type parent = newElement
def GetOID(nodeTypename: str) -> str: def GetOID(nodeTypename: str) -> str:
...@@ -259,7 +259,7 @@ def OnBasic(nodeTypename: str, node: AsnBasicNode, unused_leafTypeDict: AST_Leaf ...@@ -259,7 +259,7 @@ def OnBasic(nodeTypename: str, node: AsnBasicNode, unused_leafTypeDict: AST_Leaf
def CommonSeqSetChoice(nodeTypename: str, def CommonSeqSetChoice(nodeTypename: str,
node: Union[AsnSequence, AsnSet, AsnChoice], node: Union[AsnSequence, AsnSet, AsnChoice],
unused_leafTypeDict: AST_Leaftypes, unused_leafTypeDict: AST_Leaftypes,
isChoice: bool=False) -> None: isChoice: bool = False) -> None:
if nodeTypename in g_declaredTypes: if nodeTypename in g_declaredTypes:
return return
g_declaredTypes.add(nodeTypename) g_declaredTypes.add(nodeTypename)
......
...@@ -209,7 +209,7 @@ def CreateDeclarationForType(nodeTypename: str, names: AST_Lookup, leafTypeDict: ...@@ -209,7 +209,7 @@ def CreateDeclarationForType(nodeTypename: str, names: AST_Lookup, leafTypeDict:
CreateAlias(nodeTypename, "int32", "values of ENUMERATED %s" % nodeTypename) CreateAlias(nodeTypename, "int32", "values of ENUMERATED %s" % nodeTypename)
g_outputFile.write("\n") g_outputFile.write("\n")
elif isinstance(node, (AsnSequence, AsnSet, AsnChoice)): elif isinstance(node, (AsnSequence, AsnSet, AsnChoice)):
if len(node._members) == 0: if not node._members:
panic("Simulink_A_mapper: Simulink can't support empty Seq/Set/Choice! (%s)" % node.Location()) # pragma: no cover panic("Simulink_A_mapper: Simulink can't support empty Seq/Set/Choice! (%s)" % node.Location()) # pragma: no cover
elemNo = 0 elemNo = 0
if isinstance(node, AsnChoice): if isinstance(node, AsnChoice):
......
...@@ -46,7 +46,7 @@ def Version() -> None: ...@@ -46,7 +46,7 @@ def Version() -> None:
# noinspection PyDefaultArgument # noinspection PyDefaultArgument
def getUID(strIdentifier: str, idStore: Dict[str, str]={}) -> str: # pylint: disable=dangerous-default-value def getUID(strIdentifier: str, idStore: Dict[str, str] = {}) -> str: # pylint: disable=dangerous-default-value
def h(digits: int) -> str: def h(digits: int) -> str:
ret = "" ret = ""
for _ in range(0, digits): for _ in range(0, digits):
......
...@@ -211,7 +211,7 @@ CREATE TABLE {cleanTypename} ( ...@@ -211,7 +211,7 @@ CREATE TABLE {cleanTypename} (
def CommonSeqSetChoice(nodeTypename: str, def CommonSeqSetChoice(nodeTypename: str,
node: Union[AsnChoice, AsnSet, AsnSequence], node: Union[AsnChoice, AsnSet, AsnSequence],
unused_leafTypeDict: AST_Leaftypes, unused_leafTypeDict: AST_Leaftypes,
isChoice: bool=False) -> None: isChoice: bool = False) -> None:
cleanTypename = CleanName(nodeTypename) cleanTypename = CleanName(nodeTypename)
g_sqlOutput.write( g_sqlOutput.write(
'\nCREATE TABLE {cleanTypename} (\n id int NOT NULL,\n'.format( '\nCREATE TABLE {cleanTypename} (\n id int NOT NULL,\n'.format(
...