用于更改文件缩进的python实用程序。
indentp的Python项目详细描述
缩进
用于更改文件缩进的python脚本。
依赖关系
此软件包需要安装以下程序:
安装
安装可以通过克隆这个github存储库并运行./install.sh
脚本来完成。
克隆github存储库:
git clone https://github.com/Thijsvanede/indentpy.git
安装脚本:
chmod +x ./install.sh
./install.sh
用法
python脚本可以以多种方式使用:
- 作为安装后的命令行程序。
- 作为源代码中的命令行程序。
- 作为一个python库。
对于所有用例,我们都给出了一个使用示例。
输入特殊字符
当您希望指定诸如\t
或\n
之类的特殊字符时,可以通过组合ctrl+v
和该字符的键将这些字符放入bash
终端。示例:
\t
:ctrl+v
然后是tab
\n
:ctrl+v
然后是enter
\r\n
:ctrl+v
然后是crtl+r
然后是ctrl+v
然后是enter
命令行(已安装)
下面的帮助文件解释了缩进的用法。
Usage: indent [-h] [-w WRITE] [-o ORIG] [-t TO] [-d DELIM] file [file ...]
Change indentation of file(s).
positional arguments:
file File(s) for which to change indentation.
optional arguments:
-h Show this help text.
-d Line delimiter in original file (optional, default='\n').
-o Indentation style in original file (optional, default='\t').
-t Indentation style in desired file (optional, default=' ').
-w File to write output to (optional, default writes to inputfile).
示例
下面的示例以infile.py
为例,将原始的\t
缩进转换为4个空格,最后将其写入outfile.py
。
indent -w outfile.py -o ' ' -t ' ', infile.py
命令行(来自源代码)
要从源代码运行程序,可以同时使用Python 2
和Python 3
。下面的帮助文件解释了indent/indent.py
的用法。
usage: indent.py [-h] [-w WRITE] [-o ORIG] [-t TO] [-d DELIM] file [file ...]
Indentation change tool.
positional arguments:
file File(s) for which to change indentation.
optional arguments:
-h, --help show this help message and exit
-w WRITE, --write WRITE File to write output to (optional, if none is given,
change contents of file.
-o ORIG, --orig ORIG Indentation style in original file (optional, if none
is given, use '\t').
-t TO, --to TO Indentation style in desired file (optional, if none
is given, use 4 spaces).
-d DELIM, --delim DELIM Line delimiter in original file (optional, if none is
given, use '\n')
示例
下面的示例以infile.py
为例,将原始的\t
缩进转换为4个空格,最后将其写入outfile.py
。
python indent/indent.py -w outfile.py -o ' ' -t ' ', infile.py
Python
待办事项