1 """Simplify adding markup to a piece of text."""
2
3 import warnings
4 warnings.warn("""\
5 Bio.MarkupEditor is deprecated.
6 If you use the code in Bio.MarkupEditor, Please get in touch on
7 the Biopython mailing lists to prevent permanent removal of this
8 module.""",
9 DeprecationWarning)
10
11
12
13
14 from xml.sax import saxutils
15
16
22
25
26
29 self.left = []
30 self.right = []
31
87
89 from cStringIO import StringIO
90 file = StringIO()
91 markup.to_file(file)
92 s = file.getvalue()
93 assert s == expect, (s, expect)
94
96 markup = MarkupEditor("01234")
97 _compare(markup, "01234")
98 markup.insert_text(0, "A")
99 _compare(markup, "A01234")
100 markup.insert_text(5, "Z")
101 _compare(markup, "A01234Z")
102 markup.insert_text(5, "Y")
103 _compare(markup, "A01234YZ")
104 markup.insert_text(5, "<")
105 _compare(markup, "A01234<YZ")
106 markup.insert_raw_text(1, "BCD")
107 _compare(markup, "A0BCD1234<YZ")
108 markup.insert_raw_text(3, "<P>")
109 _compare(markup, "A0BCD12<P>34<YZ")
110 markup.insert_element(1, 3, "a", {"tag": "value"})
111 _compare(markup, 'A0<a tag="value">BCD12</a><P>34<YZ')
112 markup.insert_element(1, 1, "Q", {"R": "S"})
113 _compare(markup, 'A0<Q R="S"></Q><a tag="value">BCD12</a><P>34<YZ')
114 markup.insert_singleton(3, "br")
115 _compare(markup, 'A0<Q R="S"></Q><a tag="value">BCD12</a><br><P>34<YZ')
116
117 if __name__ == "__main__":
118 test()
119