Robot Framework Integrated Development Environment (RIDE)
tsvreader.py
Go to the documentation of this file.
1 # Copyright 2008-2015 Nokia Networks
2 # Copyright 2016- Robot Framework Foundation
3 #
4 # Licensed under the Apache License, Version 2.0 (the "License");
5 # you may not use this file except in compliance with the License.
6 # You may obtain a copy of the License at
7 #
8 # http://www.apache.org/licenses/LICENSE-2.0
9 #
10 # Unless required by applicable law or agreed to in writing, software
11 # distributed under the License is distributed on an "AS IS" BASIS,
12 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 # See the License for the specific language governing permissions and
14 # limitations under the License.
15 
16 from itertools import dropwhile
17 
18 from robotide.lib.robot.output import LOGGER
19 
20 from .robotreader import RobotReader
21 
22 
24 
25  @classmethod
26  def split_row(cls, row):
27  i = 0
28  while i < len(row) and row[i] != ' ':
29  if row[i] == '#':
30  return row
31  else:
32  i += 1
33  return [cls._strip_whitespace_strip_whitespace(cell) for cell in row.split('\t')]
34 
35  def _check_deprecations(self, cells, path, line_number):
36  cells = RobotReader._check_deprecations(self, cells, path, line_number)
37  cells = [self._deprecate_quoting_deprecate_quoting(c, path, line_number) for c in cells]
38  self._deprecate_empty_data_cells_deprecate_empty_data_cells(cells, path, line_number)
39  return cells
40 
41  def _deprecate_quoting(self, cell, path, line_number):
42  if len(cell) > 1 and cell[0] == cell[-1] == '"':
43  LOGGER.warn("TSV file '%s' has quotes around cells which is "
44  "deprecated and must be fixed. Remove quotes "
45  "from '%s' on line %d."
46  % (path, cell, line_number))
47  return cell[1:-1].replace('""', '"').strip()
48  return cell
49 
50  def _deprecate_empty_data_cells(self, cells, path, line_number):
51  data_cells = dropwhile(lambda c: not c, cells)
52  if not all(data_cells):
53  LOGGER.warn("TSV file '%s' has empty data cells which is "
54  "deprecated and must be fixed. Escape empty cells "
55  "on line %d with '${EMPTY}'." % (path, line_number))
def _deprecate_empty_data_cells(self, cells, path, line_number)
Definition: tsvreader.py:50
def _check_deprecations(self, cells, path, line_number)
Definition: tsvreader.py:35
def _deprecate_quoting(self, cell, path, line_number)
Definition: tsvreader.py:41