summaryrefslogtreecommitdiff
path: root/pyparsing/core.py
diff options
context:
space:
mode:
authorptmcg <ptmcg@austin.rr.com>2021-09-08 17:19:32 -0500
committerptmcg <ptmcg@austin.rr.com>2021-09-08 17:19:32 -0500
commit2a1df6cfc17f189ad75e70d72003884e6ad93b72 (patch)
tree8ece86444a2853f82308c351da13a6ff9e5e731d /pyparsing/core.py
parentc1f6cfdef9c59f96bc57c564f196201e04a8548f (diff)
downloadpyparsing-git-2a1df6cfc17f189ad75e70d72003884e6ad93b72.tar.gz
parseFile and create_diagram methods now accept pathlib.Path arguments
Diffstat (limited to 'pyparsing/core.py')
-rw-r--r--pyparsing/core.py7
1 files changed, 4 insertions, 3 deletions
diff --git a/pyparsing/core.py b/pyparsing/core.py
index a97a59d..b9e63af 100644
--- a/pyparsing/core.py
+++ b/pyparsing/core.py
@@ -26,6 +26,7 @@ import types
from operator import itemgetter, attrgetter
from functools import wraps
from threading import RLock
+from pathlib import Path
from .util import (
_FifoCache,
@@ -1766,7 +1767,7 @@ class ParserElement(ABC):
def parse_file(
self,
- file_or_filename: Union[str, TextIO],
+ file_or_filename: Union[str, Path, TextIO],
encoding: str = "utf-8",
parse_all: bool = False,
*,
@@ -2013,7 +2014,7 @@ class ParserElement(ABC):
def create_diagram(
self,
- output_html: Union[TextIO, str],
+ output_html: Union[TextIO, Path, str],
vertical: int = 3,
show_results_names: bool = False,
**kwargs,
@@ -2048,7 +2049,7 @@ class ParserElement(ABC):
show_results_names=show_results_names,
diagram_kwargs=kwargs,
)
- if isinstance(output_html, str):
+ if isinstance(output_html, (str, Path)):
with open(output_html, "w", encoding="utf-8") as diag_file:
diag_file.write(railroad_to_html(railroad))
else: