def test_issue144_fields_crossing_lineseg_boundary(self): from hwp5 import xmlmodel from hwp5 import treeop from fixtures import get_fixture_path from pprint import pprint pprint name = 'issue144-fields-crossing-lineseg-boundary.hwp' path = get_fixture_path(name) hwp5file = xmlmodel.Hwp5File(path) xmlevents = hwp5file.bodytext.xmlevents() #pprint(list(enumerate(xmlevents))) stack_fields = [] for ev, model in xmlevents: if ev is treeop.STARTEVENT: tag = model[0] else: tag = model if tag.startswith('Field'): if ev is treeop.STARTEVENT: stack_fields.append(model) else: stack_fields.pop() elif tag == 'LineSeg': # NO CROSSING if ev is treeop.STARTEVENT: assert len(stack_fields) == 0 else: assert len(stack_fields) == 0
def test_footnote_shape(self): from fixtures import get_fixture_path from hwp5.binmodel import Hwp5File path = get_fixture_path('footnote-endnote.hwp') hwp5file = Hwp5File(path) models = hwp5file.bodytext.section(0).models() models = list(models) fnshape = models[6] self.assertEquals(850, fnshape['content']['splitter_margin_top']) self.assertEquals(567, fnshape['content']['splitter_margin_bottom'])
def test_match_field_start_end(self): from hwp5 import binmodel, xmlmodel from fixtures import get_fixture_path path = get_fixture_path('match-field-start-end.dat') import pickle f = open(path, 'r') try: records = pickle.load(f) finally: f.close() models = binmodel.parse_models(dict(), records) events = xmlmodel.prefix_binmodels_with_event(dict(), models) events = xmlmodel.make_texts_linesegmented_and_charshaped(events) events = xmlmodel.make_extended_controls_inline(events) events = xmlmodel.match_field_start_end(events) events = list(events)
def example(filename): from fixtures import get_fixture_path from hwp5.xmlmodel import Hwp5File path = get_fixture_path(filename) return Hwp5File(path)
def get_fixture_file(self, filename): from fixtures import get_fixture_path return get_fixture_path(filename)
def example_path(filename): from fixtures import get_fixture_path return get_fixture_path(filename)