summaryrefslogtreecommitdiffstats
path: root/Demo/scripts
diff options
context:
space:
mode:
authorGeorg Brandl <georg@python.org>2010-08-02 22:55:17 (GMT)
committerGeorg Brandl <georg@python.org>2010-08-02 22:55:17 (GMT)
commit6faacd3bba36e682948fe56d481a821270499425 (patch)
treefefa3ae6da92792bbc344823754fc3cfc0804303 /Demo/scripts
parentd3f467ac7441a100eb26412424c2dd96ec3ceb67 (diff)
downloadcpython-6faacd3bba36e682948fe56d481a821270499425.zip
cpython-6faacd3bba36e682948fe56d481a821270499425.tar.gz
cpython-6faacd3bba36e682948fe56d481a821270499425.tar.bz2
Update README, remove obsolete script.
Diffstat (limited to 'Demo/scripts')
-rw-r--r--Demo/scripts/README36
-rwxr-xr-xDemo/scripts/toaiff.py107
2 files changed, 18 insertions, 125 deletions
diff --git a/Demo/scripts/README b/Demo/scripts/README
index 54cd848..b80704c 100644
--- a/Demo/scripts/README
+++ b/Demo/scripts/README
@@ -2,21 +2,21 @@ This directory contains a collection of executable Python scripts.
See also the Tools/scripts directory!
-beer.py Print the classic 'bottles of beer' list
-eqfix.py Fix .py files to use the correct equality test operator
-fact.py Factorize numbers
-find-uname.py Search for Unicode characters using regexps
-from.py Summarize mailbox
-lpwatch.py Watch BSD line printer queues
-makedir.py Like mkdir -p
-markov.py Markov chain simulation of words or characters
-mboxconvert.py Convert MH or MMDF mailboxes to unix mailbox format
-morse.py Produce morse code (as an AIFF file)
-newslist.py List all newsgroups on a NNTP server as HTML pages
-pi.py Print all digits of pi -- given enough time and memory
-pp.py Emulate some Perl command line options
-primes.py Print prime numbers
-queens.py Dijkstra's solution to Wirth's "N Queens problem"
-script.py Equivalent to BSD script(1) -- by Steen Lumholt
-unbirthday.py Print unbirthday count
-update.py Update a bunch of files according to a script.
+beer.py Print the classic 'bottles of beer' list
+eqfix.py Fix .py files to use the correct equality test operator
+fact.py Factorize numbers
+find-uname.py Search for Unicode characters using regexps
+from.py Summarize mailbox
+lpwatch.py Watch BSD line printer queues
+makedir.py Like mkdir -p
+markov.py Markov chain simulation of words or characters
+mboxconvert.py Convert MH or MMDF mailboxes to unix mailbox format
+morse.py Produce morse code (as an AIFF file)
+newslist.py List all newsgroups on a NNTP server as HTML pages
+pi.py Print all digits of pi -- given enough time and memory
+pp.py Emulate some Perl command line options
+primes.py Print prime numbers
+queens.py Dijkstra's solution to Wirth's "N Queens problem"
+script.py Equivalent to BSD script(1) -- by Steen Lumholt
+unbirthday.py Print unbirthday count
+update.py Update a bunch of files according to a script
diff --git a/Demo/scripts/toaiff.py b/Demo/scripts/toaiff.py
deleted file mode 100755
index 0e9be23..0000000
--- a/Demo/scripts/toaiff.py
+++ /dev/null
@@ -1,107 +0,0 @@
-"""Convert "arbitrary" sound files to AIFF (Apple and SGI's audio format).
-
-Input may be compressed.
-Uncompressed file type may be AIFF, WAV, VOC, 8SVX, NeXT/Sun, and others.
-An exception is raised if the file is not of a recognized type.
-Returned filename is either the input filename or a temporary filename;
-in the latter case the caller must ensure that it is removed.
-Other temporary files used are removed by the function.
-"""
-
-import os
-import tempfile
-import pipes
-import sndhdr
-
-__all__ = ["error", "toaiff"]
-
-table = {}
-
-t = pipes.Template()
-t.append('sox -t au - -t aiff -r 8000 -', '--')
-table['au'] = t
-
-# XXX The following is actually sub-optimal.
-# XXX The HCOM sampling rate can be 22k, 22k/2, 22k/3 or 22k/4.
-# XXX We must force the output sampling rate else the SGI won't play
-# XXX files sampled at 5.5k or 7.333k; however this means that files
-# XXX sampled at 11k are unnecessarily expanded.
-# XXX Similar comments apply to some other file types.
-t = pipes.Template()
-t.append('sox -t hcom - -t aiff -r 22050 -', '--')
-table['hcom'] = t
-
-t = pipes.Template()
-t.append('sox -t voc - -t aiff -r 11025 -', '--')
-table['voc'] = t
-
-t = pipes.Template()
-t.append('sox -t wav - -t aiff -', '--')
-table['wav'] = t
-
-t = pipes.Template()
-t.append('sox -t 8svx - -t aiff -r 16000 -', '--')
-table['8svx'] = t
-
-t = pipes.Template()
-t.append('sox -t sndt - -t aiff -r 16000 -', '--')
-table['sndt'] = t
-
-t = pipes.Template()
-t.append('sox -t sndr - -t aiff -r 16000 -', '--')
-table['sndr'] = t
-
-uncompress = pipes.Template()
-uncompress.append('uncompress', '--')
-
-
-class error(Exception):
- pass
-
-def toaiff(filename):
- temps = []
- ret = None
- try:
- ret = _toaiff(filename, temps)
- finally:
- for temp in temps[:]:
- if temp != ret:
- try:
- os.unlink(temp)
- except os.error:
- pass
- temps.remove(temp)
- return ret
-
-def _toaiff(filename, temps):
- if filename[-2:] == '.Z':
- (fd, fname) = tempfile.mkstemp()
- os.close(fd)
- temps.append(fname)
- sts = uncompress.copy(filename, fname)
- if sts:
- raise error(filename + ': uncompress failed')
- else:
- fname = filename
- try:
- ftype = sndhdr.whathdr(fname)
- if ftype:
- ftype = ftype[0] # All we're interested in
- except IOError as msg:
- if type(msg) == type(()) and len(msg) == 2 and \
- type(msg.args[0]) == type(0) and type(msg.args[1]) == type(''):
- msg = msg.args[1]
- if type(msg) != type(''):
- msg = repr(msg)
- raise error(filename + ': ' + msg)
- if ftype == 'aiff':
- return fname
- if ftype is None or not ftype in table:
- raise error('%s: unsupported audio file type %r' % (filename, ftype))
- (fd, temp) = tempfile.mkstemp()
- os.close(fd)
- temps.append(temp)
- sts = table[ftype].copy(fname, temp)
- if sts:
- raise error(filename + ': conversion to aiff failed')
- return temp