def _get_alignment(self): """ Return alignment type of this paragraph, e.g. ``PP.ALIGN_CENTER``. Can return |None|, meaning the paragraph has no alignment setting and its effective value is inherited from a higher-level object. """ algn = self.__p.get_algn() return ParagraphAlignment.from_text_align_type(algn)
def test_from_text_align_type_return_value(self): """ParagraphAlignment.from_text_align_type() returns correct value""" # verify ----------------------- for alignment, text_align_type in self.cases: assert_that( ParagraphAlignment.from_text_align_type(text_align_type), is_(equal_to(alignment)) )
def alignment(self): """ Horizontal alignment of this paragraph, represented by a constant value like ``PP.ALIGN_CENTER``. Its value can be |None|, meaning the paragraph has no alignment setting and its effective value is inherited from a higher-level object. """ return ParagraphAlignment.from_text_align_type(self._pPr.algn)
def _set_alignment(self, alignment): """ Set alignment of this paragraph to *alignment*, a constant value like ``PP.ALIGN_CENTER``. If *alignment* is None, any alignment setting is cleared and its effective value is inherited from a higher-level object. """ algn = ParagraphAlignment.to_text_align_type(alignment) self.__p.set_algn(algn)
def test_to_text_align_type_raises_on_bad_alignment(self): """ParagraphAlignment.to_text_align_type raises on bad value in""" with self.assertRaises(KeyError): ParagraphAlignment.to_text_align_type('foobar')
def test_from_text_align_type_raises_on_bad_key(self): """ParagraphAlignment.from_text_align_type raises on bad key""" with self.assertRaises(KeyError): ParagraphAlignment.from_text_align_type('foobar')
def alignment(self, alignment): algn = ParagraphAlignment.to_text_align_type(alignment) self._pPr.algn = algn