From 83bb2903790cf448bf838cdb8a93ca96e758bd1a Mon Sep 17 00:00:00 2001 From: Michel Pelletier Date: Sat, 6 Nov 2021 08:30:55 -0700 Subject: [PATCH] allow single hyphen to represent stdin for filename. --- cxxheaderparser/simple.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/cxxheaderparser/simple.py b/cxxheaderparser/simple.py index 0fc8a64..4ef6f24 100644 --- a/cxxheaderparser/simple.py +++ b/cxxheaderparser/simple.py @@ -24,6 +24,7 @@ See below for the contents of the returned :class:`ParsedData`. """ +import sys import inspect import typing @@ -327,7 +328,11 @@ def parse_file( if encoding is None: encoding = "utf-8-sig" - with open(filename, encoding=encoding) as fp: - content = fp.read() + if filename == "-": + content = sys.stdin.read() + else: + + with open(filename, encoding=encoding) as fp: + content = fp.read() return parse_string(content, filename=filename, options=options)