@@ -17,7 +17,9 @@ def _json_arg(value):
1717 return "'{}'" .format (json .dumps (value , separators = (',' , ':' )))
1818
1919
20- def _escape_format_placeholders (command ):
20+ def _escape_format_placeholders (command , format_placeholders = None ):
21+ format_placeholders = format_placeholders or {}
22+
2123 def _find_escaped_placeholder_end (start ):
2224 depth = 0
2325 index = start
@@ -36,6 +38,21 @@ def _find_escaped_placeholder_end(start):
3638 index += 1
3739 return None
3840
41+ def _find_format_placeholder_end (start ):
42+ index = start + 1
43+ while index < len (command ):
44+ current = command [index ]
45+ if current == '{' :
46+ return None
47+ if current == '}' :
48+ field = command [start + 1 :index ]
49+ field_name = field .split ('!' , 1 )[0 ].split (':' , 1 )[0 ].split ('.' , 1 )[0 ].split ('[' , 1 )[0 ]
50+ if field_name in format_placeholders :
51+ return index + 1
52+ return None
53+ index += 1
54+ return None
55+
3956 escaped = []
4057 index = 0
4158 while index < len (command ):
@@ -50,8 +67,13 @@ def _find_escaped_placeholder_end(start):
5067 escaped .append ('{{' )
5168 index += 1
5269 elif current == '{' :
53- escaped .append ('{{' )
54- index += 1
70+ end = _find_format_placeholder_end (index )
71+ if end is not None :
72+ escaped .append (command [index :end ])
73+ index = end
74+ else :
75+ escaped .append ('{{' )
76+ index += 1
5577 elif current == '}' :
5678 escaped .append ('}}' )
5779 index += 1
@@ -113,7 +135,8 @@ def _response_error_detection_settings(error_types=None, failover_threshold=None
113135# pylint: disable=too-many-public-methods
114136class CdnScenarioMixin :
115137 def cmd (self , command , checks = None , expect_failure = False ):
116- return super ().cmd (_escape_format_placeholders (command ), checks , expect_failure = expect_failure )
138+ return super ().cmd (_escape_format_placeholders (command , getattr (self , 'kwargs' , {})), checks ,
139+ expect_failure = expect_failure )
117140
118141 def profile_create_cmd (self , group , name , tags = None , checks = None , options = None , sku = 'STANDARD_MICROSOFT' ):
119142 command = 'cdn profile create -g {} -n {}' .format (group , name )
0 commit comments