Hide keyboard shortcuts

Hot-keys on this page

r m x p   toggle line displays

j k   next/prev highlighted chunk

0   (zero) top of page

1   (one) first highlighted chunk

1""" 

2 pyexcel_io._compact 

3 ~~~~~~~~~~~~~~~~~~~ 

4 

5 Compatibles 

6 

7 :copyright: (c) 2014-2020 by Onni Software Ltd. 

8 :license: New BSD License, see LICENSE for more details 

9""" 

10import sys 

11import logging 

12from io import BytesIO, StringIO # noqa: F401 

13from collections import OrderedDict # noqa: F401 

14 

15try: 

16 from logging import NullHandler 

17except ImportError: 

18 

19 class NullHandler(logging.Handler): 

20 def emit(self, record): 

21 pass 

22 

23 

24text_type = str 

25irange = range 

26PY2 = sys.version[0] == 2 

27 

28 

29def isstream(instance): 

30 """ check if a instance is a stream """ 

31 try: 

32 import mmap 

33 

34 i_am_not_mmap_obj = not isinstance(instance, mmap.mmap) 

35 except ImportError: 

36 # Python 2.6 or Google App Engine 

37 i_am_not_mmap_obj = True 

38 

39 return hasattr(instance, "read") and i_am_not_mmap_obj 

40 

41 

42def is_string(atype): 

43 """find out if a type is str or not""" 

44 return atype == str