rabbitmq_pdfparser
rabbitmq_pdfparser is asynchronous job library that consume RabbitMQ for PDF urls and publish pdf text back to RabbitMQ. It stops when queue is empty.
Installation
You can install this library easily with pip.
pip install rabbitmq-pdfparser
Usage
Data must send to source queue should this format:
{"id": "foo", "url": "http://example.com/foo/bar.pdf"}
As a library
import os
import asyncio
from rabbitmq_pdfparser import consume
if __name__ == '__main__':
logger = logging.getLogger("rabbitmq_pdfparser")
logger.setLevel(os.environ.get('LOG_LEVEL', "DEBUG"))
handler = logging.StreamHandler()
handler.setFormatter(
logging.Formatter(
os.environ.get('LOG_FORMAT', "%(asctime)s [%(levelname)s] %(name)s: %(message)s")
)
)
logger.addHandler(handler)
config = {
"mq_host": os.environ.get('MQ_HOST'),
"mq_port": int(os.environ.get('MQ_PORT')),
"mq_vhost": os.environ.get('MQ_VHOST'),
"mq_user": os.environ.get('MQ_USER'),
"mq_pass": os.environ.get('MQ_PASS'),
"mq_source_queue": os.environ.get('MQ_SOURCE_QUEUE'),
"mq_target_exchange": os.environ.get('MQ_TARGET_EXCHANGE'),
"mq_target_routing_key": os.environ.get('MQ_TARGET_ROUTING_KEY')
}
loop = asyncio.get_event_loop()
loop.run_until_complete(
consume(
loop=loop,
consumer_pool_size=10,
config=config
)
)
loop.close()
This library uses PyPDF2, aio_pika and aiohttp packages.
Standalone
You can also call this library as standalone PDF parser job. Just set required environment variables and run rabbitmq_pdfparser. This usecase perfectly fits when you need run it on cronjobs or kubernetes jobs.
Required environment variables:
- MQ_HOST
- MQ_PORT (optional)
- MQ_VHOST
- MQ_USER
- MQ_PASS
- MQ_SOURCE_QUEUE (Queue that job consume urls)
- MQ_TARGET_EXCHANGE (Exchange that job publish texts)
- MQ_TARGET_ROUTING_KEY (Routing key that job publish texts)
- MQ_QUEUE_DURABLE (optional, default value: True)
- CONSUMER_POOL_SIZE (optional, default value: 10)
- LOG_LEVEL (Logging level. See: Python logging module docs)
Example Kubernetes job: You can see it to kube.yaml
Metadata
Release files for rabbitmq-pdfparser 1.0.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| rabbitmq_pdfparser-1.0.1-py3-none-any.whl | Python 3 | none | any | Details for rabbitmq_pdfparser-1.0.1-py3-none-any.whl |
Release files / rabbitmq_pdfparser-1.0.1-py3-none-any.whl
| Download URL | rabbitmq_pdfparser-1.0.1-py3-none-any.whl |
|---|---|
| Size | 8.7 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
b4d3dc79b7608be10cbeac50620a004a8b4845eca386aabaaba2950f5d474497
|
|
BLAKE2b-256 checksum How to use checksums |
12f30e0728147c26f42b26b1bb7e53668b8c2c65d4941ad09ff44b158ed6ea33
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.1 CPython/3.9.15
|
Security for rabbitmq-pdfparser 1.0.1
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.