Package: python-adventure / 1.4-1

0001-Allow-import-of-adventure.__main__-module.patch Patch series | download
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
Description: Allow import of ‘adventure.__main__’ module.
Author: Ben Finney <ben+python@benfinney.id.au>
Last-Update: 2016-04-11

diff --git a/adventure/__main__.py b/adventure/__main__.py
index d5b5dca..4228ae3 100644
--- a/adventure/__main__.py
+++ b/adventure/__main__.py
@@ -15,12 +15,14 @@ from .game import Game
 
 BAUD = 1200
 
+
 def baudout(s):
     for c in s:
         sleep(9. / BAUD)  # 8 bits + 1 stop bit @ the given baud rate
         stdout.write(c)
         stdout.flush()
 
+
 def loop():
     parser = argparse.ArgumentParser(
         description='Adventure into the Colossal Caves.',
@@ -44,7 +46,9 @@ def loop():
         if words:
             baudout(game.do_command(words))
 
-try:
-    loop()
-except EOFError:
-    pass
+
+if __name__ == '__main__':
+    try:
+        loop()
+    except EOFError:
+        pass
-- 
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 :