Skip to content
This repository was archived by the owner on Apr 11, 2025. It is now read-only.

Commit a29a8cd

Browse files
committed
add docstring to get_backend
1 parent bb6ef73 commit a29a8cd

File tree

1 file changed

+36
-0
lines changed

1 file changed

+36
-0
lines changed

camelot/backends/image_conversion.py

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,42 @@ def __init__(self, backend: Any = "poppler", use_fallback: bool = True) -> None:
4545
)
4646

4747
def get_backend(self, backend):
48+
"""Retrieve the specified backend for processing.
49+
50+
This method checks if the provided backend is a string representing
51+
a known backend or an object implementing a 'convert' method. It
52+
returns an instance of the backend if valid.
53+
54+
Parameters
55+
----------
56+
backend : str or object
57+
The backend to retrieve. This can be:
58+
- A string ('poppler' or 'ghostscript') corresponding to a pre-defined backend.
59+
- An object that must implement a 'convert' method.
60+
61+
Returns
62+
-------
63+
object
64+
An instance of the specified backend.
65+
66+
Raises
67+
------
68+
NotImplementedError
69+
If the backend is a string that is not recognized or if it is an
70+
object that does not implement the 'convert' method.
71+
72+
Examples
73+
--------
74+
>> backend_instance = get_backend('poppler')
75+
>> backend_instance = get_backend(my_custom_backend)
76+
77+
Notes
78+
-----
79+
The valid backends are defined in the BACKENDS dictionary. The
80+
method verifies the backend type and raises exceptions for
81+
unsupported backends.
82+
"""
83+
4884
def implements_convert():
4985
methods = [
5086
method for method in dir(backend) if method.startswith("__") is False

0 commit comments

Comments
 (0)