Skip to content

Commit e33d136

Browse files
authored
Merge pull request #18 from fulder/master
Add map Container
2 parents f9554dc + e59b53a commit e33d136

File tree

3 files changed

+21
-0
lines changed

3 files changed

+21
-0
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,4 @@ dist
33
build
44
*.pyc
55
*.egg-info
6+
.idea

CHANGELOG

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,10 @@
22
All notable changes to this project will be documented in this file.
33
This project adheres to [Semantic Versioning](http://semver.org/).
44

5+
## Unreleased
6+
### Fixed
7+
- Fixed bug with map crashing loading of nginx.conf.
8+
59
## [1.2.0] - 2017-09-06
610
### Fixed
711
- Fixed several bugs involving parsing of messy files and brace locations (thanks @lelik9!)

nginx.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -345,6 +345,15 @@ def __init__(self, value, *args):
345345
self.name = 'geo'
346346

347347

348+
class Map(Container):
349+
"""Container for map configuration."""
350+
351+
def __init__(self, value, *args):
352+
"""Initialize."""
353+
super(Map, self).__init__(value, *args)
354+
self.name = 'map'
355+
356+
348357
class Key(object):
349358
"""Represents a simple key/value object found in an nginx config."""
350359

@@ -438,6 +447,13 @@ def loads(data, conf=True):
438447
index += m.end()
439448
continue
440449

450+
m = re.compile(r'^\s*map\s*(.*?\S+)\s*{', re.S).search(data[index:])
451+
if m:
452+
g = Map(m.group(1))
453+
lopen.insert(0, g)
454+
index += m.end()
455+
continue
456+
441457
m = re.compile(r'^(\s*)#\s*(.*?)\n', re.S).search(data[index:])
442458
if m:
443459
c = Comment(m.group(2), inline='\n' not in m.group(1))

0 commit comments

Comments
 (0)