-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest_fix.py
More file actions
32 lines (24 loc) · 909 Bytes
/
Copy pathtest_fix.py
File metadata and controls
32 lines (24 loc) · 909 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
from api_migration_system.core.api_diff_analyzer import APIDiffAnalyzer
analyzer = APIDiffAnalyzer()
old_code = """
def old_api(param):
return param * 2
"""
new_code = """
def new_api(param, scale=1):
return param * 2 * scale
"""
old_entities = analyzer.analyze_source_code(old_code)
new_entities = analyzer.analyze_source_code(new_code)
print("Old entities:", [e.name for e in old_entities])
print("New entities:", [e.name for e in new_entities])
old_key = analyzer._entity_key(old_entities[0])
new_key = analyzer._entity_key(new_entities[0])
print(f"Old key: {old_key}")
print(f"New key: {new_key}")
similarity = analyzer._calculate_similarity(new_key, old_key)
print(f"Similarity: {similarity}")
diffs = analyzer.compare_versions(old_entities, new_entities)
print(f"Number of diffs: {len(diffs)}")
for diff in diffs:
print(f" Type: {diff.change_type}, Description: {diff.description}")