def what(file, h=None):
 if (h is None):
  if isinstance(file, basestring):
   with lopen(file, u'rb') as f:
    h = f.read(HSIZE)
  else:
   location = file.tell()
   h = file.read(HSIZE)
   file.seek(location)
 if isinstance(h, bytes):
  h = memoryview(h)
 for tf in tests:
  res = tf(h)
  if res:
   return res
 if (h[:2] == '\xff\xd8'):
  return u'jpeg'
 return None

def what ( file , h = None ) : if ( h is None ) : if isinstance ( file , basestring ) : with lopen ( file , u'rb' ) as f : h = f . read ( HSIZE ) else : location = file . tell ( ) h = file . read ( HSIZE ) file . seek ( location ) if isinstance ( h , bytes ) : h = memoryview ( h ) for tf in tests : res = tf ( h ) if res : return res if ( h [ : 2 ] == '\xff\xd8' ) : return u'jpeg' return None
module identification function .