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

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 Vaadin编译小部件(插件)   java Apache Camel库是否会长期保存内存?   java什么是`。伊娃的档案?如何处理它来生成类?   如何通过反射确定Java类是否是抽象的   来自JDK 1.8.0_161的macos Java任务控制在Mac OS X上启动时冻结   java在httpSession中存储扩展对象   SpringBootApplication没有获取java@Service注释bean   java我想从具有innermap和outermap关系的hashmap创建一个hashmap?   java如何强制Eclipse链接创建完全相同类名的表?   java在pojo对象中使用映射未映射请求   java DOM W3c XML元素解析空属性   java我们可以将文本区域中的数据保存到文本文件中吗?   java如何链接首选项。xml到我的表格布局中的settingsTabFragment?   java我想设置一个私有字段来测试函数   接口中的java继承   macos我有一台mac,而java博士根本不运行我的程序   java解析时差   spring应用程序文件上传的java Jar可执行文件失败?   java向Git推送什么?