Adjust simple parse_file to accept a Path or string as filename
This commit is contained in:
parent
acc2b27332
commit
4ab7b3fd16
@ -24,6 +24,7 @@ See below for the contents of the returned :class:`ParsedData`.
|
|||||||
|
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
import os
|
||||||
import sys
|
import sys
|
||||||
import inspect
|
import inspect
|
||||||
import typing
|
import typing
|
||||||
@ -344,7 +345,7 @@ def parse_string(
|
|||||||
|
|
||||||
|
|
||||||
def parse_file(
|
def parse_file(
|
||||||
filename: str,
|
filename: typing.Union[str, os.PathLike],
|
||||||
encoding: typing.Optional[str] = None,
|
encoding: typing.Optional[str] = None,
|
||||||
*,
|
*,
|
||||||
options: typing.Optional[ParserOptions] = None,
|
options: typing.Optional[ParserOptions] = None,
|
||||||
@ -352,6 +353,7 @@ def parse_file(
|
|||||||
"""
|
"""
|
||||||
Simple function to parse a header from a file and return a data structure
|
Simple function to parse a header from a file and return a data structure
|
||||||
"""
|
"""
|
||||||
|
filename = os.fsdecode(filename)
|
||||||
|
|
||||||
if encoding is None:
|
if encoding is None:
|
||||||
encoding = "utf-8-sig"
|
encoding = "utf-8-sig"
|
||||||
|
Loading…
x
Reference in New Issue
Block a user