MCPcopy Create free account
hub / github.com/psf/black / read_data_from_file

Function read_data_from_file

tests/util.py:172–188  ·  view source on GitHub ↗
(file_name: Path)

Source from the content-addressed store, hash-verified

170
171
172def read_data_from_file(file_name: Path) -> Tuple[str, str]:
173 with open(file_name, "r", encoding="utf8") as test:
174 lines = test.readlines()
175 _input: List[str] = []
176 _output: List[str] = []
177 result = _input
178 for line in lines:
179 line = line.replace(EMPTY_LINE, "")
180 if line.rstrip() == "# output":
181 result = _output
182 continue
183
184 result.append(line)
185 if _input and not _output:
186 # If there's no output marker, treat the entire file as already pre-formatted.
187 _output = _input[:]
188 return "".join(_input).strip() + "\n", "".join(_output).strip() + "\n"
189
190
191def read_jupyter_notebook(subdir_name: str, name: str, data: bool = True) -> str:

Callers 4

test_pipingMethod · 0.90
test_python37Method · 0.90
read_dataFunction · 0.85

Calls 2

replaceMethod · 0.80
appendMethod · 0.45

Tested by 3

test_pipingMethod · 0.72
test_python37Method · 0.72