summaryrefslogtreecommitdiffstats
path: root/Lib
diff options
context:
space:
mode:
authorBenjamin Peterson <benjamin@python.org>2008-08-16 16:48:16 (GMT)
committerBenjamin Peterson <benjamin@python.org>2008-08-16 16:48:16 (GMT)
commit0b95290f4eca1e608cec105807b2295efe21685f (patch)
tree39d25665fbf5ae070d2e9b2eb1875506326d3c4d /Lib
parent0067bd68c979e88b96e8eb5001d0e184ea949bb0 (diff)
downloadcpython-0b95290f4eca1e608cec105807b2295efe21685f.zip
cpython-0b95290f4eca1e608cec105807b2295efe21685f.tar.gz
cpython-0b95290f4eca1e608cec105807b2295efe21685f.tar.bz2
Merged revisions 65713 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk ........ r65713 | benjamin.peterson | 2008-08-16 11:29:02 -0500 (Sat, 16 Aug 2008) | 1 line #3424 rearrange the order of tests in imghdr to place more common types first ........
Diffstat (limited to 'Lib')
-rw-r--r--Lib/imghdr.py50
1 files changed, 25 insertions, 25 deletions
diff --git a/Lib/imghdr.py b/Lib/imghdr.py
index c00c816..6ee45da 100644
--- a/Lib/imghdr.py
+++ b/Lib/imghdr.py
@@ -34,12 +34,18 @@ def what(file, h=None):
tests = []
-def test_rgb(h, f):
- """SGI image library"""
- if h.startswith(b'\001\332'):
- return 'rgb'
+def test_jpeg(h, f):
+ """JPEG data in JFIF or Exif format"""
+ if h[6:10] in (b'JFIF', b'Exif'):
+ return 'jpeg'
-tests.append(test_rgb)
+tests.append(test_jpeg)
+
+def test_png(h, f):
+ if h.startswith(b'\211PNG\r\n\032\n'):
+ return 'png'
+
+tests.append(test_png)
def test_gif(h, f):
"""GIF ('87 and '89 variants)"""
@@ -48,6 +54,20 @@ def test_gif(h, f):
tests.append(test_gif)
+def test_tiff(h, f):
+ """TIFF (can be in Motorola or Intel byte order)"""
+ if h[:2] in (b'MM', b'II'):
+ return 'tiff'
+
+tests.append(test_tiff)
+
+def test_rgb(h, f):
+ """SGI image library"""
+ if h.startswith(b'\001\332'):
+ return 'rgb'
+
+tests.append(test_rgb)
+
def test_pbm(h, f):
"""PBM (portable bitmap)"""
if len(h) >= 3 and \
@@ -72,13 +92,6 @@ def test_ppm(h, f):
tests.append(test_ppm)
-def test_tiff(h, f):
- """TIFF (can be in Motorola or Intel byte order)"""
- if h[:2] in (b'MM', b'II'):
- return 'tiff'
-
-tests.append(test_tiff)
-
def test_rast(h, f):
"""Sun raster file"""
if h.startswith(b'\x59\xA6\x6A\x95'):
@@ -93,25 +106,12 @@ def test_xbm(h, f):
tests.append(test_xbm)
-def test_jpeg(h, f):
- """JPEG data in JFIF or Exif format"""
- if h[6:10] in (b'JFIF', b'Exif'):
- return 'jpeg'
-
-tests.append(test_jpeg)
-
def test_bmp(h, f):
if h.startswith(b'BM'):
return 'bmp'
tests.append(test_bmp)
-def test_png(h, f):
- if h.startswith(b'\211PNG\r\n\032\n'):
- return 'png'
-
-tests.append(test_png)
-
#--------------------#
# Small test program #
#--------------------#