def makeelement(tagname, tagtext=None, nsprefix='w', attributes=None, attrnsprefix=None):
 namespacemap = None
 if isinstance(nsprefix, list):
  namespacemap = {}
  for prefix in nsprefix:
   namespacemap[prefix] = nsprefixes[prefix]
  nsprefix = nsprefix[0]
 if nsprefix:
  namespace = ('{%s}' % nsprefixes[nsprefix])
 else:
  namespace = ''
 newelement = etree.Element((namespace + tagname), nsmap=namespacemap)
 if attributes:
  if (not attrnsprefix):
   if (nsprefix == 'w'):
    attributenamespace = namespace
   else:
    attributenamespace = ''
  else:
   attributenamespace = (('{' + nsprefixes[attrnsprefix]) + '}')
  for tagattribute in attributes:
   newelement.set((attributenamespace + tagattribute), attributes[tagattribute])
 if tagtext:
  newelement.text = tagtext
 return newelement

def makeelement ( tagname , tagtext = None , nsprefix = 'w' , attributes = None , attrnsprefix = None ) : namespacemap = None if isinstance ( nsprefix , list ) : namespacemap = { } for prefix in nsprefix : namespacemap [ prefix ] = nsprefixes [ prefix ] nsprefix = nsprefix [ 0 ] if nsprefix : namespace = ( '{%s}' % nsprefixes [ nsprefix ] ) else : namespace = '' newelement = etree . Element ( ( namespace + tagname ) , nsmap = namespacemap ) if attributes : if ( not attrnsprefix ) : if ( nsprefix == 'w' ) : attributenamespace = namespace else : attributenamespace = '' else : attributenamespace = ( ( '{' + nsprefixes [ attrnsprefix ] ) + '}' ) for tagattribute in attributes : newelement . set ( ( attributenamespace + tagattribute ) , attributes [ tagattribute ] ) if tagtext : newelement . text = tagtext return newelement
create an element & return it .