Menu

KeyError on import of generated module

Help
2017-06-13
2017-06-13
  • Eric Bunton

    Eric Bunton - 2017-06-13

    When I attempt to import the module that gets generated I get an KeyError. Did I do something wrong during generation.

    >>> import test
    Traceback (most recent call last):
      File "<stdin>", line 1, in <module>
      File "/<redacted>/raw/test.py", line 700250, in <module>
        ActionAddSelTestEntry._Automaton = _BuildAutomaton_800()
      File "/<redacted>/raw/test.py", line 700242, in _BuildAutomaton_800
        symbol = pyxb.binding.content.ElementUse(ActionAddSelTestEntry._UseForTag(pyxb.namespace.ExpandedName(None, 'filler')), pyxb.utils.utility.Location('/<redacted>/xml-mgmt.xsd', 44937, 6))
      File "/<redacted>/venv/lib/python3.6/site-packages/pyxb/binding/basis.py", line 2144, in _UseForTag
        rv = cls._ElementMap[tag]
    KeyError: <pyxb.namespace.ExpandedName object at 0x119d24358>
    
     
  • Peter A. Bigot

    Peter A. Bigot - 2017-06-13

    No. The schema element at that point has minOccurs=0 maxOccurs=0 which means it doesn't exist. PyXB seems to remove it, which means the remaining reference to it while building the automaton fails. This is now filed as issue #79. I don't know when it will be worked.

     
  • Eric Bunton

    Eric Bunton - 2017-06-13

    The schema you referenced is correct. Any ideas on a possible workaround? Or a way to exclude pieces of a schema from having code generated?

     
  • Eric Bunton

    Eric Bunton - 2017-06-13

    The schema you referenced is correct. Any ideas on a possible workaround? Or a way to exclude pieces of a schema from having code generated?

     
  • Peter A. Bigot

    Peter A. Bigot - 2017-06-13

    If you delete the filler elements from within the sequence, the bindings module can be imported.

    sed -i -e /filler/d xml-mgmt.xsd
    
     

Log in to post a comment.