Commit eb648d8e authored by Thanassis Tsiodras's avatar Thanassis Tsiodras
Browse files

Addressed mypy findings for aadl2glueC.

parent 83c67471
...@@ -81,6 +81,8 @@ but with an extra call to OnFinal at the end. ...@@ -81,6 +81,8 @@ but with an extra call to OnFinal at the end.
import os import os
import sys import sys
import hashlib import hashlib
import pickle
import tempfile
from distutils import spawn from distutils import spawn
from typing import cast, Optional, Dict, List, Tuple, Set, Any # NOQA pylint: disable=unused-import from typing import cast, Optional, Dict, List, Tuple, Set, Any # NOQA pylint: disable=unused-import
...@@ -154,8 +156,8 @@ of each SUBPROGRAM param.''' ...@@ -154,8 +156,8 @@ of each SUBPROGRAM param.'''
except: except:
panic("The configured cache folder:\n\n\t" + projectCache + panic("The configured cache folder:\n\n\t" + projectCache +
"\n\n...is not there!\n") "\n\n...is not there!\n")
cachedModelExists = False
aadlASTcache = None aadlASTcache = None
astInfo = None
if projectCache is not None: if projectCache is not None:
filehash = hashlib.md5() filehash = hashlib.md5()
for each in sorted(sys.argv[1:]): for each in sorted(sys.argv[1:]):
...@@ -167,15 +169,10 @@ of each SUBPROGRAM param.''' ...@@ -167,15 +169,10 @@ of each SUBPROGRAM param.'''
print("[DMT] No cached AADL model found for", print("[DMT] No cached AADL model found for",
",".join(sys.argv[1:])) ",".join(sys.argv[1:]))
else: else:
cachedModelExists = True
print("[DMT] Reusing cached AADL model for", print("[DMT] Reusing cached AADL model for",
",".join(sys.argv[1:])) ",".join(sys.argv[1:]))
astInfo = pickle.load(open(aadlASTcache, 'rb'), fix_imports=False)
import pickle if astInfo is None:
if cachedModelExists:
astInfo = pickle.load(open(aadlASTcache, 'rb'), fix_imports=False)
else:
import tempfile
f = tempfile.NamedTemporaryFile(delete=False) f = tempfile.NamedTemporaryFile(delete=False)
astFile = f.name astFile = f.name
f.close() f.close()
...@@ -547,18 +544,16 @@ def main() -> None: ...@@ -547,18 +544,16 @@ def main() -> None:
uniqueDataFiles[param._signal._asnFilename][sp._language].append(sp) uniqueDataFiles[param._signal._asnFilename][sp._language].append(sp)
asn1files = list(uniqueDataFiles.keys()) asn1files = list(uniqueDataFiles.keys())
asnFile = None # type: Optional[str]
if len(asn1files) == 1: if len(asn1files) == 1:
asnFile = asn1files[0] asnFile = asn1files[0]
commonPy.asnParser.ParseAsnFileList(asn1files) commonPy.asnParser.ParseAsnFileList(asn1files)
elif asn1files: elif asn1files:
panic("There appear to be more than one ASN.1 files referenced (%s)..." % str(asn1files)) panic("There appear to be more than one ASN.1 files referenced (%s)..." % str(asn1files))
if asnFile is not None: inform("Checking that all base nodes have mandatory ranges set in %s..." % asnFile)
inform("Checking that all base nodes have mandatory ranges set in %s..." % asnFile) names = commonPy.asnParser.g_names
names = commonPy.asnParser.g_names for node in names.values():
for node in names.values(): verify.VerifyRanges(node, names)
verify.VerifyRanges(node, names)
SystemsAndImplementations = commonPy.aadlAST.g_subProgramImplementations[:] SystemsAndImplementations = commonPy.aadlAST.g_subProgramImplementations[:]
SystemsAndImplementations.extend(commonPy.aadlAST.g_threadImplementations[:]) SystemsAndImplementations.extend(commonPy.aadlAST.g_threadImplementations[:])
......
Supports Markdown
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