30
30
31
31
import objdictgen
32
32
from objdictgen import jsonod
33
+ from objdictgen .node import Node
33
34
from objdictgen .printing import format_node
34
35
from objdictgen .typing import TDiffEntries , TDiffNodes , TPath
35
36
36
37
T = TypeVar ('T' )
37
38
38
- if TYPE_CHECKING :
39
- from objdictgen .node import Node
40
-
41
39
# Initalize the python logger to simply output to stdout
42
40
log = logging .getLogger ()
43
41
log .setLevel (logging .INFO )
@@ -79,7 +77,7 @@ def open_od(fname: TPath|str, validate=True, fix=False) -> "Node":
79
77
""" Open and validate the OD file"""
80
78
81
79
try :
82
- od = objdictgen .LoadFile (fname )
80
+ od = Node .LoadFile (fname , validate = validate )
83
81
84
82
if validate :
85
83
od .Validate (fix = fix )
@@ -145,6 +143,7 @@ def main(debugopts: DebugOpts, args: Sequence[str]|None = None):
145
143
# -- COMMON --
146
144
opt_debug = dict (action = 'store_true' , help = "Debug: enable tracebacks on errors" )
147
145
opt_od = dict (metavar = 'od' , default = None , help = "Object dictionary" )
146
+ opt_novalidate = dict (action = 'store_true' , help = "Don't validate input files" )
148
147
149
148
parser .add_argument ('--version' , action = 'version' , version = '%(prog)s ' + objdictgen .__version__ )
150
149
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):
175
174
help = "Store in internal format (json only)" )
176
175
subp .add_argument ('--no-sort' , action = "store_true" ,
177
176
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]
180
178
subp .add_argument ('-D' , '--debug' , ** opt_debug ) # type: ignore[arg-type]
181
179
182
180
# -- DIFF --
@@ -186,8 +184,7 @@ def main(debugopts: DebugOpts, args: Sequence[str]|None = None):
186
184
subp .add_argument ('od1' , ** opt_od ) # type: ignore[arg-type]
187
185
subp .add_argument ('od2' , ** opt_od ) # type: ignore[arg-type]
188
186
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]
191
188
subp .add_argument ('--show' , action = "store_true" , help = "Show difference data" )
192
189
subp .add_argument ('-D' , '--debug' , ** opt_debug ) # type: ignore[arg-type]
193
190
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):
214
211
subp .add_argument ('--unused' , action = "store_true" , help = "Include unused profile parameters" )
215
212
subp .add_argument ('--internal' , action = "store_true" , help = "Show internal data" )
216
213
subp .add_argument ('-D' , '--debug' , ** opt_debug ) # type: ignore[arg-type]
214
+ subp .add_argument ('--novalidate' , ** opt_novalidate ) # type: ignore[arg-type]
217
215
subp .add_argument ('--no-color' , action = 'store_true' , help = "Disable colored output" )
218
216
219
217
# -- NETWORK --
@@ -270,7 +268,7 @@ def main(debugopts: DebugOpts, args: Sequence[str]|None = None):
270
268
# -- CONVERT command --
271
269
elif opts .command in ("convert" , "conv" , "gen" ):
272
270
273
- od = open_od (opts .od , fix = opts .fix )
271
+ od = open_od (opts .od , fix = opts .fix , validate = not opts . novalidate )
274
272
275
273
to_remove : set [int ] = set ()
276
274
@@ -347,7 +345,7 @@ def main(debugopts: DebugOpts, args: Sequence[str]|None = None):
347
345
if len (opts .od ) > 1 :
348
346
print (Fore .LIGHTBLUE_EX + name + '\n ' + "=" * len (name ) + Style .RESET_ALL )
349
347
350
- od = open_od (name )
348
+ od = open_od (name , validate = not opts . novalidate )
351
349
for line in format_node (od , name , index = opts .index , opts = opts ):
352
350
print (line )
353
351
0 commit comments