Commit 46e4ed9c by 陈森彬

封装正则匹配

parent b1a699a5
Showing with 6 additions and 5 deletions
#!/usr/bin/env python
# -*- coding:utf-8 -*-
import re
from config import unit_map, cast_map, unit_regex, special_tuple, encap_list, temp_map, special_str
from config import unit_map, cast_map, unit_regex, special_tuple, encap_list, temp_map, special_str, encap_regex
unit_pattern = re.compile('(\d+|\d+[\\\./?]\d+)(' + unit_regex + ')([.a-zA-Z\\-]?)')
encap_pattern = re.compile('.*('+encap_regex+').*')
def is_float(s):
......@@ -183,8 +184,9 @@ def check_encap(kw):
:param kw:
:return:
"""
if kw in encap_list:
return True
encap_res = encap_pattern.findall(kw)
if encap_res:
return encap_res
return False
......
......@@ -132,9 +132,8 @@ class UCHandler(tornado.web.RequestHandler):
if check_temp(kw_info):
attrs_list.append(kw_info)
else:
encap_res = self.encap_par.findall(kw_info)
encap_res = check_encap(kw)
if encap_res:
if check_encap(encap_res[0]):
encap_list.append(encap_res[0])
continue
if kw_info and check_symbol(kw_info):
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment