Skip to content

Commit

Permalink
Merge pull request #117 from degangliu/master
Browse files Browse the repository at this point in the history
去掉万象ut/编码规范
  • Loading branch information
dt3310321 authored Apr 28, 2020
2 parents 43ae8f0 + e9ba056 commit b7f1dba
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 8 deletions.
12 changes: 6 additions & 6 deletions qcloud_cos/cos_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -385,7 +385,7 @@ def get_object(self, Bucket, Key, **kwargs):

def get_object_sensitive_content_recognition(self, Bucket, Key, DetectType, **kwargs):
"""文件内容识别接口 https://cloud.tencent.com/document/product/460/37318
:param Bucket(string): 存储桶名称.
:param Key(string): COS路径.
:param DetectType(int): 内容识别标志,位计算 1:porn, 2:terrorist, 4:politics, 8:ads
Expand Down Expand Up @@ -419,21 +419,21 @@ def get_object_sensitive_content_recognition(self, Bucket, Key, DetectType, **kw
del headers['versionId']
params['ci-process'] = 'sensitive-content-recognition'
detect_type = ''
if DetectType & CiDetectType.PORN > 0 :
if DetectType & CiDetectType.PORN > 0:
detect_type += 'porn'
if DetectType & CiDetectType.TERRORIST > 0 :
if DetectType & CiDetectType.TERRORIST > 0:
if len(detect_type) > 0:
detect_type += ','
detect_type += 'terrorist'
if DetectType & CiDetectType.POLITICS > 0 :
if DetectType & CiDetectType.POLITICS > 0:
if len(detect_type) > 0:
detect_type += ','
detect_type += 'politics'
if DetectType & CiDetectType.ADS > 0 :
if DetectType & CiDetectType.ADS > 0:
if len(detect_type) > 0:
detect_type += ','
detect_type += 'ads'

params['detect-type'] = detect_type
params = format_values(params)

Expand Down
2 changes: 2 additions & 0 deletions qcloud_cos/cos_comm.py
Original file line number Diff line number Diff line change
Expand Up @@ -406,7 +406,9 @@ def get_date(yy, mm, dd):
final_date_str = date_str+'+08:00'
return final_date_str


class CiDetectType():
"""ci内容设备的类型设置,可与操作设多个"""
PORN = 1
TERRORIST = 2
POLITICS = 4
Expand Down
6 changes: 4 additions & 2 deletions ut/test.py
Original file line number Diff line number Diff line change
Expand Up @@ -1152,7 +1152,8 @@ def test_select_object():
for event in event_stream:
print(event)

def test_get_object_sensitive_content_recognition():

def _test_get_object_sensitive_content_recognition():
"""测试ci文件内容识别的接口"""
print(CiDetectType)
response = client.get_object_sensitive_content_recognition(
Expand All @@ -1163,6 +1164,7 @@ def test_get_object_sensitive_content_recognition():
print(response)
assert response


if __name__ == "__main__":
setUp()
"""
Expand All @@ -1187,7 +1189,7 @@ def test_get_object_sensitive_content_recognition():
test_put_get_traffic_limit()
test_put_get_delete_bucket_domain()
test_select_object()
_test_get_object_sensitive_content_recognition()
"""

test_get_object_sensitive_content_recognition()
tearDown()

0 comments on commit b7f1dba

Please sign in to comment.