Skip to content

Commit d5edbf0

Browse files
authored
Merge pull request #7 from gjbex/development
Development
2 parents 2018439 + d994cb7 commit d5edbf0

File tree

4 files changed

+36
-0
lines changed

4 files changed

+36
-0
lines changed

Diff for: source-code/README.md

+2
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,8 @@ to create it. There is some material not covered in the presentation as well.
2828
configuration files.
2929
1. `data-formats`: illustrates how to deal with data formats such as CSV
3030
files, binary data and XML.
31+
1. `directory-entrypoint`: illustrates how to define an application entry point in
32+
a directory.
3133
1. `enviroment-variables`: illustrates how to use environment variables to set paths
3234
in a script.
3335
1. `hydra`: Facebook Hydra application framework illustration.

Diff for: source-code/directory-entrypoint/README.md

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
# Directory entry point
2+
3+
Using `__main__.py` as an entry point, the Python interpreter can run a
4+
directory.
5+
6+
## What is it?
7+
8+
1. `messenger`: directory containing the application.
9+
1. `messenger/__main__.py`: Python application entry point.
10+
1. `messenger/messenger.py`: Python module defining some functions for the
11+
application.
+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
import argparse
2+
import messenger
3+
import sys
4+
5+
6+
arg_parser = argparse.ArgumentParser(description='say something to the user')
7+
arg_parser.add_argument('--hello', action='store_true', help='say hello')
8+
arg_parser.add_argument('--bye', action='store_true', help='say bye')
9+
arg_parser.add_argument('name', help='name to talk to')
10+
options = arg_parser.parse_args()
11+
12+
if options.hello:
13+
messenger.say_hello(options.name)
14+
if options.bye:
15+
messenger.say_bye(options.name)
16+
if not (options.hello or options.bye):
17+
print(f"don't know what to say to {options.name}", file=sys.stderr)
18+
sys.exit(1)
+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
def say_hello(name):
2+
print(f'hello {name}')
3+
4+
def say_bye(name):
5+
print(f'bye {name}')

0 commit comments

Comments
 (0)