User:Miriya52/week8

Refer to project glossary for acronyms and definitions. Week 8: January 23 - 27

Objectives

 * Implement functionality for reading in .txt file to parser. Pass test_gift_structures: (test_string, test_read_string, test_read_file))
 * Add more types to parser

While debugging functionality for reading in .txt file to parser, found that imported text is showing up in parser by the int representation.
File "/Users/annaliao/repos/pyslet/pyslet/gift/structures.py", line 1968, in read_from_entity parser.parse_document(self) File "/Users/annaliao/repos/pyslet/pyslet/gift/parser.py", line 512, in parse_document self.parse_element File "/Users/annaliao/repos/pyslet/pyslet/gift/parser.py", line 673, in parse_element self.parse_content File "/Users/annaliao/repos/pyslet/pyslet/gift/parser.py", line 749, in parse_content raise GIFTFatalError("parse_content: unexpected character, %s" % self.the_char) pyslet.gift.parser.GIFTFatalError: parse_content: unexpected character, 47

For example:

>>> parser.the_char 47 >>> parser.next_char >>> parser.the_char 47 >>> parser.next_char >>> parser.the_char 72 >>> parser.next_char >>> parser.the_char 101 >>> parser.next_char >>> parser.the_char 108

unicode conversion from file to parser. '/': https://unicode-table.com/en/#002F, &#47 'H': https://unicode-table.com/en/#0048, &#72 'e': https://unicode-table.com/en/#0065, &#101 'l': https://unicode-table.com/en/#006C, &#108

Fixed this issue by casting chr to get the unicode str representation of the int.

if isinstance(self.the_char, int): self.the_char = chr(self.the_char)

Not a good long term solution. Need to find where this is happening when reading in a file, or have a function for converting.

STATUS : test_gift_structures.test_string and test_gift_structures.test_read_file are the unittests for this functionality. These tests are not passing yet.

parser.parse_content
This is where the logic for parsing a GIFT formatted string occurs.

structures.escape_char_data
There are special control characters for the GIFT format, including '//', '::', '{', '=', '~'. These need to be addressed when parsing a GIFT formatted text. Specifically, when the quiz author intentionally wants it included in the text, and when it is an invalid use in the text.

Summary

 * Point 1
 * Point 2

Plan for next week

 * Point 1
 * Point 2