@@ -23,10 +23,11 @@ def _prepare_if_args(stmt):
23
23
24
24
25
25
def parse (filename , onerror = None , catch_errors = True , ignore = (), single = False ,
26
- comments = False , strict = False , combine = False ):
26
+ comments = False , strict = False , combine = False , check_ctx = True ,
27
+ check_args = True ):
27
28
"""
28
29
Parses an nginx config file and returns a nested dict payload
29
-
30
+
30
31
:param filename: string contianing the name of the config file to parse
31
32
:param onerror: function that determines what's saved in "callback"
32
33
:param catch_errors: bool; if False, parse stops after first error
@@ -35,6 +36,8 @@ def parse(filename, onerror=None, catch_errors=True, ignore=(), single=False,
35
36
:param single: bool; if True, including from other files doesn't happen
36
37
:param comments: bool; if True, including comments to json payload
37
38
:param strict: bool; if True, unrecognized directives raise errors
39
+ :param check_ctx: bool; if True, runs context analysis on directives
40
+ :param check_args: bool; if True, runs arg count analysis on directives
38
41
:returns: a payload that describes the parsed nginx config
39
42
"""
40
43
config_dir = os .path .dirname (filename )
@@ -131,7 +134,10 @@ def _parse(parsing, tokens, ctx=(), consume=False):
131
134
132
135
try :
133
136
# raise errors if this statement is invalid
134
- analyze (fname , stmt , token , ctx , strict = strict )
137
+ analyze (
138
+ fname = fname , stmt = stmt , term = token , ctx = ctx , strict = strict ,
139
+ check_ctx = check_ctx , check_args = check_args
140
+ )
135
141
except NgxParserDirectiveError as e :
136
142
if catch_errors :
137
143
_handle_error (parsing , e )
0 commit comments