service.preclass.processors.ppt2text module
- class service.preclass.processors.ppt2text.SERVICE[source]
Bases:
object
Service class for handling PowerPoint to text conversion tasks.
Static Attributes:
- _collection (MongoClient=preclass.ppt2text): MongoDB collection for storing job information
- _queue_name (str): RabbitMQ queue name for the service. Default to preclass-ppt2text
- _logger: Logger instance for the service
- static callback(ch, method, properties, body)[source]
Process PowerPoint conversion jobs from the RabbitMQ queue.
- Parameters:
ch – RabbitMQ channel
method – RabbitMQ method frame
properties – RabbitMQ properties
body – Message body containing the job ID
- static launch_worker()[source]
Launch the worker to process PowerPoint conversion jobs.
Starts consuming messages from the RabbitMQ queue and processes them. Can be terminated with CTRL+C.
- static trigger(parent_service, lecture_id, parent_job_id)[source]
Trigger a new PPT to text conversion job.
- Parameters:
parent_service (str) – Name of the parent service
lecture_id (ObjectId) – MongoDB ObjectId of the lecture
parent_job_id (ObjectId) – MongoDB ObjectId of the parent job
- Returns:
The job ID of the created conversion task
- Return type:
str
- service.preclass.processors.ppt2text.extract_text_from_ppt(ppt_path, png_path, lecture_id)[source]
Extract text and images from PowerPoint slides and store them in the database.
- Parameters:
ppt_path (str) – Path to the PowerPoint file
png_path (str) – Directory path where PNG images will be stored
lecture_id (ObjectId) – MongoDB ObjectId of the lecture
- Return type:
None
The function processes each slide to: - Extract text content from shapes - Convert slide to PNG image - Store both text and image in the database
- service.preclass.processors.ppt2text.now(tz=None)
Returns new datetime object representing current time local to tz.
- tz
Timezone object.
If no tz is specified, uses local timezone.