<s> from __future__ import ( <EOL> absolute_import , <EOL> print_function , <EOL> unicode_literals , <EOL> ) <EOL> from pydocx . openxml . packaging . open_xml_part_container import OpenXmlPartContainer <EOL> from pydocx . util . xml import parse_xml_from_string <EOL> class OpenXmlPart ( OpenXmlPartContainer ) : <EOL> '''<STR_LIT>''' <EOL> def __init__ ( <EOL> self , <EOL> uri , <EOL> open_xml_package , <EOL> ) : <EOL> super ( OpenXmlPart , self ) . __init__ ( ) <EOL> self . _root_element = None <EOL> self . uri = uri <EOL> self . open_xml_package = open_xml_package <EOL> @ property <EOL> def root_element ( self ) : <EOL> if self . _root_element is None : <EOL> if self . stream is None : <EOL> return <EOL> data = self . stream . read ( ) <EOL> self . _root_element = parse_xml_from_string ( <EOL> xml = data , <EOL> remove_namespaces = True , <EOL> ) <EOL> return self . _root_element <EOL> @ property <EOL> def package_part ( self ) : <EOL> return self . open_xml_package . package . get_part ( self . uri ) <EOL> @ property <EOL> def stream ( self ) : <EOL> part = self . package_part <EOL> if part : <EOL> return part . stream </s>
