XjdZddlmZddlmZddlmZddlmZddl m Z ddl m Z ddl mZdd lmZmZGd d e Zy ) zz&Styles.__contains__..sXu5>>]2Xs)r ui2internalanyr style_lst)rnamers @r __contains__zStyles.__contains__s.!--d3 X @W@WXXXrc |jjtj|}| t |S|jj |}|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. zFstyle 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)rkey style_elmmsgs r __getitem__zStyles.__getitem__s{ MM--i.C.CC.HI   * *MM++C0  ZC ka 0 * *03677rc<d|jjDS)Nc32K|]}t|ywr)r )rrs rrz"Styles.__iter__..2sI U#Is)rr!rs r__iter__zStyles.__iter__1sI1H1HIIrc@t|jjSr)lenrr!r1s r__len__zStyles.__len__4s4==**++rctj|}||vrtd|z|jj |||}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_style7sP **40  CdJK K // JPE""rcT|jj|}|yt|S)zpReturn the default style for `style_type` or |None| if no default is defined for that type (not common).N)r default_forr )rr9rs rdefaultzStyles.defaultCs+ ))*5 =E""rcL||j|S|j||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)rstyle_idr9s rr(zStyles.get_by_idKs*  << + +x44rcp|yt|tr|j||S|j||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_namer9s r get_style_idzStyles.get_style_idUs=    y 100 K K// zJ JrcHt|jjS)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_latentStylesr1s r latent_styleszStyles.latent_stylesds DMMAACDDrc|r|jj|nd}||j|k7r|j|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 )rrBr9rs rrAzStyles._get_by_idksF 6> ''14 =EJJ*4<< + +E""rc,|j|||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`. )rE)rr;r9s rrFzStyles._get_style_id_from_namevs,,T*-=zJJrc|j|k7rtd|jd|||j|k(ry|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)rMr7r?rB)rrr9s rrEzStyles._get_style_id_from_stylesC :: #%**V`ab b DLL, ,~~r)rr)r+str)F)r9r)rB str | Noner9r)r;rPr9rreturnrQ)rr r9rrRrQ)__name__ __module__ __qualname____doc__rr#r.r2r5r<r?r(rHpropertyrKrArFrE __classcell__)rs@rr r s^ Y 8$J, ##5 KEE #K rr N)rV __future__rwarningsrdocx.enum.stylerdocx.oxml.stylesr docx.sharedr docx.stylesrdocx.styles.latentr docx.styles.styler r r rrrbs.B")&$!+5y\yr