Pattern Matching for the Python AST
Project description
Pattern Matcher for Python AST
This tool is about finding patterns in AST structures. As such, it may be useful for static analysis and linting.
import pmast
pm = pmast.PatternDispatch()
@pm('FunctionDef.Return')
def on_return(data, fd, ret):
# Store return statement (an ast node) for each function
data[fd.name] = ret
class Foo(object):
def x(self):
return 3
def y(self, foo, bar):
return 4
data = pm.dispatch(Foo)
assert data['x'].value.n == 3
assert data['y'].value.n == 4
The intent here is to be a little bit like XPath for the Python AST module.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
pmast-0.1.1.tar.gz
(2.3 kB
view details)
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
pmast-0.1.1-py3-none-any.whl
(3.5 kB
view details)
File details
Details for the file pmast-0.1.1.tar.gz.
File metadata
- Download URL: pmast-0.1.1.tar.gz
- Upload date:
- Size: 2.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.21.0 setuptools/40.8.0 requests-toolbelt/0.9.1 tqdm/4.31.1 CPython/3.6.1
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
3a32a5543d255b3498de675c05be96b445859a759af02e39002ae7c5f19803a3
|
|
| MD5 |
2b570fe0f01a12ecb0d1c907b92ae304
|
|
| BLAKE2b-256 |
6e539fe26bf5a0076d2c7501af89a206e24abe74d2e8a7dad78e56407fe9e416
|
File details
Details for the file pmast-0.1.1-py3-none-any.whl.
File metadata
- Download URL: pmast-0.1.1-py3-none-any.whl
- Upload date:
- Size: 3.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.21.0 setuptools/40.8.0 requests-toolbelt/0.9.1 tqdm/4.31.1 CPython/3.6.1
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
031ac64e3ab6dbc0c5693c591cb9a4b7c6e0f5faa0289e5a9897525df1dab3c4
|
|
| MD5 |
bfe4f2b50dba3993087c5735fa3ae333
|
|
| BLAKE2b-256 |
5aea6343f8c2e0ee30a2ff07dd18143775b139c24ff9dd35f37999456c451dcf
|