/usr/lib/python3/dist-packages/xlsxwriter/app.py is in python3-xlsxwriter 0.9.6-0.1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 | ###############################################################################
#
# App - A class for writing the Excel XLSX App file.
#
# Copyright 2013-2016, John McNamara, jmcnamara@cpan.org
#
# Package imports.
from . import xmlwriter
class App(xmlwriter.XMLwriter):
"""
A class for writing the Excel XLSX App file.
"""
###########################################################################
#
# Public API.
#
###########################################################################
def __init__(self):
"""
Constructor.
"""
super(App, self).__init__()
self.part_names = []
self.heading_pairs = []
self.properties = {}
def _add_part_name(self, part_name):
# Add the name of a workbook Part such as 'Sheet1' or 'Print_Titles'.
self.part_names.append(part_name)
def _add_heading_pair(self, heading_pair):
# Add the name of a workbook Heading Pair such as 'Worksheets',
# 'Charts' or 'Named Ranges'.
# Ignore empty pairs such as chartsheets.
if not heading_pair[1]:
return
self.heading_pairs.append(('lpstr', heading_pair[0]))
self.heading_pairs.append(('i4', heading_pair[1]))
def _set_properties(self, properties):
# Set the document properties.
self.properties = properties
###########################################################################
#
# Private API.
#
###########################################################################
def _assemble_xml_file(self):
# Assemble and write the XML file.
# Write the XML declaration.
self._xml_declaration()
self._write_properties()
self._write_application()
self._write_doc_security()
self._write_scale_crop()
self._write_heading_pairs()
self._write_titles_of_parts()
self._write_manager()
self._write_company()
self._write_links_up_to_date()
self._write_shared_doc()
self._write_hyperlink_base()
self._write_hyperlinks_changed()
self._write_app_version()
self._xml_end_tag('Properties')
# Close the file.
self._xml_close()
###########################################################################
#
# XML methods.
#
###########################################################################
def _write_properties(self):
# Write the <Properties> element.
schema = 'http://schemas.openxmlformats.org/officeDocument/2006/'
xmlns = schema + 'extended-properties'
xmlns_vt = schema + 'docPropsVTypes'
attributes = [
('xmlns', xmlns),
('xmlns:vt', xmlns_vt),
]
self._xml_start_tag('Properties', attributes)
def _write_application(self):
# Write the <Application> element.
self._xml_data_element('Application', 'Microsoft Excel')
def _write_doc_security(self):
# Write the <DocSecurity> element.
self._xml_data_element('DocSecurity', '0')
def _write_scale_crop(self):
# Write the <ScaleCrop> element.
self._xml_data_element('ScaleCrop', 'false')
def _write_heading_pairs(self):
# Write the <HeadingPairs> element.
self._xml_start_tag('HeadingPairs')
self._write_vt_vector('variant', self.heading_pairs)
self._xml_end_tag('HeadingPairs')
def _write_titles_of_parts(self):
# Write the <TitlesOfParts> element.
parts_data = []
self._xml_start_tag('TitlesOfParts')
for part_name in self.part_names:
parts_data.append(('lpstr', part_name))
self._write_vt_vector('lpstr', parts_data)
self._xml_end_tag('TitlesOfParts')
def _write_vt_vector(self, base_type, vector_data):
# Write the <vt:vector> element.
attributes = [
('size', len(vector_data)),
('baseType', base_type),
]
self._xml_start_tag('vt:vector', attributes)
for vt_data in vector_data:
if base_type == 'variant':
self._xml_start_tag('vt:variant')
self._write_vt_data(vt_data)
if base_type == 'variant':
self._xml_end_tag('vt:variant')
self._xml_end_tag('vt:vector')
def _write_vt_data(self, vt_data):
# Write the <vt:*> elements such as <vt:lpstr> and <vt:if>.
self._xml_data_element("vt:%s" % vt_data[0], vt_data[1])
def _write_company(self):
company = self.properties.get('company', '')
self._xml_data_element('Company', company)
def _write_manager(self):
# Write the <Manager> element.
if 'manager' not in self.properties:
return
self._xml_data_element('Manager', self.properties['manager'])
def _write_links_up_to_date(self):
# Write the <LinksUpToDate> element.
self._xml_data_element('LinksUpToDate', 'false')
def _write_shared_doc(self):
# Write the <SharedDoc> element.
self._xml_data_element('SharedDoc', 'false')
def _write_hyperlink_base(self):
# Write the <HyperlinkBase> element.
hyperlink_base = self.properties.get('hyperlink_base')
if hyperlink_base is None:
return
self._xml_data_element('HyperlinkBase', hyperlink_base)
def _write_hyperlinks_changed(self):
# Write the <HyperlinksChanged> element.
self._xml_data_element('HyperlinksChanged', 'false')
def _write_app_version(self):
# Write the <AppVersion> element.
self._xml_data_element('AppVersion', '12.0000')
|