1313from docx .oxml .coreprops import CT_CoreProperties
1414from lxml .etree import FunctionNamespace
1515from lxml .etree import QName
16- from six import binary_type
17- from six import text_type
1816
1917from docxcompose .utils import NS
2018from docxcompose .utils import word_to_python_date_format
@@ -38,17 +36,17 @@ def value2vt(value):
3836 el .text = "true" if value else "false"
3937 elif isinstance (value , int ):
4038 el = parse_xml (CUSTOM_PROPERTY_TYPES ["int" ])
41- el .text = text_type (value )
39+ el .text = str (value )
4240 elif isinstance (value , float ):
4341 el = parse_xml (CUSTOM_PROPERTY_TYPES ["float" ])
44- el .text = text_type (value )
42+ el .text = str (value )
4543 elif isinstance (value , datetime ):
4644 el = parse_xml (CUSTOM_PROPERTY_TYPES ["datetime" ])
4745 el .text = value .strftime ("%Y-%m-%dT%H:%M:%SZ" )
48- elif isinstance (value , text_type ):
46+ elif isinstance (value , str ):
4947 el = parse_xml (CUSTOM_PROPERTY_TYPES ["text" ])
5048 el .text = value
51- elif isinstance (value , binary_type ):
49+ elif isinstance (value , bytes ):
5250 value = value .decode ("utf-8" )
5351 el = parse_xml (CUSTOM_PROPERTY_TYPES ["text" ])
5452 el .text = value
@@ -171,7 +169,7 @@ def __delitem__(self, key):
171169 # Renumber pids
172170 pid = MIN_PID
173171 for prop in self ._element :
174- prop .set ("pid" , text_type (pid ))
172+ prop .set ("pid" , str (pid ))
175173 pid += 1
176174
177175 self ._update_part ()
@@ -235,7 +233,7 @@ def add(self, name, value):
235233 prop = parse_xml ('<cp:property xmlns:cp="{}"/>' .format (NS ["cp" ]))
236234 prop .set ("fmtid" , CUSTOM_PROPERTY_FMTID )
237235 prop .set ("name" , name )
238- prop .set ("pid" , text_type (pid ))
236+ prop .set ("pid" , str (pid ))
239237 value_el = value2vt (value )
240238 prop .append (value_el )
241239 self ._element .append (prop )
@@ -345,7 +343,7 @@ class FieldBase(object):
345343 """Class used to represent a docproperty field in the document.xml."""
346344
347345 fieldname_and_format_search_expr = re .compile (
348- r'DOCPROPERTY +"{0,1}([^\\]*?)"{0,1} +(?:\\\@ +"{0,1}([^\\]*?)"{0,1} +){0,1}\\\* MERGEFORMAT' ,
346+ r'DOCPROPERTY +"{0,1}([^\\]*?)"{0,1} +(?:\\\@ +"{0,1}([^\\]*?)"{0,1} +){0,1}\\\* MERGEFORMAT' , # noqa
349347 flags = re .UNICODE ,
350348 )
351349
@@ -365,7 +363,7 @@ def _format_value(self, value, language=None):
365363 return format_datetime (value , self .date_format , locale = language )
366364 return format_datetime (value , self .date_format )
367365 else :
368- return text_type (value )
366+ return str (value )
369367
370368 def update (self , value , language = None ):
371369 """Sets the value of the docproperty in the document"""
0 commit comments