Skip to content

Commit

Permalink
Fix some miscellaneous issues breaking expectations/tests
Browse files Browse the repository at this point in the history
  • Loading branch information
oerc0122 committed Nov 28, 2024
1 parent 4259ec3 commit 0966aa4
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 3 deletions.
2 changes: 1 addition & 1 deletion castep_outputs/cli/args.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ def parse_args(to_parse: Sequence[str] = ()) -> argparse.Namespace:
Examples
--------
>>> parse_args()
parse_args()
"""
args = ARG_PARSER.parse_args()

Expand Down
1 change: 1 addition & 0 deletions castep_outputs/cli/castep_outputs_main.py
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,7 @@ def parse_all(
elif isinstance(output, io.TextIOBase):
file_dumper(data, output)
else:
output = Path(output)
with output.open("a+", encoding="utf-8") as out_file:
file_dumper(data, out_file)

Expand Down
14 changes: 12 additions & 2 deletions castep_outputs/utilities/filewrapper.py
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ def get_lines(
*,
eof_possible: bool = False,
) -> Block:
"""
r"""
Read the next `n_lines` from `in_file` and return the block.
Parameters
Expand All @@ -133,14 +133,24 @@ def get_lines(
------
IOError
If EOF reached and ``not eof_possible``.
Examples
--------
>>> from io import StringIO
>>> x = StringIO('Hello\nThere\nFriend')
>>> block = Block.get_lines(x, 2)
>>> type(block).__name__
'Block'
>>> block.aslist()
['Hello\n', 'There\n']
"""
block = cls(in_file)

data: list[str] = []
for i, line in enumerate(in_file, 1):
if i > n_lines:
break
data += line
data.append(line)
else:
if not eof_possible:
if hasattr(in_file, "name"):
Expand Down

0 comments on commit 0966aa4

Please sign in to comment.