summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAngus Salkeld <asalkeld@redhat.com>2013-03-27 18:00:11 +1100
committerAngus Salkeld <asalkeld@redhat.com>2013-03-27 18:00:11 +1100
commite30d70074f278f58457d9d2b278815b5ccb39a63 (patch)
tree337d8ee14b2b6072848a6c72825ca987268295af
parent845a106c0fe44afa32d47befc9d2a67cfe223d3e (diff)
downloadpython-ceilometerclient-1.0.0.tar.gz
Make it possible to pass -q "metadata.field=value"1.0.0
Currently the regex doesn't account for the "." Change-Id: Ia01bb3e2a79e54fd01b0b6fa5437827694d4fb96 Signed-off-by: Angus Salkeld <asalkeld@redhat.com>
-rw-r--r--ceilometerclient/v2/options.py10
-rw-r--r--tests/v2/test_options.py4
2 files changed, 10 insertions, 4 deletions
diff --git a/ceilometerclient/v2/options.py b/ceilometerclient/v2/options.py
index debf6b2..cd3767f 100644
--- a/ceilometerclient/v2/options.py
+++ b/ceilometerclient/v2/options.py
@@ -59,11 +59,13 @@ def cli_to_array(cli_query):
def split_by_op(string):
# two character split (<=,!=)
- fragments = re.findall(r'(\w+)([><!]=)([^ -,\t\n\r\f\v]+)', string)
- if len(fragments) == 0:
+ frags = re.findall(r'([[a-zA-Z0-9_.]+)([><!]=)([^ -,\t\n\r\f\v]+)',
+ string)
+ if len(frags) == 0:
#single char split (<,=)
- fragments = re.findall(r'(\w+)([><=])([^ -,\t\n\r\f\v]+)', string)
- return fragments
+ frags = re.findall(r'([a-zA-Z0-9_.]+)([><=])([^ -,\t\n\r\f\v]+)',
+ string)
+ return frags
opts = []
queries = cli_query.split(';')
diff --git a/tests/v2/test_options.py b/tests/v2/test_options.py
index 33b1a2b..6ee5a22 100644
--- a/tests/v2/test_options.py
+++ b/tests/v2/test_options.py
@@ -66,3 +66,7 @@ class CliTest(unittest.TestCase):
def test_invalid_operator(self):
self.assertRaises(ValueError, options.cli_to_array, 'this=2.4;fooo-doof')
+
+ def test_with_dot(self):
+ ar = options.cli_to_array('metadata.this<=34')
+ self.assertEqual(ar, [{'field': 'metadata.this','op': 'le','value': '34'}])