<s> from __future__ import absolute_import , unicode_literals <EOL> from django . utils . encoding import python_2_unicode_compatible <EOL> from wagtail . wagtailcore import blocks <EOL> from wagtail . wagtailembeds . format import embed_to_frontend_html <EOL> @ python_2_unicode_compatible <EOL> class EmbedValue ( object ) : <EOL> """<STR_LIT>""" <EOL> def __init__ ( self , url ) : <EOL> self . url = url <EOL> def __str__ ( self ) : <EOL> return embed_to_frontend_html ( self . url ) <EOL> class EmbedBlock ( blocks . URLBlock ) : <EOL> def get_default ( self ) : <EOL> if not self . meta . default : <EOL> return None <EOL> elif isinstance ( self . meta . default , EmbedValue ) : <EOL> return self . meta . default <EOL> else : <EOL> return EmbedValue ( self . meta . default ) <EOL> def to_python ( self , value ) : <EOL> if not value : <EOL> return None <EOL> else : <EOL> return EmbedValue ( value ) <EOL> def get_prep_value ( self , value ) : <EOL> if value is None : <EOL> return '<STR_LIT>' <EOL> else : <EOL> return value . url <EOL> def value_for_form ( self , value ) : <EOL> if value is None : <EOL> return '<STR_LIT>' <EOL> else : <EOL> return value . url <EOL> def value_from_form ( self , value ) : <EOL> if not value : <EOL> return None <EOL> else : <EOL> return EmbedValue ( value ) <EOL> class Meta : <EOL> icon = "<STR_LIT>" </s>
