Mercurial > iscconf
changeset 26:7c9e3a91d133
Allow upper-case mac addresses
| author | Radomir Dopieralski <sheep-devel@sheep.art.pl> |
|---|---|
| date | Wed, 25 Mar 2015 14:00:17 +0100 |
| parents | 4057843ce0db |
| children | b62facad5df4 |
| files | iscconf/parser.py tests/test_dhcp.py |
| diffstat | 2 files changed, 12 insertions(+), 2 deletions(-) [+] |
line wrap: on
line diff
--- a/iscconf/parser.py Thu Nov 15 13:54:26 2012 +0100 +++ b/iscconf/parser.py Wed Mar 25 14:00:17 2015 +0100 @@ -11,7 +11,6 @@ t_NAME = r'[a-zA-Z!][a-zA-Z0-9-]*[a-zA-Z0-9]*' # Added ! for support of allow-query { !key external; }; t_IPADDR = r'([0-2]?[0-9]?[0-9][.]){3}[0-2]?[0-9]?[0-9]' t_DOMAIN = r'([a-z][a-z0-9-]*[.])+[a-z][a-z0-9-]*[.]?' -t_MACADDR = r'([0-9a-fA-F][0-9a-fA-F]:){5}[0-9a-fA-F][0-9a-fA-F]' t_BRACE_OPEN = r'{' t_BRACE_CLOSE = r'}' t_SEMICOLON = ';' @@ -29,8 +28,13 @@ class LexicalError(Error): pass +def t_MACADDR(t): + r'([0-9a-fA-F][0-9a-fA-F]:){5}[0-9a-fA-F][0-9a-fA-F]' + t.value = t.value.lower() + return t + def t_INTEGER(t): - r'-?[0-9]+(?![a-f0-9:.])' # Avoid conflicts with MAC and IP addresses + r'-?[0-9]+(?![a-fA-F0-9:.])' # Avoid conflicts with MAC and IP addresses t.value = int(t.value) return t
--- a/tests/test_dhcp.py Thu Nov 15 13:54:26 2012 +0100 +++ b/tests/test_dhcp.py Wed Mar 25 14:00:17 2015 +0100 @@ -20,6 +20,12 @@ (): '2e:2c:45:e8:c9:23', }) + def test_mac_2E(self): + data = iscconf.parse("2E:2C:45:E8:C9:23;") + self.assertEqual(data, { + (): '2e:2c:45:e8:c9:23', + }) + def test_single(self): data = iscconf.parse("""\ host s10557.dc2 {
