Skip to main content

A simple yet flexible utility to convert indentation.

Project description

A simple yet flexible utility to convert indentation in your source code files.

Why?

I needed to convert indentations in a source code file, and I wasn’t able to find anything really flexible to do this. So, this is an attempt to code something flexible enough to handle any possible use-case.

Installation

From GitHub

To install the latest revision, just clone the repository and run the setup.py script:

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

From PyPI

As usual…:

pip install FixIndents

Usage

fixindents -h

usage: fixindents.py [-h] [--version] (--source-tabs | --source-size SIZE)
                     (--dest-tabs | --dest-size SIZE) --source SOURCE
                     (--dest DEST | --debug) [--exclude EXCLUDE]
                     [--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 EXCLUDE     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.

Exemples

Convert fixindents.py 4-spaces indents to tab indents, write to fixendents_tabs.py:

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

Convert previously created fixindents_tabs.py to 2-spaces indents, write to fixindents_space.py:

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

Convert all files in the FixIndents folder from 4-spaces to tabs, write to the FixIndentsTabs folder:

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

Convert 4-spaces .py files in the FixIndents folder to tabs, write to the FixIndentsTabs folder:

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

Contribute

Feel free to fork this repository and improve the code, any pull-request will be welcome.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

FixIndents-0.1.tar.gz (2.6 kB view details)

Uploaded Source

File details

Details for the file FixIndents-0.1.tar.gz.

File metadata

  • Download URL: FixIndents-0.1.tar.gz
  • Upload date:
  • Size: 2.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for FixIndents-0.1.tar.gz
Algorithm Hash digest
SHA256 a3c67ce02013caf2b4b74c91496050d0f03d7badd601a135d54f94368b3386b9
MD5 c0fc44a18e81dfd9ef129b12d7b40224
BLAKE2b-256 0274b251ce3368ec27933a03ddcf694e2c178ecc63553f4e94cb25aa04e676f9

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page