Commit 82c68c60 authored by patrik.simons@neotide.fi's avatar patrik.simons@neotide.fi
Browse files

Rename max_row and max_column to row_counter and col_counter so they are not...

Rename max_row and max_column to row_counter and col_counter so they are not confused with the worksheet properties.

--HG--
branch : issue-1321
parent 56f540840142
......@@ -92,7 +92,7 @@ class WorkSheetParser(object):
self.data_only = data_only
self.shared_formulae = {}
self.array_formulae = {}
self.max_row = self.max_column = 0
self.row_counter = self.col_counter = 0
self.tables = TablePartList()
self.date_formats = date_formats
self.row_dimensions = {}
......@@ -172,7 +172,7 @@ class WorkSheetParser(object):
def parse_cell(self, element):
data_type = element.get('t', 'n')
coordinate = element.get('r')
self.max_column += 1
self.col_counter += 1
style_id = element.get('s', 0)
if style_id:
style_id = int(style_id)
......@@ -185,7 +185,7 @@ class WorkSheetParser(object):
if coordinate:
row, column = coordinate_to_tuple(coordinate)
else:
row, column = self.max_row, self.max_column
row, column = self.row_counter, self.col_counter
if not self.data_only and element.find(FORMULA_TAG) is not None:
data_type = 'f'
......@@ -258,18 +258,18 @@ class WorkSheetParser(object):
attrs = dict(row.attrib)
if "r" in attrs:
self.max_row = int(attrs['r'])
self.row_counter = int(attrs['r'])
else:
self.max_row += 1
self.max_column = 0
self.row_counter += 1
self.col_counter = 0
keys = {k for k in attrs if not k.startswith('{')}
if keys != {'r', 'spans'} and keys != {'r'}:
# don't create dimension objects unless they have relevant information
self.row_dimensions[str(self.max_row)] = attrs
self.row_dimensions[str(self.row_counter)] = attrs
cells = [self.parse_cell(el) for el in row]
return self.max_row, cells
return self.row_counter, cells
def parse_formatting(self, element):
......@@ -333,7 +333,7 @@ class WorksheetReader(object):
c.data_type = cell['data_type']
self.ws._cells[(cell['row'], cell['column'])] = c
self.ws.formula_attributes = self.parser.array_formulae
self.ws._current_row = self.parser.max_row
self.ws._current_row = self.parser.row_counter
def bind_formatting(self):
......
......@@ -466,8 +466,8 @@ class TestWorksheetParser:
parser.shared_strings = ["Whatever"] * 10
parser.parse_row(element)
assert parser.max_row == 1
assert parser.max_column == 5
assert parser.row_counter == 1
assert parser.col_counter == 5
def test_row_and_cell_without_coordinates(self, WorkSheetParser):
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment