def __init__(self, path): log.debug('opening notebook root directory: %s', path) self.path = path with open(os.path.join(path, 'worksheet.html'), 'rb') as f: self.ws = f.read().decode('utf-8') with open(os.path.join(path, 'worksheet_conf.pickle')) as f: self.conf = cPickle.load(f)
def __init__(self, path): log.debug('opening notebook root directory: %s', path) self.path = path with open(os.path.join(path, 'worksheet.html'), 'rb') as f: self.ws = f.read().decode('utf-8') with open(os.path.join(path, 'worksheet_conf.pickle')) as f: self.conf = cPickle.load(f)
def _read_cell_output(self): assert self.is_cell_mid self.pos += 1 accumulator = [] while not (self.is_cell_back or self.is_finished): log.debug('Read cell output: %s', self.line) accumulator.append(self.get_line_and_forward()) return unescape(u'\n'.join(accumulator).strip())
def _try_read_text(self): accumulator = [] while not (self.is_cell_front or self.is_finished): log.debug('Read text: %s', self.line) accumulator.append(self.get_line_and_forward()) accumulator = u'\n'.join(accumulator).strip() if accumulator: return TextCell(accumulator)
def _read_cell_output(self): assert self.is_cell_mid self.pos += 1 accumulator = [] while not (self.is_cell_back or self.is_finished): log.debug('Read cell output: %s', self.line) accumulator.append(self.get_line_and_forward()) return unescape(u'\n'.join(accumulator).strip())
def _try_read_text(self): accumulator = [] while not (self.is_cell_front or self.is_finished): log.debug('Read text: %s', self.line) accumulator.append(self.get_line_and_forward()) accumulator = u'\n'.join(accumulator).strip() if accumulator: return TextCell(accumulator)
def __init__(self, worksheet_html): self.worksheet_lines = worksheet_html.splitlines() self.pos = 0 self.index = -1 log.debug('Worksheet has %s lines', len(self.worksheet_lines))
def cells(self): for cell in WorksheetParser(self.ws): log.debug('Cell: %s', cell) yield cell
def __init__(self, worksheet_html): self.worksheet_lines = worksheet_html.splitlines() self.pos = 0 self.index = -1 log.debug('Worksheet has %s lines', len(self.worksheet_lines))
def cells(self): for cell in WorksheetParser(self.ws): log.debug('Cell: %s', cell) yield cell