Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
S
sun
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
谢林臻
sun
Commits
43dabfeb
Commit
43dabfeb
authored
Aug 09, 2019
by
张英杰
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
修改输入内容判断
parent
3f1ee7a2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
17 additions
and
5 deletions
+17
-5
skin_check.py
api/skin_check.py
+16
-5
requirements.txt
requirements.txt
+1
-0
No files found.
api/skin_check.py
View file @
43dabfeb
...
...
@@ -2,7 +2,11 @@
# -*- coding: utf-8 -*-
import
json
import
string
import
re
from
zhon
import
(
hanzi
,
pinyin
,
)
from
alpha_types.venus.enum
import
(
SKIN_ALL_CLASSIFY
,
...
...
@@ -94,7 +98,6 @@ class SkinCheckConfig(APIView):
:param text:
:return:
"""
text
=
text
.
encode
(
"utf-8"
)
.
decode
(
"utf-8"
)
return
text
.
replace
(
" "
,
""
)
def
_input_string_check
(
self
,
text
,
check_str
):
...
...
@@ -104,9 +107,17 @@ class SkinCheckConfig(APIView):
:param check_str:
:return: 没有标签符号,默认返回True
"""
punctuation_marks
=
list
(
filter
(
lambda
x
:
x
in
string
.
punctuation
,
text
))
if
punctuation_marks
:
if
re
.
search
(
"[{}]+"
.
format
(
hanzi
.
punctuation
),
text
):
# 如果存在中文标点符号
return
False
punctuation_marks
=
re
.
findall
(
"[{}]+"
.
format
(
pinyin
.
punctuation
),
text
)
# 英文标点符号
if
len
(
punctuation_marks
)
==
len
(
text
):
# 如果全部是英文标点符号
return
False
elif
punctuation_marks
:
# 判断是否都是以 check_str 分隔
return
all
(
map
(
lambda
p
:
p
==
check_str
,
punctuation_marks
))
return
True
def
get
(
self
,
request
):
...
...
@@ -200,7 +211,7 @@ class SkinCheckConfig(APIView):
if
_raise_message
:
return
{
"message"
:
u"{}
标点符号错误!请以英文逗号分隔
"
.
format
(
_raise_message
),
"message"
:
u"{}
文案有误!请输入文字,多个文字之间以英文逗号分隔!
"
.
format
(
_raise_message
),
}
info_logger
.
info
(
"skin_check config modify data: {}"
.
format
(
json
.
dumps
(
modify_data
)))
...
...
requirements.txt
View file @
43dabfeb
...
...
@@ -20,3 +20,4 @@ kombu==4.2.2.post1
requests
==2.21.0
redis
==2.10.6
openpyxl
==2.6.2
zhon
==1.1.5
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