Skip to content

Commit c6efbc4

Browse files
authored
Merge pull request #76 from SynBioDex/75-pdf_reader
Fix #75
2 parents dae22f6 + 54857c5 commit c6efbc4

File tree

3 files changed

+18
-4
lines changed

3 files changed

+18
-4
lines changed

.github/workflows/python-app.yml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,11 @@ jobs:
2626
with:
2727
python-version: ${{ matrix.python-version }}
2828
- name: Setup Graphviz
29-
uses: ts-graphviz/setup-graphviz@v1
29+
uses: ts-graphviz/setup-graphviz@v1.2
30+
with:
31+
# Skip to run brew update command on macOS.
32+
# See https://github.com/ts-graphviz/setup-graphviz/issues/457
33+
macos-skip-brew-update: 'true' # defalt false
3034
- name: Install Python dependencies
3135
shell: bash
3236
run: |

sbol_factory/uml_factory.py

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,12 @@
22

33
import sbol3 as sbol
44
import pylatex
5-
from PyPDF2 import PdfFileReader
5+
import PyPDF2
6+
if PyPDF2.__version__.split('.')[0] < '3':
7+
from PyPDF2 import PdfFileReader
8+
else:
9+
# PdfFileReader is deprecated and was removed in PyPDF2 3.0.0. Use PdfReader instead.
10+
from PyPDF2 import PdfReader as PdfFileReader
611

712
import os
813
import graphviz
@@ -61,7 +66,12 @@ def generate(self, output_path):
6166
outfile += '.pdf'
6267
width = 470 # default \textwidth of LaTeX document
6368
with open(os.path.join(output_path, outfile), 'rb') as pdf:
64-
width = PdfFileReader(pdf).getPage(0).mediaBox[2]
69+
if PyPDF2.__version__.split('.')[0] < '3':
70+
# reader.getPage(pageNumber) is deprecated and was removed in PyPDF2 3.0.0. Use reader.pages[page_number] instead.
71+
width = PdfFileReader(pdf).getPage(0).mediaBox[2]
72+
else:
73+
width = PdfFileReader(pdf).pages[0].mediabox[2]
74+
6575
self._generate(class_uri, self.write_class_definition, 0, class_name, output_path, width)
6676

6777
fname_tex = f'{self.prefix}DataModel'

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
setup(name='sbol_factory',
88
description='Ontology-driven data modeling',
9-
version='1.1',
9+
version='1.1.1.post1',
1010
install_requires=[
1111
'sbol3>=1.0b12', # Note: implicitly includes rdflib
1212
'sparqlwrapper>=1.8.5',

0 commit comments

Comments
 (0)