aoptk.literature.utils ====================== .. py:module:: aoptk.literature.utils Classes ------- .. autoapisummary:: aoptk.literature.utils.AsyncRequestLimiter Functions --------- .. autoapisummary:: aoptk.literature.utils.is_europepmc_id aoptk.literature.utils.convert_image_format aoptk.literature.utils.convert_to_png aoptk.literature.utils._image_in_this_format_already_exists aoptk.literature.utils.remove_pmc_prefix Module Contents --------------- .. py:class:: AsyncRequestLimiter(requests_per_second: int) Asynchronous request limiter to control the rate of API calls. .. py:attribute:: min_interval .. py:attribute:: _lock .. py:attribute:: _next_allowed :value: 0.0 .. py:method:: wait_turn() -> None :async: Wait until it's the turn for the next request based on the rate limit. .. py:function:: is_europepmc_id(publication_id: aoptk.literature.id.ID) -> bool Check if the given publication ID is a EuropePMC ID. .. py:function:: convert_image_format(images_to_convert_path: list[pathlib.Path], target_format: str = 'png') -> list[pathlib.Path] Convert every image in a list to the specified format. :param images_to_convert_path: The images to convert. :param target_format: The desired image format (e.g., 'png', 'jpg'). .. py:function:: convert_to_png(inpath: pathlib.Path, outpath: pathlib.Path) -> None Convert an image to PNG format. :param inpath: The path of the input image. :param outpath: The path where the converted image will be saved. .. py:function:: _image_in_this_format_already_exists(target_format: str, image_path: pathlib.Path) -> bool Check if the image is already in the target format. :param target_format: The desired image format (e.g., 'png', 'jpg'). :param image_path: The path of the image to check. .. py:function:: remove_pmc_prefix(ids: list[aoptk.literature.id.ID]) -> list[aoptk.literature.id.ID] Remove the 'PMC' prefix from ID. :param ids: A list of IDs to remove the prefix from. :type ids: list[ID]