Skip to content

Commit

Permalink
Merge pull request #76 from SynBioDex/75-pdf_reader
Browse files Browse the repository at this point in the history
Fix #75
  • Loading branch information
bbartley authored Jan 12, 2023
2 parents dae22f6 + 54857c5 commit c6efbc4
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 4 deletions.
6 changes: 5 additions & 1 deletion .github/workflows/python-app.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,11 @@ jobs:
with:
python-version: ${{ matrix.python-version }}
- name: Setup Graphviz
uses: ts-graphviz/setup-graphviz@v1
uses: ts-graphviz/[email protected]
with:
# Skip to run brew update command on macOS.
# See https://github.com/ts-graphviz/setup-graphviz/issues/457
macos-skip-brew-update: 'true' # defalt false
- name: Install Python dependencies
shell: bash
run: |
Expand Down
14 changes: 12 additions & 2 deletions sbol_factory/uml_factory.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,12 @@

import sbol3 as sbol
import pylatex
from PyPDF2 import PdfFileReader
import PyPDF2
if PyPDF2.__version__.split('.')[0] < '3':
from PyPDF2 import PdfFileReader
else:
# PdfFileReader is deprecated and was removed in PyPDF2 3.0.0. Use PdfReader instead.
from PyPDF2 import PdfReader as PdfFileReader

import os
import graphviz
Expand Down Expand Up @@ -61,7 +66,12 @@ def generate(self, output_path):
outfile += '.pdf'
width = 470 # default \textwidth of LaTeX document
with open(os.path.join(output_path, outfile), 'rb') as pdf:
width = PdfFileReader(pdf).getPage(0).mediaBox[2]
if PyPDF2.__version__.split('.')[0] < '3':
# reader.getPage(pageNumber) is deprecated and was removed in PyPDF2 3.0.0. Use reader.pages[page_number] instead.
width = PdfFileReader(pdf).getPage(0).mediaBox[2]
else:
width = PdfFileReader(pdf).pages[0].mediabox[2]

self._generate(class_uri, self.write_class_definition, 0, class_name, output_path, width)

fname_tex = f'{self.prefix}DataModel'
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

setup(name='sbol_factory',
description='Ontology-driven data modeling',
version='1.1',
version='1.1.1.post1',
install_requires=[
'sbol3>=1.0b12', # Note: implicitly includes rdflib
'sparqlwrapper>=1.8.5',
Expand Down

0 comments on commit c6efbc4

Please sign in to comment.