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程序里面的目录,过滤到第三方库的目录下的文件

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
【社区内容提示】社区部分内容疑似由AI辅助生成,浏览时请结合常识与多方信息审慎甄别。
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

相关阅读更多精彩内容

  • 一、Python简介和环境搭建以及pip的安装 4课时实验课主要内容 【Python简介】: Python 是一个...
    _小老虎_阅读 11,314评论 0 10
  • Spring Cloud为开发人员提供了快速构建分布式系统中一些常见模式的工具(例如配置管理,服务发现,断路器,智...
    卡卡罗2017阅读 136,153评论 19 139
  • Spring Boot 参考指南 介绍 转载自:https://www.gitbook.com/book/qbgb...
    毛宇鹏阅读 47,153评论 6 342
  • feisky云计算、虚拟化与Linux技术笔记posts - 1014, comments - 298, trac...
    不排版阅读 9,414评论 0 5
  • 残阳如血,晚风还没来得及吹过,一场大雨便不期而至。远处的夕阳和倾盆而下的大雨相融合,多少显得有些诡异,然而小巷中的...
    土土豆豆阅读 1,895评论 1 3

友情链接更多精彩内容