Skip to content

Commit 7bf336d

Browse files
author
Anton Liparin
committed
Added support for nginx geo module configuration
1 parent 77ebeb9 commit 7bf336d

File tree

2 files changed

+15
-1
lines changed

2 files changed

+15
-1
lines changed

nginx.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -231,6 +231,16 @@ def __init__(self, value, *args):
231231
self.name = 'upstream'
232232

233233

234+
class Geo(Container):
235+
"""
236+
Container for geo module configuration
237+
See docs here: http://nginx.org/en/docs/http/ngx_http_geo_module.html
238+
"""
239+
def __init__(self, value, *args):
240+
super(Geo, self).__init__(value, *args)
241+
self.name = 'geo'
242+
243+
234244
class Key(object):
235245
def __init__(self, name, value):
236246
self.name = name
@@ -265,6 +275,10 @@ def loads(data, conf=True):
265275
ups = re.match('\s*upstream\s*(.*\S+)\s*{', line).group(1)
266276
u = Upstream(ups)
267277
lopen.insert(0, u)
278+
if re.match('\s*geo\s*\$.*\s{', line):
279+
geo = re.match('\s*geo\s+(\$.*)\s{', line).group(1)
280+
s = Geo(geo)
281+
lopen.insert(0, s)
268282
if re.match('.*;', line):
269283
kname, kval = re.match('.*(?:^|^\s*|{\s*)(\S+)\s(.+);', line).group(1, 2)
270284
if "#" not in kname:

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
setup(
66
name='python-nginx',
7-
version='0.2',
7+
version='0.2.1',
88
description='Create and modify nginx serverblock configs in Python',
99
author='Jacob Cook',
1010
author_email='jacob@peakwinter.net',

0 commit comments

Comments
 (0)