Skip to content

Commit

Permalink
create table row for each document
Browse files Browse the repository at this point in the history
  • Loading branch information
raindrum committed Dec 5, 2021
1 parent b48b451 commit 69351dc
Show file tree
Hide file tree
Showing 5 changed files with 35 additions and 7 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ The sections below give a bit more detail on these concepts. If you want an exam

Every exhibit's filename (or folder name) must have a number or capital letter. For instance, `101` and `A` are both valid folder names, representing Exhibit 101 or Exhibit A, respectively.

You may also give each exhibit a title, which will appear in the exhibit list. If the exhibit is a folder full of named documents, the title is optional. If the exhibit is a PDF or image, it *must* have a title.
You may also give each exhibit a title. If an exhibit is a folder full of named documents, the title is optional. If the exhibit is a PDF or image, it *must* have a title.

An exhibit has a title if, after the exhibit number, the filename has a period, space, and then some text. An example of a titled exhibit is `103. Party Communications`.

Expand Down
36 changes: 32 additions & 4 deletions exhibiter/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
# python standard imports
from re import search, sub, fullmatch
from pathlib import Path
from copy import copy

# third-party imports
from pdfrw import PdfReader, PdfWriter, buildxobj, toreportlab
Expand Down Expand Up @@ -100,10 +101,10 @@ def from_path(
exhibit = cls(
index,
title,
number_pages=number_pages,
page_label_coords=page_label_coords,
rotate_landscape_pics=rotate_landscape_pics,
evidentiary_disputes=evidentiary_disputes,
number_pages = number_pages,
page_label_coords = page_label_coords,
rotate_landscape_pics = rotate_landscape_pics,
evidentiary_disputes = evidentiary_disputes,
)

# add all evidence from the path to it
Expand Down Expand Up @@ -268,6 +269,7 @@ def write_list(
party_label: str = "Defense",
show_page_numbers: bool = True,
reserve_rebuttal: bool = True,
row_per_doc: bool = True,
):
"""Save a Word document listing the given exhibits in detail."""
template = str(Path(__file__).parent.absolute() / "template.docx")
Expand All @@ -283,6 +285,30 @@ def write_list(
f"{party_label.upper()} EXHIBITS"
).bold = True

# treat each doc as its own exhibit
if row_per_doc:
new_exhibits = []
for exhibit in exhibits:
for document in exhibit.documents:
start = document['page_span'][0]
end = document['page_span'][1]
index = exhibit.index

if len(exhibit.documents) == 1:
pass
elif end > start:
index = f'{index}-{start}\nto\n{index}-{end}'
else:
index = f'{index}-{start}'

new_exhibit = Exhibit(
index = index,
title = document['name'],
)
new_exhibit.documents = [document]
new_exhibits.append(new_exhibit)
exhibits = new_exhibits

for exhibit in exhibits:
# add a table row, to represent the exhibit
row = exhibit_list.tables[0].add_row()
Expand Down Expand Up @@ -333,6 +359,8 @@ def write_list(
if reserve_rebuttal:
# calculate the next exhibit number or letter
last_index = exhibits[-1].index
if '-' in last_index:
last_index = last_index.split('-')[0]
if search("[A-Y]", last_index):
next_index = chr(ord(last_index) + 1)
else:
Expand Down
2 changes: 1 addition & 1 deletion exhibiter/gui.py
Original file line number Diff line number Diff line change
Expand Up @@ -285,7 +285,7 @@ def load_exhibits(self):
)
)

# update theGUI
# update the GUI
self.exhibits_need_regen = False
self.docx_save_btn.setEnabled(True)
self.pdf_save_btn.setEnabled(True)
Expand Down
Binary file modified exhibiter/template.docx
Binary file not shown.
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

setuptools.setup(
name='exhibiter',
version='1.0.3',
version='1.1.0',
description='a tool to organize evidence for litigation',
author='Simon Raindrum Sherred',
author_email='simonraindrum@gmail.com',
Expand Down

0 comments on commit 69351dc

Please sign in to comment.