Update gh workflow and remove logging
parent
ff7260a228
commit
0c20cb0be8
|
|
@ -7,7 +7,28 @@ jobs:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
strategy:
|
strategy:
|
||||||
matrix:
|
matrix:
|
||||||
python-version: [3.6, 3.7, 3.8, 3.9]
|
python-version: [3.6, 3.7, 3.8]
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v2
|
||||||
|
- name: Set up Python ${{ matrix.python-version }}
|
||||||
|
uses: actions/setup-python@v2
|
||||||
|
with:
|
||||||
|
python-version: ${{ matrix.python-version }}
|
||||||
|
- name: Install camelot with dependencies
|
||||||
|
run: |
|
||||||
|
make install
|
||||||
|
- name: Test with pytest
|
||||||
|
run: |
|
||||||
|
make test
|
||||||
|
|
||||||
|
test_latest:
|
||||||
|
name: Test on ${{ matrix.os }} with Python 3.9
|
||||||
|
runs-on: ${{ matrix.os }}
|
||||||
|
strategy:
|
||||||
|
matrix:
|
||||||
|
os: [ubuntu-latest, macos-latest, windows-latest]
|
||||||
|
python-version: [3.9]
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v2
|
- uses: actions/checkout@v2
|
||||||
|
|
|
||||||
|
|
@ -1,11 +1,8 @@
|
||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
|
|
||||||
import logging
|
|
||||||
|
|
||||||
from .poppler_backend import PopplerBackend
|
from .poppler_backend import PopplerBackend
|
||||||
from .ghostscript_backend import GhostscriptBackend
|
from .ghostscript_backend import GhostscriptBackend
|
||||||
|
|
||||||
logger = logging.getLogger("camelot")
|
|
||||||
backends = {"poppler": PopplerBackend, "ghostscript": GhostscriptBackend}
|
backends = {"poppler": PopplerBackend, "ghostscript": GhostscriptBackend}
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -23,9 +20,7 @@ class ImageConversionBackend(object):
|
||||||
converter = backends[self.backend]()
|
converter = backends[self.backend]()
|
||||||
converter.convert(pdf_path, png_path)
|
converter.convert(pdf_path, png_path)
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
logger.info(
|
import sys
|
||||||
f"Image conversion backend '{self.backend}' failed with '{str(e)}'"
|
|
||||||
)
|
|
||||||
|
|
||||||
if self.use_fallback:
|
if self.use_fallback:
|
||||||
for fallback in self.fallbacks:
|
for fallback in self.fallbacks:
|
||||||
|
|
@ -35,10 +30,13 @@ class ImageConversionBackend(object):
|
||||||
converter = backends[fallback]()
|
converter = backends[fallback]()
|
||||||
converter.convert(pdf_path, png_path)
|
converter.convert(pdf_path, png_path)
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
logger.info(
|
raise type(e)(
|
||||||
f"Image conversion backend '{fallback}' failed with '{str(e)}'"
|
str(e) + f" with image conversion backend '{fallback}'"
|
||||||
)
|
).with_traceback(sys.exc_info()[2])
|
||||||
continue
|
continue
|
||||||
else:
|
else:
|
||||||
logger.info(f"Image conversion backend '{fallback}' succeeded")
|
|
||||||
break
|
break
|
||||||
|
else:
|
||||||
|
raise type(e)(
|
||||||
|
str(e) + f" with image conversion backend '{self.backend}'"
|
||||||
|
).with_traceback(sys.exc_info()[2])
|
||||||
|
|
|
||||||
|
|
@ -36,7 +36,7 @@ def test_lattice_contour_plot_poppler():
|
||||||
@pytest.mark.mpl_image_compare(baseline_dir="files/baseline_plots", remove_text=True)
|
@pytest.mark.mpl_image_compare(baseline_dir="files/baseline_plots", remove_text=True)
|
||||||
def test_lattice_contour_plot_ghostscript():
|
def test_lattice_contour_plot_ghostscript():
|
||||||
filename = os.path.join(testdir, "foo.pdf")
|
filename = os.path.join(testdir, "foo.pdf")
|
||||||
tables = camelot.read_pdf(filename, backend=ImageConversionBackend('ghostscript'))
|
tables = camelot.read_pdf(filename, backend=ImageConversionBackend("ghostscript"))
|
||||||
return camelot.plot(tables[0], kind="contour")
|
return camelot.plot(tables[0], kind="contour")
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -57,7 +57,7 @@ def test_line_plot_poppler():
|
||||||
@pytest.mark.mpl_image_compare(baseline_dir="files/baseline_plots", remove_text=True)
|
@pytest.mark.mpl_image_compare(baseline_dir="files/baseline_plots", remove_text=True)
|
||||||
def test_line_plot_ghostscript():
|
def test_line_plot_ghostscript():
|
||||||
filename = os.path.join(testdir, "foo.pdf")
|
filename = os.path.join(testdir, "foo.pdf")
|
||||||
tables = camelot.read_pdf(filename, backend=ImageConversionBackend('ghostscript'))
|
tables = camelot.read_pdf(filename, backend=ImageConversionBackend("ghostscript"))
|
||||||
return camelot.plot(tables[0], kind="line")
|
return camelot.plot(tables[0], kind="line")
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -71,7 +71,7 @@ def test_joint_plot_poppler():
|
||||||
@pytest.mark.mpl_image_compare(baseline_dir="files/baseline_plots", remove_text=True)
|
@pytest.mark.mpl_image_compare(baseline_dir="files/baseline_plots", remove_text=True)
|
||||||
def test_joint_plot_ghostscript():
|
def test_joint_plot_ghostscript():
|
||||||
filename = os.path.join(testdir, "foo.pdf")
|
filename = os.path.join(testdir, "foo.pdf")
|
||||||
tables = camelot.read_pdf(filename, backend=ImageConversionBackend('ghostscript'))
|
tables = camelot.read_pdf(filename, backend=ImageConversionBackend("ghostscript"))
|
||||||
return camelot.plot(tables[0], kind="joint")
|
return camelot.plot(tables[0], kind="joint")
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -85,5 +85,5 @@ def test_grid_plot_poppler():
|
||||||
@pytest.mark.mpl_image_compare(baseline_dir="files/baseline_plots", remove_text=True)
|
@pytest.mark.mpl_image_compare(baseline_dir="files/baseline_plots", remove_text=True)
|
||||||
def test_grid_plot_ghostscript():
|
def test_grid_plot_ghostscript():
|
||||||
filename = os.path.join(testdir, "foo.pdf")
|
filename = os.path.join(testdir, "foo.pdf")
|
||||||
tables = camelot.read_pdf(filename, backend=ImageConversionBackend('ghostscript'))
|
tables = camelot.read_pdf(filename, backend=ImageConversionBackend("ghostscript"))
|
||||||
return camelot.plot(tables[0], kind="grid")
|
return camelot.plot(tables[0], kind="grid")
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue