Page Menu
Home
Software Heritage
Search
Configure Global Search
Log In
Files
F8392884
renderers.py
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
768 B
Subscribers
None
renderers.py
View Options
import
yaml
from
rest_framework
import
renderers
class
YAMLRenderer
(
renderers
.
BaseRenderer
):
"""
Renderer which serializes to YAML.
"""
media_type
=
'application/yaml'
format
=
'yaml'
charset
=
'utf-8'
ensure_ascii
=
False
default_flow_style
=
False
def
render
(
self
,
data
,
accepted_media_type
=
None
,
renderer_context
=
None
):
"""
Renders `data` into serialized YAML.
"""
assert
yaml
,
'YAMLRenderer requires pyyaml to be installed'
if
data
is
None
:
return
''
return
yaml
.
dump
(
data
,
stream
=
None
,
encoding
=
self
.
charset
,
allow_unicode
=
not
self
.
ensure_ascii
,
default_flow_style
=
self
.
default_flow_style
)
File Metadata
Details
Attached
Mime Type
text/x-python
Expires
Jun 4 2025, 7:04 PM (10 w, 1 d ago)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
3310935
Attached To
rDWAPPS Web applications
Event Timeline
Log In to Comment