@@ -747,8 +747,7 @@ def delete_objects(self, Bucket, Delete={}, **kwargs):
747747 Delete=objects
748748 )
749749 """
750- lst = ['<Object>' , '</Object>' ] # 类型为list的标签
751- xml_config = format_xml (data = Delete , root = 'Delete' , lst = lst )
750+ xml_config = format_xml (data = Delete , root = 'Delete' )
752751 headers = mapped (kwargs )
753752 headers ['Content-MD5' ] = get_md5 (xml_config )
754753 headers ['Content-Type' ] = 'application/xml'
@@ -1141,12 +1140,9 @@ def put_object_acl(self, Bucket, Key, AccessControlPolicy={}, **kwargs):
11411140 GrantRead='id="qcs::cam::uin/123:uin/456",id="qcs::cam::uin/123:uin/123"'
11421141 )
11431142 """
1144- lst = [ # 类型为list的标签
1145- '<Grant>' ,
1146- '</Grant>' ]
11471143 xml_config = ""
11481144 if AccessControlPolicy :
1149- xml_config = format_xml (data = AccessControlPolicy , root = 'AccessControlPolicy' , lst = lst )
1145+ xml_config = format_xml (data = AccessControlPolicy , root = 'AccessControlPolicy' )
11501146 headers = mapped (kwargs )
11511147 params = {'acl' : '' }
11521148 url = self ._conf .uri (bucket = Bucket , path = Key )
@@ -1610,12 +1606,9 @@ def put_bucket_acl(self, Bucket, AccessControlPolicy={}, **kwargs):
16101606 GrantRead='id="qcs::cam::uin/123:uin/456",id="qcs::cam::uin/123:uin/123"'
16111607 )
16121608 """
1613- lst = [ # 类型为list的标签
1614- '<Grant>' ,
1615- '</Grant>' ]
16161609 xml_config = ""
16171610 if AccessControlPolicy :
1618- xml_config = format_xml (data = AccessControlPolicy , root = 'AccessControlPolicy' , lst = lst )
1611+ xml_config = format_xml (data = AccessControlPolicy , root = 'AccessControlPolicy' )
16191612 headers = mapped (kwargs )
16201613 params = {'acl' : '' }
16211614 url = self ._conf .uri (bucket = Bucket )
@@ -1699,18 +1692,7 @@ def put_bucket_cors(self, Bucket, CORSConfiguration={}, **kwargs):
16991692 CORSConfiguration=cors_config
17001693 )
17011694 """
1702- lst = [ # 类型为list的标签
1703- '<CORSRule>' ,
1704- '<AllowedOrigin>' ,
1705- '<AllowedMethod>' ,
1706- '<AllowedHeader>' ,
1707- '<ExposeHeader>' ,
1708- '</CORSRule>' ,
1709- '</AllowedOrigin>' ,
1710- '</AllowedMethod>' ,
1711- '</AllowedHeader>' ,
1712- '</ExposeHeader>' ]
1713- xml_config = format_xml (data = CORSConfiguration , root = 'CORSConfiguration' , lst = lst )
1695+ xml_config = format_xml (data = CORSConfiguration , root = 'CORSConfiguration' )
17141696 headers = mapped (kwargs )
17151697 headers ['Content-MD5' ] = get_md5 (xml_config )
17161698 headers ['Content-Type' ] = 'application/xml'
@@ -1833,17 +1815,7 @@ def put_bucket_lifecycle(self, Bucket, LifecycleConfiguration={}, **kwargs):
18331815 )
18341816 """
18351817 # 类型为list的标签
1836- lst = [
1837- '<Rule>' ,
1838- '<Tag>' ,
1839- '<Transition>' ,
1840- '<NoncurrentVersionTransition>' ,
1841- '</NoncurrentVersionTransition>' ,
1842- '</Transition>' ,
1843- '</Tag>' ,
1844- '</Rule>'
1845- ]
1846- xml_config = format_xml (data = LifecycleConfiguration , root = 'LifecycleConfiguration' , lst = lst )
1818+ xml_config = format_xml (data = LifecycleConfiguration , root = 'LifecycleConfiguration' )
18471819 headers = mapped (kwargs )
18481820 headers ['Content-MD5' ] = get_md5 (xml_config )
18491821 headers ['Content-Type' ] = 'application/xml'
@@ -2068,8 +2040,7 @@ def put_bucket_replication(self, Bucket, ReplicationConfiguration={}, **kwargs):
20682040 ReplicationConfiguration=replication_config
20692041 )
20702042 """
2071- lst = ['<Rule>' , '</Rule>' ] # 类型为list的标签
2072- xml_config = format_xml (data = ReplicationConfiguration , root = 'ReplicationConfiguration' , lst = lst )
2043+ xml_config = format_xml (data = ReplicationConfiguration , root = 'ReplicationConfiguration' )
20732044 headers = mapped (kwargs )
20742045 headers ['Content-MD5' ] = get_md5 (xml_config )
20752046 headers ['Content-Type' ] = 'application/xml'
@@ -2197,7 +2168,12 @@ def put_bucket_website(self, Bucket, WebsiteConfiguration={}, **kwargs):
21972168 WebsiteConfiguration=website_config
21982169 )
21992170 """
2200- xml_config = format_xml (data = WebsiteConfiguration , root = 'WebsiteConfiguration' , parent_child = True )
2171+ # 重构 WebsiteConfiguration['RoutingRules']
2172+ WebsiteConfigurationCpy = copy .deepcopy (WebsiteConfiguration )
2173+ if 'RoutingRules' in WebsiteConfigurationCpy .keys ():
2174+ WebsiteConfigurationCpy ['RoutingRules' ] = {'RoutingRule' : WebsiteConfigurationCpy ['RoutingRules' ]}
2175+
2176+ xml_config = format_xml (data = WebsiteConfigurationCpy , root = 'WebsiteConfiguration' )
22012177 headers = mapped (kwargs )
22022178 headers ['Content-MD5' ] = get_md5 (xml_config )
22032179 headers ['Content-Type' ] = 'application/xml'
@@ -2496,8 +2472,7 @@ def put_bucket_domain(self, Bucket, DomainConfiguration={}, **kwargs):
24962472 DomainConfiguration=domain_config
24972473 )
24982474 """
2499- lst = ['<DomainRule>' , '</DomainRule>' ] # 类型为list的标签
2500- xml_config = format_xml (data = DomainConfiguration , root = 'DomainConfiguration' , lst = lst )
2475+ xml_config = format_xml (data = DomainConfiguration , root = 'DomainConfiguration' )
25012476 headers = mapped (kwargs )
25022477 headers ['Content-MD5' ] = get_md5 (xml_config )
25032478 headers ['Content-Type' ] = 'application/xml'
@@ -2600,8 +2575,7 @@ def put_bucket_domain_certificate(self, Bucket, DomainCertificateConfiguration,
26002575 DomainCertificateConfiguration=domain_cert_config
26012576 )
26022577 """
2603- lst = ['<DomainList>' , '</DomainList>' ] # 类型为list的标签
2604- xml_config = format_xml (data = DomainCertificateConfiguration , root = 'DomainCertificate' , lst = lst )
2578+ xml_config = format_xml (data = DomainCertificateConfiguration , root = 'DomainCertificate' )
26052579 headers = mapped (kwargs )
26062580 headers ['Content-MD5' ] = get_md5 (xml_config )
26072581 headers ['Content-Type' ] = 'application/xml'
@@ -2714,8 +2688,7 @@ def put_bucket_origin(self, Bucket, OriginConfiguration={}, **kwargs):
27142688 OriginConfiguration=origin_config
27152689 )
27162690 """
2717- lst = ['<OriginRule>' , '</OriginRule>' ] # 类型为list的标签
2718- xml_config = format_xml (data = OriginConfiguration , root = 'OriginConfiguration' , lst = lst )
2691+ xml_config = format_xml (data = OriginConfiguration , root = 'OriginConfiguration' )
27192692 headers = mapped (kwargs )
27202693 headers ['Content-MD5' ] = get_md5 (xml_config )
27212694 headers ['Content-Type' ] = 'application/xml'
@@ -2848,9 +2821,8 @@ def put_bucket_inventory(self, Bucket, Id, InventoryConfiguration={}, **kwargs):
28482821 InventoryConfiguration=inventory_config
28492822 )
28502823 """
2851- lst = ['<Field>' , '</Field>' ] # 类型为list的标签
28522824 InventoryConfiguration ['Id' ] = Id
2853- xml_config = format_xml (data = InventoryConfiguration , root = 'InventoryConfiguration' , lst = lst )
2825+ xml_config = format_xml (data = InventoryConfiguration , root = 'InventoryConfiguration' )
28542826 headers = mapped (kwargs )
28552827 headers ['Content-MD5' ] = get_md5 (xml_config )
28562828 headers ['Content-Type' ] = 'application/xml'
@@ -2965,8 +2937,7 @@ def put_object_tagging(self, Bucket, Key, Tagging={}, **kwargs):
29652937 Tagging=tagging_set
29662938 )
29672939 """
2968- lst = ['<Tag>' , '</Tag>' ] # 类型为list的标签
2969- xml_config = format_xml (data = Tagging , root = 'Tagging' , lst = lst )
2940+ xml_config = format_xml (data = Tagging , root = 'Tagging' )
29702941 headers = mapped (kwargs )
29712942 params = {'tagging' : '' }
29722943 if 'versionId' in headers :
@@ -3089,8 +3060,7 @@ def put_bucket_tagging(self, Bucket, Tagging={}, **kwargs):
30893060 Tagging=tagging_set
30903061 )
30913062 """
3092- lst = ['<Tag>' , '</Tag>' ] # 类型为list的标签
3093- xml_config = format_xml (data = Tagging , root = 'Tagging' , lst = lst )
3063+ xml_config = format_xml (data = Tagging , root = 'Tagging' )
30943064 headers = mapped (kwargs )
30953065 headers ['Content-MD5' ] = get_md5 (xml_config )
30963066 headers ['Content-Type' ] = 'application/xml'
@@ -3203,8 +3173,7 @@ def put_bucket_referer(self, Bucket, RefererConfiguration={}, **kwargs):
32033173 RefererConfiguration=referer_config
32043174 )
32053175 """
3206- lst = ['<Domain>' , '</Domain>' ] # 类型为list的标签
3207- xml_config = format_xml (data = RefererConfiguration , root = 'RefererConfiguration' , lst = lst )
3176+ xml_config = format_xml (data = RefererConfiguration , root = 'RefererConfiguration' )
32083177 headers = mapped (kwargs )
32093178 headers ['Content-MD5' ] = get_md5 (xml_config )
32103179 headers ['Content-Type' ] = 'application/xml'
@@ -4059,13 +4028,7 @@ def put_bucket_encryption(self, Bucket, ServerSideEncryptionConfiguration={}, **
40594028 :param kwargs(dict): 设置请求的headers.
40604029 :return: None.
40614030 """
4062- # 类型为list的标签
4063- lst = [
4064- '<Rule>' ,
4065- '</Rule>'
4066- ]
4067- xml_config = format_xml (data = ServerSideEncryptionConfiguration , root = 'ServerSideEncryptionConfiguration' ,
4068- lst = lst )
4031+ xml_config = format_xml (data = ServerSideEncryptionConfiguration , root = 'ServerSideEncryptionConfiguration' )
40694032 headers = mapped (kwargs )
40704033 params = {'encryption' : '' }
40714034 url = self ._conf .uri (bucket = Bucket )
@@ -6012,21 +5975,7 @@ def ci_auditing_image_batch(self, Bucket, Input, DetectType=None, BizType=None,
60125975 'Conf' : conf
60135976 }
60145977
6015- lst = [ # 类型为list的标签
6016- '<Input>' ,
6017- '<Object>' ,
6018- '<Url>' ,
6019- '<Interval>' ,
6020- '<MaxFrames>' ,
6021- '<DataId>' ,
6022- '</Input>' ,
6023- '</Object>' ,
6024- '</Url>' ,
6025- '</Interval>' ,
6026- '</MaxFrames>' ,
6027- '</DataId>' ]
6028-
6029- xml_request = format_xml (data = request , root = 'Request' , lst = lst )
5978+ xml_request = format_xml (data = request , root = 'Request' )
60305979 headers ['Content-Type' ] = 'application/xml'
60315980
60325981 path = 'image/auditing'
@@ -6586,7 +6535,7 @@ def ci_create_media_jobs(self, Bucket, Jobs={}, Lst={}, **kwargs):
65866535
65876536 :param Bucket(string): 存储桶名称.
65886537 :param Jobs(dict): 创建任务的配置.
6589- :param Lst(dict): 创建任务dict转xml时去除Key数组.
6538+ :param Lst(dict): 创建任务dict转xml时去除Key数组. TODO 替换成 xmltodict 库后可以将 Lst 参数去掉
65906539 :param kwargs(dict): 设置请求的headers.
65916540 :return(dict): 查询成功返回的结果,dict类型.
65926541
@@ -6613,7 +6562,7 @@ def ci_create_media_jobs(self, Bucket, Jobs={}, Lst={}, **kwargs):
66136562 headers = final_headers
66146563
66156564 params = format_values (params )
6616- xml_config = format_xml (data = Jobs , root = 'Request' , lst = Lst )
6565+ xml_config = format_xml (data = Jobs , root = 'Request' )
66176566 path = "/jobs"
66186567 url = self ._conf .uri (bucket = Bucket , path = path , endpoint = self ._conf ._endpoint_ci )
66196568 logger .info ("create_media_jobs result, url=:{url} ,headers=:{headers}, params=:{params}, xml_config=:{xml_config}" .format (
@@ -6640,7 +6589,7 @@ def ci_create_media_pic_jobs(self, Bucket, Jobs={}, Lst={}, **kwargs):
66406589
66416590 :param Bucket(string): 存储桶名称.
66426591 :param Jobs(dict): 创建任务的配置.
6643- :param Lst(dict): 创建任务dict转xml时去除Key数组.
6592+ :param Lst(dict): 创建任务dict转xml时去除Key数组. TODO 替换为 xmltodict 库后可以将 Lst 参数去掉
66446593 :param kwargs(dict): 设置请求的headers.
66456594 :return(dict): 查询成功返回的结果,dict类型.
66466595
@@ -6667,7 +6616,7 @@ def ci_create_media_pic_jobs(self, Bucket, Jobs={}, Lst={}, **kwargs):
66676616 headers = final_headers
66686617
66696618 params = format_values (params )
6670- xml_config = format_xml (data = Jobs , root = 'Request' , lst = Lst )
6619+ xml_config = format_xml (data = Jobs , root = 'Request' )
66716620 path = "/pic_jobs"
66726621 url = self ._conf .uri (bucket = Bucket , path = path , endpoint = self ._conf ._endpoint_ci )
66736622 logger .info ("create_media_pic_jobs result, url=:{url} ,headers=:{headers}, params=:{params}, xml_config=:{xml_config}" .format (
0 commit comments