MCPcopy Index your code
hub / github.com/python/cpython / write_table

Function write_table

Tools/c-analyzer/c_common/tables.py:119–150  ·  view source on GitHub ↗

Write each of the rows to the given ???-separated (e.g. tab) file.

(outfile, header, rows, *,
                sep='\t',
                fix=None,
                backup=True,
                _open=open,
                _get_writer=csv.writer,
                )

Source from the content-addressed store, hash-verified

117
118
119def write_table(outfile, header, rows, *,
120 sep='\t',
121 fix=None,
122 backup=True,
123 _open=open,
124 _get_writer=csv.writer,
125 ):
126 """Write each of the rows to the given ???-separated (e.g. tab) file."""
127 if backup:
128 fsutil.create_backup(outfile, backup)
129 if isinstance(outfile, str):
130 with _open(outfile, 'w', newline='') as outfile:
131 return write_table(
132 outfile,
133 header,
134 rows,
135 sep=sep,
136 fix=fix,
137 backup=backup,
138 _open=_open,
139 _get_writer=_get_writer,
140 )
141
142 if isinstance(header, str):
143 header = header.split(sep or '\t')
144 fix_row = _normalize_fix_write(fix)
145 writer = _get_writer(outfile, delimiter=sep or '\t')
146 writer.writerow(header)
147 for row in rows:
148 writer.writerow(
149 tuple(fix_row(row))
150 )
151
152
153def parse_table(entries, sep, header=None, rawsep=None, *,

Callers

nothing calls this directly

Calls 5

_normalize_fix_writeFunction · 0.85
_get_writerFunction · 0.85
fix_rowFunction · 0.85
writerowMethod · 0.80
splitMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…