• Stars
    star
    117
  • Rank 301,828 (Top 6 %)
  • Language
    Python
  • License
    MIT License
  • Created over 3 years ago
  • Updated 4 months ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

源码格式自动化调整工具

Formatting 源码格式自动化调整工具

如果喜欢请Star,这是对本开源项目最大的鼓励,谢谢


本文件会自动递归遍历指定文件夹下的所有文件或者指定的文件(默认对.c/.h/.cpp/.hpp,也可以改成你想要的文件类型)进行扫描:

  • 将源文件编码统一为UTF-8

  • 将TAB键替换为4空格

  • 将每行末尾多余的空格删除,并统一换行符为'\n'

  • 将RT-Thread版权信息的截至年份修改至今年(若文件不涉及此问题,程序会自动忽略)

  • 将上海睿赛德版权信息的截至年份修改至今年(若文件不涉及此问题,程序会自动忽略)

安装依赖软件包

pip install -r requirements.txt

本软件为python3源码

使用方法

方法一

直接运行脚本,根据提示信息,输入要扫描的文件夹或者文件名即可。

▸ python formatting.py
Please enter work path or file to format: test_dir

方法二

可以直接在命令行参数中指定需要格式化的文件夹或者文件名

▸ python formatting.py [dir/file_name]

[] 表示内容是可选的

教学视频

https://www.bilibili.com/video/BV1XN411Q7n3

注意

建议git的换行转换设置为:

git config --global core.autocrlf input
git config --global core.safecrlf false
git config --global core.filemode false

使用协议

本软件为MIT协议,可以自由免费使用,无论是个人目的还是商业目的,但是发现本脚本有任何问题,请提PR协助修复。

More Repositories

1

RT-Thread-wrapper-of-uCOS-III

RT-Thread操作系统的uCOS-III兼容层 | uCOS-III RTOS Application Compatibility Layer (ACL) for RT-Thread
C
99
star
2

RT-Thread-wrapper-of-uCOS-II

RT-Thread操作系统的uCOS-II兼容层 | uCOS-II RTOS Application Compatibility Layer (ACL) for RT-Thread
C
33
star
3

rt_vsnprintf_full

rt_vsnprintf完整功能版本 | Fully functional version of rt_vsnprintf
C
16
star
4

minizip

zip manipulation library | zip压缩解压库
C
12
star
5

rt_memcpy_cm

rt_memcpy Cortex-M 汇编加速版
Assembly
11
star
6

Qfplib-M0-full

A free, fast and compact ARM Cortex-M0 floating-point library
Assembly
11
star
7

Qfplib-M0-tiny

A free ARM Cortex-M0 floating-point library in 1 kbyte
Assembly
10
star
8

rt_kprintf_threadsafe

rt_kprintf线程安全版本
C
10
star
9

Qfplib-M3

A free, fast and accurate ARM Cortex-M3 floating-point library
Assembly
7
star
10

termbox

Termbox for RT-Thread | Library for writing text-based user interfaces
C
6
star
11

mem_sandbox

memory sandbox for RT-Thread
C
5
star
12

ki

A text editor in less than 1000 LOC with syntax highlight and search.
C
4
star
13

uC-Modbus-for-RT-Thread

Micrium uC/Modbus for RT-Thread
C
4
star
14

uC-CRC-for-RT-Thread

Micrium uC/CRC for RT-Thread
C
3
star
15

threes

RT-Thread终端益智类游戏 | An indie puzzle video game runs on RT-Thread console
C
2
star
16

donut

a 3D spinning donut
C
2
star
17

uC-Clk-for-RT-Thread

Micrium uC/Clk for RT-Thread
C
2
star
18

uC-Common-for-RT-Thread

Micrium uC/Common for RT-Thread
C
2
star
19

minilibc-4.0.2

RT-Thread 4.0.2 minilibc
C
2
star
20

Ppool

基于pthread的线程池库
C
2
star
21

mysterywolf

profile
1
star
22

cal

A command-line calendar
C
1
star
23

aclock

A Terminal Clock
C
1
star
24

c2048

RT-Thread终端益智类游戏 | An indie puzzle video game runs on RT-Thread console
C
1
star