Page as string. Similar to general Element.__repr__, except showing the (pageNumber, index) as it is stored in the parent document. And not showing (self.x, self.y), as most pages will not be part of another page (although it is allowed and there could be situations to do so,
(self)
| 190 | index = property(_get_index) |
| 191 | |
| 192 | def __repr__(self): |
| 193 | """Page as string. Similar to general Element.__repr__, except showing |
| 194 | the (pageNumber, index) as it is stored in the parent document. And not |
| 195 | showing (self.x, self.y), as most pages will not be part of another |
| 196 | page (although it is allowed and there could be situations to do so, |
| 197 | e.g. if a page is used as illustration in another page.) |
| 198 | |
| 199 | >>> from pagebot.document import Document |
| 200 | >>> from pagebot.constants import A4 |
| 201 | >>> doc = Document(name='TestDoc', autoPages=8, size=A4) |
| 202 | >>> doc[5] # Remembers original unit size. |
| 203 | <Page #5 default (210mm, 297mm)> |
| 204 | """ |
| 205 | if self.title: |
| 206 | name = ' ' + self.title |
| 207 | elif self.name: |
| 208 | name = ' ' + self.name |
| 209 | else: # No name |
| 210 | name = ' Unplaced' |
| 211 | |
| 212 | if self.elements: |
| 213 | elements = ' E(%d)' % len(self.elements) |
| 214 | else: |
| 215 | elements = '' |
| 216 | |
| 217 | pn = '' |
| 218 | |
| 219 | if self.parent: # If there is a parent, get the (pageNumber, index) tuple. |
| 220 | if self._pn is not None: # Hard coded page number, then ignore document index. |
| 221 | pn_index = self._pn |
| 222 | else: |
| 223 | pn_index = self.parent.getPageNumber(self) |
| 224 | |
| 225 | if pn_index is not None: |
| 226 | if pn_index[1]: # Index > 1, then show. |
| 227 | pn = ' #%d:%d' % pn_index |
| 228 | else: |
| 229 | pn = ' #%d' % pn_index[0] |
| 230 | |
| 231 | return '<%s%s%s (%s, %s)%s>' % (self.__class__.__name__, pn, name, self.w, self.h, elements) |
| 232 | |
| 233 | def _get_isLeft(self): |
| 234 | """Answers if this is a left page (even pagenumber), unless the |
nothing calls this directly
no test coverage detected