fix: импорт под новый формат опросника 5.25
- clean_value не портит аббревиатуры/номера (АРМ №1, СКУД)
- ПО: 'Названия программ...' → {{item.software}}
- 'локальную сеть' → is_has_lan (поле is_local_network)
- Цель обработки ПД — значение из объединённой ячейки (val_b)
- Роли комиссии ищутся и в колонке E, и в Примечании (D)
- Проверено на присланном опроснике: КПП, подразделение по
безопасности, действия с ПДн, структура ИС — импортируются
This commit is contained in:
+28
-12
@@ -34,14 +34,19 @@ def clean_value(val):
|
|||||||
text = text.replace('\n', ' ').replace('\r', ' ')
|
text = text.replace('\n', ' ').replace('\r', ' ')
|
||||||
text = ' '.join(text.split())
|
text = ' '.join(text.split())
|
||||||
# Приведение регистра: если текст содержит только заглавные буквы РУ
|
# Приведение регистра: если текст содержит только заглавные буквы РУ
|
||||||
|
# НО не трогаем аббревиатуры/номера (АРМ №1, ИС, ЕМСЭД, СКУД и т.п.)
|
||||||
if len(text) > 4 and any('А' <= c <= 'Я' or c == 'Ё' for c in text):
|
if len(text) > 4 and any('А' <= c <= 'Я' or c == 'Ё' for c in text):
|
||||||
has_lower = any('а' <= c <= 'я' or c == 'ё' for c in text)
|
has_lower = any('а' <= c <= 'я' or c == 'ё' for c in text)
|
||||||
if not has_lower:
|
has_digit_or_num = bool(re.search(r'[0-9№«»"\']', text))
|
||||||
|
if not has_lower and not has_digit_or_num:
|
||||||
words = text.split()
|
words = text.split()
|
||||||
if len(words) >= 3:
|
# если есть короткая аббревиатура целиком заглавными — не трогаем
|
||||||
text = text.title()
|
has_abbr = any(len(w) <= 4 and w.isupper() and any('А' <= c <= 'Я' for c in w) for w in words)
|
||||||
else:
|
if not has_abbr:
|
||||||
text = text.capitalize()
|
if len(words) >= 3:
|
||||||
|
text = text.title()
|
||||||
|
else:
|
||||||
|
text = text.capitalize()
|
||||||
return text
|
return text
|
||||||
|
|
||||||
|
|
||||||
@@ -220,6 +225,13 @@ def _import_152_is_list(wb, data, settings, log_fn):
|
|||||||
if val_b:
|
if val_b:
|
||||||
is_obj['structure'] = val_b
|
is_obj['structure'] = val_b
|
||||||
continue
|
continue
|
||||||
|
if 'названия программ' in field_lower or ('программ' in field_lower and 'ос взаимодейств' in field_lower):
|
||||||
|
if val_b:
|
||||||
|
is_obj['software'] = val_b
|
||||||
|
continue
|
||||||
|
if 'локальную сеть' in field_lower:
|
||||||
|
is_obj['is_has_lan'] = is_checked
|
||||||
|
continue
|
||||||
if 'количество записей' in field_lower or 'количество субъект' in field_lower:
|
if 'количество записей' in field_lower or 'количество субъект' in field_lower:
|
||||||
if val_b:
|
if val_b:
|
||||||
is_obj['personalDataCount'] = val_b
|
is_obj['personalDataCount'] = val_b
|
||||||
@@ -270,8 +282,8 @@ def _import_152_is_list(wb, data, settings, log_fn):
|
|||||||
if 'цель обработки' in field_lower:
|
if 'цель обработки' in field_lower:
|
||||||
current_section = 'purpose'
|
current_section = 'purpose'
|
||||||
elif current_section == 'purpose':
|
elif current_section == 'purpose':
|
||||||
purpose_val = field or val_b or ''
|
purpose_val = val_b or field or ''
|
||||||
if purpose_val and 'выбрать' not in purpose_val.lower():
|
if purpose_val and 'выбрать' not in purpose_val.lower() and ':' not in purpose_val[:40]:
|
||||||
is_obj['purpose'] = purpose_val
|
is_obj['purpose'] = purpose_val
|
||||||
log_fn(f" Цель: {purpose_val[:80]}")
|
log_fn(f" Цель: {purpose_val[:80]}")
|
||||||
current_section = 'header'
|
current_section = 'header'
|
||||||
@@ -404,11 +416,15 @@ def _import_152_employees(wb, data, settings, log_fn):
|
|||||||
|
|
||||||
if in_commission:
|
if in_commission:
|
||||||
role = 'Член комиссии'
|
role = 'Член комиссии'
|
||||||
if col_e:
|
# Роль ищем в колонках E (было) и D (Примечание — новый формат)
|
||||||
e_lower = col_e.lower()
|
for col in (col_e, col_d):
|
||||||
for keyword, role_name in COMMISSION_ROLES.items():
|
if col:
|
||||||
if keyword in e_lower:
|
col_lower = col.lower()
|
||||||
role = role_name
|
for keyword, role_name in COMMISSION_ROLES.items():
|
||||||
|
if keyword in col_lower:
|
||||||
|
role = role_name
|
||||||
|
break
|
||||||
|
if role != 'Член комиссии':
|
||||||
break
|
break
|
||||||
if not col_b and not col_c:
|
if not col_b and not col_c:
|
||||||
continue
|
continue
|
||||||
|
|||||||
Reference in New Issue
Block a user