2021-11-10 00:59:10 +01:00
|
|
|
import os
|
|
|
|
from pathlib import Path
|
|
|
|
|
|
|
|
import unasync
|
|
|
|
|
2021-11-10 20:31:02 +01:00
|
|
|
ADDITIONAL_REPLACEMENTS = {
|
|
|
|
"aredis_om": "redis_om",
|
2022-08-10 14:21:13 +02:00
|
|
|
"async_redis": "sync_redis",
|
2021-11-10 20:31:02 +01:00
|
|
|
":tests.": ":tests_sync.",
|
2022-05-01 16:03:05 +02:00
|
|
|
"pytest_asyncio": "pytest",
|
2022-05-01 17:15:50 +02:00
|
|
|
"py_test_mark_asyncio": "py_test_mark_sync",
|
2021-11-10 20:31:02 +01:00
|
|
|
}
|
|
|
|
|
2021-11-10 00:59:10 +01:00
|
|
|
|
|
|
|
def main():
|
|
|
|
rules = [
|
|
|
|
unasync.Rule(
|
|
|
|
fromdir="/aredis_om/",
|
|
|
|
todir="/redis_om/",
|
2021-11-10 20:31:02 +01:00
|
|
|
additional_replacements=ADDITIONAL_REPLACEMENTS,
|
|
|
|
),
|
|
|
|
unasync.Rule(
|
|
|
|
fromdir="/tests/",
|
|
|
|
todir="/tests_sync/",
|
|
|
|
additional_replacements=ADDITIONAL_REPLACEMENTS,
|
2021-11-10 00:59:10 +01:00
|
|
|
),
|
|
|
|
]
|
2022-05-01 17:15:50 +02:00
|
|
|
filepaths = []
|
2022-08-10 14:21:13 +02:00
|
|
|
for root, _, filenames in os.walk(Path(__file__).absolute().parent):
|
2022-05-01 17:15:50 +02:00
|
|
|
for filename in filenames:
|
2022-08-10 14:21:13 +02:00
|
|
|
if filename.rpartition(".")[-1] in (
|
|
|
|
"py",
|
|
|
|
"pyi",
|
|
|
|
):
|
2022-05-01 17:15:50 +02:00
|
|
|
filepaths.append(os.path.join(root, filename))
|
2021-11-10 00:59:10 +01:00
|
|
|
|
2022-05-01 17:15:50 +02:00
|
|
|
unasync.unasync_files(filepaths, rules)
|
2021-11-10 00:59:10 +01:00
|
|
|
|
|
|
|
|
|
|
|
if __name__ == "__main__":
|
|
|
|
main()
|