Skip to content

Commit

Permalink
Added strict mode.
Browse files Browse the repository at this point in the history
  • Loading branch information
aworkin authored and lextm committed Mar 5, 2024
1 parent 4f82b27 commit b67f586
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 3 deletions.
8 changes: 5 additions & 3 deletions pysmi/codegen/intermediate.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ class IntermediateCodeGen(AbstractCodeGen):

indent = " " * 4
fakeidx = 1000 # starting index for fake symbols
strictCompliance = True

def __init__(self):
self._rows = set()
Expand Down Expand Up @@ -180,9 +181,10 @@ def regSym(

if moduleIdentity:
if self._moduleIdentityOid:
# TODO: maybe we should show a warning here
# raise error.PySmiSemanticError("Duplicate module identity")
pass
if self.strictCompliance:
raise error.PySmiSemanticError("Duplicate module identity")
else:
pass
else:
self._moduleIdentityOid = outDict["oid"]

Expand Down
8 changes: 8 additions & 0 deletions pysmi/scripts/mibdump.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ def start():

# Defaults
verboseFlag = True
strictFlag = False
mibSources = []
doFuzzyMatchingFlag = True
mibSearchers = []
Expand All @@ -60,6 +61,7 @@ def start():
Usage: {} [--help]
[--version]
[--quiet]
[--strict]
[--debug=<{}>]
[--mib-source=<URI>]
[--mib-searcher=<PATH|PACKAGE>]
Expand Down Expand Up @@ -97,6 +99,7 @@ def start():
"help",
"version",
"quiet",
"strict",
"debug=",
"mib-source=",
"mib-searcher=",
Expand Down Expand Up @@ -157,6 +160,9 @@ def start():
if opt[0] == "--quiet":
verboseFlag = False

if opt[0] == "--strict":
strictFlag = True

if opt[0] == "--debug":
debug.setLogger(debug.Debug(*opt[1].split(",")))

Expand Down Expand Up @@ -294,6 +300,7 @@ def start():
searchers.append(StubSearcher(*mibStubs))

codeGenerator = PySnmpCodeGen()
codeGenerator.strictCompliance = strictFlag

fileWriter = PyFileWriter(dstDirectory).setOptions(
pyCompile=pyCompileFlag, pyOptimizationLevel=pyOptimizationLevel
Expand Down Expand Up @@ -331,6 +338,7 @@ def start():
]

codeGenerator = JsonCodeGen()
codeGenerator.strictCompliance = strictFlag

fileWriter = FileWriter(dstDirectory).setOptions(suffix=".json")

Expand Down

0 comments on commit b67f586

Please sign in to comment.