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 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.

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.2.tar.gz (2.6 kB view details)

Uploaded Source

File details

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

File metadata

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

File hashes

Hashes for FixIndents-0.2.tar.gz
Algorithm Hash digest
SHA256 8aa3993f931cdce22a0748ecd85b195e656ecbbe9d547d6a18055f8b86f5aadc
MD5 508a4c48c23dce9f8981e51ec20ff25a
BLAKE2b-256 bc9e60c4e679e942e9c628bc0a14b6f8e2cdb8633455ecc4d0abb7b0622c5493

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