Skip to main content
This is a pre-production deployment of Warehouse. Changes made here affect the production instance of PyPI (pypi.python.org).
Help us improve Python packaging - Donate today!

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.

Release History

Release History

This version
History Node

0.2

History Node

0.1

Download Files

Download Files

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

File Name & Checksum SHA256 Checksum Help Version File Type Upload Date
FixIndents-0.2.tar.gz (2.6 kB) Copy SHA256 Checksum SHA256 Source Aug 22, 2013

Supported By

WebFaction WebFaction Technical Writing Elastic Elastic Search Pingdom Pingdom Monitoring Dyn Dyn DNS Sentry Sentry Error Logging CloudAMQP CloudAMQP RabbitMQ Heroku Heroku PaaS Kabu Creative Kabu Creative UX & Design Fastly Fastly CDN DigiCert DigiCert EV Certificate Rackspace Rackspace Cloud Servers DreamHost DreamHost Log Hosting