Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions app/main/checks/presentation_checks/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,3 +17,4 @@
from .name_of_image_check import PresImageCaptureCheck
from .task_tracker import TaskTracker
from .overview_in_tasks import OverviewInTasks
from .aspect_ratio_check import PresAspectRatioCheck
54 changes: 54 additions & 0 deletions app/main/checks/presentation_checks/aspect_ratio_check.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
import math

from ..base_check import BasePresCriterion, answer

class Ratio:
ASCPECT_RATIO_PRECISION = 2

def __init__(self, width, height):
self.width = width
self.height = height
if height == 0:
self.value = 0
else:
self.value = round(width / height, self.ASCPECT_RATIO_PRECISION)

def __eq__(self, other):
return self.value == other.value

def __hash__(self):
return hash(self.value)

def __str__(self):
gcd_value = math.gcd(self.width, self.height)
if gcd_value == 0:
return "0:0"
simplified_width = self.width // gcd_value
simplified_height = self.height // gcd_value
return f'{simplified_width}:{simplified_height}'


class PresAspectRatioCheck(BasePresCriterion):
label = "Проверка соотношения сторон слайда"
description = ""
id = 'pres_aspect_ratio_check'

def __init__(self, file_info, correct_ratios=("16:9", "4:3")):
super().__init__(file_info)
self.correct_ratios = set(Ratio(*map(int, x.split(':'))) for x in correct_ratios)

def __is_correct_ratio(self, aspect_ratio: Ratio):
return aspect_ratio in self.correct_ratios

def check(self):
width = self.file.prs.slide_width
height = self.file.prs.slide_height

aspect_ratio = Ratio(width, height)

if self.__is_correct_ratio(aspect_ratio):
return answer(True, f"Соотношение сторон слайдов ({aspect_ratio}) соответствует стандарту.")

correct_ratios_str = ", ".join(map(str, self.correct_ratios))
return answer(False,
f'Соотношение сторон слайдов ({aspect_ratio}) не соответствует стандарту ({correct_ratios_str}).')
Copy link
Collaborator

@HadronCollider HadronCollider Feb 15, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Чтобы не пугать пользователя фидбеком Соотношение сторон слайдов (68336:47625) не соответствует стандарту (16:9, 4:3). - давайте указывать в дополнение (или вместо вычисленных aspect_ratio) ширина/высота (=размеры полученные из файла) - чтобы было понятно о чем речь и где проблема

Также добавьте краткую инструкцию - как исправить