Coverage for /var/srv/projects/api.amasfac.comuna18.com/tmp/venv/lib/python3.9/site-packages/xlrd/timemachine.py: 41%

34 statements  

« prev     ^ index     » next       coverage.py v6.4.4, created at 2023-07-17 14:22 -0600

1## 

2# <p>Copyright (c) 2006-2012 Stephen John Machin, Lingfo Pty Ltd</p> 

3# <p>This module is part of the xlrd package, which is released under a BSD-style licence.</p> 

4## 

5 

6# timemachine.py -- adaptation for single codebase. 

7# Currently supported: 2.6 to 2.7, 3.2+ 

8# usage: from timemachine import * 

9 

10from __future__ import print_function 

11 

12import sys 

13 

14python_version = sys.version_info[:2] # e.g. version 2.6 -> (2, 6) 

15 

16if python_version >= (3, 0): 16 ↛ 36line 16 didn't jump to line 36, because the condition on line 16 was never false

17 # Python 3 

18 BYTES_LITERAL = lambda x: x.encode('latin1') 18 ↛ exitline 18 didn't run the lambda on line 18

19 UNICODE_LITERAL = lambda x: x 

20 BYTES_ORD = lambda byte: byte 20 ↛ exitline 20 didn't run the lambda on line 20

21 from io import BytesIO as BYTES_IO 

22 def fprintf(f, fmt, *vargs): 

23 fmt = fmt.replace("%r", "%a") 

24 if fmt.endswith('\n'): 

25 print(fmt[:-1] % vargs, file=f) 

26 else: 

27 print(fmt % vargs, end=' ', file=f) 

28 EXCEL_TEXT_TYPES = (str, bytes, bytearray) # xlwt: isinstance(obj, EXCEL_TEXT_TYPES) 

29 REPR = ascii 

30 xrange = range 

31 unicode = lambda b, enc: b.decode(enc) 31 ↛ exitline 31 didn't run the lambda on line 31

32 ensure_unicode = lambda s: s 32 ↛ exitline 32 didn't run the lambda on line 32

33 unichr = chr 

34else: 

35 # Python 2 

36 BYTES_LITERAL = lambda x: x 

37 UNICODE_LITERAL = lambda x: x.decode('latin1') 

38 BYTES_ORD = ord 

39 from cStringIO import StringIO as BYTES_IO 

40 def fprintf(f, fmt, *vargs): 

41 if fmt.endswith('\n'): 

42 print(fmt[:-1] % vargs, file=f) 

43 else: 

44 print(fmt % vargs, end=' ', file=f) 

45 try: 

46 EXCEL_TEXT_TYPES = basestring # xlwt: isinstance(obj, EXCEL_TEXT_TYPES) 

47 except NameError: 

48 EXCEL_TEXT_TYPES = (str, unicode) 

49 REPR = repr 

50 xrange = xrange 

51 # following used only to overcome 2.x ElementTree gimmick which 

52 # returns text as `str` if it's ascii, otherwise `unicode` 

53 ensure_unicode = unicode # used only in xlsx.py