cpg2py 1.2.0__tar.gz → 1.2.1__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (29) hide show
  1. {cpg2py-1.2.0/cpg2py.egg-info → cpg2py-1.2.1}/PKG-INFO +2 -3
  2. {cpg2py-1.2.0 → cpg2py-1.2.1}/cpg2py/_abc/graph.py +10 -15
  3. {cpg2py-1.2.0 → cpg2py-1.2.1}/cpg2py/_cpg/graph.py +7 -7
  4. {cpg2py-1.2.0 → cpg2py-1.2.1/cpg2py.egg-info}/PKG-INFO +2 -3
  5. {cpg2py-1.2.0 → cpg2py-1.2.1}/pyproject.toml +1 -1
  6. {cpg2py-1.2.0 → cpg2py-1.2.1}/LICENSE +0 -0
  7. {cpg2py-1.2.0 → cpg2py-1.2.1}/MANIFEST.in +0 -0
  8. {cpg2py-1.2.0 → cpg2py-1.2.1}/README.md +0 -0
  9. {cpg2py-1.2.0 → cpg2py-1.2.1}/cpg2py/__init__.py +0 -0
  10. {cpg2py-1.2.0 → cpg2py-1.2.1}/cpg2py/_abc/__init__.py +0 -0
  11. {cpg2py-1.2.0 → cpg2py-1.2.1}/cpg2py/_abc/edge.py +0 -0
  12. {cpg2py-1.2.0 → cpg2py-1.2.1}/cpg2py/_abc/node.py +0 -0
  13. {cpg2py-1.2.0 → cpg2py-1.2.1}/cpg2py/_abc/storage.py +0 -0
  14. {cpg2py-1.2.0 → cpg2py-1.2.1}/cpg2py/_cpg/__init__.py +0 -0
  15. {cpg2py-1.2.0 → cpg2py-1.2.1}/cpg2py/_cpg/edge.py +0 -0
  16. {cpg2py-1.2.0 → cpg2py-1.2.1}/cpg2py/_cpg/node.py +0 -0
  17. {cpg2py-1.2.0 → cpg2py-1.2.1}/cpg2py/_exceptions.py +0 -0
  18. {cpg2py-1.2.0 → cpg2py-1.2.1}/cpg2py/_logger.py +0 -0
  19. {cpg2py-1.2.0 → cpg2py-1.2.1}/cpg2py.egg-info/SOURCES.txt +0 -0
  20. {cpg2py-1.2.0 → cpg2py-1.2.1}/cpg2py.egg-info/dependency_links.txt +0 -0
  21. {cpg2py-1.2.0 → cpg2py-1.2.1}/cpg2py.egg-info/requires.txt +0 -0
  22. {cpg2py-1.2.0 → cpg2py-1.2.1}/cpg2py.egg-info/top_level.txt +0 -0
  23. {cpg2py-1.2.0 → cpg2py-1.2.1}/setup.cfg +0 -0
  24. {cpg2py-1.2.0 → cpg2py-1.2.1}/tests/test_edge.py +0 -0
  25. {cpg2py-1.2.0 → cpg2py-1.2.1}/tests/test_exceptions.py +0 -0
  26. {cpg2py-1.2.0 → cpg2py-1.2.1}/tests/test_generics.py +0 -0
  27. {cpg2py-1.2.0 → cpg2py-1.2.1}/tests/test_graph.py +0 -0
  28. {cpg2py-1.2.0 → cpg2py-1.2.1}/tests/test_node.py +0 -0
  29. {cpg2py-1.2.0 → cpg2py-1.2.1}/tests/test_storage.py +0 -0
@@ -1,6 +1,6 @@
1
- Metadata-Version: 2.4
1
+ Metadata-Version: 2.1
2
2
  Name: cpg2py
3
- Version: 1.2.0
3
+ Version: 1.2.1
4
4
  Summary: A graph-based data structure designed for querying CSV files in Joern format in Python
5
5
  Author-email: samhsu-dev <yxu166@jhu.edu>
6
6
  License: MIT License
@@ -52,7 +52,6 @@ Requires-Dist: pytest-cov>=4.0.0; extra == "dev"
52
52
  Requires-Dist: black>=23.0.0; extra == "dev"
53
53
  Requires-Dist: isort>=5.12.0; extra == "dev"
54
54
  Requires-Dist: pylint>=2.17.0; extra == "dev"
55
- Dynamic: license-file
56
55
 
57
56
  # cpg2py
58
57
 
@@ -16,6 +16,8 @@ _EdgeType = TypeVar("_EdgeType", bound=AbcEdgeQuerier, covariant=True)
16
16
  # Type variables for concrete implementations (invariant)
17
17
  _ConcreteNodeType = TypeVar("_ConcreteNodeType", bound=AbcNodeQuerier)
18
18
  _ConcreteEdgeType = TypeVar("_ConcreteEdgeType", bound=AbcEdgeQuerier)
19
+ _NodeCondition = Callable[[_NodeType], bool]
20
+ _EdgeCondition = Callable[[_EdgeType], bool]
19
21
 
20
22
 
21
23
  class AbcGraphQuerier(abc.ABC, Generic[_ConcreteNodeType, _ConcreteEdgeType]):
@@ -36,15 +38,8 @@ class AbcGraphQuerier(abc.ABC, Generic[_ConcreteNodeType, _ConcreteEdgeType]):
36
38
  _ConcreteNodeType: The concrete node type returned by node() and related methods
37
39
  _ConcreteEdgeType: The concrete edge type returned by edge() and used in conditions
38
40
  """
39
-
40
- __NodeCondition = Callable[[_NodeType], bool]
41
- __EdgeCondition = Callable[[_EdgeType], bool]
42
-
43
41
  __always_true = lambda _: True
44
42
 
45
- __NodesResult = Iterable[_ConcreteNodeType]
46
- __EdgesResult = Iterable[_ConcreteEdgeType]
47
-
48
43
  def __init__(self, target: Storage, maxdepth: int = -1) -> None:
49
44
  """
50
45
  Initializes a graph querier.
@@ -95,7 +90,7 @@ class AbcGraphQuerier(abc.ABC, Generic[_ConcreteNodeType, _ConcreteEdgeType]):
95
90
  raise NotImplementedError
96
91
 
97
92
  def nodes(
98
- self, who_satisifies: __NodeCondition = __always_true
93
+ self, who_satisifies: _NodeCondition = __always_true
99
94
  ) -> Iterable[_ConcreteNodeType]:
100
95
  """
101
96
  Returns all nodes matching the condition.
@@ -112,7 +107,7 @@ class AbcGraphQuerier(abc.ABC, Generic[_ConcreteNodeType, _ConcreteEdgeType]):
112
107
  yield cur_node
113
108
 
114
109
  def first_node(
115
- self, who_satisifies: __NodeCondition = __always_true
110
+ self, who_satisifies: _NodeCondition = __always_true
116
111
  ) -> Optional[_ConcreteNodeType]:
117
112
  """
118
113
  Returns the first node matching the condition.
@@ -126,7 +121,7 @@ class AbcGraphQuerier(abc.ABC, Generic[_ConcreteNodeType, _ConcreteEdgeType]):
126
121
  return next(self.nodes(who_satisifies), None)
127
122
 
128
123
  def edges(
129
- self, who_satisifies: __EdgeCondition = __always_true
124
+ self, who_satisifies: _EdgeCondition = __always_true
130
125
  ) -> Iterable[_ConcreteEdgeType]:
131
126
  """
132
127
  Returns all edges matching the condition.
@@ -143,7 +138,7 @@ class AbcGraphQuerier(abc.ABC, Generic[_ConcreteNodeType, _ConcreteEdgeType]):
143
138
  yield cur_edge
144
139
 
145
140
  def succ(
146
- self, of: _ConcreteNodeType, who_satisifies: __EdgeCondition = __always_true
141
+ self, of: _ConcreteNodeType, who_satisifies: _EdgeCondition = __always_true
147
142
  ) -> Iterable[_ConcreteNodeType]:
148
143
  """
149
144
  Returns successor nodes connected to the input node.
@@ -163,7 +158,7 @@ class AbcGraphQuerier(abc.ABC, Generic[_ConcreteNodeType, _ConcreteEdgeType]):
163
158
  yield node
164
159
 
165
160
  def prev(
166
- self, of: _ConcreteNodeType, who_satisifies: __EdgeCondition = __always_true
161
+ self, of: _ConcreteNodeType, who_satisifies: _EdgeCondition = __always_true
167
162
  ) -> Iterable[_ConcreteNodeType]:
168
163
  """
169
164
  Returns predecessor nodes connected to the input node.
@@ -183,7 +178,7 @@ class AbcGraphQuerier(abc.ABC, Generic[_ConcreteNodeType, _ConcreteEdgeType]):
183
178
  yield node
184
179
 
185
180
  def __bfs_search(
186
- self, root: _ConcreteNodeType, condition: __EdgeCondition, reverse: bool
181
+ self, root: _ConcreteNodeType, condition: _EdgeCondition, reverse: bool
187
182
  ) -> Iterable[_ConcreteNodeType]:
188
183
  """
189
184
  Returns nodes from src node by BFS order (src node not included).
@@ -217,7 +212,7 @@ class AbcGraphQuerier(abc.ABC, Generic[_ConcreteNodeType, _ConcreteEdgeType]):
217
212
  yield cur_node
218
213
 
219
214
  def descendants(
220
- self, src: _ConcreteNodeType, condition: __EdgeCondition = __always_true
215
+ self, src: _ConcreteNodeType, condition: _EdgeCondition = __always_true
221
216
  ) -> Iterable[_ConcreteNodeType]:
222
217
  """
223
218
  Returns descendants from src node by BFS order (src node not included).
@@ -232,7 +227,7 @@ class AbcGraphQuerier(abc.ABC, Generic[_ConcreteNodeType, _ConcreteEdgeType]):
232
227
  return self.__bfs_search(src, condition, reverse=False)
233
228
 
234
229
  def ancestors(
235
- self, src: _ConcreteNodeType, condition: __EdgeCondition = __always_true
230
+ self, src: _ConcreteNodeType, condition: _EdgeCondition = __always_true
236
231
  ) -> Iterable[_ConcreteNodeType]:
237
232
  """
238
233
  Returns ancestors from src node by BFS order (src node not included).
@@ -22,7 +22,7 @@ class CpgGraph(AbcGraphQuerier[CpgNode, CpgEdge]):
22
22
  throughout the graph operations.
23
23
  """
24
24
 
25
- __EdgeCondition = Callable[[CpgEdge], bool]
25
+ _EdgeCondition = Callable[[CpgEdge], bool]
26
26
  __always_true = lambda _: True
27
27
 
28
28
  def __init__(self, target: Storage) -> None:
@@ -104,7 +104,7 @@ class CpgGraph(AbcGraphQuerier[CpgNode, CpgEdge]):
104
104
  logger.error("Cannot find top file node from node %s", of_nid)
105
105
  raise TopFileNotFoundError(of_nid)
106
106
 
107
- def succ(self, of: CpgNode, who_satisifies: __EdgeCondition = __always_true) -> Iterable[CpgNode]:
107
+ def succ(self, of: CpgNode, who_satisifies: _EdgeCondition = __always_true) -> Iterable[CpgNode]:
108
108
  """
109
109
  Returns successor nodes connected to the input node.
110
110
 
@@ -117,7 +117,7 @@ class CpgGraph(AbcGraphQuerier[CpgNode, CpgEdge]):
117
117
  """
118
118
  return super().succ(of, who_satisifies)
119
119
 
120
- def prev(self, of: CpgNode, who_satisifies: __EdgeCondition = __always_true) -> Iterable[CpgNode]:
120
+ def prev(self, of: CpgNode, who_satisifies: _EdgeCondition = __always_true) -> Iterable[CpgNode]:
121
121
  """
122
122
  Returns predecessor nodes connected to the input node.
123
123
 
@@ -130,7 +130,7 @@ class CpgGraph(AbcGraphQuerier[CpgNode, CpgEdge]):
130
130
  """
131
131
  return super().prev(of, who_satisifies)
132
132
 
133
- def children(self, of: CpgNode, extra: __EdgeCondition = __always_true) -> Iterable[CpgNode]:
133
+ def children(self, of: CpgNode, extra: _EdgeCondition = __always_true) -> Iterable[CpgNode]:
134
134
  """
135
135
  Returns child nodes connected via PARENT_OF edges.
136
136
 
@@ -143,7 +143,7 @@ class CpgGraph(AbcGraphQuerier[CpgNode, CpgEdge]):
143
143
  """
144
144
  return self.succ(of, lambda e: extra(e) and (e.type == "PARENT_OF"))
145
145
 
146
- def parent(self, of: CpgNode, extra: __EdgeCondition = __always_true) -> Iterable[CpgNode]:
146
+ def parent(self, of: CpgNode, extra: _EdgeCondition = __always_true) -> Iterable[CpgNode]:
147
147
  """
148
148
  Returns parent nodes connected via PARENT_OF edges.
149
149
 
@@ -156,7 +156,7 @@ class CpgGraph(AbcGraphQuerier[CpgNode, CpgEdge]):
156
156
  """
157
157
  return self.prev(of, lambda e: extra(e) and (e.type == "PARENT_OF"))
158
158
 
159
- def flow_to(self, of: CpgNode, extra: __EdgeCondition = __always_true) -> Iterable[CpgNode]:
159
+ def flow_to(self, of: CpgNode, extra: _EdgeCondition = __always_true) -> Iterable[CpgNode]:
160
160
  """
161
161
  Returns successor nodes connected via FLOWS_TO edges.
162
162
 
@@ -169,7 +169,7 @@ class CpgGraph(AbcGraphQuerier[CpgNode, CpgEdge]):
169
169
  """
170
170
  return self.succ(of, lambda e: extra(e) and (e.type == "FLOWS_TO"))
171
171
 
172
- def flow_from(self, of: CpgNode, extra: __EdgeCondition = __always_true) -> Iterable[CpgNode]:
172
+ def flow_from(self, of: CpgNode, extra: _EdgeCondition = __always_true) -> Iterable[CpgNode]:
173
173
  """
174
174
  Returns predecessor nodes connected via FLOWS_TO edges.
175
175
 
@@ -1,6 +1,6 @@
1
- Metadata-Version: 2.4
1
+ Metadata-Version: 2.1
2
2
  Name: cpg2py
3
- Version: 1.2.0
3
+ Version: 1.2.1
4
4
  Summary: A graph-based data structure designed for querying CSV files in Joern format in Python
5
5
  Author-email: samhsu-dev <yxu166@jhu.edu>
6
6
  License: MIT License
@@ -52,7 +52,6 @@ Requires-Dist: pytest-cov>=4.0.0; extra == "dev"
52
52
  Requires-Dist: black>=23.0.0; extra == "dev"
53
53
  Requires-Dist: isort>=5.12.0; extra == "dev"
54
54
  Requires-Dist: pylint>=2.17.0; extra == "dev"
55
- Dynamic: license-file
56
55
 
57
56
  # cpg2py
58
57
 
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
4
4
 
5
5
  [project]
6
6
  name = "cpg2py"
7
- version = "1.2.0"
7
+ version = "1.2.1"
8
8
  description = "A graph-based data structure designed for querying CSV files in Joern format in Python"
9
9
  readme = "README.md"
10
10
  authors = [
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes