Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add setup.py and rearrange package structure
- Allows installing via pip (once we register it) - Allows using onelinerizer as a command line tool - Allows importing onelinerize from onelinerizer
- Loading branch information
Showing
12 changed files
with
125 additions
and
73 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,6 @@ | ||
*.pyc | ||
stocks.csv | ||
*.egg-info | ||
build/ | ||
dist/ | ||
.ve |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
from setuptools import setup | ||
|
||
setup( | ||
name="onelinerizer", | ||
version="1.0.0", | ||
author="Chelsea Voss", | ||
author_email="csvoss@mit.edu", | ||
maintainer="Chelsea Voss and Anders Kaseorg", | ||
maintainer_email="onelinerizer@mit.edu", | ||
url='https://github.com/csvoss/onelinerizer', | ||
description='Convert any Python file into a single line of code.', | ||
packages=['onelinerizer'], | ||
entry_points={ | ||
'console_scripts': ['onelinerizer=onelinerizer.__main__:main'], | ||
}, | ||
test_suite='onelinerizer.runtests', | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
language: python | ||
python: | ||
- "2.7" | ||
script: python runtests.py | ||
script: python setup.py test |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
from .onelinerizer import onelinerize |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
import argparse | ||
import sys | ||
|
||
from .onelinerizer import onelinerize | ||
|
||
def main(): | ||
usage = ['onelinerizer --help', | ||
'onelinerizer [--debug] [infile.py [outfile.py]]', | ||
] | ||
parser = argparse.ArgumentParser(usage='\n '.join(usage), | ||
description=("if infile is given and outfile is not, outfile will be " | ||
"infile_ol.py")) | ||
parser.add_argument('infile', nargs='?') | ||
parser.add_argument('outfile', nargs='?') | ||
parser.add_argument('--debug', action='store_true') | ||
args = parser.parse_args() | ||
original = None | ||
if args.infile is None: | ||
# I have gotten no arguments. Look at sys.stdin | ||
original = sys.stdin.read() | ||
outfilename = None | ||
elif args.outfile is None: | ||
# I have gotten one argument. If there's something to read from | ||
# sys.stdin, read from there. | ||
if args.infile.endswith('.py'): | ||
outfilename = '_ol.py'.join(args.infile.rsplit(".py", 1)) | ||
else: | ||
outfilename = args.infile + '_ol.py' | ||
else: | ||
outfilename = args.outfile | ||
|
||
if original is None: | ||
infile = open(args.infile) | ||
original = infile.read().strip() | ||
infile.close() | ||
onelinerized = onelinerize(original) | ||
if outfilename is None: | ||
print onelinerized | ||
else: | ||
outfi = open(outfilename, 'w') | ||
outfi.write(onelinerized + '\n') | ||
outfi.close() | ||
|
||
if args.debug: | ||
if outfilename is None: | ||
# redirect to sys.stderr if I'm writing outfile to sys.stdout | ||
sys.stdout = sys.stderr | ||
print '--- ORIGINAL ---------------------------------' | ||
print original | ||
print '----------------------------------------------' | ||
scope = {} | ||
try: | ||
exec(original, scope) | ||
except Exception as e: | ||
traceback.print_exc(e) | ||
print '--- ONELINERIZED -----------------------------' | ||
print onelinerized | ||
print '----------------------------------------------' | ||
scope = {} | ||
try: | ||
exec(onelinerized, scope) | ||
except Exception as e: | ||
traceback.print_exc(e) | ||
|
||
if __name__ == '__main__': | ||
main() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
(lambda __g: (lambda __mod: [(setup(name='onelinerizer', version='1.0.0', author='Chelsea Voss', author_email='csvoss@mit.edu', maintainer='Chelsea Voss and Anders Kaseorg', maintainer_email='onelinerizer@mit.edu', url='https://github.com/csvoss/onelinerizer', description='Convert any Python file into a single line of code.', packages=['onelinerizer'], entry_points={'console_scripts': ['onelinerizer=onelinerizer.__main__:main']}, test_suite='onelinerizer.runtests'), None)[1] for __g['setup'] in [(__mod.setup)]][0])(__import__('setuptools', __g, __g, ('setup',), 0)))(globals()) |
This file was deleted.
Oops, something went wrong.