OC自动化格式


2018-8-8完善了下,支持过滤目录和文件。
但是使用git的话,测试了,不能基于这个分支一直commit,不然万一有问题,无法保存。
git rebase 和 补丁方案都测试失败了。
感觉看这代码要gg,准备准备后事吧。。做的xcode模板都没用了...还有oclint不添加了...
Filter_DIRS = ['FaceManage']
Filter_FILES = ['AppDelegate.m', 'AppDelegate.h']
#mode = 1
paths = []##过滤的网址
allPaths = []
import os
import sys
import getopt
path = os.getcwd()

def is_filter_the_dir(path):
    """
        过滤目录
        """
    for filter_dir in Filter_DIRS:
        if filter_dir in path:
            return True
    return False

def is_filter_the_file(path):
    """
    过滤文件
    """
    name = os.path.basename(path)
    for filter_file in Filter_FILES:
        if name == filter_file:
            return True
    return False
    

for root, dirs, files in os.walk(path):
    if is_filter_the_dir(root):continue
    for name in files:
        if (name.endswith(".h") or name.endswith(".m")):
            localpath = root + '/' + name
            if is_filter_the_file(localpath):continue
            print localpath
            os.system("clang-format -i %s -style=File" %(localpath))

原始介绍,乙方代码快来了,感觉要个工具格式化下。

clang-format 配置文件,带一个批量格式化项目代码的脚本。 将 .clang-format 和 ClangFormat.py 都放在项目主目录 安装 clang-format
brew install clang-format
运行 ClangFormat.py
python ClangFormat.py
格式化完成。不过我的配置文件我还不是很满意,你可以在我的配置文件上调整。

1.原始地址https://github.com/raozhizhen/clang-format

2.clang-format运行报错 使用自己的clang-forma
3.brew install clang-format 需要安装
4.python ClangFormat.py 运行
5.修改py程序里面的目录,过滤到第三方库的目录下的文件

你可能感兴趣的:(OC自动化格式)