3030
3131import objdictgen
3232from objdictgen import jsonod
33+ from objdictgen .node import Node
3334from objdictgen .printing import format_node
3435from objdictgen .typing import TDiffEntries , TDiffNodes , TPath
3536
3637T = TypeVar ('T' )
3738
38- if TYPE_CHECKING :
39- from objdictgen .node import Node
40-
4139# Initalize the python logger to simply output to stdout
4240log = logging .getLogger ()
4341log .setLevel (logging .INFO )
@@ -79,7 +77,7 @@ def open_od(fname: TPath|str, validate=True, fix=False) -> "Node":
7977 """ Open and validate the OD file"""
8078
8179 try :
82- od = objdictgen .LoadFile (fname )
80+ od = Node .LoadFile (fname , validate = validate )
8381
8482 if validate :
8583 od .Validate (fix = fix )
@@ -145,6 +143,7 @@ def main(debugopts: DebugOpts, args: Sequence[str]|None = None):
145143 # -- COMMON --
146144 opt_debug = dict (action = 'store_true' , help = "Debug: enable tracebacks on errors" )
147145 opt_od = dict (metavar = 'od' , default = None , help = "Object dictionary" )
146+ opt_novalidate = dict (action = 'store_true' , help = "Don't validate input files" )
148147
149148 parser .add_argument ('--version' , action = 'version' , version = '%(prog)s ' + objdictgen .__version__ )
150149 parser .add_argument ('--no-color' , action = 'store_true' , help = "Disable colored output" )
@@ -175,8 +174,7 @@ def main(debugopts: DebugOpts, args: Sequence[str]|None = None):
175174 help = "Store in internal format (json only)" )
176175 subp .add_argument ('--no-sort' , action = "store_true" ,
177176 help = "Don't order of parameters in output OD" )
178- subp .add_argument ('--novalidate' , action = "store_true" ,
179- help = "Don't validate files before conversion" )
177+ subp .add_argument ('--novalidate' , ** opt_novalidate ) # type: ignore[arg-type]
180178 subp .add_argument ('-D' , '--debug' , ** opt_debug ) # type: ignore[arg-type]
181179
182180 # -- DIFF --
@@ -186,8 +184,7 @@ def main(debugopts: DebugOpts, args: Sequence[str]|None = None):
186184 subp .add_argument ('od1' , ** opt_od ) # type: ignore[arg-type]
187185 subp .add_argument ('od2' , ** opt_od ) # type: ignore[arg-type]
188186 subp .add_argument ('--internal' , action = "store_true" , help = "Diff internal object" )
189- subp .add_argument ('--novalidate' , action = "store_true" ,
190- help = "Don't validate input files before diff" )
187+ subp .add_argument ('--novalidate' , ** opt_novalidate ) # type: ignore[arg-type]
191188 subp .add_argument ('--show' , action = "store_true" , help = "Show difference data" )
192189 subp .add_argument ('-D' , '--debug' , ** opt_debug ) # type: ignore[arg-type]
193190 subp .add_argument ('--no-color' , action = 'store_true' , help = "Disable colored output" )
@@ -214,6 +211,7 @@ def main(debugopts: DebugOpts, args: Sequence[str]|None = None):
214211 subp .add_argument ('--unused' , action = "store_true" , help = "Include unused profile parameters" )
215212 subp .add_argument ('--internal' , action = "store_true" , help = "Show internal data" )
216213 subp .add_argument ('-D' , '--debug' , ** opt_debug ) # type: ignore[arg-type]
214+ subp .add_argument ('--novalidate' , ** opt_novalidate ) # type: ignore[arg-type]
217215 subp .add_argument ('--no-color' , action = 'store_true' , help = "Disable colored output" )
218216
219217 # -- NETWORK --
@@ -270,7 +268,7 @@ def main(debugopts: DebugOpts, args: Sequence[str]|None = None):
270268 # -- CONVERT command --
271269 elif opts .command in ("convert" , "conv" , "gen" ):
272270
273- od = open_od (opts .od , fix = opts .fix )
271+ od = open_od (opts .od , fix = opts .fix , validate = not opts . novalidate )
274272
275273 to_remove : set [int ] = set ()
276274
@@ -347,7 +345,7 @@ def main(debugopts: DebugOpts, args: Sequence[str]|None = None):
347345 if len (opts .od ) > 1 :
348346 print (Fore .LIGHTBLUE_EX + name + '\n ' + "=" * len (name ) + Style .RESET_ALL )
349347
350- od = open_od (name )
348+ od = open_od (name , validate = not opts . novalidate )
351349 for line in format_node (od , name , index = opts .index , opts = opts ):
352350 print (line )
353351
0 commit comments