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

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第三方库


热门话题
javascript通过WebSocket将服务器时间推送到多个客户端   这种java字节转换是如何工作的   数据库错误。sql。SQLEception:参数索引超出范围(1>参数数,为0)   java如何在搜索时过滤选定的viewpager片段中的recyclerview?   java如何使用OpenCV将图像转换为黑白图像并在ANDROID中消除阴影   Spring MVC项目中的java HTTP服务器状态404错误   Spring MVC中的java JSR303自定义约束验证器   java如何基于另一个ArrayList的值显示ArrayList中的特定项?   java如何在firebase messages节点获取最后发送给我的消息?   部署后在google app engine上运行servlet时发生java错误   java如何使用servlet在两个jsp之间发送数据   java日历年中的周是月中的周   从URL读取一个资源并直接返回这些字节作为REST请求的响应,Java 7和spring MVC 3.2不存储内存