<s> from __future__ import absolute_import <EOL> """<STR_LIT>""" <EOL> import re <EOL> from functools import partial <EOL> from openpyxl import LXML <EOL> if LXML is True : <EOL> from lxml . etree import ( <EOL> Element , <EOL> ElementTree , <EOL> SubElement , <EOL> fromstring , <EOL> tostring , <EOL> register_namespace , <EOL> iterparse , <EOL> QName , <EOL> xmlfile <EOL> ) <EOL> from xml . etree . cElementTree import iterparse <EOL> else : <EOL> try : <EOL> from xml . etree . cElementTree import ( <EOL> ElementTree , <EOL> Element , <EOL> SubElement , <EOL> fromstring , <EOL> tostring , <EOL> iterparse , <EOL> QName <EOL> ) <EOL> except ImportError : <EOL> from xml . etree . ElementTree import ( <EOL> ElementTree , <EOL> Element , <EOL> SubElement , <EOL> fromstring , <EOL> tostring , <EOL> iterparse , <EOL> QName <EOL> ) <EOL> from . namespace import register_namespace <EOL> from et_xmlfile import xmlfile <EOL> from openpyxl . xml . constants import ( <EOL> CHART_NS , <EOL> DRAWING_NS , <EOL> SHEET_DRAWING_NS , <EOL> CHART_DRAWING_NS , <EOL> SHEET_MAIN_NS , <EOL> REL_NS , <EOL> VTYPES_NS , <EOL> COREPROPS_NS , <EOL> DCTERMS_NS , <EOL> DCTERMS_PREFIX <EOL> ) <EOL> _iterparse = iterparse <EOL> def safe_iterparse ( source , * args , ** kw ) : <EOL> return _iterparse ( source ) <EOL> iterparse = safe_iterparse <EOL> register_namespace ( DCTERMS_PREFIX , DCTERMS_NS ) <EOL> register_namespace ( '<STR_LIT>' , '<STR_LIT>' ) <EOL> register_namespace ( '<STR_LIT>' , COREPROPS_NS ) <EOL> register_namespace ( '<STR_LIT:c>' , CHART_NS ) <EOL> register_namespace ( '<STR_LIT:a>' , DRAWING_NS ) <EOL> register_namespace ( '<STR_LIT:s>' , SHEET_MAIN_NS ) <EOL> register_namespace ( '<STR_LIT:r>' , REL_NS ) <EOL> register_namespace ( '<STR_LIT>' , VTYPES_NS ) <EOL> register_namespace ( '<STR_LIT>' , SHEET_DRAWING_NS ) <EOL> register_namespace ( '<STR_LIT>' , CHART_DRAWING_NS ) <EOL> tostring = partial ( tostring , encoding = "<STR_LIT:utf-8>" ) <EOL> def safe_iterator ( node , tag = None ) : <EOL> """<STR_LIT>""" <EOL> if node is None : <EOL> return [ ] <EOL> if hasattr ( node , "<STR_LIT>" ) : <EOL> return node . iter ( tag ) <EOL> else : <EOL> return node . getiterator ( tag ) <EOL> def ConditionalElement ( node , tag , condition , attr = None ) : <EOL> """<STR_LIT>""" <EOL> sub = partial ( SubElement , node , tag ) <EOL> if bool ( condition ) : <EOL> if isinstance ( attr , str ) : <EOL> elem = sub ( { attr : '<STR_LIT:1>' } ) <EOL> elif isinstance ( attr , dict ) : <EOL> elem = sub ( attr ) <EOL> else : <EOL> elem = sub ( ) <EOL> return elem <EOL> NS_REGEX = re . compile ( "<STR_LIT>" ) <EOL> def localname ( node ) : <EOL> m = NS_REGEX . match ( node . tag ) <EOL> return m . group ( '<STR_LIT>' ) </s>
