Coverage for /pythoncovmergedfiles/medio/medio/usr/local/lib/python3.8/site-packages/openpyxl/packaging/extended.py: 100%

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

73 statements  

1# Copyright (c) 2010-2024 openpyxl 

2 

3 

4from openpyxl.descriptors.serialisable import Serialisable 

5from openpyxl.descriptors import ( 

6 Typed, 

7) 

8from openpyxl.descriptors.nested import ( 

9 NestedText, 

10) 

11 

12from openpyxl.xml.constants import XPROPS_NS 

13from openpyxl import __version__ 

14 

15 

16class DigSigBlob(Serialisable): 

17 

18 __elements__ = __attrs__ = () 

19 

20 

21class VectorLpstr(Serialisable): 

22 

23 __elements__ = __attrs__ = () 

24 

25 

26class VectorVariant(Serialisable): 

27 

28 __elements__ = __attrs__ = () 

29 

30 

31class ExtendedProperties(Serialisable): 

32 

33 """ 

34 See 22.2 

35 

36 Most of this is irrelevant but Excel is very picky about the version number 

37 

38 It uses XX.YYYY (Version.Build) and expects everyone else to 

39 

40 We provide Major.Minor and the full version in the application name 

41 """ 

42 

43 tagname = "Properties" 

44 

45 Template = NestedText(expected_type=str, allow_none=True) 

46 Manager = NestedText(expected_type=str, allow_none=True) 

47 Company = NestedText(expected_type=str, allow_none=True) 

48 Pages = NestedText(expected_type=int, allow_none=True) 

49 Words = NestedText(expected_type=int,allow_none=True) 

50 Characters = NestedText(expected_type=int, allow_none=True) 

51 PresentationFormat = NestedText(expected_type=str, allow_none=True) 

52 Lines = NestedText(expected_type=int, allow_none=True) 

53 Paragraphs = NestedText(expected_type=int, allow_none=True) 

54 Slides = NestedText(expected_type=int, allow_none=True) 

55 Notes = NestedText(expected_type=int, allow_none=True) 

56 TotalTime = NestedText(expected_type=int, allow_none=True) 

57 HiddenSlides = NestedText(expected_type=int, allow_none=True) 

58 MMClips = NestedText(expected_type=int, allow_none=True) 

59 ScaleCrop = NestedText(expected_type=bool, allow_none=True) 

60 HeadingPairs = Typed(expected_type=VectorVariant, allow_none=True) 

61 TitlesOfParts = Typed(expected_type=VectorLpstr, allow_none=True) 

62 LinksUpToDate = NestedText(expected_type=bool, allow_none=True) 

63 CharactersWithSpaces = NestedText(expected_type=int, allow_none=True) 

64 SharedDoc = NestedText(expected_type=bool, allow_none=True) 

65 HyperlinkBase = NestedText(expected_type=str, allow_none=True) 

66 HLinks = Typed(expected_type=VectorVariant, allow_none=True) 

67 HyperlinksChanged = NestedText(expected_type=bool, allow_none=True) 

68 DigSig = Typed(expected_type=DigSigBlob, allow_none=True) 

69 Application = NestedText(expected_type=str, allow_none=True) 

70 AppVersion = NestedText(expected_type=str, allow_none=True) 

71 DocSecurity = NestedText(expected_type=int, allow_none=True) 

72 

73 __elements__ = ('Application', 'AppVersion', 'DocSecurity', 'ScaleCrop', 

74 'LinksUpToDate', 'SharedDoc', 'HyperlinksChanged') 

75 

76 def __init__(self, 

77 Template=None, 

78 Manager=None, 

79 Company=None, 

80 Pages=None, 

81 Words=None, 

82 Characters=None, 

83 PresentationFormat=None, 

84 Lines=None, 

85 Paragraphs=None, 

86 Slides=None, 

87 Notes=None, 

88 TotalTime=None, 

89 HiddenSlides=None, 

90 MMClips=None, 

91 ScaleCrop=None, 

92 HeadingPairs=None, 

93 TitlesOfParts=None, 

94 LinksUpToDate=None, 

95 CharactersWithSpaces=None, 

96 SharedDoc=None, 

97 HyperlinkBase=None, 

98 HLinks=None, 

99 HyperlinksChanged=None, 

100 DigSig=None, 

101 Application=None, 

102 AppVersion=None, 

103 DocSecurity=None, 

104 ): 

105 self.Template = Template 

106 self.Manager = Manager 

107 self.Company = Company 

108 self.Pages = Pages 

109 self.Words = Words 

110 self.Characters = Characters 

111 self.PresentationFormat = PresentationFormat 

112 self.Lines = Lines 

113 self.Paragraphs = Paragraphs 

114 self.Slides = Slides 

115 self.Notes = Notes 

116 self.TotalTime = TotalTime 

117 self.HiddenSlides = HiddenSlides 

118 self.MMClips = MMClips 

119 self.ScaleCrop = ScaleCrop 

120 self.HeadingPairs = None 

121 self.TitlesOfParts = None 

122 self.LinksUpToDate = LinksUpToDate 

123 self.CharactersWithSpaces = CharactersWithSpaces 

124 self.SharedDoc = SharedDoc 

125 self.HyperlinkBase = HyperlinkBase 

126 self.HLinks = None 

127 self.HyperlinksChanged = HyperlinksChanged 

128 self.DigSig = None 

129 self.Application = f"Microsoft Excel Compatible / Openpyxl {__version__}" 

130 self.AppVersion = ".".join(__version__.split(".")[:-1]) 

131 self.DocSecurity = DocSecurity 

132 

133 

134 def to_tree(self): 

135 tree = super().to_tree() 

136 tree.set("xmlns", XPROPS_NS) 

137 return tree