document

Module document |
[hide private]
[frames] | no frames]

## Source Code for Module document

     1
     2  from baseObjects import Document
     3
     4  # Data:  data, creator, history, filename, offset, length, mimeType, parent
     5  # MARC mimetype is application/marc (RFC2220)
     6
     7 -class StringDocument(Document):
     8
     9 -    def __init__(self, text, creator="", history=[], mimeType="", parent=None, filename=None, schema=""):
    10          self.schema = schema
    11          self.size = 0
    12          self.text = text
    13          self.mimeType = mimeType
    14          self.filename = filename
    15          if (history):
    16              self.processHistory = history
    17          else:
    18              self.processHistory = []
    19          if creator:
    20              self.processHistory.append(creator)
    21          if parent:
    22              self.parent = parent
    23
    24 -    def get_raw(self):
    25          return self.text
    26
    27 -    def find_exception(self, e):
    28          # Find the cause of a parse exception as reported by expat
    29          line = e._linenum - 1
    30          lines = self.text.split('\n')
    31          l = lines[line]
    32          chr = e._colnum
    33          start = min(0, chr - 10)
    34          end = min(chr+70, len(l))
    35          return l[start:end]
    36