redis-om-python/make_sync.py

42 lines
994 B
Python
Raw Normal View History

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