Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 7 additions & 9 deletions docxcompose/properties.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,6 @@
from docxcompose.utils import xpath
from lxml.etree import FunctionNamespace
from lxml.etree import QName
from six import binary_type
from six import text_type
import pkg_resources
import re

Expand All @@ -36,17 +34,17 @@ def value2vt(value):
el.text = 'true' if value else 'false'
elif isinstance(value, int):
el = parse_xml(CUSTOM_PROPERTY_TYPES['int'])
el.text = text_type(value)
el.text = str(value)
elif isinstance(value, float):
el = parse_xml(CUSTOM_PROPERTY_TYPES['float'])
el.text = text_type(value)
el.text = str(value)
elif isinstance(value, datetime):
el = parse_xml(CUSTOM_PROPERTY_TYPES['datetime'])
el.text = value.strftime('%Y-%m-%dT%H:%M:%SZ')
elif isinstance(value, text_type):
elif isinstance(value, str):
el = parse_xml(CUSTOM_PROPERTY_TYPES['text'])
el.text = value
elif isinstance(value, binary_type):
elif isinstance(value, bytes):
value = value.decode('utf-8')
el = parse_xml(CUSTOM_PROPERTY_TYPES['text'])
el.text = value
Expand Down Expand Up @@ -162,7 +160,7 @@ def __delitem__(self, key):
# Renumber pids
pid = MIN_PID
for prop in self._element:
prop.set('pid', text_type(pid))
prop.set('pid', str(pid))
pid += 1

self._update_part()
Expand Down Expand Up @@ -226,7 +224,7 @@ def add(self, name, value):
prop = parse_xml('<cp:property xmlns:cp="{}"/>'.format(NS['cp']))
prop.set('fmtid', CUSTOM_PROPERTY_FMTID)
prop.set('name', name)
prop.set('pid', text_type(pid))
prop.set('pid', str(pid))
value_el = value2vt(value)
prop.append(value_el)
self._element.append(prop)
Expand Down Expand Up @@ -356,7 +354,7 @@ def _format_value(self, value, language=None):
return format_datetime(value, self.date_format, locale=language)
return format_datetime(value, self.date_format)
else:
return text_type(value)
return str(value)

def update(self, value, language=None):
""" Sets the value of the docproperty in the document
Expand Down
2 changes: 0 additions & 2 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
# Get more from https://pypi.python.org/pypi?%3Aaction=list_classifiers
classifiers=[
"Programming Language :: Python",
"Programming Language :: Python :: 2.7",
"Programming Language :: Python :: 3",
"Operating System :: OS Independent",
"License :: OSI Approved :: MIT License",
Expand All @@ -35,7 +34,6 @@
'lxml',
'python-docx >= 0.8.8',
'setuptools',
'six',
'babel',
],
extras_require={
Expand Down