2021-04-13 10:45:05 +02:00
|
|
|
# Copyright: Ankitects Pty Ltd and contributors
|
|
|
|
# License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
|
|
|
|
|
2020-03-04 12:34:18 +01:00
|
|
|
# a quick script to compare methods in the two schedulers
|
|
|
|
|
|
|
|
import inspect
|
2020-11-01 05:26:58 +01:00
|
|
|
import sys
|
|
|
|
from difflib import SequenceMatcher, unified_diff
|
|
|
|
|
2020-03-04 12:34:18 +01:00
|
|
|
from anki.sched import Scheduler as S1
|
|
|
|
from anki.schedv2 import Scheduler as S2
|
|
|
|
|
|
|
|
s1map = {}
|
|
|
|
for k, v in S1.__dict__.items():
|
|
|
|
if not callable(v):
|
|
|
|
continue
|
|
|
|
s1map[k] = v
|
|
|
|
|
|
|
|
s2map = {}
|
|
|
|
for k, v in S2.__dict__.items():
|
|
|
|
if not callable(v):
|
|
|
|
continue
|
|
|
|
s2map[k] = v
|
|
|
|
|
|
|
|
for k, v in s1map.items():
|
|
|
|
if k not in s2map:
|
|
|
|
continue
|
|
|
|
|
|
|
|
s1b = inspect.getsource(v)
|
|
|
|
s2b = inspect.getsource(s2map[k])
|
|
|
|
ratio = SequenceMatcher(None, s1b, s2b).ratio()
|
|
|
|
|
|
|
|
if ratio >= 0.90:
|
|
|
|
print("*" * 80)
|
|
|
|
print(k, "%d%%" % (ratio * 100))
|
|
|
|
sys.stdout.writelines(
|
|
|
|
"\n".join(unified_diff(s1b.splitlines(), s2b.splitlines(), lineterm=""))
|
|
|
|
)
|
|
|
|
print()
|