mirror of
https://github.com/Nikolay-Shirokov/cc-1c-skills.git
synced 2026-09-29 05:25:53 +03:00
feat(cf-validate): проверка 10 — тела конфигурации Ext/*.xml в версии Configuration.xml
Конфигурация для платформы — такой же объект, как остальные: Configuration.xml и его штампованные тела Ext/*.xml (CommandInterface, MainSectionCommandInterface, HomePageWorkArea, Splash, MainSectionPicture, Logo) загружаются только в одной версии формата — иначе «Версия формата загружаемого файла … отличается от версии формата ранее загруженных файлов». Проверено на 8.3.27.1859: расхождение любого из этих файлов с Configuration.xml — отказ; Configuration.xml вместе со всеми своими телами в другой версии, чем объекты, — грузится. Сквозного обхода выгрузки нет: на ERP это 74 тыс. файлов, а платформа при загрузке и так называет файл. Co-Authored-By: Sergei Pleshanov <2357qwr@gmail.com> Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
This commit is contained in:
co-authored by
Sergei Pleshanov
Claude Opus 5.5
parent
c943acefa2
commit
5a62b37017
@@ -1,4 +1,4 @@
|
||||
# cf-validate v1.10 — Validate 1C configuration root structure
|
||||
# cf-validate v1.11 — Validate 1C configuration root structure
|
||||
# Source: https://github.com/Nikolay-Shirokov/cc-1c-skills
|
||||
[CmdletBinding(PositionalBinding=$false)]
|
||||
param(
|
||||
@@ -103,6 +103,21 @@ function Get-FormatRank([string]$ver) {
|
||||
return 0
|
||||
}
|
||||
|
||||
# Штамп версии формата — атрибут version КОРНЕВОГО элемента файла. Копия общего эталона (семья
|
||||
# root_version, авторитет — meta-validate).
|
||||
function Get-RootVersion([string]$xmlPath) {
|
||||
if (-not (Test-Path -LiteralPath $xmlPath -PathType Leaf)) { return $null }
|
||||
$buf = New-Object byte[] 4096
|
||||
$fs = [System.IO.File]::OpenRead($xmlPath)
|
||||
try { $len = $fs.Read($buf, 0, $buf.Length) } finally { $fs.Dispose() }
|
||||
$head = [System.Text.Encoding]::UTF8.GetString($buf, 0, $len)
|
||||
$m = [regex]::Match($head, '<[A-Za-z_][\w.:-]*(\s[^>]*)?/?>')
|
||||
if (-not $m.Success) { return $null }
|
||||
$v = [regex]::Match($m.Groups[1].Value, '(?:^|\s)version="([^"]*)"')
|
||||
if ($v.Success) { return $v.Groups[1].Value }
|
||||
return $null
|
||||
}
|
||||
|
||||
# --- Reference tables ---
|
||||
$guidPattern = '^[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}$'
|
||||
$identPattern = '^[A-Za-z\u0410-\u042F\u0401\u0430-\u044F\u0451_][A-Za-z0-9\u0410-\u042F\u0401\u0430-\u044F\u0451_]*$'
|
||||
@@ -623,6 +638,28 @@ if ($formRefsChecked -eq 0) {
|
||||
foreach ($err in $formRefErrors) { Report-Error "9. $err" }
|
||||
}
|
||||
|
||||
# --- Check 10: тела конфигурации Ext/*.xml в версии Configuration.xml ---
|
||||
# Конфигурация для платформы — такой же объект, как остальные: Configuration.xml и штампованные тела
|
||||
# Ext/*.xml (CommandInterface, HomePageWorkArea, Splash, …) загружаются только в одной версии формата
|
||||
# («Версия формата загружаемого файла … отличается от версии формата ранее загруженных файлов»).
|
||||
$cfgExtDir = Join-Path $configDir "Ext"
|
||||
$cfgBodiesOk = 0
|
||||
$cfgBodyErrors = 0
|
||||
if ($version -and (Test-Path $cfgExtDir -PathType Container)) {
|
||||
$bodyNames = @(Get-ChildItem $cfgExtDir -Filter "*.xml" -File | ForEach-Object { $_.Name })
|
||||
[Array]::Sort($bodyNames, [StringComparer]::Ordinal)
|
||||
foreach ($bn in $bodyNames) {
|
||||
$bodyVer = Get-RootVersion (Join-Path $cfgExtDir $bn)
|
||||
if (-not $bodyVer) { continue }
|
||||
if ($bodyVer -eq $version) { $cfgBodiesOk++; continue }
|
||||
$cfgBodyErrors++
|
||||
Report-Error "10. Ext/$bn is stamped $bodyVer, Configuration.xml $version — the platform refuses to load parts of one object in different formats"
|
||||
}
|
||||
}
|
||||
if ($cfgBodyErrors -eq 0 -and $cfgBodiesOk -gt 0) {
|
||||
Report-OK "10. Format version: $cfgBodiesOk stamped Ext part(s) agree with Configuration.xml"
|
||||
}
|
||||
|
||||
# --- Final output ---
|
||||
& $finalize
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
#!/usr/bin/env python3
|
||||
# cf-validate v1.10 — Validate 1C configuration XML structure
|
||||
# cf-validate v1.11 — Validate 1C configuration XML structure
|
||||
# Source: https://github.com/Nikolay-Shirokov/cc-1c-skills
|
||||
"""Validates Configuration.xml: root structure, InternalInfo, properties, ChildObjects, languages."""
|
||||
import sys, os, argparse, re
|
||||
@@ -148,6 +148,22 @@ def format_rank(ver):
|
||||
return int(m.group(1)) * 100 + int(m.group(2)) if m else 0
|
||||
|
||||
|
||||
# Штамп версии формата — атрибут version КОРНЕВОГО элемента файла. Копия общего эталона (семья
|
||||
# root_version, авторитет — meta-validate).
|
||||
def root_version(xml_path):
|
||||
if not os.path.isfile(xml_path):
|
||||
return None
|
||||
with open(xml_path, "rb") as f:
|
||||
head = f.read(4096).decode("utf-8", errors="ignore")
|
||||
m = re.search(r'<[A-Za-z_][\w.:-]*(\s[^>]*)?/?>', head)
|
||||
if not m:
|
||||
return None
|
||||
v = re.search(r'(?:^|\s)version="([^"]*)"', m.group(1) or "")
|
||||
if v:
|
||||
return v.group(1)
|
||||
return None
|
||||
|
||||
|
||||
class Reporter:
|
||||
def __init__(self, max_errors, detailed=False):
|
||||
self.errors = 0
|
||||
@@ -636,6 +652,29 @@ def main():
|
||||
for err in form_ref_errors:
|
||||
r.error(f'9. {err}')
|
||||
|
||||
# --- Check 10: тела конфигурации Ext/*.xml в версии Configuration.xml ---
|
||||
# Конфигурация для платформы — такой же объект, как остальные: Configuration.xml и штампованные тела
|
||||
# Ext/*.xml (CommandInterface, HomePageWorkArea, Splash, …) загружаются только в одной версии формата
|
||||
# («Версия формата загружаемого файла … отличается от версии формата ранее загруженных файлов»).
|
||||
cfg_ext_dir = os.path.join(config_dir, 'Ext')
|
||||
cfg_bodies_ok = 0
|
||||
cfg_body_errors = 0
|
||||
if version and os.path.isdir(cfg_ext_dir):
|
||||
body_names = sorted(n for n in os.listdir(cfg_ext_dir)
|
||||
if n.lower().endswith('.xml') and os.path.isfile(os.path.join(cfg_ext_dir, n)))
|
||||
for bn in body_names:
|
||||
body_ver = root_version(os.path.join(cfg_ext_dir, bn))
|
||||
if not body_ver:
|
||||
continue
|
||||
if body_ver == version:
|
||||
cfg_bodies_ok += 1
|
||||
continue
|
||||
cfg_body_errors += 1
|
||||
r.error(f'10. Ext/{bn} is stamped {body_ver}, Configuration.xml {version} '
|
||||
'— the platform refuses to load parts of one object in different formats')
|
||||
if cfg_body_errors == 0 and cfg_bodies_ok > 0:
|
||||
r.ok(f'10. Format version: {cfg_bodies_ok} stamped Ext part(s) agree with Configuration.xml')
|
||||
|
||||
# --- Final output ---
|
||||
r.finalize(out_file)
|
||||
sys.exit(1 if r.errors > 0 else 0)
|
||||
|
||||
Reference in New Issue
Block a user