diff --git a/README.md b/README.md index 20bec02..f2a7a84 100755 --- a/README.md +++ b/README.md @@ -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`. diff --git a/exhibiter/__init__.py b/exhibiter/__init__.py index c6057a3..9001c22 100755 --- a/exhibiter/__init__.py +++ b/exhibiter/__init__.py @@ -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 @@ -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 @@ -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") @@ -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() @@ -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: diff --git a/exhibiter/gui.py b/exhibiter/gui.py index eb7252f..cd337a7 100755 --- a/exhibiter/gui.py +++ b/exhibiter/gui.py @@ -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) diff --git a/exhibiter/template.docx b/exhibiter/template.docx index 29d5e0b..bb1df7f 100644 Binary files a/exhibiter/template.docx and b/exhibiter/template.docx differ diff --git a/setup.py b/setup.py index 1ddb534..09a3915 100755 --- a/setup.py +++ b/setup.py @@ -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',