qpid-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From r..@apache.org
Subject svn commit: r1058654 - in /qpid/trunk/qpid/python/qpid: messaging/address.py tests/messaging/address.py
Date Thu, 13 Jan 2011 16:37:59 GMT
Author: rhs
Date: Thu Jan 13 16:37:59 2011
New Revision: 1058654

URL: http://svn.apache.org/viewvc?rev=1058654&view=rev
Log:
made address parser recognize lowercase true and false

Modified:
    qpid/trunk/qpid/python/qpid/messaging/address.py
    qpid/trunk/qpid/python/qpid/tests/messaging/address.py

Modified: qpid/trunk/qpid/python/qpid/messaging/address.py
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/python/qpid/messaging/address.py?rev=1058654&r1=1058653&r2=1058654&view=diff
==============================================================================
--- qpid/trunk/qpid/python/qpid/messaging/address.py (original)
+++ qpid/trunk/qpid/python/qpid/messaging/address.py Thu Jan 13 16:37:59 2011
@@ -31,9 +31,6 @@ SEMI = l.define("SEMI", r";")
 SLASH = l.define("SLASH", r"/")
 COMMA = l.define("COMMA", r",")
 NUMBER = l.define("NUMBER", r'[+-]?[0-9]*\.?[0-9]+')
-TRUE = l.define("TRUE", r'True')
-FALSE = l.define("FALSE", r'False')
-NONE = l.define("NONE", r'None')
 ID = l.define("ID", r'[a-zA-Z_](?:[a-zA-Z0-9_-]*[a-zA-Z0-9_])?')
 STRING = l.define("STRING", r""""(?:[^\\"]|\\.)*"|'(?:[^\\']|\\.)*'""")
 ESC = l.define("ESC", r"\\[^ux]|\\x[0-9a-fA-F][0-9a-fA-F]|\\u[0-9a-fA-F][0-9a-fA-F][0-9a-fA-F][0-9a-fA-F]")
@@ -59,15 +56,19 @@ def tok2str(tok):
   else:
     return tok.value
 
+CONSTANTS = {
+  "True": True,
+  "true": True,
+  "False": False,
+  "false": False,
+  "None": None
+  }
+
 def tok2obj(tok):
-  if tok.type in (STRING, NUMBER):
+  if tok.type == ID:
+    return CONSTANTS.get(tok.value, tok.value)
+  elif tok.type in (STRING, NUMBER):
     return eval(tok.value)
-  elif tok.type == TRUE:
-    return True
-  elif tok.type == FALSE:
-    return False
-  elif tok.type == NONE:
-    return None
   else:
     return tok.value
 
@@ -136,7 +137,7 @@ class AddressParser(Parser):
     return (key, val)
 
   def value(self):
-    if self.matches(NUMBER, STRING, ID, TRUE, FALSE, NONE):
+    if self.matches(NUMBER, STRING, ID):
       return tok2obj(self.eat())
     elif self.matches(LBRACE):
       return self.map()

Modified: qpid/trunk/qpid/python/qpid/tests/messaging/address.py
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/python/qpid/tests/messaging/address.py?rev=1058654&r1=1058653&r2=1058654&view=diff
==============================================================================
--- qpid/trunk/qpid/python/qpid/tests/messaging/address.py (original)
+++ qpid/trunk/qpid/python/qpid/tests/messaging/address.py Thu Jan 13 16:37:59 2011
@@ -19,8 +19,8 @@
 
 
 from qpid.tests import Test
-from qpid.messaging.address import lex, parse, ParseError, EOF, ID, NONE, \
-    NUMBER, SYM, WSPACE, LEXER
+from qpid.messaging.address import lex, parse, ParseError, EOF, ID, NUMBER, \
+    SYM, WSPACE, LEXER
 from qpid.lexer import Token
 from qpid.harness import Skipped
 from qpid.tests.parser import ParserBase
@@ -149,8 +149,11 @@ class AddressTests(ParserBase, Test):
   def testNegativeNum(self):
     self.lex("-3", NUMBER)
 
-  def testNone(self):
-    self.lex("None", NONE)
+  def testIdNum(self):
+    self.lex("id1", ID)
+
+  def testIdSpaceNum(self):
+    self.lex("id 1", ID, NUMBER)
 
   def testHash(self):
     self.valid("foo/bar.#", "foo", "bar.#")
@@ -312,5 +315,7 @@ class AddressTests(ParserBase, Test):
                "name", "subject", {"foo.bar": "value"})
 
   def testBoolean(self):
-    self.valid("name/subject; { true: True, false: False }",
-               "name", "subject", {"true": True, "false": False})
+    self.valid("name/subject; { true1: True, true2: true, "
+               "false1: False, false2: false }",
+               "name", "subject", {"true1": True, "true2": True,
+                                   "false1": False, "false2": False})



---------------------------------------------------------------------
Apache Qpid - AMQP Messaging Implementation
Project:      http://qpid.apache.org
Use/Interact: mailto:commits-subscribe@qpid.apache.org


Mime
View raw message