<s> """<STR_LIT>""" <EOL> from __future__ import absolute_import <EOL> from warnings import warn <EOL> from . . opc . constants import RELATIONSHIP_TYPE as RT <EOL> from . . opc . package import XmlPart <EOL> from . . opc . packuri import PackURI <EOL> from . slide import Slide <EOL> from . . util import lazyproperty <EOL> class PresentationPart ( XmlPart ) : <EOL> """<STR_LIT>""" <EOL> @ property <EOL> def sldMasterIdLst ( self ) : <EOL> """<STR_LIT>""" <EOL> return self . _element . get_or_add_sldMasterIdLst ( ) <EOL> @ lazyproperty <EOL> def slide_masters ( self ) : <EOL> """<STR_LIT>""" <EOL> return _SlideMasters ( self ) <EOL> @ property <EOL> def slidemasters ( self ) : <EOL> """<STR_LIT>""" <EOL> msg = ( <EOL> '<STR_LIT>' <EOL> '<STR_LIT>' <EOL> ) <EOL> warn ( msg , UserWarning , stacklevel = <NUM_LIT:2> ) <EOL> return self . slide_masters <EOL> @ property <EOL> def slide_height ( self ) : <EOL> """<STR_LIT>""" <EOL> sldSz = self . _element . sldSz <EOL> return sldSz . cy <EOL> @ slide_height . setter <EOL> def slide_height ( self , height ) : <EOL> sldSz = self . _element . sldSz <EOL> sldSz . cy = height <EOL> @ property <EOL> def slide_width ( self ) : <EOL> """<STR_LIT>""" <EOL> sldSz = self . _element . sldSz <EOL> return sldSz . cx <EOL> @ slide_width . setter <EOL> def slide_width ( self , width ) : <EOL> sldSz = self . _element . sldSz <EOL> sldSz . cx = width <EOL> @ lazyproperty <EOL> def slides ( self ) : <EOL> """<STR_LIT>""" <EOL> sldIdLst = self . _element . get_or_add_sldIdLst ( ) <EOL> slides = _Slides ( sldIdLst , self ) <EOL> slides . rename_slides ( ) <EOL> return slides <EOL> class _Slides ( object ) : <EOL> """<STR_LIT>""" <EOL> def __init__ ( self , sldIdLst , prs ) : <EOL> super ( _Slides , self ) . __init__ ( ) <EOL> self . _sldIdLst = sldIdLst <EOL> self . _prs = prs <EOL> def __getitem__ ( self , idx ) : <EOL> """<STR_LIT>""" <EOL> if idx >= len ( self . _sldIdLst ) : <EOL> raise IndexError ( '<STR_LIT>' ) <EOL> rId = self . _sldIdLst [ idx ] . rId <EOL> return self . _prs . related_parts [ rId ] <EOL> def __iter__ ( self ) : <EOL> """<STR_LIT>""" <EOL> for sldId in self . _sldIdLst : <EOL> rId = sldId . rId <EOL> yield self . _prs . related_parts [ rId ] <EOL> def __len__ ( self ) : <EOL> """<STR_LIT>""" <EOL> return len ( self . _sldIdLst ) <EOL> def add_slide ( self , slidelayout ) : <EOL> """<STR_LIT>""" <EOL> partname = self . _next_partname <EOL> package = self . _prs . package <EOL> slide = Slide . new ( slidelayout , partname , package ) <EOL> rId = self . _prs . relate_to ( slide , RT . SLIDE ) <EOL> self . _sldIdLst . add_sldId ( rId ) <EOL> return slide <EOL> def index ( self , item ) : <EOL> """<STR_LIT>""" <EOL> item_id = id ( item ) <EOL> for idx , slide in enumerate ( self ) : <EOL> if id ( slide ) == item_id : <EOL> return idx <EOL> raise ValueError ( '<STR_LIT>' % item ) <EOL> def rename_slides ( self ) : <EOL> """<STR_LIT>""" <EOL> for idx , slide in enumerate ( self ) : <EOL> partname_str = '<STR_LIT>' % ( idx + <NUM_LIT:1> ) <EOL> slide . partname = PackURI ( partname_str ) <EOL> @ property <EOL> def _next_partname ( self ) : <EOL> """<STR_LIT>""" <EOL> partname_str = '<STR_LIT>' % ( len ( self ) + <NUM_LIT:1> ) <EOL> return PackURI ( partname_str ) <EOL> class _SlideMasters ( object ) : <EOL> """<STR_LIT>""" <EOL> def __init__ ( self , presentation ) : <EOL> super ( _SlideMasters , self ) . __init__ ( ) <EOL> self . _presentation = presentation <EOL> def __getitem__ ( self , idx ) : <EOL> """<STR_LIT>""" <EOL> sldMasterId_lst = self . _sldMasterIdLst . sldMasterId_lst <EOL> if idx >= len ( sldMasterId_lst ) : <EOL> raise IndexError ( '<STR_LIT>' ) <EOL> rId = sldMasterId_lst [ idx ] . rId <EOL> return self . _presentation . related_parts [ rId ] <EOL> def __iter__ ( self ) : <EOL> """<STR_LIT>""" <EOL> for rId in self . _iter_rIds ( ) : <EOL> yield self . _presentation . related_parts [ rId ] <EOL> def __len__ ( self ) : <EOL> """<STR_LIT>""" <EOL> return len ( self . _sldMasterIdLst ) <EOL> def _iter_rIds ( self ) : <EOL> """<STR_LIT>""" <EOL> sldMasterId_lst = self . _sldMasterIdLst . sldMasterId_lst <EOL> for sldMasterId in sldMasterId_lst : <EOL> yield sldMasterId . rId <EOL> @ property <EOL> def _sldMasterIdLst ( self ) : <EOL> """<STR_LIT>""" <EOL> return self . _presentation . sldMasterIdLst </s>
