coreen / normalize-spaces Goto Github PK
View Code? Open in Web Editor NEWnormalize stdin to all spaces or all tabs
normalize stdin to all spaces or all tabs
Generate executable via ``` gcc -Wall -g -std=c11 -o tabReplace tabReplace.c fileProcessing.c replacement.c gcc -Wall -g -std=c11 -o spaceReplace spaceReplace.c fileProcessing.c replacement.c ``` Run with ``` ./tabReplace ./spaceReplace ``` Test file execution with `server.py` Sample Test Output ``` $ ./spaceReplace please enter the number of spaces a TAB character should equal: 3 do you want trailing spaces after TAB conversion to be dropped? [Y/N]: N leaving spaces in conversion requested what type of input will be provided? [F(ile)/S(tdin)]: F please enter the input file to process: server.py how should output be formatted? [I(nline)/E(xternal File)]: E please enter the output file to process: test.py ``` See test.py for the example output
Repro Steps
$ ./spaceReplace
please enter the number of spaces a TAB character should equal:
3
do you want trailing spaces after TAB conversion to be dropped? [Y/N]:
Y
dropping trailing spaces
what type of input will be provided? [F(ile)/S(tdin)]:
F
please enter the input file to process:
server.py
how should output be formatted? [I(nline)/E(xternal File)]:
I
Note: Outputs to tmp.txt
when inline option specified
Expected Output
"""
sample Python 2 Flask server with mix of spaces and tabs
Python 3 does not allow for mixed space/tab use
Python 2 highly recommends conversion to only spaces
(Source: https://www.python.org/dev/peps/pep-0008/#tabs-or-spaces)
The normalize-spaces executable can be used for proper conversion for both
"""
from flask import Flask
app = Flask(__name__)
@app.route('/')
def home():
return 'Started Flask server on port 5000!'
if __name__ == "__main__":
app.run(debug=True)
Actual Output
"""
samplePython2Flaskserverwithmixofspacesandtabs
Python3doesnotallowformixedspace/tabuse
Python2highlyrecommendsconversiontoonlyspaces
(Source:https://www.python.org/dev/peps/pep-0008/#tabs-or-spaces)
Thenormalize-spacesexecutablecanbeusedforproperconversionforboth
"""
fromflaskimportFlask
app=Flask(__name__)
@app.route('/')
defhome():
return'StartedFlaskserveronport5000!'
if__name__=="__main__":
app.run(debug=True)
Currently inline file replacement creates a tmp.txt
file with the processed output. As a consumer, I still need to manually run the following shell commands in order to have the output be truly inline.
rm <inputFilename>
mv tmp.txt <inputFilename>
Ideally this would be done within the program itself.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.