Skip to content
Snippets Groups Projects
Commit 3bfb1141 authored by antondmtvch's avatar antondmtvch
Browse files

Реализован скрипт замены некорректных импортов

parent 38fdb61e
No related branches found
No related tags found
No related merge requests found
...@@ -23,7 +23,7 @@ clean-build: ...@@ -23,7 +23,7 @@ clean-build:
rm -fr dist/ rm -fr dist/
rm -fr .eggs/ rm -fr .eggs/
find . -name '*.egg-info' -exec rm -fr {} + find . -name '*.egg-info' -exec rm -fr {} +
find . -name '*.egg' -exec rm -f {} + find . -name '*.egg' -exec rm -f {} + || true
clean-pyc: clean-pyc:
find . -name '*.pyc' -exec rm -f {} + find . -name '*.pyc' -exec rm -f {} +
...@@ -62,3 +62,4 @@ release: dist ...@@ -62,3 +62,4 @@ release: dist
install: clean generate install-requirements install: clean generate install-requirements
python setup.py install python setup.py install
python fix_imports.py
import re
import os
from pathlib import Path
REGEXP = re.compile(
r"(from )"
r"("
r"clients|collaborators|collections|common|delivery|environments|extensions|files|images|invitations"
r"|items|locales|members|organizations|references|roles|spaces|status|users|versions.+|"
r")"
r"( import.*pb2)"
)
PERXIS_DIR_NAME = "perxis"
PERXIS_PATH = (Path(__file__).parent.absolute()).joinpath(PERXIS_DIR_NAME)
def main():
for path, _, files in os.walk(PERXIS_PATH):
for name in files:
file_path = os.path.join(path, name)
with open(file_path, "r+") as f:
text = f.read()
result = re.sub(REGEXP, rf"\1{PERXIS_DIR_NAME}.\2\3", text)
f.seek(0)
f.write(result)
if __name__ == "__main__":
main()
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment