-
Notifications
You must be signed in to change notification settings - Fork 87
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
crossplane.parse('nginx.conf')
fails with a valid nginx config file.
#110
Comments
In the example Many NGINX users split their config into different files, combining them via I see two options to get the parser happy:
|
Hi @ryepup ! you were right, the In [8]: conf = crossplane.parse('nginx.conf')
In [9]: conf["status"]
Out[9]: 'ok'
In [10]: conf["errors"]
Out[10]: []
In [11]: crossplane.build(conf["config"])
---------------------------------------------------------------------------
KeyError Traceback (most recent call last)
Cell In[11], line 1
----> 1 crossplane.build(conf["config"])
File ~/trabajos/canonical/env/lib/python3.11/site-packages/crossplane/builder.py:122, in build(payload, indent, tabs, header)
119 return output
121 body = ''
--> 122 body = _build_block(body, payload, 0, 0)
123 return head + body
File ~/trabajos/canonical/env/lib/python3.11/site-packages/crossplane/builder.py:88, in build.<locals>._build_block(output, block, depth, last_line)
85 margin = padding * depth
87 for stmt in block:
---> 88 directive = _enquote(stmt['directive'])
89 line = stmt.get('line', 0)
91 if directive == '#' and line == last_line:
KeyError: 'directive' If I remove the In [16]: conf = crossplane.parse('nginx.conf')
In [17]: conf["status"]
Out[17]: 'ok'
In [18]: conf["errors"]
Out[18]: []
In [19]: crossplane.build(conf["config"])
---------------------------------------------------------------------------
KeyError Traceback (most recent call last)
Cell In[19], line 1
----> 1 crossplane.build(conf["config"])
File ~/trabajos/canonical/env/lib/python3.11/site-packages/crossplane/builder.py:122, in build(payload, indent, tabs, header)
119 return output
121 body = ''
--> 122 body = _build_block(body, payload, 0, 0)
123 return head + body
File ~/trabajos/canonical/env/lib/python3.11/site-packages/crossplane/builder.py:88, in build.<locals>._build_block(output, block, depth, last_line)
85 margin = padding * depth
87 for stmt in block:
---> 88 directive = _enquote(stmt['directive'])
89 line = stmt.get('line', 0)
91 if directive == '#' and line == last_line:
KeyError: 'directive' Here are the two files: |
This line is the problem:
The crossplane/crossplane/formatter.py Line 7 in 3e616a8
|
Describe the bug
crossplane.parse('nginx.conf')
fails with a valid nginx config file.To Reproduce
Steps to reproduce the behavior:
nginx.conf
) with the this content:conf = crossplane.parse('nginx.conf')
onnginx.conf
file.build()
with this config I get:Expected behavior
I expect that
crossplane.parse()
parse the config file without any issues since this config is used by a nginx instance without any errors.Your environment
The text was updated successfully, but these errors were encountered: