Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
lichenggang
/
bom_identify
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Snippets
Settings
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
46e4ed9c
authored
Jan 25, 2021
by
陈森彬
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
封装正则匹配
parent
b1a699a5
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
8 additions
and
7 deletions
utils/functions.py
valid_server.py
utils/functions.py
View file @
46e4ed9c
#!/usr/bin/env python
#!/usr/bin/env python
# -*- coding:utf-8 -*-
# -*- coding:utf-8 -*-
import
re
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
\\
-]?)'
)
unit_pattern
=
re
.
compile
(
'(
\
d+|
\
d+[
\\
\
./?]
\
d+)('
+
unit_regex
+
')([.a-zA-Z
\\
-]?)'
)
encap_pattern
=
re
.
compile
(
'.*('
+
encap_regex
+
').*'
)
def
is_float
(
s
):
def
is_float
(
s
):
...
@@ -183,8 +184,9 @@ def check_encap(kw):
...
@@ -183,8 +184,9 @@ def check_encap(kw):
:param kw:
:param kw:
:return:
:return:
"""
"""
if
kw
in
encap_list
:
encap_res
=
encap_pattern
.
findall
(
kw
)
return
True
if
encap_res
:
return
encap_res
return
False
return
False
...
...
valid_server.py
View file @
46e4ed9c
...
@@ -132,11 +132,10 @@ class UCHandler(tornado.web.RequestHandler):
...
@@ -132,11 +132,10 @@ class UCHandler(tornado.web.RequestHandler):
if
check_temp
(
kw_info
):
if
check_temp
(
kw_info
):
attrs_list
.
append
(
kw_info
)
attrs_list
.
append
(
kw_info
)
else
:
else
:
encap_res
=
self
.
encap_par
.
findall
(
kw_info
)
encap_res
=
check_encap
(
kw
)
if
encap_res
:
if
encap_res
:
if
check_encap
(
encap_res
[
0
]):
encap_list
.
append
(
encap_res
[
0
])
encap_list
.
append
(
encap_res
[
0
])
continue
continue
if
kw_info
and
check_symbol
(
kw_info
):
if
kw_info
and
check_symbol
(
kw_info
):
words_list
.
append
(
kw_info
)
words_list
.
append
(
kw_info
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment