File: 0007-Move-exception-handling-and-exit-status-choice-into-.patch

package info (click to toggle)
python-adventure 1.4-1
  • links: PTS, VCS
  • area: main
  • in suites: buster, stretch
  • size: 760 kB
  • ctags: 327
  • sloc: python: 1,991; makefile: 36; sh: 33
file content (57 lines) | stat: -rw-r--r-- 1,478 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
Description: Move exception handling and exit status choice into ‘main’ function.
Author: Ben Finney <ben+python@benfinney.id.au>
Last-Update: 2016-04-11

diff --git a/adventure/__main__.py b/adventure/__main__.py
index 47b741c..0b0d254 100644
--- a/adventure/__main__.py
+++ b/adventure/__main__.py
@@ -84,22 +84,29 @@ def main(argv=None):
 
         :param argv: Sequence of command-line arguments to the process.
             If ``None``, defaults to `sys.argv`.
-        :return: None.
+        :return: Exit status (integer) for the process.
 
         """
     if argv is None:
         argv = sys.argv
 
-    parser = AdventureArgumentParser(prog=argv[0])
-    options = parser.parse_args(argv[1:])
+    exit_status = 0
 
-    game = make_or_resume_game(options.savefile)
+    try:
+        parser = AdventureArgumentParser(prog=argv[0])
+        options = parser.parse_args(argv[1:])
 
-    loop(game)
+        game = make_or_resume_game(options.savefile)
 
+        loop(game)
 
-if __name__ == '__main__':
-    try:
-        main(sys.argv)
     except EOFError:
-        pass
+        # End of command input.
+        exit_status = 0
+
+    return exit_status
+
+
+if __name__ == '__main__':
+    exit_status = main(sys.argv)
+    sys.exit(exit_status)
-- 
Local variables:
coding: utf-8
mode: diff
time-stamp-format: "%:y-%02m-%02d"
time-stamp-start: "^Last-Update:[ 	]+"
time-stamp-end: "$"
time-stamp-line-limit: 20
End:
vim: fileencoding=utf-8 filetype=diff :