MCPcopy Create free account
hub / github.com/aws/aws-cli / to_string

Method to_string

awscli/botocore/useragent.py:195–216  ·  view source on GitHub ↗

Create string like 'prefix/name#value' from a UserAgentComponent.

(self)

Source from the content-addressed store, hash-verified

193 size_config: Optional[UserAgentComponentSizeConfig] = None
194
195 def to_string(self):
196 """Create string like 'prefix/name#value' from a UserAgentComponent."""
197 clean_prefix = sanitize_user_agent_string_component(
198 self.prefix, allow_hash=True
199 )
200 clean_name = sanitize_user_agent_string_component(
201 self.name, allow_hash=False
202 )
203 if self.value is None or self.value == '':
204 clean_string = f'{clean_prefix}/{clean_name}'
205 else:
206 clean_value = sanitize_user_agent_string_component(
207 self.value, allow_hash=True
208 )
209 clean_string = f'{clean_prefix}/{clean_name}#{clean_value}'
210 if self.size_config is not None:
211 clean_string = self._truncate_string(
212 clean_string,
213 self.size_config.max_size_in_bytes,
214 self.size_config.delimiter,
215 )
216 return clean_string
217
218 def _truncate_string(self, string, max_size, delimiter):
219 """

Calls 2

_truncate_stringMethod · 0.95