summaryrefslogtreecommitdiffstats
path: root/Mac
diff options
context:
space:
mode:
authorNeal Norwitz <nnorwitz@gmail.com>2006-03-17 06:49:51 (GMT)
committerNeal Norwitz <nnorwitz@gmail.com>2006-03-17 06:49:51 (GMT)
commitce96f69d69a6020c780145c89a17a8391b63624b (patch)
tree7325a9bfaddf191e49910532df1fa4210c335196 /Mac
parent9e2b9665ae9f94a07da54156c48e2cd411a23746 (diff)
downloadcpython-ce96f69d69a6020c780145c89a17a8391b63624b.zip
cpython-ce96f69d69a6020c780145c89a17a8391b63624b.tar.gz
cpython-ce96f69d69a6020c780145c89a17a8391b63624b.tar.bz2
Get rid of a bunch more raw_input references
Diffstat (limited to 'Mac')
-rw-r--r--Mac/Demo/resources/copyres.py6
-rw-r--r--Mac/Demo/sound/morselib.py40
2 files changed, 33 insertions, 13 deletions
diff --git a/Mac/Demo/resources/copyres.py b/Mac/Demo/resources/copyres.py
index 528ff16..cb1fa8e 100644
--- a/Mac/Demo/resources/copyres.py
+++ b/Mac/Demo/resources/copyres.py
@@ -6,6 +6,12 @@ READ = 1
WRITE = 2
smAllScripts = -3
+def raw_input(prompt):
+ import sys
+ sys.stdout.write(prompt)
+ sys.stdout.flush()
+ return sys.stdin.readline()
+
def copyres(src, dst):
"""Copy resource from src file to dst file."""
diff --git a/Mac/Demo/sound/morselib.py b/Mac/Demo/sound/morselib.py
index 98e2590..3c7493f 100644
--- a/Mac/Demo/sound/morselib.py
+++ b/Mac/Demo/sound/morselib.py
@@ -61,11 +61,10 @@ morsetab = {
}
def morsecode(s):
- from string import lower
m = ''
for c in s:
- c = lower(c)
- if morsetab.has_key(c):
+ c = c.lower()
+ if c in morsetab:
c = morsetab[c] + ' '
else:
c = '? '
@@ -107,9 +106,12 @@ class BaseMorse:
def sendmorse(self, s):
for c in s:
- if c == '.': self.dot()
- elif c == '-': self.dah()
- else: self.pdah()
+ if c == '.':
+ self.dot()
+ elif c == '-':
+ self.dah()
+ else:
+ self.pdah()
self.pdot()
def sendascii(self, s):
@@ -122,8 +124,9 @@ class BaseMorse:
import Audio_mac
class MyAudio(Audio_mac.Play_Audio_mac):
def _callback(self, *args):
- if hasattr(self, 'usercallback'): self.usercallback()
- apply(Audio_mac.Play_Audio_mac._callback, (self,) + args)
+ if hasattr(self, 'usercallback'):
+ self.usercallback()
+ Audio_mac.Play_Audio_mac._callback(self, args)
class MacMorse(BaseMorse):
@@ -169,12 +172,21 @@ class MacMorse(BaseMorse):
def usercallback(self):
if self.morsequeue:
c, self.morsequeue = self.morsequeue[0], self.morsequeue[1:]
- if c == '.': self.dot()
- elif c == '-': self.dah()
- else: self.pdah()
+ if c == '.':
+ self.dot()
+ elif c == '-':
+ self.dah()
+ else:
+ self.pdah()
self.pdot()
+def raw_input(prompt):
+ import sys
+ sys.stdout.write(prompt)
+ sys.stdout.flush()
+ return sys.stdin.readline()
+
def test():
m = MacMorse()
while 1:
@@ -183,6 +195,8 @@ def test():
except (EOFError, KeyboardInterrupt):
break
m.send(line)
- while m.morsequeue: pass
+ while m.morsequeue:
+ pass
-test()
+if __name__ == '__main__':
+ test()