Skip to content

Commit f07520f

Browse files
committed
Remove in container class Types value parameter. Fix regexp pattern in directive parsing.
1 parent 21f833b commit f07520f

File tree

1 file changed

+10
-10
lines changed

1 file changed

+10
-10
lines changed

nginx.py

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -309,9 +309,9 @@ def __init__(self, value, *args):
309309
class Types(Container):
310310
"""Container for MIME type mapping."""
311311

312-
def __init__(self, value, *args):
312+
def __init__(self, *args):
313313
"""Initialize."""
314-
super(Types, self).__init__(value, *args)
314+
super(Types, self).__init__('', *args)
315315
self.name = 'types'
316316

317317

@@ -436,51 +436,51 @@ def loads(data, conf=True):
436436
index += m.end()
437437
continue
438438

439-
m = re.compile(r'^\s*location\s*(.*?)\s*{', re.S).search(data[index:])
439+
m = re.compile(r'^\s*location\s+([^;].*?)\s+{', re.S).search(data[index:])
440440
if m:
441441
l = Location(m.group(1))
442442
lopen.insert(0, l)
443443
index += m.end()
444444
continue
445445

446-
m = re.compile(r'^\s*if\s*(.*?)\s*{', re.S).search(data[index:])
446+
m = re.compile(r'^\s*if\s+([^;].*?)\s+{', re.S).search(data[index:])
447447
if m:
448448
ifs = If(m.group(1))
449449
lopen.insert(0, ifs)
450450
index += m.end()
451451
continue
452452

453-
m = re.compile(r'^\s*upstream\s*(.*?)\s*{', re.S).search(data[index:])
453+
m = re.compile(r'^\s*upstream\s+([^;].*?)\s+{', re.S).search(data[index:])
454454
if m:
455455
u = Upstream(m.group(1))
456456
lopen.insert(0, u)
457457
index += m.end()
458458
continue
459459

460-
m = re.compile(r'^\s*geo\s*(.*?)\s*{', re.S).search(data[index:])
460+
m = re.compile(r'^\s*geo\s+([^;].*?)\s+{', re.S).search(data[index:])
461461
if m:
462462
g = Geo(m.group(1))
463463
lopen.insert(0, g)
464464
index += m.end()
465465
continue
466466

467-
m = re.compile(r'^\s*map\s*(.*?)\s*{', re.S).search(data[index:])
467+
m = re.compile(r'^\s*map\s+([^;].*?)\s+{', re.S).search(data[index:])
468468
if m:
469469
g = Map(m.group(1))
470470
lopen.insert(0, g)
471471
index += m.end()
472472
continue
473473

474-
m = re.compile(r'^\s*limit_except\s*(.*?)\s*{', re.S).search(data[index:])
474+
m = re.compile(r'^\s*limit_except\s+([^;].*?)\s+{', re.S).search(data[index:])
475475
if m:
476476
l = LimitExcept(m.group(1))
477477
lopen.insert(0, l)
478478
index += m.end()
479479
continue
480480

481-
m = re.compile(r'^\s*types\s*(.*?)\s*{', re.S).search(data[index:])
481+
m = re.compile(r'^\s*types\s*{', re.S).search(data[index:])
482482
if m:
483-
l = Types(m.group(1))
483+
l = Types()
484484
lopen.insert(0, l)
485485
index += m.end()
486486
continue

0 commit comments

Comments
 (0)