跳转到主要内容

面向切面编程

项目描述

# 建议

[面向切面编程](https://en.wikipedia.org/wiki/Aspect-oriented_programming)

## TODO

1. 修复星号导入
1. 补丁已导入的对象 (`patch_project`)

## 使用方法

```python
import aop


def multiply(context)
print(context.args)
print(context.kwargs)
yield
context.result *= 100


aop.register(
handler=multiply,
modules=aop.match(equals='math'),
targets=aop.match(regexp='(sin|cos)')
)
```

Ok, let's check

```python
In [2]: import math

In [3]: math.cos(0)
(0,)
{}
Out[3]: 100.0
```

支持