by

Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Activity
    Anna Liao
    @anna-liao
    that's good then
    that's what my code does now
    it just lumps all the elements together in one string
    so it is different from how it worked with just an Element.
    d = structures.Document(base_uri='choice.xml')
    d.read()
    dlines = bytes(d).split(b'\n')
    ok, I guess I will leave it as is
    looks like for a document root, it just lumps all the elements into a single string. seems a bit odd
    That was taken from this unittest
    John Vandenberg
    @jayvdb
    instead of doing it in a unit test, try it in the python console. soemthing like
    $ python3
    >>> import os
    >>> import os.path
    >>> TEST_DATA_DIR = '.../data_xml20081126')
    >>> os.chdir(TEST_DATA_DIR)
    >>> from pyslet.xml import structures
    >>> d = structures.Document(base_uri='readFile.xml')
    >>> d.read()
    (replacing ... in the path with the location of the data dir)
    then you can look at d in more detail
    bytes(d) doesnt tell you much -- that almost certainly re-serialises d into a bytestream
    instead, do type(d), and dir(d) to look at the d object type, and what attributes it has that can be explored
    Anna Liao
    @anna-liao
    I ran it in a console, not in a unittest
    sure, i will check the type
    Anna Liao
    @anna-liao

    dir(d)
    ['ChildElement', 'Create', 'DiffString', 'GenerateXML', 'GetBase', 'GetChildClass', 'GetChildren', 'G
    etElementByID', 'GetElementClass', 'GetLang', 'GetSpace', 'GetUniqueID', 'Read', 'ReadFromEntity', 'R
    eadFromStream', 'RegisterElement', 'SetBase', 'SetLang', 'UnregisterElement', 'Update', 'ValidationEr
    ror', 'WriteXML', 'XMLParser', 'bytes', 'class', 'delattr', 'dict', 'dir', 'doc ', 'eq', 'format', 'ge', 'getattribute', 'gt', 'hash', 'init', 'le'
    , 'lt', 'module', 'ne', 'new', 'reduce', 'reduce_ex', 'repr', 'setattr ', 'sizeof', 'str', 'subclasshook', 'unicode', 'weakref__', 'add_child', 'base_uri
    ', 'create', 'data', 'declaration', 'diff_string', 'dtd', 'generate_xml', 'get_base', 'get_child_clas
    s', 'get_children', 'get_element_by_id', 'get_element_class', 'get_lang', 'get_space', 'get_unique_id
    ', 'idTable', 'lang', 'parent', 'processing_instruction', 'read', 'read_from_entity', 'read_from_stre
    am', 'register_element', 'req_manager', 'root', 'set_base', 'set_lang', 'unregister_element', 'update
    ', 'validation_error', 'write_xml']

    d.dict
    {'parent': None, 'idTable': {}, 'root': <pyslet.xml.structures.Element object at 0x106095240>, 'req_manag
    er': None, 'dtd': <pyslet.xml.structures.XMLDTD object at 0x103f40eb8>, 'data': [], 'declaration': None,
    'base_uri': <pyslet.rfc2396.FileURL object at 0x103b3cba8>, 'lang': None}

    d.root.get_value()
    Traceback (most recent call last):
    File "<input>", line 1, in <module>
    d.root.get_value()
    File "/Users/annaliao/repos/pyslet/pyslet/xml/structures.py", line 2335, in get_value
    return join_characters(self.generate_value(ignore_elements))
    File "/Users/annaliao/repos/pyslet/pyslet/xml/structures.py", line 2305, in generate_value
    raise XMLMixedContentError(str(self))
    pyslet.xml.structures.XMLMixedContentError:

    <assessmentItem adaptive="false" identifier="choice" timeDependent="false" title="Unattended Luggage" xml ns="http://www.imsglobal.org/xsd/imsqti_v2p2" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:s chemaLocation="http://www.imsglobal.org/xsd/imsqti_v2p2 http://www.imsglobal.org/xsd/qti/qtiv2p2/imsqti_v 2p2.xsd"><responseDeclaration baseType="identifier" cardinality="single" identifier="RESPONSE"><correctRe sponse><value>ChoiceA</value></correctResponse></responseDeclaration> <outcomeDeclaration baseType="float " cardinality="single" identifier="SCORE"><defaultValue><value>0</value></defaultValue></outcomeDeclarati on> <itemBody><p>Look at the text in the picture.</p> <p><img alt="NEVER LEAVE LUGGAGE UNATTENDED" src="i mages/sign.png"/></p> <choiceInteraction maxChoices="1" responseIdentifier="RESPONSE" shuffle="false"><pr ompt>What does it say?</prompt> <simpleChoice identifier="ChoiceA">You must stay with your luggage at all
    times.</simpleChoice> <simpleChoice identifier="ChoiceB">Do not let someone else look after your luggage
    .</simpleChoice> <simpleChoice identifier="ChoiceC">Remember your luggage when you leave.</simpleChoice><
    /choiceInteraction></itemBody> <responseProcessing template="http://www.imsglobal.org/question/qti_v2p2/r ptemplates/match_correct"/></assessmentItem>doc

    children = list(d.get_children())
    len(children)
    1
    children
    [<pyslet.xml.structures.Element object at 0x106095240>]
    children[0].xmlname
    'assessmentItem'
    children[0].get_value()
    Traceback (most recent call last):
    File "<input>", line 1, in <module>
    children[0].get_value()
    File "/Users/annaliao/repos/pyslet/pyslet/xml/structures.py", line 2335, in get_value
    return join_characters(self.generate_value(ignore_elements))
    File "/Users/annaliao/repos/pyslet/pyslet/xml/structures.py", line 2305, in generate_value
    raise XMLMixedContentError(str(self))
    pyslet.xml.structures.XMLMixedContentError:

    <assessmentItem adaptive="false" identifier="choice" timeDependent="false" title="Unattended Luggage" xml ns="http://www.imsglobal.org/xsd/imsqti_v2p2" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:s chemaLocation="http://www.imsglobal.org/xsd/imsqti_v2p2 http://www.imsglobal.org/xsd/qti/qtiv2p2/imsqti_v 2p2.xsd"><responseDeclaration baseType="identifier" cardinality="single" identifier="RESPONSE"><correctRe sponse><value>ChoiceA</value></correctResponse></responseDeclaration> <outcomeDeclaration baseType="float " cardinality="single" identifier="SCORE"><defaultValue><value>0</value></defaultValue></outcomeDeclarati on> <itemBody><p>Look at the text in the picture.</p> <p><img alt="NEVER LEAVE LUGGAGE UNATTENDED" src="i mages/sign.png"/></p> <choiceInteraction maxChoices="1" responseIdentifier="RESPONSE" shuffle="false"><pr ompt>What does it say?</prompt> <simpleChoice identifier="ChoiceA">You must stay with your luggage at all
    times.</simpleChoice> <simpleChoice identifier="ChoiceB">Do not let someone else look after your luggage
    .</simpleChoice> <simpleChoice identifier="ChoiceC">Remember your luggage when you leave.</simpleChoice><
    /choiceInteraction></itemBody> <responseProcessing template="http://www.imsglobal.org/question/qti_v2p2/r ptemplates/match_correct"/></assessmentItem>

    So that looks about right
    or consistent with when I make the same calls on my document
    len(children) is 1
    children[0].xmlname is only the first element name
    and getting the value of that child is just all the elements lumped together
    thanks for the suggestions
    Anna Liao
    @anna-liao
    Once again, I'm running into issues with the bytes/str incompatibility in CI, but not in manual tox: https://travis-ci.org/anna-liao/pyslet/builds/202693838
    Do you have suggestions on how to resolve that issue in CI? You had mentioned previously that it is a py2/py3 issue
    It affects being able to use the base_uri, which is used when reading files
    Just to clarify, the unittests for that commit passes in manual tox.
    John Vandenberg
    @jayvdb
    Nod. Ill provide a fix for your str/bytes problems when i get home this afternoon.
    Anna Liao
    @anna-liao
    thanks!
    Anna Liao
    @anna-liao
    Hello, I am wondering if I can get some feedback and guidance on wrapping up this project. It will help me to set a timeline to the completion of this internship. I am planning on moving on to another project in March, so looking to finish my work on this project in March. Thanks.
    Anna Liao
    @anna-liao
    Hello, just a note that I won't be available most of next week as I am moving and have some other personal obligations. I'm happy to continue on this project the following week. Hope you have a good weekend.
    M. Volz
    @mvolz
    Cheers
    M. Volz
    @mvolz
    Hi Anna, we need your final report by March 6th, although not if we are extended the project- I'm not sure if we ever definitively decided on that? What do you think- do you need more time?
    Anna Liao
    @anna-liao
    Hello @mvolz, yes, can I extend the project?
    Anna Liao
    @anna-liao
    I will start writing up a final report this week
    M. Volz
    @mvolz
    Ok, by how many weeks?
    Anna Liao
    @anna-liao
    One week is good for me.
    M. Volz
    @mvolz
    Ok
    Anna Liao
    @anna-liao
    Or should I include more information?
    M. Volz
    @mvolz
    Maybe some links to code and blog posts and things would be good.
    Are we ready to suit a pull request yet?
    John Vandenberg
    @jayvdb
    I dont think so, No pushes in last 14 days according to https://github.com/anna-liao/pyslet/branches
    Anna Liao
    @anna-liao
    Ah yes, I'm waiting for some feedback on the code?
    I haven't received any for the last 14 days.
    Thanks
    Actually, I haven't received any technical feedback for more like 3 weeks
    Anna Liao
    @anna-liao
    I will need to move on from this project to a new project next week. If I receive any feedback to move this towards a pull request, I can look into it.
    Anna Liao
    @anna-liao
    @mvolz I added links to code and blog posts in the final report, as requested: https://www.mediawiki.org/wiki/User:Miriya52/Outreachy13_Final_Report