;idZddlmZddlmZddlmZddlmZddl m Z ddl m Z ddl mZdd lmZmZGd d e Zd S) zz&Styles.__contains__..s*XXu5>]2XXXXXXr)r ui2internalanyr style_lst)rnamers @r __contains__zStyles.__contains__s;!-d33 XXXX @WXXXXXXrkeystrc(|jtj|}|t |S|j|}|(d}t |tdt |Std|z)zEnables dictionary-style access by UI name. Lookup by style id is deprecated, triggers a warning, and will be removed in a near-future release. NzFstyle lookup by style_id is deprecated. Use style name as key instead.) stacklevelzno style with name '%s') r get_by_namerrr get_by_idr UserWarningKeyError)rr$ style_elmmsgs r __getitem__zStyles.__getitem__s M--i.CC.H.HII   ** *M++C00  ZC ka 0 0 0 0 ** *036777rc.d|jjDS)Nc34K|]}t|VdSr)r )rrs rrz"Styles.__iter__..2s*II U##IIIIIIr)rr!rs r__iter__zStyles.__iter__1sII1HIIIIrc4t|jjSr)lenrr!r2s r__len__zStyles.__len__4s4=*+++rFctj|}||vrtd|z|j|||}t |S)zReturn a newly added style object of `style_type` and identified by `name`. A builtin style can be defined by passing True for the optional `builtin` argument. z$document already contains style '%s')rr ValueErrorradd_style_of_typer )rr" style_typebuiltin style_namers r add_stylezStyles.add_style7sZ *400   CdJKK K // JPPE"""rr:rc\|j|}|dSt|S)zpReturn the default style for `style_type` or |None| if no default is defined for that type (not common).N)r default_forr )rr:rs rdefaultzStyles.defaultCs1 ))*55 =4E"""rstyle_id str | Nonec\|||S|||S)zReturn the style of `style_type` matching `style_id`. Returns the default for `style_type` if `style_id` is not found or is |None|, or if the style having `style_id` is not of `style_type`. )r@ _get_by_id)rrAr:s rr*zStyles.get_by_idKs0  << ++ +x444rc|dSt|tr|||S|||S)arReturn the id of the style corresponding to `style_or_name`, or |None| if `style_or_name` is |None|. If `style_or_name` is not a style object, the style is looked up using `style_or_name` as a style name, raising |ValueError| if no style with that name is defined. Raises |ValueError| if the target style is not of `style_type`. N) isinstancer _get_style_id_from_style_get_style_id_from_name)r style_or_namer:s r get_style_idzStyles.get_style_idUsN  4  y 1 1 K00 KK K// zJJ JrcNt|jS)zA |LatentStyles| object providing access to the default behaviors for latent styles and the collection of |_LatentStyle| objects that define overrides of those defaults for a particular named latent style.)r rget_or_add_latentStylesr2s r latent_styleszStyles.latent_stylesds DMAACCDDDrc|r|j|nd}| |j|kr||St |S)zReturn the style of `style_type` matching `style_id`. Returns the default for `style_type` if `style_id` is not found or if the style having `style_id` is not of `style_type`. N)rr*typer@r )rrAr:rs rrDzStyles._get_by_idksT 6>G ''1114 =EJ*44<< ++ +E"""rr<returnc:||||S)aReturn the id of the style of `style_type` corresponding to `style_name`. Returns |None| if that style is the default style for `style_type`. Raises |ValueError| if the named style is not found in the document or does not match `style_type`. )rG)rr<r:s rrHzStyles._get_style_id_from_namevs,,T*-=zJJJrrr c|j|krtd|jd||||krdS|jS)zId of `style`, or |None| if it is the default style of `style_type`. Raises |ValueError| if style is not of `style_type`. zassigned style is type z , need type N)rOr8r@rA)rrr:s rrGzStyles._get_style_id_from_stylesT : # #*%***V`V`abb b DLL,, , ,4~r)rr)r$r%)F)r:r)rArBr:r)r<r%r:rrPrB)rr r:rrPrB)__name__ __module__ __qualname____doc__rr#r/r3r6r=r@r*rJpropertyrMrDrHrG __classcell__)rs@rr r s: YYY 8888$JJJ,,, # # # #####5555 K K KEEXE # # # #KKKK        rr N)rV __future__rwarningsrdocx.enum.stylerdocx.oxml.stylesr docx.sharedr docx.stylesrdocx.styles.latentr docx.styles.styler r r rrrbsBB""""""))))))&&&&&&$$$$$$!!!!!!++++++55555555yyyyy\yyyyyr