X Tutup
Skip to content

Commit e586504

Browse files
author
Steve Canny
committed
reorg: shorten 'Collection' suffix to 's'
1 parent 629cadb commit e586504

File tree

11 files changed

+106
-111
lines changed

11 files changed

+106
-111
lines changed

docs/api/table.rst

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -56,15 +56,15 @@ Protocol example::
5656
:members:
5757

5858

59-
|_RowCollection| objects
60-
------------------------
59+
|_Rows| objects
60+
---------------
6161

62-
.. autoclass:: _RowCollection
62+
.. autoclass:: _Rows
6363
:members:
6464

6565

66-
|_ColumnCollection| objects
67-
---------------------------
66+
|_Columns| objects
67+
------------------
6868

69-
.. autoclass:: _ColumnCollection
69+
.. autoclass:: _Columns
7070
:members:

docs/conf.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@
7575
7676
.. |_Column| replace:: :class:`_Column`
7777
78-
.. |_ColumnCollection| replace:: :class:`_ColumnCollection`
78+
.. |_Columns| replace:: :class:`_Columns`
7979
8080
.. |Document| replace:: :class:`Document`
8181
@@ -103,11 +103,11 @@
103103
104104
.. |_Relationship| replace:: :class:`_Relationship`
105105
106-
.. |RelationshipCollection| replace:: :class:`_RelationshipCollection`
106+
.. |Relationships| replace:: :class:`_Relationships`
107107
108108
.. |_Row| replace:: :class:`_Row`
109109
110-
.. |_RowCollection| replace:: :class:`_RowCollection`
110+
.. |_Rows| replace:: :class:`_Rows`
111111
112112
.. |Run| replace:: :class:`Run`
113113

docx/opc/package.py

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -135,10 +135,10 @@ def relate_to(self, part, reltype):
135135
@lazyproperty
136136
def rels(self):
137137
"""
138-
Return a reference to the |RelationshipCollection| holding the
139-
relationships for this package.
138+
Return a reference to the |Relationships| instance holding the
139+
collection of relationships for this package.
140140
"""
141-
return RelationshipCollection(PACKAGE_URI.baseURI)
141+
return Relationships(PACKAGE_URI.baseURI)
142142

143143
def save(self, pkg_file):
144144
"""
@@ -282,10 +282,9 @@ def related_parts(self):
282282
@lazyproperty
283283
def rels(self):
284284
"""
285-
|RelationshipCollection| instance holding the relationships for this
286-
part.
285+
|Relationships| instance holding the relationships for this part.
287286
"""
288-
return RelationshipCollection(self._partname.baseURI)
287+
return Relationships(self._partname.baseURI)
289288

290289
def target_ref(self, rId):
291290
"""
@@ -352,12 +351,12 @@ def _part_cls_for(cls, content_type):
352351
return cls.default_part_type
353352

354353

355-
class RelationshipCollection(dict):
354+
class Relationships(dict):
356355
"""
357356
Collection object for |_Relationship| instances, having list semantics.
358357
"""
359358
def __init__(self, baseURI):
360-
super(RelationshipCollection, self).__init__()
359+
super(Relationships, self).__init__()
361360
self._baseURI = baseURI
362361
self._target_parts_by_rId = {}
363362

docx/opc/pkgreader.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -75,11 +75,11 @@ def _load_serialized_parts(phys_reader, pkg_srels, content_types):
7575
@staticmethod
7676
def _srels_for(phys_reader, source_uri):
7777
"""
78-
Return |_SerializedRelationshipCollection| instance populated with
78+
Return |_SerializedRelationships| instance populated with
7979
relationships for source identified by *source_uri*.
8080
"""
8181
rels_xml = phys_reader.rels_xml_for(source_uri)
82-
return _SerializedRelationshipCollection.load_from_xml(
82+
return _SerializedRelationships.load_from_xml(
8383
source_uri.baseURI, rels_xml)
8484

8585
@staticmethod
@@ -256,13 +256,13 @@ def target_partname(self):
256256
return self._target_partname
257257

258258

259-
class _SerializedRelationshipCollection(object):
259+
class _SerializedRelationships(object):
260260
"""
261261
Read-only sequence of |_SerializedRelationship| instances corresponding
262262
to the relationships item XML passed to constructor.
263263
"""
264264
def __init__(self):
265-
super(_SerializedRelationshipCollection, self).__init__()
265+
super(_SerializedRelationships, self).__init__()
266266
self._srels = []
267267

268268
def __iter__(self):
@@ -272,11 +272,11 @@ def __iter__(self):
272272
@staticmethod
273273
def load_from_xml(baseURI, rels_item_xml):
274274
"""
275-
Return |_SerializedRelationshipCollection| instance loaded with the
275+
Return |_SerializedRelationships| instance loaded with the
276276
relationships contained in *rels_item_xml*. Returns an empty
277277
collection if *rels_item_xml* is |None|.
278278
"""
279-
srels = _SerializedRelationshipCollection()
279+
srels = _SerializedRelationships()
280280
if rels_item_xml is not None:
281281
rels_elm = oxml_fromstring(rels_item_xml)
282282
for rel_elm in rels_elm.Relationship_lst:

docx/table.py

Lines changed: 14 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -29,18 +29,16 @@ def cell(self, row_idx, col_idx):
2929
@lazyproperty
3030
def columns(self):
3131
"""
32-
|_ColumnCollection| instance containing the sequence of rows in this
33-
table.
32+
|_Columns| instance containing the sequence of rows in this table.
3433
"""
35-
return _ColumnCollection(self._tbl)
34+
return _Columns(self._tbl)
3635

3736
@lazyproperty
3837
def rows(self):
3938
"""
40-
|_RowCollection| instance containing the sequence of rows in this
41-
table.
39+
|_Rows| instance containing the sequence of rows in this table.
4240
"""
43-
return _RowCollection(self._tbl)
41+
return _Rows(self._tbl)
4442

4543
@property
4644
def style(self):
@@ -112,16 +110,16 @@ def cells(self):
112110
Sequence of |_Cell| instances corresponding to cells in this column.
113111
Supports ``len()``, iteration and indexed access.
114112
"""
115-
return _ColumnCellCollection(self._tbl, self._gridCol)
113+
return _ColumnCells(self._tbl, self._gridCol)
116114

117115

118-
class _ColumnCellCollection(object):
116+
class _ColumnCells(object):
119117
"""
120118
Sequence of |_Cell| instances corresponding to the cells in a table
121119
column.
122120
"""
123121
def __init__(self, tbl, gridCol):
124-
super(_ColumnCellCollection, self).__init__()
122+
super(_ColumnCells, self).__init__()
125123
self._tbl = tbl
126124
self._gridCol = gridCol
127125

@@ -155,13 +153,13 @@ def _tr_lst(self):
155153
return self._tbl.tr_lst
156154

157155

158-
class _ColumnCollection(object):
156+
class _Columns(object):
159157
"""
160158
Sequence of |_Column| instances corresponding to the columns in a table.
161159
Supports ``len()``, iteration and indexed access.
162160
"""
163161
def __init__(self, tbl):
164-
super(_ColumnCollection, self).__init__()
162+
super(_Columns, self).__init__()
165163
self._tbl = tbl
166164

167165
def __getitem__(self, idx):
@@ -215,15 +213,15 @@ def cells(self):
215213
Sequence of |_Cell| instances corresponding to cells in this row.
216214
Supports ``len()``, iteration and indexed access.
217215
"""
218-
return _RowCellCollection(self._tr)
216+
return _RowCells(self._tr)
219217

220218

221-
class _RowCellCollection(object):
219+
class _RowCells(object):
222220
"""
223221
Sequence of |_Cell| instances corresponding to the cells in a table row.
224222
"""
225223
def __init__(self, tr):
226-
super(_RowCellCollection, self).__init__()
224+
super(_RowCells, self).__init__()
227225
self._tr = tr
228226

229227
def __getitem__(self, idx):
@@ -244,13 +242,13 @@ def __len__(self):
244242
return len(self._tr.tc_lst)
245243

246244

247-
class _RowCollection(object):
245+
class _Rows(object):
248246
"""
249247
Sequence of |_Row| instances corresponding to the rows in a table.
250248
Supports ``len()``, iteration and indexed access.
251249
"""
252250
def __init__(self, tbl):
253-
super(_RowCollection, self).__init__()
251+
super(_Rows, self).__init__()
254252
self._tbl = tbl
255253

256254
def __getitem__(self, idx):

features/steps/table.py

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,7 @@
1010

1111
from docx import Document
1212
from docx.table import (
13-
_Cell, _Column, _ColumnCellCollection, _ColumnCollection, _Row,
14-
_RowCellCollection, _RowCollection
13+
_Cell, _Column, _ColumnCells, _Columns, _Row, _RowCells, _Rows
1514
)
1615

1716
from .helpers import test_docx
@@ -144,28 +143,28 @@ def then_can_access_row_cell_by_index(context):
144143
def then_can_access_cell_collection_of_column(context):
145144
column = context.column
146145
cells = column.cells
147-
assert isinstance(cells, _ColumnCellCollection)
146+
assert isinstance(cells, _ColumnCells)
148147

149148

150149
@then('I can access the cell collection of the row')
151150
def then_can_access_cell_collection_of_row(context):
152151
row = context.row
153152
cells = row.cells
154-
assert isinstance(cells, _RowCellCollection)
153+
assert isinstance(cells, _RowCells)
155154

156155

157156
@then('I can access the column collection of the table')
158157
def then_can_access_column_collection_of_table(context):
159158
table = context.table_
160159
columns = table.columns
161-
assert isinstance(columns, _ColumnCollection)
160+
assert isinstance(columns, _Columns)
162161

163162

164163
@then('I can access the row collection of the table')
165164
def then_can_access_row_collection_of_table(context):
166165
table = context.table_
167166
rows = table.rows
168-
assert isinstance(rows, _RowCollection)
167+
assert isinstance(rows, _Rows)
169168

170169

171170
@then('I can get the length of the column cell collection')

0 commit comments

Comments
 (0)
X Tutup