forked from PaddlePaddle/Paddle
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
46 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
#!/usr/bin/env python | ||
from __future__ import print_function | ||
import difflib | ||
import sys | ||
|
||
with open(sys.argv[1], 'r') as f: | ||
origin = f.read() | ||
origin = origin.splitlines() | ||
|
||
with open(sys.argv[2], 'r') as f: | ||
new = f.read() | ||
new = new.splitlines() | ||
|
||
differ = difflib.Differ() | ||
result = differ.compare(origin, new) | ||
|
||
error = False | ||
print('API Difference is: ') | ||
for each_diff in result: | ||
if each_diff[0] in ['-', '?']: # delete or change API is not allowed | ||
error = True | ||
elif each_diff[0] == '+': | ||
# only new layers is allowed. | ||
if not each_diff.startswith('+ paddle.fluid.layers.'): | ||
error = True | ||
|
||
if each_diff[0] != ' ': | ||
print(each_diff) | ||
|
||
if error: | ||
sys.exit(1) |