Skip to content
This repository was archived by the owner on Mar 8, 2020. It is now read-only.
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions bblfsh/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,8 @@ def __init__(self, endpoint):
self._channel = grpc.insecure_channel(endpoint)
self._stub = ProtocolServiceStub(self._channel)

def parse_uast(self, filename, language=None, contents=None, timeout=None):
def parse_uast(self, filename, language=None, contents=None, timeout=None,
unicode_errors="ignore"):
"""
Queries the Babelfish server and receives the UAST for the specified
file.
Expand All @@ -40,14 +41,16 @@ def parse_uast(self, filename, language=None, contents=None, timeout=None):
:param contents: The contents of the file. IF None, it is read from \
filename.
:param timeout: The request timeout in seconds.
:param unicode_errors: This is passed to open() and changes the way \
Unicode read errors are handled.
:type filename: str
:type language: str
:type contents: str
:type timeout: float
:return: UAST object.
"""
if contents is None:
with open(filename) as fin:
with open(filename, errors=unicode_errors) as fin:
contents = fin.read()
request = ParseUASTRequest(filename=os.path.basename(filename),
content=contents,
Expand Down