Files
kadastr14/models/cadastral_record.py
2025-08-12 23:53:44 +05:00

34 lines
1.5 KiB
Python
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
"""
Модель для хранения информации о кадастровом объекте.
"""
from typing import Set
class CadastralRecord:
def __init__(self, main_number: str, file_path: str, all_numbers: Set[str] = None):
"""
Инициализация записи о кадастровом объекте
Args:
main_number: Основной кадастровый номер объекта
file_path: Путь к XML файлу
all_numbers: Все кадастровые номера, найденные в том же XML файле
"""
self.number = main_number # Оставляем для обратной совместимости
self.main_number = main_number
self.file_path = file_path
self.all_numbers = all_numbers if all_numbers is not None else {main_number}
@property
def other_numbers(self) -> Set[str]:
"""Возвращает все номера кроме основного"""
return self.all_numbers - {self.main_number}
def __str__(self):
other_count = len(self.other_numbers)
if other_count > 0:
return f"Объект {self.main_number} (+{other_count} номеров), файл: {self.file_path}"
return f"Объект {self.main_number}, файл: {self.file_path}"
def __repr__(self):
return f"CadastralRecord('{self.main_number}', '{self.file_path}', {self.all_numbers})"