一个简单而灵活的工具来转换缩进。

FixIndents的Python项目详细描述


一个简单而灵活的工具,用于转换源代码文件中的缩进。

为什么?

我需要转换源代码文件中的缩进,但我没有 能够找到任何真正灵活的方式来做到这一点。所以,这是一次尝试 编写足够灵活的处理任何可能的用例的代码。

安装

来自github

要安装最新版本,只需克隆存储库并运行setup.py脚本:

git clone https://github.com/mattoufoutu/FixIndents.git
cd FixIndents
python setup.py install

来自Pypi

像往常一样…:

pip install FixIndents

用法

< H3>固定物-h<EH3>
usage: fixindents.py [-h] [--version] (--source-tabs | --source-size SIZE)
                     (--dest-tabs | --dest-size SIZE) --source SOURCE
                     (--dest DEST | --debug) [--exclude FOLDERS]
                     [--extensions EXTENSIONS]

A simple yet flexible utility to convert indentation.

optional arguments:
  -h, --help            show this help message and exit
  --version             show program's version number and exit
  --source-tabs         Source file uses tabs for indentation.
  --source-size SIZE    Indents size in source file(s).
  --dest-tabs           Use tabs for indentation in destination file.
  --dest-size SIZE      Indents size in destination file.
  --source SOURCE       File of folder from which code should be read.
  --dest DEST           File or folder to which code should be written.
  --debug               Output converted data to console, don't write
                        anything.
  --exclude FOLDERS     Comma-separated list of directory names to ignore.
                        Only useful when SOURCE is a directory.
  --extensions EXTENSIONS
                        Comma-separated list of specific file extensions to
                        convert. Only useful when SOURCE is a directory.

示例

fixindents.py4空格缩进转换为制表符缩进,写入fixendents_tabs.py

fixindents.py --source-size 4 --dest-tabs --source fixindents.py --dest fixindents_tabs.py

将以前创建的fixindents_tabs.py转换为两个空格的缩进,写入fixindents_space.py

fixindents.py --source-tabs --dest-size 2 --source fixindents_tabs.py --dest fixindents_space.py

FixIndents文件夹中的所有文件从4个空格转换为制表符,写入FixIndentsTabs文件夹:

fixindents.py --source-size 4 --dest-tabs --source FixIndents --dest FixIndentsTabs

FixIndents文件夹中的4个空格.py文件转换为制表符,写入FixIndentsTabs文件夹:

fixindents.py --source-size 4 --dest-tabs --source FixIndents --dest FixIndentsTabs --extentions ".py"

贡献

请随意分叉这个存储库并改进代码,任何pull请求 会很受欢迎的。

欢迎加入QQ群-->: 979659372 Python中文网_新手群

推荐PyPI第三方库


热门话题
java数据未插入SQLite数据库   Java中内存有效的对象创建   java在方法内部使用“this”(不用于调用方法、构造函数或变量)   java为什么这里会出现NullPointerException?   在REST中使用HATEOAS导致的java循环依赖   java如何定制spring boot横幅?   Java数字基数计算器(即基数10到基数5)   如果在Kotlin vs Java中声明,用作全局上下文的安卓 MainApplication类将崩溃   用于过滤对象的Java lambda函数   java从字符串数组中获取整数列表   java为什么Maven找不到org。json JPMS自动模块?   java将字符串数组转换为int   仅当与阈值字节匹配时,java才会在映射中填充字符串值