Source Code for Me (

Allows you to paste souce code to blogs! Adapted for Twitter! Here is Search Form in case you missed your code.
Tags: Python,remove_spaces_from_end,remove_fake_tabs,remove_tabs_from_end,replace_tabs_with_spaces,replace_spaces_with_tabs,pps, Created At: 10/24/2016 8:22:06 PMViews:

HTML view:
Copy Source | Copy HTML
#!/usr/bin/env python
import re
import sys
def remove_spaces_from_end(string):
    ret = re.sub(" *$", "", string)
    return ret
def remove_fake_tabs(string, tabWidth):
    ret = re.sub("<-->", "\t", string)
    return ret
def remove_tabs_from_end(string):
    ret = re.sub("\t*$", "", string)
    return ret
def replace_tabs_with_spaces(string, tabWidth):
    ret = re.sub("\t", " "*tabWidth, string)
    return ret
def replace_spaces_with_tabs(string, tabWidth):
    ret = re.sub(" "*tabWidth, "\t", string)
    return ret
def pps():
    tabWidth = 4
    sys.argv[:1] = []
    #print (sys.argv)
    if "-replace" in sys.argv:
    if "-totabs" in sys.argv:
    for srcfile in sys.argv:
        src = open(srcfile, "r")
        buffer = ""
        for line in src:
            buffer += line
            buffer = remove_spaces_from_end(buffer)
            if to_tabs=="yes":
                buffer = replace_spaces_with_tabs(buffer, tabWidth)
                buffer = replace_tabs_with_spaces(buffer, tabWidth)
            buffer = remove_fake_tabs(buffer, tabWidth)
            buffer = remove_tabs_from_end(buffer)
        if replace == "no":
            print (buffer)
            dst = open(srcfile, "w")
if __name__ == "__main__":

Based on Manoli.Net's CodeFormatter. Made by Topbot (c) 2008-2017