3030
3131import objdictgen
3232from objdictgen import jsonod
33+ from objdictgen .node import Node
3334from objdictgen .typing import TDiffEntries , TDiffNodes , TPath
3435
3536T = TypeVar ('T' )
3637
37- if TYPE_CHECKING :
38- from objdictgen .node import Node
39-
4038# Initalize the python logger to simply output to stdout
4139log = logging .getLogger ()
4240log .setLevel (logging .INFO )
@@ -78,7 +76,7 @@ def open_od(fname: TPath|str, validate=True, fix=False) -> "Node":
7876 """ Open and validate the OD file"""
7977
8078 try :
81- od = objdictgen .LoadFile (fname )
79+ od = Node .LoadFile (fname , validate = validate )
8280
8381 if validate :
8482 od .Validate (fix = fix )
@@ -197,6 +195,7 @@ def main(debugopts: DebugOpts, args: Sequence[str]|None = None):
197195 # -- COMMON --
198196 opt_debug = dict (action = 'store_true' , help = "Debug: enable tracebacks on errors" )
199197 opt_od = dict (metavar = 'od' , default = None , help = "Object dictionary" )
198+ opt_novalidate = dict (action = 'store_true' , help = "Don't validate input files" )
200199
201200 parser .add_argument ('--version' , action = 'version' , version = '%(prog)s ' + objdictgen .__version__ )
202201 parser .add_argument ('--no-color' , action = 'store_true' , help = "Disable colored output" )
@@ -227,8 +226,7 @@ def main(debugopts: DebugOpts, args: Sequence[str]|None = None):
227226 help = "Store in internal format (json only)" )
228227 subp .add_argument ('--no-sort' , action = "store_true" ,
229228 help = "Don't order of parameters in output OD" )
230- subp .add_argument ('--novalidate' , action = "store_true" ,
231- help = "Don't validate files before conversion" )
229+ subp .add_argument ('--novalidate' , ** opt_novalidate ) # type: ignore[arg-type]
232230 subp .add_argument ('-D' , '--debug' , ** opt_debug ) # type: ignore[arg-type]
233231
234232 # -- DIFF --
@@ -238,8 +236,7 @@ def main(debugopts: DebugOpts, args: Sequence[str]|None = None):
238236 subp .add_argument ('od1' , ** opt_od ) # type: ignore[arg-type]
239237 subp .add_argument ('od2' , ** opt_od ) # type: ignore[arg-type]
240238 subp .add_argument ('--internal' , action = "store_true" , help = "Diff internal object" )
241- subp .add_argument ('--novalidate' , action = "store_true" ,
242- help = "Don't validate input files before diff" )
239+ subp .add_argument ('--novalidate' , ** opt_novalidate ) # type: ignore[arg-type]
243240 subp .add_argument ('--show' , action = "store_true" , help = "Show difference data" )
244241 subp .add_argument ('-D' , '--debug' , ** opt_debug ) # type: ignore[arg-type]
245242 subp .add_argument ('--no-color' , action = 'store_true' , help = "Disable colored output" )
@@ -265,6 +262,7 @@ def main(debugopts: DebugOpts, args: Sequence[str]|None = None):
265262 subp .add_argument ('--short' , action = "store_true" , help = "Do not list sub-index" )
266263 subp .add_argument ('--unused' , action = "store_true" , help = "Include unused profile parameters" )
267264 subp .add_argument ('-D' , '--debug' , ** opt_debug ) # type: ignore[arg-type]
265+ subp .add_argument ('--novalidate' , ** opt_novalidate ) # type: ignore[arg-type]
268266 subp .add_argument ('--no-color' , action = 'store_true' , help = "Disable colored output" )
269267
270268 # -- NETWORK --
@@ -321,7 +319,7 @@ def main(debugopts: DebugOpts, args: Sequence[str]|None = None):
321319 # -- CONVERT command --
322320 elif opts .command in ("convert" , "conv" , "gen" ):
323321
324- od = open_od (opts .od , fix = opts .fix )
322+ od = open_od (opts .od , fix = opts .fix , validate = not opts . novalidate )
325323
326324 to_remove : set [int ] = set ()
327325
@@ -398,7 +396,7 @@ def main(debugopts: DebugOpts, args: Sequence[str]|None = None):
398396 if len (opts .od ) > 1 :
399397 print (Fore .LIGHTBLUE_EX + name + '\n ' + "=" * len (name ) + Style .RESET_ALL )
400398
401- od = open_od (name )
399+ od = open_od (name , validate = not opts . novalidate )
402400 for line in list_od (od , name , opts ):
403401 print (line )
404402
0 commit comments