This method is called when the user calls the factory
instance E.
# - - - E l e m e n t M a k e r . _ _ c a l l _ _
def __call__(self, tag, *argList, **attr):
'''Handle calls to a factory instance.
'''
First we create a new, empty element with the given tag name.
#-- 1 --
# [ elt := a new et.Element with name (tag) ]
elt = et.Element(tag)
If the attr dictionary has anything in
it, we can use the function stored in self.__typeMap[dict] to process those
attributes.
#-- 2 --
# [ elt := elt with attributes made from the key-value
# pairs in attr ]
# else -> I ]
if attr:
self.__typeMap[dict](elt, attr)
Next, process the positional arguments in a loop, using
each argument's type to extract from self.__typeMap the proper handler for that type.
For this logic, see Section 14.10, “ElementMaker.__handleArg(): Process
one positional argument”.
#-- 3 --
# [ if the types of all the members of pos are also
# keys in self.__typeMap ->
# elt := elt modified as per the corresponding
# functions from self.__typeMap
# else -> raise TypeError ]
for arg in argList:
#-- 3 body --
# [ if type(arg) is a key in self.__typeMap ->
# elt := elt modified as per self.__typeMap[type(arg)]
# else -> raise TypeError ]
self.__handleArg(elt, arg)
Finally, return the shiny new element to the caller.
#-- 4 --
return elt