mirror of
https://github.com/certbot/certbot.git
synced 2026-06-05 06:42:10 -04:00
Rename NginxParser to RawNginxParser
This commit is contained in:
parent
b245394355
commit
eaef4065e3
2 changed files with 13 additions and 13 deletions
|
|
@ -6,7 +6,7 @@ from pyparsing import (
|
|||
Optional, OneOrMore, ZeroOrMore, pythonStyleComment)
|
||||
|
||||
|
||||
class NginxParser(object):
|
||||
class RawNginxParser(object):
|
||||
"""
|
||||
A class that parses nginx configuration with pyparsing
|
||||
"""
|
||||
|
|
@ -50,7 +50,7 @@ class NginxParser(object):
|
|||
return self.parse().asList()
|
||||
|
||||
|
||||
class NginxDumper(object):
|
||||
class RawNginxDumper(object):
|
||||
"""
|
||||
A class that dumps nginx configuration from the provided tree.
|
||||
"""
|
||||
|
|
@ -93,7 +93,7 @@ class NginxDumper(object):
|
|||
# (like pyyaml, picker or json)
|
||||
|
||||
def loads(source):
|
||||
return NginxParser(source).as_list()
|
||||
return RawNginxParser(source).as_list()
|
||||
|
||||
|
||||
def load(_file):
|
||||
|
|
@ -101,7 +101,7 @@ def load(_file):
|
|||
|
||||
|
||||
def dumps(blocks, indentation=4):
|
||||
return NginxDumper(blocks, indentation).as_string()
|
||||
return RawNginxDumper(blocks, indentation).as_string()
|
||||
|
||||
|
||||
def dump(blocks, _file, indentation=4):
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
import operator
|
||||
import unittest
|
||||
|
||||
from letsencrypt.client.plugins.nginx.nginxparser import (NginxParser,
|
||||
from letsencrypt.client.plugins.nginx.nginxparser import (RawNginxParser,
|
||||
load, dumps, dump)
|
||||
from letsencrypt.client.plugins.nginx.tests import util
|
||||
|
||||
|
|
@ -9,25 +9,25 @@ from letsencrypt.client.plugins.nginx.tests import util
|
|||
first = operator.itemgetter(0)
|
||||
|
||||
|
||||
class TestNginxParser(unittest.TestCase):
|
||||
class TestRawNginxParser(unittest.TestCase):
|
||||
|
||||
def test_assignments(self):
|
||||
parsed = NginxParser.assignment.parseString('root /test;').asList()
|
||||
parsed = RawNginxParser.assignment.parseString('root /test;').asList()
|
||||
self.assertEqual(parsed, ['root', '/test'])
|
||||
parsed = NginxParser.assignment.parseString('root /test;'
|
||||
'foo bar;').asList()
|
||||
parsed = RawNginxParser.assignment.parseString('root /test;'
|
||||
'foo bar;').asList()
|
||||
self.assertEqual(parsed, ['root', '/test'], ['foo', 'bar'])
|
||||
|
||||
def test_blocks(self):
|
||||
parsed = NginxParser.block.parseString('foo {}').asList()
|
||||
parsed = RawNginxParser.block.parseString('foo {}').asList()
|
||||
self.assertEqual(parsed, [[['foo'], []]])
|
||||
parsed = NginxParser.block.parseString('location /foo{}').asList()
|
||||
parsed = RawNginxParser.block.parseString('location /foo{}').asList()
|
||||
self.assertEqual(parsed, [[['location', '/foo'], []]])
|
||||
parsed = NginxParser.block.parseString('foo { bar foo; }').asList()
|
||||
parsed = RawNginxParser.block.parseString('foo { bar foo; }').asList()
|
||||
self.assertEqual(parsed, [[['foo'], [['bar', 'foo']]]])
|
||||
|
||||
def test_nested_blocks(self):
|
||||
parsed = NginxParser.block.parseString('foo { bar {} }').asList()
|
||||
parsed = RawNginxParser.block.parseString('foo { bar {} }').asList()
|
||||
block, content = first(parsed)
|
||||
self.assertEqual(first(content), [['bar'], []])
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue