Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def clone_page_content(src_page, dst_page, mapping, salt):
src_boxes_lines = src_page.boxes
dst_boxes_lines = []
for src_boxes_line in src_boxes_lines:
src_boxes = src_boxes_line.word_boxes
dst_boxes_line = [clone_box(box, mapping, salt) for box in src_boxes]
dst_boxes_line = LineBox(dst_boxes_line, src_boxes_line.position)
dst_boxes_lines.append(dst_boxes_line)
dst_page.boxes = dst_boxes_lines
dst_page.img = clone_img(src_page.img)
def clone_page_content(src_page, dst_page, mapping, salt):
src_boxes_lines = src_page.boxes
dst_boxes_lines = []
for src_boxes_line in src_boxes_lines:
src_boxes = src_boxes_line.word_boxes
dst_boxes_line = [clone_box(box, mapping, salt) for box in src_boxes]
dst_boxes_line = LineBox(dst_boxes_line, src_boxes_line.position)
dst_boxes_lines.append(dst_boxes_line)
dst_page.boxes = dst_boxes_lines
dst_page.img = clone_img(src_page.img)
try:
box_builder = pyocr.builders.LineBoxBuilder()
with self.fs.open(boxfile, 'r') as file_desc:
boxes = box_builder.read_file(file_desc)
if boxes != []:
return boxes
# fallback: old format: word boxes
# shouldn't be used anymore ...
box_builder = pyocr.builders.WordBoxBuilder()
with self.fs.open(boxfile, 'r') as file_desc:
boxes = box_builder.read_file(file_desc)
if len(boxes) <= 0:
return []
logger.warning("WARNING: Doc %s uses old box format" %
(str(self.doc)))
return [pyocr.builders.LineBox(boxes, boxes[0].position)]
except IOError as exc:
logger.error("Unable to get boxes for '%s': %s"
% (self.doc.docid, exc))
return []