py3: remove has_key from odf2xhtml

This commit is contained in:
Kovid Goyal 2019-05-20 16:12:42 +05:30
parent cb5ac309fa
commit ed1571af6e
No known key found for this signature in database
GPG Key ID: 06BC317B515ACE7C
5 changed files with 7 additions and 9 deletions

View File

@ -43,7 +43,7 @@ def StyleRefElement(stylename=None, classnames=None, **args):
def DrawElement(name=None, **args):
e = Element(name=name, **args)
if not args.has_key('displayname'):
if 'displayname' not in args:
e.setAttrNS(DRAWNS,'display-name', name)
return e
@ -179,4 +179,3 @@ def StrokeDash(**args):
def TextBox(**args):
return Element(qname = (DRAWNS,'text-box'), **args)

View File

@ -341,7 +341,7 @@ class Element(Node):
"""
if namespace is None: namespace = ""
prefix = _nsassign(namespace)
if not self.namespaces.has_key(namespace):
if namespace not in self.namespaces:
self.namespaces[namespace] = prefix
return prefix

View File

@ -124,13 +124,13 @@ class OpenDocument:
def build_caches(self, element):
""" Called from element.py
"""
if not self.element_dict.has_key(element.qname):
if element.qname not in self.element_dict:
self.element_dict[element.qname] = []
self.element_dict[element.qname].append(element)
if element.qname == (STYLENS, u'style'):
self.__register_stylename(element) # Add to style dictionary
styleref = element.getAttrNS(TEXTNS,u'style-name')
if styleref is not None and self._styles_ooo_fix.has_key(styleref):
if styleref is not None and styleref in self._styles_ooo_fix:
element.setAttrNS(TEXTNS,u'style-name', self._styles_ooo_fix[styleref])
def __register_stylename(self, element):
@ -142,7 +142,7 @@ class OpenDocument:
if name is None:
return
if element.parentNode.qname in ((OFFICENS,u'styles'), (OFFICENS,u'automatic-styles')):
if self._styles_dict.has_key(name):
if name in self._styles_dict:
newname = 'M'+name # Rename style
self._styles_ooo_fix[name] = newname
# From here on all references to the old name will refer to the new one

View File

@ -24,7 +24,7 @@ from .element import Element
def StyleElement(**args):
e = Element(**args)
if args.get('check_grammar', True) == True:
if not args.has_key('displayname'):
if 'displayname' not in args:
e.setAttrNS(STYLENS,'display-name', args.get('name'))
return e
@ -145,4 +145,3 @@ def TableRowProperties(**args):
def TextProperties(**args):
return Element(qname = (STYLENS,'text-properties'), **args)

View File

@ -158,7 +158,7 @@ class UserFields(object):
all_fields = self.document.getElementsByType(UserFieldDecl)
for f in all_fields:
field_name = f.getAttribute('name')
if data.has_key(field_name):
if field_name in data:
value_type = f.getAttribute('valuetype')
value = data.get(field_name)
if value_type == 'string':