Skip to content
This repository was archived by the owner on Mar 8, 2020. It is now read-only.

Commit 3c42cb1

Browse files
committed
Rename the methods to match PB/SDK
1 parent 1e394bd commit 3c42cb1

4 files changed

Lines changed: 11 additions & 11 deletions

File tree

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ API
99
from bblfsh import BblfshClient
1010
1111
client = BblfshClient("0.0.0.0:9432")
12-
print(client.fetch_uast("/path/to/file.py"))
12+
print(client.parse_uast("/path/to/file.py"))
1313
```
1414

1515
Command line

bblfsh/__main__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ def main():
2727
if not args.disable_bblfsh_autorun:
2828
ensure_bblfsh_is_running()
2929
client = BblfshClient(args.endpoint)
30-
print(client.fetch_uast(args.file, args.language))
30+
print(client.parse_uast(args.file, args.language))
3131

3232

3333
if __name__ == "__main__":

bblfsh/client.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -27,27 +27,27 @@ def __init__(self, endpoint):
2727
self._channel = grpc.insecure_channel(endpoint)
2828
self._stub = ProtocolServiceStub(self._channel)
2929

30-
def fetch_uast(self, file_path, language=None, contents=None):
30+
def parse_uast(self, filename, language=None, contents=None):
3131
"""
3232
Queries the Babelfish server and receives the UAST for the specified
3333
file.
3434
35-
:param file_path: The path to the file. Can be arbitrary if contents \
35+
:param filename: The path to the file. Can be arbitrary if contents \
3636
is not None.
3737
:param language: The programming language of the file. Refer to \
3838
https://doc.bblf.sh/languages.html for the list of \
3939
currently supported languages. None means autodetect.
4040
:param contents: The contents of the file. IF None, it is read from \
41-
file_path.
42-
:type file_path: str
41+
filename.
42+
:type filename: str
4343
:type language: str
4444
:type contents: str
4545
:return: UAST object.
4646
"""
4747
if contents is None:
48-
with open(file_path) as fin:
48+
with open(filename) as fin:
4949
contents = fin.read()
50-
request = ParseUASTRequest(filename=os.path.basename(file_path),
50+
request = ParseUASTRequest(filename=os.path.basename(filename),
5151
content=contents,
5252
language=self._scramble_language(language))
5353
response = self._stub.ParseUAST(request)

bblfsh/test.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,17 +26,17 @@ def setUp(self):
2626
self.client = BblfshClient("0.0.0.0:9432")
2727

2828
def testUASTDefaultLanguage(self):
29-
uast = self.client.fetch_uast(__file__)
29+
uast = self.client.parse_uast(__file__)
3030
self._validate_uast(uast)
3131

3232
def testUASTPython(self):
33-
uast = self.client.fetch_uast(__file__, language="Python")
33+
uast = self.client.parse_uast(__file__, language="Python")
3434
self._validate_uast(uast)
3535

3636
def testUASTFileContents(self):
3737
with open(__file__) as fin:
3838
contents = fin.read()
39-
uast = self.client.fetch_uast("file.py", contents=contents)
39+
uast = self.client.parse_uast("file.py", contents=contents)
4040
self._validate_uast(uast)
4141

4242
def _validate_uast(self, uast):

0 commit comments

Comments
 (0)