From 16f16b9c6a06a39af02d282d46e12edbcfac9cf9 Mon Sep 17 00:00:00 2001 From: Russell Stewart Date: Tue, 10 Jun 2014 00:41:27 -0700 Subject: [PATCH 01/11] Changed license to MIT. --- setup.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/setup.py b/setup.py index 82f664a..5fbedfb 100644 --- a/setup.py +++ b/setup.py @@ -6,6 +6,6 @@ version='0.1.5', description='Command line utility for Python', scripts=[os.path.join('bin', 'pythonpy')], - license='Creative Commons Attribution-Noncommercial-Share Alike license', + license='MIT', long_description=open('README.rst').read(), ) From 7ee3e62bd6d82476e3f76f596694d2a7059c3c97 Mon Sep 17 00:00:00 2001 From: Russell Stewart Date: Tue, 10 Jun 2014 11:30:24 -0700 Subject: [PATCH 02/11] 0.1.6 --- setup.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/setup.py b/setup.py index 5fbedfb..2bd295f 100644 --- a/setup.py +++ b/setup.py @@ -3,7 +3,7 @@ setup( name='pythonpy', - version='0.1.5', + version='0.1.6', description='Command line utility for Python', scripts=[os.path.join('bin', 'pythonpy')], license='MIT', From 148b562b9107bd4a4ab801405dab62794e0c6033 Mon Sep 17 00:00:00 2001 From: Russell Stewart Date: Tue, 10 Jun 2014 11:37:39 -0700 Subject: [PATCH 03/11] Fixed readme issue for 0.1.7 --- MANIFEST | 2 +- setup.py | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/MANIFEST b/MANIFEST index 69e500c..c217127 100644 --- a/MANIFEST +++ b/MANIFEST @@ -2,4 +2,4 @@ README.txt setup.py bin/pythonpy -pythonpy/__init__.py +test/test_pythonpy.py diff --git a/setup.py b/setup.py index 2bd295f..2ecc3c4 100644 --- a/setup.py +++ b/setup.py @@ -3,9 +3,9 @@ setup( name='pythonpy', - version='0.1.6', + version='0.1.7', description='Command line utility for Python', scripts=[os.path.join('bin', 'pythonpy')], license='MIT', - long_description=open('README.rst').read(), + #long_description=open('README.rst').read(), ) From 8c0f6d95a1cd20600f96bd05e3ba6787f1d05538 Mon Sep 17 00:00:00 2001 From: Russell Stewart Date: Tue, 10 Jun 2014 11:42:03 -0700 Subject: [PATCH 04/11] Added readme back to setup.py --- setup.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/setup.py b/setup.py index 2ecc3c4..0be56af 100644 --- a/setup.py +++ b/setup.py @@ -3,9 +3,9 @@ setup( name='pythonpy', - version='0.1.7', + version='0.1.8dev', description='Command line utility for Python', scripts=[os.path.join('bin', 'pythonpy')], license='MIT', - #long_description=open('README.rst').read(), + long_description=open('README.txt').read(), ) From 031dc71ea697d3b10c666e1920ba324158e891d7 Mon Sep 17 00:00:00 2001 From: Russell Stewart Date: Tue, 10 Jun 2014 11:50:56 -0700 Subject: [PATCH 05/11] Added README.txt back to setup.py for 0.1.8 --- setup.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/setup.py b/setup.py index 0be56af..182634a 100644 --- a/setup.py +++ b/setup.py @@ -3,7 +3,7 @@ setup( name='pythonpy', - version='0.1.8dev', + version='0.1.8', description='Command line utility for Python', scripts=[os.path.join('bin', 'pythonpy')], license='MIT', From eda9fc713b8a29d0e3d754a7885273be30907428 Mon Sep 17 00:00:00 2001 From: Russell Stewart Date: Tue, 10 Jun 2014 16:22:48 -0700 Subject: [PATCH 06/11] Changed initial example in README to be more interesting. --- README.txt | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/README.txt b/README.txt index 27aef0c..80d6a2f 100644 --- a/README.txt +++ b/README.txt @@ -1,13 +1,9 @@ # install sudo pip install pythonpy; alias py='pythonpy' -# float arithmetic -$ py '3 * 1.5' -4.5 - -# exponentiation -$ py '7**3' -343 +# arithmetic +$ py '24 * 60 ** 2' +86400 # number sequence $ py 'range(3)' From f94a5e33cfaf73934819704cd5833af1d8666982 Mon Sep 17 00:00:00 2001 From: Russell Stewart Date: Tue, 10 Jun 2014 16:25:02 -0700 Subject: [PATCH 07/11] Added floating point example back to readme. --- README.txt | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/README.txt b/README.txt index 80d6a2f..0e22ea5 100644 --- a/README.txt +++ b/README.txt @@ -5,6 +5,10 @@ sudo pip install pythonpy; alias py='pythonpy' $ py '24 * 60 ** 2' 86400 +# floating point numbers +$ py '1.0/98' +0.010204081632 + # number sequence $ py 'range(3)' 0 From 2012ebdfb2c3ced75c09d528e2f50b97f36a3832 Mon Sep 17 00:00:00 2001 From: Russell Stewart Date: Tue, 10 Jun 2014 16:29:33 -0700 Subject: [PATCH 08/11] Updated README.rst to match README.txt --- README.rst | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/README.rst b/README.rst index ceab535..07e4751 100644 --- a/README.rst +++ b/README.rst @@ -15,23 +15,23 @@ For a permanent alias (For Bash users): :: -Float arithmetic +Arithmetic ---------------- :: - $ py '3 * 1.5' - 4.5 + $ py '24 * 60 ** 2' + 86400 :: -Exponentiation +Floating point -------------- :: - $ py '7**3' - 343 + $ py '1.0/98' + 0.010204081632 :: From 9307b2f80b9c7383f65b5912904227a6f7f42e33 Mon Sep 17 00:00:00 2001 From: Russell Stewart Date: Tue, 10 Jun 2014 19:27:00 -0700 Subject: [PATCH 09/11] Changed -sv system to --si and --so system This will make it easier to understand --so and --si as they behave analogously to --jo and --ji --- bin/pythonpy | 57 ++++++++++++++++++++++++++++------------------------ 1 file changed, 31 insertions(+), 26 deletions(-) diff --git a/bin/pythonpy b/bin/pythonpy index 4f03da5..896572a 100755 --- a/bin/pythonpy +++ b/bin/pythonpy @@ -13,34 +13,34 @@ import sys parser = argparse.ArgumentParser() parser.add_argument('evaluation', nargs='?', default='None') parser.add_argument('-c', '--cmd') -parser.add_argument('--ji' '--json_in', - dest='json_input', action='store_const', - const=True, default=False) -parser.add_argument('--jo' '--json_out', - dest='json_output', action='store_const', - const=True, default=False) parser.add_argument('-x' '--line_by_line', dest='line_by_line', action='store_const', const=True, default=False, help='sum the integers (default: find the max)') -parser.add_argument('-sv' '--split_values', - dest='split_values', - default=False, - help='sum the integers (default: find the max)') -parser.add_argument('-l', '--list_of_stdin', - dest='list_of_stdin', action='store_const', - const=True, default=False) parser.add_argument('-fx', '--filter', dest='filter_result', action='store_const', const=True, default=False) +parser.add_argument('-l', '--list_of_stdin', + dest='list_of_stdin', action='store_const', + const=True, default=False) parser.add_argument('--i', '--ignore_exceptions', dest='ignore_exceptions', action='store_const', const=True, default=False) +parser.add_argument('--si', '--split_input', dest='split_input') +parser.add_argument('--so', '--split_output', dest='split_output') +parser.add_argument('--ji' '--json_input', + dest='json_input', action='store_const', + const=True, default=False) +parser.add_argument('--jo' '--json_output', + dest='json_output', action='store_const', + const=True, default=False) args = parser.parse_args() if args.json_input: stdin = (json.loads(x.rstrip()) for x in sys.stdin) +elif args.split_input: + stdin = (re.split(args.split_input, x.rstrip()) for x in sys.stdin) else: stdin = (x.rstrip() for x in sys.stdin) @@ -67,21 +67,26 @@ elif args.list_of_stdin: result = eval(args.evaluation) elif args.filter_result: result = (x for x in stdin if eval(args.evaluation)) -elif args.split_values: - result = (eval(args.evaluation) for sv in - (re.split(args.split_values, x) for x in stdin)) else: result = eval(args.evaluation) +def format(output): + if output == None: + return None + elif args.json_output: + return json.dumps(output) + elif args.split_output: + return args.split_output.join(output) + else: + return output + + if hasattr(result, '__iter__'): for x in result: - if x is not None: - if args.json_output: - print json.dumps(x) - else: - print x -elif result is not None: - if args.json_output: - print json.dumps(result) - else: - print result + formatted = format(x) + if formatted: + print formatted +else: + formatted = format(result) + if formatted: + print formatted From 185c0a2c6264e449086f0bc649c6ef941cbf213a Mon Sep 17 00:00:00 2001 From: Russell Stewart Date: Tue, 10 Jun 2014 19:45:54 -0700 Subject: [PATCH 10/11] Improved the help descriptions --- bin/pythonpy | 36 ++++++++++++++++++++---------------- 1 file changed, 20 insertions(+), 16 deletions(-) diff --git a/bin/pythonpy b/bin/pythonpy index 896572a..5739a03 100755 --- a/bin/pythonpy +++ b/bin/pythonpy @@ -12,28 +12,32 @@ import sys parser = argparse.ArgumentParser() parser.add_argument('evaluation', nargs='?', default='None') -parser.add_argument('-c', '--cmd') -parser.add_argument('-x' '--line_by_line', - dest='line_by_line', action='store_const', +parser.add_argument('-x', dest='lines_of_stdin', action='store_const', const=True, default=False, - help='sum the integers (default: find the max)') -parser.add_argument('-fx', '--filter', - dest='filter_result', action='store_const', - const=True, default=False) -parser.add_argument('-l', '--list_of_stdin', - dest='list_of_stdin', action='store_const', - const=True, default=False) + help='treat each row as x') +parser.add_argument('-fx', dest='filter_result', action='store_const', + const=True, default=False, + help='keep rows satisfying condition(x)') +parser.add_argument('-l', dest='list_of_stdin', action='store_const', + const=True, default=False, + help='treat list of stdin as l') +parser.add_argument('-c', dest='cmd', help='run code before expression') parser.add_argument('--i', '--ignore_exceptions', dest='ignore_exceptions', action='store_const', - const=True, default=False) -parser.add_argument('--si', '--split_input', dest='split_input') -parser.add_argument('--so', '--split_output', dest='split_output') + const=True, default=False, + help='') +parser.add_argument('--si', '--split_input', dest='split_input', + help='pre-process each row with re.split(delimiter)') +parser.add_argument('--so', '--split_output', dest='split_output', + help='post-process each row with delimiter.join(row)') parser.add_argument('--ji' '--json_input', dest='json_input', action='store_const', - const=True, default=False) + const=True, default=False, + help='pre-process each row with json.loads(row)') parser.add_argument('--jo' '--json_output', dest='json_output', action='store_const', - const=True, default=False) + const=True, default=False, + help='post-process each row with json.dumps(row)') args = parser.parse_args() @@ -52,7 +56,7 @@ if args.cmd: if args.cmd: exec(args.cmd) -if args.line_by_line: +if args.lines_of_stdin: if args.ignore_exceptions: def safe_eval(text, x): try: From b072a33b22de4c0b348c5550288de005c796cacb Mon Sep 17 00:00:00 2001 From: Low Kian Seong Date: Thu, 12 Jun 2014 15:48:27 +0800 Subject: [PATCH 11/11] Update setup.py I forgot to add this the other day for you, the url that links from pypi to github. --- setup.py | 1 + 1 file changed, 1 insertion(+) diff --git a/setup.py b/setup.py index 182634a..9aea9f0 100644 --- a/setup.py +++ b/setup.py @@ -8,4 +8,5 @@ scripts=[os.path.join('bin', 'pythonpy')], license='MIT', long_description=open('README.txt').read(), + url='https://github.com/Russell91/pythonpy', )