Skip to content

Commit 58828e5

Browse files
author
jacook
committed
allow string load to list
1 parent 58f198a commit 58828e5

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

nginx/main.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,7 @@ def as_block(self):
171171
else:
172172
y = x.as_block()
173173
ret.append(INDENT+y)
174-
ret.append('}\n\n')
174+
ret.append('}\n')
175175
return ret
176176

177177

@@ -234,8 +234,8 @@ def as_block(self):
234234
return self.name + ' ' + self.value + ';\n'
235235

236236

237-
def loads(data):
238-
f = Conf()
237+
def loads(data, conf=True):
238+
f = Conf() if conf else []
239239
lopen = []
240240
for line in data.split('\n'):
241241
if re.match('\s*server\s*{', line):
@@ -257,22 +257,22 @@ def loads(data):
257257
closenum = len(re.findall('}', line))
258258
while closenum > 0:
259259
if isinstance(lopen[0], Server):
260-
f.add(lopen[0])
260+
f.add(lopen[0]) if conf else f.append(lopen[0])
261261
lopen.pop(0)
262262
elif isinstance(lopen[0], Container):
263263
c = lopen[0]
264264
lopen.pop(0)
265265
if lopen:
266266
lopen[0].add(c)
267267
else:
268-
f.add(c)
268+
f.add(c) if conf else f.append(c)
269269
closenum = closenum - 1
270270
if re.match('\s*#\s*', line):
271271
c = Comment(re.match('\s*#\s*(.*)$', line).group(1))
272272
if len(lopen):
273273
lopen[0].add(c)
274274
else:
275-
f.add(c)
275+
f.add(c) if conf else f.append(c)
276276
return f
277277

278278
def load(fobj):

0 commit comments

Comments
 (0)