<s> from . length import XLength , YLength <EOL> class Viewport ( object ) : <EOL> def __init__ ( self , content = None , parent = None ) : <EOL> self . _x = None <EOL> self . _computed_x = <NUM_LIT:0> <EOL> if content . get ( '<STR_LIT:x>' ) : <EOL> self . _x = XLength ( content . get ( '<STR_LIT:x>' ) , parent ) <EOL> self . _computed_x = float ( self . _x ) <EOL> self . _y = None <EOL> self . _computed_y = <NUM_LIT:0> <EOL> if content . get ( '<STR_LIT:y>' ) : <EOL> self . _y = XLength ( content . get ( '<STR_LIT:y>' ) , parent ) <EOL> self . _computed_y = float ( self . _y ) <EOL> self . _width = None <EOL> self . _computed_width = <NUM_LIT> <EOL> if content . get ( '<STR_LIT:width>' ) : <EOL> self . _width = XLength ( content . get ( '<STR_LIT:width>' ) , parent ) <EOL> self . _computed_width = float ( self . _width ) <EOL> self . _height = None <EOL> self . _computed_height = <NUM_LIT> <EOL> if content . get ( '<STR_LIT>' ) : <EOL> self . _height = YLength ( content . get ( '<STR_LIT>' ) , parent ) <EOL> self . _computed_height = float ( self . _height ) <EOL> @ property <EOL> def x ( self ) : <EOL> return self . _computed_x <EOL> @ property <EOL> def y ( self ) : <EOL> return self . _computed_y <EOL> @ property <EOL> def width ( self ) : <EOL> return self . _computed_width <EOL> @ property <EOL> def height ( self ) : <EOL> return self . _computed_height <EOL> def __repr__ ( self ) : <EOL> s = repr ( ( self . _x , self . _y , self . _width , self . _height ) ) <EOL> return s <EOL> @ property <EOL> def xml ( self ) : <EOL> return self . _xml <EOL> @ property <EOL> def _xml ( self , prefix = "<STR_LIT>" ) : <EOL> s = "<STR_LIT>" <EOL> if self . _x : <EOL> s += '<STR_LIT>' % repr ( self . _x ) <EOL> if self . _y : <EOL> s += '<STR_LIT>' % repr ( self . _y ) <EOL> if self . _width : <EOL> s += '<STR_LIT>' % repr ( self . _width ) <EOL> if self . _height : <EOL> s += '<STR_LIT>' % repr ( self . _height ) <EOL> return s </s>
