From 7f748cce132934b5a24b1828af3840cc313bf2da Mon Sep 17 00:00:00 2001 From: krishnatray Date: Sun, 26 Apr 2020 20:54:08 -0700 Subject: [PATCH] added shell script to pull data from upstream added directory py --- pull_upstream.sh | 3 ++ py/hello_world.py | 72 +++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 75 insertions(+) create mode 100755 pull_upstream.sh create mode 100755 py/hello_world.py diff --git a/pull_upstream.sh b/pull_upstream.sh new file mode 100755 index 000000000..9b6870d33 --- /dev/null +++ b/pull_upstream.sh @@ -0,0 +1,3 @@ +#git remote add upstream https://github.com/kyclark/tiny_python_projects.git +git pull upstream master +git push diff --git a/py/hello_world.py b/py/hello_world.py new file mode 100755 index 000000000..da19cfe9f --- /dev/null +++ b/py/hello_world.py @@ -0,0 +1,72 @@ +#!/usr/bin/env python3 +""" +Author : sushil +Date : 2020-04-05 +Purpose: Rock the Casbah +""" + +import argparse + + +# -------------------------------------------------- +def get_args(): + """Get command-line arguments""" + + parser = argparse.ArgumentParser( + description='Rock the Casbah', + formatter_class=argparse.ArgumentDefaultsHelpFormatter) + + parser.add_argument('positional', + metavar='str', + help='A positional argument') + + parser.add_argument('-a', + '--arg', + help='A named string argument', + metavar='str', + type=str, + default='') + + parser.add_argument('-i', + '--int', + help='A named integer argument', + metavar='int', + type=int, + default=0) + + parser.add_argument('-f', + '--file', + help='A readable file', + metavar='FILE', + type=argparse.FileType('r'), + default=None) + + parser.add_argument('-o', + '--on', + help='A boolean flag', + action='store_true') + + return parser.parse_args() + + +# -------------------------------------------------- +def main(): + """Make a jazz noise here""" + + args = get_args() + str_arg = args.arg + int_arg = args.int + file_arg = args.file + flag_arg = args.on + pos_arg = args.positional + + print(f'str_arg = "{str_arg}"') + print(f'int_arg = "{int_arg}"') + print('file_arg = "{}"'.format(file_arg.name if file_arg else '')) + print(f'flag_arg = "{flag_arg}"') + print(f'positional = "{pos_arg}"') + + +# -------------------------------------------------- +if __name__ == '__main__': + main()