Coverage for /pythoncovmergedfiles/medio/medio/usr/local/lib/python3.8/site-packages/xlsxwriter/rich_value_structure.py: 25%

Shortcuts on this page

r m x   toggle line displays

j k   next/prev highlighted chunk

0   (zero) top of page

1   (one) first highlighted chunk

28 statements  

1############################################################################### 

2# 

3# RichValueStructure - A class for writing the Excel XLSX rdrichvaluestructure.xml file. 

4# 

5# SPDX-License-Identifier: BSD-2-Clause 

6# Copyright 2013-2024, John McNamara, jmcnamara@cpan.org 

7# 

8 

9# Package imports. 

10from . import xmlwriter 

11 

12 

13class RichValueStructure(xmlwriter.XMLwriter): 

14 """ 

15 A class for writing the Excel XLSX rdrichvaluestructure.xml file. 

16 

17 

18 """ 

19 

20 ########################################################################### 

21 # 

22 # Public API. 

23 # 

24 ########################################################################### 

25 

26 def __init__(self): 

27 """ 

28 Constructor. 

29 

30 """ 

31 

32 super(RichValueStructure, self).__init__() 

33 self.has_embedded_descriptions = False 

34 

35 ########################################################################### 

36 # 

37 # Private API. 

38 # 

39 ########################################################################### 

40 

41 def _assemble_xml_file(self): 

42 # Assemble and write the XML file. 

43 

44 # Write the XML declaration. 

45 self._xml_declaration() 

46 

47 # Write the rvStructures element. 

48 self._write_rv_structures() 

49 

50 self._xml_end_tag("rvStructures") 

51 

52 # Close the file. 

53 self._xml_close() 

54 

55 ########################################################################### 

56 # 

57 # XML methods. 

58 # 

59 ########################################################################### 

60 def _write_rv_structures(self): 

61 # Write the <rvStructures> element. 

62 xmlns = "http://schemas.microsoft.com/office/spreadsheetml/2017/richdata" 

63 count = "1" 

64 

65 attributes = [ 

66 ("xmlns", xmlns), 

67 ("count", count), 

68 ] 

69 

70 self._xml_start_tag("rvStructures", attributes) 

71 

72 # Write the s element. 

73 self._write_s() 

74 

75 def _write_s(self): 

76 # Write the <s> element. 

77 t = "_localImage" 

78 attributes = [("t", t)] 

79 

80 self._xml_start_tag("s", attributes) 

81 

82 # Write the k elements. 

83 self._write_k("_rvRel:LocalImageIdentifier", "i") 

84 self._write_k("CalcOrigin", "i") 

85 

86 if self.has_embedded_descriptions: 

87 self._write_k("Text", "s") 

88 

89 self._xml_end_tag("s") 

90 

91 def _write_k(self, name, type): 

92 # Write the <k> element. 

93 attributes = [ 

94 ("n", name), 

95 ("t", type), 

96 ] 

97 

98 self._xml_empty_tag("k", attributes)