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

Commit 22d9675

Browse files
author
Juanjo Alvarez
committed
Renamed some symbols for consistency
1 parent 1cf2327 commit 22d9675

4 files changed

Lines changed: 27 additions & 27 deletions

File tree

bblfsh/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
from bblfsh.client import BblfshClient
2-
from bblfsh.pyuast import find
2+
from bblfsh.pyuast import filter

bblfsh/__main__.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import argparse
22
import sys
33

4-
from bblfsh.pyuast import find
4+
from bblfsh.pyuast import filter
55

66
from bblfsh.client import BblfshClient
77
from bblfsh.launcher import ensure_bblfsh_is_running
@@ -29,7 +29,7 @@ def setup():
2929
return args
3030

3131
def run_query(root, query, mapn, as_array):
32-
result = find(root, query)
32+
result = filter(root, query)
3333

3434
if not result:
3535
print("Nothing found")

bblfsh/pyuast.c

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -23,22 +23,22 @@ static int ReadLen(const void *data, const char *prop)
2323
return PySequence_Size(children_obj);
2424
}
2525

26-
static const char *GetInternalType(const void *node)
26+
static const char *InternalType(const void *node)
2727
{
2828
return ReadStr(node, "internal_type");
2929
}
3030

31-
static const char *GetToken(const void *node)
31+
static const char *Token(const void *node)
3232
{
3333
return ReadStr(node, "token");
3434
}
3535

36-
static int GetChildrenSize(const void *node)
36+
static int ChildrenSize(const void *node)
3737
{
3838
return ReadLen(node, "children");
3939
}
4040

41-
static void *GetChild(const void *data, int index)
41+
static void *ChildAt(const void *data, int index)
4242
{
4343
PyObject *node = (PyObject *)data;
4444
PyObject *children_obj = PyObject_GetAttrString(node, "children");
@@ -49,12 +49,12 @@ static void *GetChild(const void *data, int index)
4949
return PyList_GET_ITEM(seq, index);
5050
}
5151

52-
static int GetRolesSize(const void *node)
52+
static int RolesSize(const void *node)
5353
{
5454
return ReadLen(node, "roles");
5555
}
5656

57-
static uint16_t GetRoleAt(const void *data, int index)
57+
static uint16_t RoleAt(const void *data, int index)
5858
{
5959
PyObject *node = (PyObject *)data;
6060
PyObject *roles_obj = PyObject_GetAttrString(node, "roles");
@@ -64,7 +64,7 @@ static uint16_t GetRoleAt(const void *data, int index)
6464
return (uint16_t)PyLong_AsUnsignedLong(PyList_GET_ITEM(seq, index));
6565
}
6666

67-
static int GetPropertiesSize(const void *data)
67+
static int PropertiesSize(const void *data)
6868
{
6969
PyObject *node = (PyObject *)data;
7070
PyObject *properties_obj = PyObject_GetAttrString(node, "properties");
@@ -74,7 +74,7 @@ static int GetPropertiesSize(const void *data)
7474
return (int)PyLong_AsLong(properties_obj);
7575
}
7676

77-
static const char *GetPropertyAt(const void *data, int index)
77+
static const char *PropertyAT(const void *data, int index)
7878
{
7979
PyObject *node = (PyObject *)data;
8080
PyObject *properties_obj = PyObject_GetAttrString(node, "properties");
@@ -91,7 +91,7 @@ static Uast *ctx;
9191
/////////// PYTHON API //////////////
9292
/////////////////////////////////////
9393

94-
static PyObject *PyFind(PyObject *self, PyObject *args)
94+
static PyObject *PyFilter(PyObject *self, PyObject *args)
9595
{
9696
PyObject *obj = NULL;
9797
const char *query = NULL;
@@ -116,7 +116,7 @@ static PyObject *PyFind(PyObject *self, PyObject *args)
116116
}
117117

118118
static PyMethodDef extension_methods[] = {
119-
{"find", PyFind, METH_VARARGS, "Find a node in the UAST"},
119+
{"filter", PyFilter, METH_VARARGS, "Filter nodes in the UAST using the given query"},
120120
{NULL, NULL, 0, NULL}
121121
};
122122

@@ -135,14 +135,14 @@ static struct PyModuleDef module_def = {
135135
PyMODINIT_FUNC PyInit_pyuast(void)
136136
{
137137
NodeIface iface = {
138-
.InternalType = GetInternalType,
139-
.Token = GetToken,
140-
.ChildrenSize = GetChildrenSize,
141-
.ChildAt = GetChild,
142-
.RolesSize = GetRolesSize,
143-
.RoleAt = GetRoleAt,
144-
.PropertiesSize = GetPropertiesSize,
145-
.PropertyAt = GetPropertyAt,
138+
.InternalType = InternalType,
139+
.Token = Token,
140+
.ChildrenSize = ChildrenSize,
141+
.ChildAt = ChildAt,
142+
.RolesSize = RolesSize,
143+
.RoleAt = RoleAt,
144+
.PropertiesSize = PropertiesSize,
145+
.PropertyAt = PropertyAT,
146146
};
147147

148148
ctx = UastNew(iface);

bblfsh/test.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
import docker
44

5-
from bblfsh import BblfshClient, find
5+
from bblfsh import BblfshClient, filter
66
from bblfsh.github.com.bblfsh.sdk.protocol.generated_pb2 import ParseResponse
77
from github.com.bblfsh.sdk.uast.generated_pb2 import Node
88
from bblfsh.launcher import ensure_bblfsh_is_running
@@ -37,13 +37,13 @@ def testUASTFileContents(self):
3737
contents = fin.read()
3838
uast = self.client.parse("file.py", contents=contents)
3939
self._validate_uast(uast)
40-
self._validate_find(uast)
40+
self._validate_filter(uast)
4141

42-
def testBrokenFind(self):
42+
def testBrokenFilter(self):
4343
from sys import version_info
4444
if version_info[0:2] != (3, 4):
4545
# Skip test 3.4: cant capture SystemException from binary modules
46-
self.assertRaises(SystemError, find, 0, "foo")
46+
self.assertRaises(SystemError, filter, 0, "foo")
4747

4848
def _validate_uast(self, uast):
4949
self.assertIsNotNone(uast)
@@ -53,8 +53,8 @@ def _validate_uast(self, uast):
5353
self.assertEqual(len(uast.errors), 0)
5454
self.assertIsInstance(uast.uast, Node)
5555

56-
def _validate_find(self, uast):
57-
results = find(uast.uast, "//Import[@roleImportDeclaration]//alias")
56+
def _validate_filter(self, uast):
57+
results = filter(uast.uast, "//Import[@roleImportDeclaration]//alias")
5858
self.assertEqual(len(results), 2)
5959
self.assertEqual(results[0].token, "unittest")
6060
self.assertEqual(results[1].token, "docker")

0 commit comments

Comments
 (0)