def repr_str(dumper: Dumper, data: str) -> str: """A YAML Representer that handles strings, breaking multi-line strings into something a lot more readable in the yaml output. This is useful for representing long, multiline strings in templates or in stack parameters. :param dumper: The Dumper that is being used to serialize this object :param data: The string to serialize :return: The represented string """ if '\n' in data: return dumper.represent_scalar(u'tag:yaml.org,2002:str', data, style='|') return dumper.represent_str(data)
def bytes_representer(dumper: yaml.Dumper, obj): try: return dumper.represent_str(obj.decode('utf-8')) except UnicodeError: return dumper.represent_str(binascii.hexlify(obj).decode('utf-8'))
def represent_granularity(dumper: yaml.Dumper, data: Granularity): return dumper.represent_str(data.value)
def path_representer(dump: yaml.Dumper, dump_path: Path) -> str: """Representer that dum path objects to YAML""" return dump.represent_str(str(dump_path))
def _yaml_represent_datetime(dumper: yaml.Dumper, data: bson.Decimal128) -> str: string = DATETIME_FIELD._serialize(data, "none", SpanJSONEncoder.EMPTY) return dumper.represent_str(string)
def _yaml_represent_decimal(dumper: yaml.Dumper, data: decimal.Decimal) -> str: string = str(data) return dumper.represent_str(string)
def _yaml_represent_uuid(dumper: yaml.Dumper, data: uuid.UUID) -> str: string = str(data) return dumper.represent_str(string)
def _yaml_represent_bytes(dumper: yaml.Dumper, data: bytes) -> str: string = data.hex() return dumper.represent_str(string)
def fraction_representer(dumper: yaml.Dumper, data: fractions.Fraction): return dumper.represent_str(str(data))