Skip to content
Snippets Groups Projects
Select Git revision
  • 738cc1efd40a9740648ed216392f39435ef55288
  • master default protected
  • bugfix/fix-return-var-in-find
  • feature/upgrade2
  • v1.10.0
  • v1.8.2
  • v1.8.1
  • v1.8.0
  • 1.7.3
  • v1.7.1
  • v1.6.1
  • v1.6.0
  • v1.5.0
  • v1.4.1
  • v1.3.0
  • v1.2.2
  • v1.2.1
  • v1.2.0
  • v1.0.1
  • v1.0.0
  • v0.0.23
  • v0.0.17
  • v0.0.10
  • v0.0.9
24 results

fix_imports.py

Blame
  • fix_imports.py 824 B
    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_DIR_PATH = (Path(__file__).parent.absolute()).joinpath(PERXIS_DIR_NAME)
    
    
    def main():
        for path, _, files in os.walk(PERXIS_DIR_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()