From d347dce3c4050a40a1c36411ab2762c835b348b2 Mon Sep 17 00:00:00 2001 From: Isaku Yamahata Date: Fri, 26 Oct 2012 05:51:25 +0900 Subject: wsgi/routes: add regex pattern for each REST component Signed-off-by: Isaku Yamahata Signed-off-by: FUJITA Tomonori --- ryu/app/wsgi.py | 4 ++++ ryu/lib/dpid.py | 4 +++- ryu/lib/mac.py | 2 ++ 3 files changed, 9 insertions(+), 1 deletion(-) diff --git a/ryu/app/wsgi.py b/ryu/app/wsgi.py index e21a5cb8..38809922 100644 --- a/ryu/app/wsgi.py +++ b/ryu/app/wsgi.py @@ -29,6 +29,10 @@ gflags.DEFINE_string('wsapi_host', '', 'webapp listen host') gflags.DEFINE_integer('wsapi_port', 8080, 'webapp listen port') +HEX_PATTERN = r'0x[0-9a-z]+' +DIGIT_PATTERN = r'[1-9][0-9]*' + + class ControllerBase(object): special_vars = ['action', 'controller'] diff --git a/ryu/lib/dpid.py b/ryu/lib/dpid.py index 8c8bf759..1224ae0e 100644 --- a/ryu/lib/dpid.py +++ b/ryu/lib/dpid.py @@ -18,7 +18,9 @@ # string representation is in hex without '0x' _DPID_LEN = 16 -_DPID_FMT = '%0' + str(_DPID_LEN) + 'x' +_DPID_LEN_STR = str(_DPID_LEN) +_DPID_FMT = '%0' + _DPID_LEN_STR + 'x' +DPID_PATTERN = r'[0-9a-f]{%d}' % _DPID_LEN def dpid_to_str(dpid): diff --git a/ryu/lib/mac.py b/ryu/lib/mac.py index 20826435..3cb2df39 100644 --- a/ryu/lib/mac.py +++ b/ryu/lib/mac.py @@ -16,6 +16,8 @@ import itertools +# string representation +HADDR_PATTERN = r'([0-9a-f]{2}:){5}[0-9a-f]{2}' # Internal representation of mac address is string[6] _HADDR_LEN = 6 -- cgit v1.2.3