30 self.
_pipe_splitter_pipe_splitter = re.compile(
u'[ \t\xa0]+\|(?=[ \t\xa0]+)')
37 def read(self, file, populator, path=None):
38 path = path
or getattr(file,
'name',
'<file-like object>')
39 process = table_start = preamble =
False
41 for lineno, line
in enumerate(Utf8Reader(file).readlines(), start=1):
44 cells = self.
split_rowsplit_row(line.rstrip())
47 if line.lstrip().startswith(
'#'):
52 if cells
and cells[0].strip().startswith(
'*')
and \
53 populator.start_table([c.replace(
'*',
'').strip()
55 process = table_start =
True
61 populator.add_preamble(line)
62 elif process
and not preamble:
65 return populator.eof()
70 start_d_quote = end_d_quote =
False
71 start_s_quote = end_s_quote =
False
90 if line[i] ==
'#' and not start_d_quote
and not start_s_quote:
95 if i>0
and line[i-1] !=
'\\' and (line[i+1] ==
' ' or line[i+1] ==
'#'):
103 if index < len(line):
106 row.append(line[index:])
113 for i, v
in enumerate(row):
118 if first_non_empty != -1:
119 for i
in range(len(row)-1, first_non_empty, -1):
124 if len(row) > 1
and first_non_empty > 1
and row[0] ==
'' and row[1] !=
'':
132 row = row[1:-1]
if row[-2:]
in self.
_pipe_ends_pipe_ends
else row[1:]
138 for original
in cells:
140 if normalized != original:
141 if len(normalized) != len(original):
142 msg =
'Collapsing consecutive whitespace'
144 msg =
'Converting whitespace characters to ASCII spaces'
145 LOGGER.warn(
"%s during parsing is deprecated. Fix %s in file "
147 % (msg,
prepr(original), path, line_number))
152 return string.strip()
156 if string.startswith(
'#'):
158 return ' '.join(string.split())
168 if not line.startswith(
'*')
and not line.startswith(
'#'):
174 for idx
in range(0, len(line)):
179 self.
_space_splitter_space_splitter = re.compile(
r"[ \t\xa0]{" + f
"{self._spaces}" +
"}|\t+")
def read(self, file, populator, path=None)
def _normalize_whitespace(string)
def _check_deprecations(self, cells, path, line_number)
def check_separator(self, line)
if line.startswith('*') and not self._cell_section: row = line.strip('*').strip(' ') if row in ['Keyw...
def sharp_strip(self, line)
def _strip_whitespace(cls, string)
def __init__(self, spaces=2)
def prepr(item, width=80)