Skip to content
Snippets Groups Projects
Select Git revision
  • f8dfaaad37f61012fc0c7ea139c4d712211231bf
  • master default protected
  • suffa/cumulantfourth_order_correction_with_psm
  • mr_refactor_wfb
  • Sparse
  • WallLaw
  • improved_comm
  • release/1.3.7
  • release/1.3.6
  • release/1.3.5
  • release/1.3.4
  • release/1.3.3
  • release/1.3.2
  • release/1.3.1
  • release/1.3
  • release/1.2
  • release/1.1.1
  • release/1.1
  • release/1.0.1
  • release/1.0
  • release/0.4.4
  • release/0.4.3
  • release/0.4.2
  • release/0.4.1
  • release/0.4.0
  • release/0.3.4
  • release/0.3.3
27 results

stencils.py

Blame
  • clang_format.py 749 B
    import subprocess
    import shutil
    
    from ..configuration import SfgCodeStyle
    from ..exceptions import SfgException
    
    
    def invoke_clang_format(code: str, codestyle: SfgCodeStyle) -> str:
        args = [codestyle.clang_format_binary, f"--style={codestyle.code_style}"]
    
        if not shutil.which("clang-format"):
            if codestyle.force_clang_format:
                raise SfgException("Could not find clang-format binary.")
            else:
                return code
    
        result = subprocess.run(args, input=code, capture_output=True, text=True)
    
        if result.returncode != 0:
            if codestyle.force_clang_format:
                raise SfgException(f"Call to clang-format failed: \n{result.stderr}")
            else:
                return code
    
        return result.stdout