mirror of
https://github.com/Nikolay-Shirokov/cc-1c-skills.git
synced 2026-07-20 01:20:59 +03:00
Merge dev-web: composite types, d5p1 namespace, IndentationError fixes
- meta-edit/meta-compile: composite types via + separator (PS+PY) - d5p1 namespace for reference types instead of cfg: - lxml post-processing fix for d5p1 in meta-edit PY - meta-info/form-info: normalize d5p1 prefix in readers (PS+PY) - Fix module-level IndentationError in 10 Python scripts
This commit is contained in:
@@ -9,7 +9,7 @@ from collections import OrderedDict
|
|||||||
from lxml import etree
|
from lxml import etree
|
||||||
|
|
||||||
sys.stdout.reconfigure(encoding="utf-8")
|
sys.stdout.reconfigure(encoding="utf-8")
|
||||||
sys.stderr.reconfigure(encoding="utf-8")
|
sys.stderr.reconfigure(encoding="utf-8")
|
||||||
|
|
||||||
# --- Argument parsing ---
|
# --- Argument parsing ---
|
||||||
parser = argparse.ArgumentParser(description="Analyze 1C configuration structure", allow_abbrev=False)
|
parser = argparse.ArgumentParser(description="Analyze 1C configuration structure", allow_abbrev=False)
|
||||||
|
|||||||
@@ -9,7 +9,7 @@ import sys
|
|||||||
from lxml import etree
|
from lxml import etree
|
||||||
|
|
||||||
sys.stdout.reconfigure(encoding="utf-8")
|
sys.stdout.reconfigure(encoding="utf-8")
|
||||||
sys.stderr.reconfigure(encoding="utf-8")
|
sys.stderr.reconfigure(encoding="utf-8")
|
||||||
|
|
||||||
# ── arg parsing ──────────────────────────────────────────────
|
# ── arg parsing ──────────────────────────────────────────────
|
||||||
|
|
||||||
|
|||||||
@@ -58,8 +58,8 @@ function Format-Type($typeNode) {
|
|||||||
$typeSet = $typeNode.SelectSingleNode("v8:TypeSet", $ns)
|
$typeSet = $typeNode.SelectSingleNode("v8:TypeSet", $ns)
|
||||||
if ($typeSet) {
|
if ($typeSet) {
|
||||||
$val = $typeSet.InnerText
|
$val = $typeSet.InnerText
|
||||||
# Strip cfg: prefix for DefinedType, keep as-is
|
# Strip cfg:/d5p1: prefix for DefinedType, keep as-is
|
||||||
if ($val -like "cfg:*") { $val = $val.Substring(4) }
|
$val = $val -replace '^(cfg|d\d+p\d+):', ''
|
||||||
return $val
|
return $val
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -101,7 +101,7 @@ function Format-Type($typeNode) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
"xs:binary" { $parts += "binary" }
|
"xs:binary" { $parts += "binary" }
|
||||||
"cfg:*" { $parts += $raw.Substring(4) }
|
{ $_ -like "cfg:*" -or $_ -match '^d\d+p\d+:' } { $parts += ($raw -replace '^(cfg|d\d+p\d+):', '') }
|
||||||
"v8:ValueTable" { $parts += "ValueTable" }
|
"v8:ValueTable" { $parts += "ValueTable" }
|
||||||
"v8:ValueTree" { $parts += "ValueTree" }
|
"v8:ValueTree" { $parts += "ValueTree" }
|
||||||
"v8:ValueListType" { $parts += "ValueList" }
|
"v8:ValueListType" { $parts += "ValueList" }
|
||||||
|
|||||||
@@ -102,8 +102,8 @@ def format_type(type_node):
|
|||||||
parts.append("dateTime")
|
parts.append("dateTime")
|
||||||
elif raw == "xs:binary":
|
elif raw == "xs:binary":
|
||||||
parts.append("binary")
|
parts.append("binary")
|
||||||
elif raw.startswith("cfg:"):
|
elif raw.startswith("cfg:") or re.match(r'^d\d+p\d+:', raw):
|
||||||
parts.append(raw[4:])
|
parts.append(re.sub(r'^(?:cfg|d\d+p\d+):', '', raw))
|
||||||
elif raw == "v8:ValueTable":
|
elif raw == "v8:ValueTable":
|
||||||
parts.append("ValueTable")
|
parts.append("ValueTable")
|
||||||
elif raw == "v8:ValueTree":
|
elif raw == "v8:ValueTree":
|
||||||
|
|||||||
@@ -69,6 +69,8 @@ Constant (Константа), DefinedType (ОпределяемыйТип), Com
|
|||||||
|
|
||||||
Русские синонимы типов: `Строка`, `Число`, `Булево`, `Дата`, `СправочникСсылка.Xxx`, `ДокументСсылка.Xxx`, `ПланСчетовСсылка.Xxx`.
|
Русские синонимы типов: `Строка`, `Число`, `Булево`, `Дата`, `СправочникСсылка.Xxx`, `ДокументСсылка.Xxx`, `ПланСчетовСсылка.Xxx`.
|
||||||
|
|
||||||
|
Составной тип (несколько допустимых типов через `+`): `"Значение: Строка + Число(15,2) + Дата + CatalogRef.Контрагенты"`.
|
||||||
|
|
||||||
Флаги: `req`, `index`, `indexAdditional`, `nonneg`, `master`, `mainFilter`, `denyIncomplete`, `useInTotals`.
|
Флаги: `req`, `index`, `indexAdditional`, `nonneg`, `master`, `mainFilter`, `denyIncomplete`, `useInTotals`.
|
||||||
|
|
||||||
## Примеры
|
## Примеры
|
||||||
|
|||||||
@@ -198,6 +198,15 @@ function Emit-TypeContent {
|
|||||||
param([string]$indent, [string]$typeStr)
|
param([string]$indent, [string]$typeStr)
|
||||||
if (-not $typeStr) { return }
|
if (-not $typeStr) { return }
|
||||||
|
|
||||||
|
# Composite type: "Type1 + Type2 + Type3"
|
||||||
|
if ($typeStr.Contains(' + ')) {
|
||||||
|
$parts = $typeStr -split '\s*\+\s*'
|
||||||
|
foreach ($part in $parts) {
|
||||||
|
Emit-TypeContent $indent $part.Trim()
|
||||||
|
}
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
$typeStr = Resolve-TypeStr $typeStr
|
$typeStr = Resolve-TypeStr $typeStr
|
||||||
|
|
||||||
# Boolean
|
# Boolean
|
||||||
@@ -254,9 +263,9 @@ function Emit-TypeContent {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
# Reference types: CatalogRef.XXX, DocumentRef.XXX, etc.
|
# Reference types — use local xmlns declaration for 1C compatibility
|
||||||
if ($typeStr -match '^(CatalogRef|DocumentRef|EnumRef|ChartOfAccountsRef|ChartOfCharacteristicTypesRef|ChartOfCalculationTypesRef|ExchangePlanRef|BusinessProcessRef|TaskRef)\.(.+)$') {
|
if ($typeStr -match '^(CatalogRef|DocumentRef|EnumRef|ChartOfAccountsRef|ChartOfCharacteristicTypesRef|ChartOfCalculationTypesRef|ExchangePlanRef|BusinessProcessRef|TaskRef)\.(.+)$') {
|
||||||
X "$indent<v8:Type>cfg:$typeStr</v8:Type>"
|
X "$indent<v8:Type xmlns:d5p1=`"http://v8.1c.ru/8.1/data/enterprise/current-config`">d5p1:$typeStr</v8:Type>"
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1237,7 +1246,7 @@ function Emit-DefinedTypeProperties {
|
|||||||
foreach ($vt in $valueTypes) {
|
foreach ($vt in $valueTypes) {
|
||||||
$resolved = Resolve-TypeStr "$vt"
|
$resolved = Resolve-TypeStr "$vt"
|
||||||
if ($resolved -match '^(CatalogRef|DocumentRef|EnumRef|ChartOfAccountsRef|ChartOfCharacteristicTypesRef|ChartOfCalculationTypesRef|ExchangePlanRef|BusinessProcessRef|TaskRef)\.') {
|
if ($resolved -match '^(CatalogRef|DocumentRef|EnumRef|ChartOfAccountsRef|ChartOfCharacteristicTypesRef|ChartOfCalculationTypesRef|ExchangePlanRef|BusinessProcessRef|TaskRef)\.') {
|
||||||
X "$i`t<v8:Type>cfg:$resolved</v8:Type>"
|
X "$i`t<v8:Type xmlns:d5p1=`"http://v8.1c.ru/8.1/data/enterprise/current-config`">d5p1:$resolved</v8:Type>"
|
||||||
} elseif ($resolved -eq "Boolean") {
|
} elseif ($resolved -eq "Boolean") {
|
||||||
X "$i`t<v8:Type>xs:boolean</v8:Type>"
|
X "$i`t<v8:Type>xs:boolean</v8:Type>"
|
||||||
} elseif ($resolved -match '^String') {
|
} elseif ($resolved -match '^String') {
|
||||||
@@ -1342,7 +1351,7 @@ function Emit-EventSubscriptionProperties {
|
|||||||
X "$i<Source>"
|
X "$i<Source>"
|
||||||
foreach ($src in $sources) {
|
foreach ($src in $sources) {
|
||||||
$resolved = Resolve-TypeStr "$src"
|
$resolved = Resolve-TypeStr "$src"
|
||||||
X "$i`t<v8:Type>cfg:$resolved</v8:Type>"
|
X "$i`t<v8:Type xmlns:d5p1=`"http://v8.1c.ru/8.1/data/enterprise/current-config`">d5p1:$resolved</v8:Type>"
|
||||||
}
|
}
|
||||||
X "$i</Source>"
|
X "$i</Source>"
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@@ -11,7 +11,7 @@ import uuid
|
|||||||
import xml.etree.ElementTree as ET
|
import xml.etree.ElementTree as ET
|
||||||
|
|
||||||
sys.stdout.reconfigure(encoding="utf-8")
|
sys.stdout.reconfigure(encoding="utf-8")
|
||||||
sys.stderr.reconfigure(encoding="utf-8")
|
sys.stderr.reconfigure(encoding="utf-8")
|
||||||
|
|
||||||
# ---------------------------------------------------------------------------
|
# ---------------------------------------------------------------------------
|
||||||
# Inline utilities
|
# Inline utilities
|
||||||
@@ -207,6 +207,12 @@ def resolve_type_str(type_str):
|
|||||||
def emit_type_content(indent, type_str):
|
def emit_type_content(indent, type_str):
|
||||||
if not type_str:
|
if not type_str:
|
||||||
return
|
return
|
||||||
|
# Composite type: "Type1 + Type2 + Type3"
|
||||||
|
if ' + ' in type_str:
|
||||||
|
parts = [p.strip() for p in type_str.split('+')]
|
||||||
|
for part in parts:
|
||||||
|
emit_type_content(indent, part)
|
||||||
|
return
|
||||||
type_str = resolve_type_str(type_str)
|
type_str = resolve_type_str(type_str)
|
||||||
# Boolean
|
# Boolean
|
||||||
if type_str == 'Boolean':
|
if type_str == 'Boolean':
|
||||||
@@ -254,10 +260,10 @@ def emit_type_content(indent, type_str):
|
|||||||
dt_name = m.group(1)
|
dt_name = m.group(1)
|
||||||
X(f'{indent}<v8:TypeSet>cfg:DefinedType.{dt_name}</v8:TypeSet>')
|
X(f'{indent}<v8:TypeSet>cfg:DefinedType.{dt_name}</v8:TypeSet>')
|
||||||
return
|
return
|
||||||
# Reference types
|
# Reference types — use local xmlns declaration for 1C compatibility
|
||||||
m = re.match(r'^(CatalogRef|DocumentRef|EnumRef|ChartOfAccountsRef|ChartOfCharacteristicTypesRef|ChartOfCalculationTypesRef|ExchangePlanRef|BusinessProcessRef|TaskRef)\.(.+)$', type_str)
|
m = re.match(r'^(CatalogRef|DocumentRef|EnumRef|ChartOfAccountsRef|ChartOfCharacteristicTypesRef|ChartOfCalculationTypesRef|ExchangePlanRef|BusinessProcessRef|TaskRef)\.(.+)$', type_str)
|
||||||
if m:
|
if m:
|
||||||
X(f'{indent}<v8:Type>cfg:{type_str}</v8:Type>')
|
X(f'{indent}<v8:Type xmlns:d5p1="http://v8.1c.ru/8.1/data/enterprise/current-config">d5p1:{type_str}</v8:Type>')
|
||||||
return
|
return
|
||||||
# Fallback
|
# Fallback
|
||||||
X(f'{indent}<v8:Type>{type_str}</v8:Type>')
|
X(f'{indent}<v8:Type>{type_str}</v8:Type>')
|
||||||
@@ -1066,7 +1072,7 @@ def emit_defined_type_properties(indent):
|
|||||||
for vt in value_types:
|
for vt in value_types:
|
||||||
resolved = resolve_type_str(str(vt))
|
resolved = resolve_type_str(str(vt))
|
||||||
if re.match(r'^(CatalogRef|DocumentRef|EnumRef|ChartOfAccountsRef|ChartOfCharacteristicTypesRef|ChartOfCalculationTypesRef|ExchangePlanRef|BusinessProcessRef|TaskRef)\.', resolved):
|
if re.match(r'^(CatalogRef|DocumentRef|EnumRef|ChartOfAccountsRef|ChartOfCharacteristicTypesRef|ChartOfCalculationTypesRef|ExchangePlanRef|BusinessProcessRef|TaskRef)\.', resolved):
|
||||||
X(f'{i}\t<v8:Type>cfg:{resolved}</v8:Type>')
|
X(f'{i}\t<v8:Type xmlns:d5p1="http://v8.1c.ru/8.1/data/enterprise/current-config">d5p1:{resolved}</v8:Type>')
|
||||||
elif resolved == 'Boolean':
|
elif resolved == 'Boolean':
|
||||||
X(f'{i}\t<v8:Type>xs:boolean</v8:Type>')
|
X(f'{i}\t<v8:Type>xs:boolean</v8:Type>')
|
||||||
elif re.match(r'^String', resolved):
|
elif re.match(r'^String', resolved):
|
||||||
@@ -1155,7 +1161,7 @@ def emit_event_subscription_properties(indent):
|
|||||||
X(f'{i}<Source>')
|
X(f'{i}<Source>')
|
||||||
for src in sources:
|
for src in sources:
|
||||||
resolved = resolve_type_str(str(src))
|
resolved = resolve_type_str(str(src))
|
||||||
X(f'{i}\t<v8:Type>cfg:{resolved}</v8:Type>')
|
X(f'{i}\t<v8:Type xmlns:d5p1="http://v8.1c.ru/8.1/data/enterprise/current-config">d5p1:{resolved}</v8:Type>')
|
||||||
X(f'{i}</Source>')
|
X(f'{i}</Source>')
|
||||||
else:
|
else:
|
||||||
X(f'{i}<Source/>')
|
X(f'{i}<Source/>')
|
||||||
|
|||||||
@@ -81,6 +81,9 @@ Batch через `;;` во всех операциях. Подробный си
|
|||||||
# Добавить реквизиты
|
# Добавить реквизиты
|
||||||
-Operation add-attribute -Value "Комментарий: Строка(200) ;; Сумма: Число(15,2) | index"
|
-Operation add-attribute -Value "Комментарий: Строка(200) ;; Сумма: Число(15,2) | index"
|
||||||
|
|
||||||
|
# Составной тип (несколько типов через +)
|
||||||
|
-Operation add-attribute -Value "Значение: Строка + Число(15,2) + Дата + CatalogRef.Контрагенты"
|
||||||
|
|
||||||
# Добавить ТЧ с реквизитами
|
# Добавить ТЧ с реквизитами
|
||||||
-Operation add-ts -Value "Товары: Ном: CatalogRef.Ном | req, Кол: Число(15,3), Цена: Число(15,2)"
|
-Operation add-ts -Value "Товары: Ном: CatalogRef.Ном | req, Кол: Число(15,3), Цена: Число(15,2)"
|
||||||
|
|
||||||
|
|||||||
@@ -18,6 +18,20 @@
|
|||||||
-Operation add-attribute -Value "Склад: CatalogRef.Склады >> after Организация"
|
-Operation add-attribute -Value "Склад: CatalogRef.Склады >> after Организация"
|
||||||
```
|
```
|
||||||
|
|
||||||
|
## Составные типы
|
||||||
|
|
||||||
|
Для реквизитов с несколькими допустимыми типами — разделитель `+`:
|
||||||
|
```powershell
|
||||||
|
-Operation add-attribute -Value "Значение: Строка + Число(15,2) + Дата + CatalogRef.Контрагенты"
|
||||||
|
-Operation add-attribute -Value "Значение: Строка + Число(15,2) | req"
|
||||||
|
-Operation modify-ts-attribute -Value "Данные.Значение: type=Строка + Число(15,2) + Дата"
|
||||||
|
```
|
||||||
|
|
||||||
|
В JSON DSL — массив в `type`:
|
||||||
|
```json
|
||||||
|
{ "name": "Значение", "type": ["Строка", "Число(15,2)", "Дата", "CatalogRef.Контрагенты"] }
|
||||||
|
```
|
||||||
|
|
||||||
## add-attribute / add-dimension / add-resource / add-column
|
## add-attribute / add-dimension / add-resource / add-column
|
||||||
|
|
||||||
```powershell
|
```powershell
|
||||||
|
|||||||
@@ -120,6 +120,19 @@ powershell.exe -NoProfile -File .claude/skills/meta-edit/scripts/meta-edit.ps1 -
|
|||||||
| commands | команды |
|
| commands | команды |
|
||||||
| properties | свойства |
|
| properties | свойства |
|
||||||
|
|
||||||
|
## Составные типы
|
||||||
|
|
||||||
|
Для полей с несколькими допустимыми типами — массив в `type`:
|
||||||
|
|
||||||
|
```json
|
||||||
|
{ "name": "Значение", "type": ["Строка", "Число(15,2)", "Дата", "CatalogRef.Контрагенты"] }
|
||||||
|
```
|
||||||
|
|
||||||
|
В inline-формате — через `+`:
|
||||||
|
```
|
||||||
|
"Значение: Строка + Число(15,2) + Дата + CatalogRef.Контрагенты"
|
||||||
|
```
|
||||||
|
|
||||||
## Синонимы типов
|
## Синонимы типов
|
||||||
|
|
||||||
`Строка(200)`, `Число(15,2)`, `Булево`, `Дата`, `ДатаВремя`, `ХранилищеЗначения`, `СправочникСсылка.XXX`, `ДокументСсылка.XXX`, `ПеречислениеСсылка.XXX`, `ОпределяемыйТип.XXX`.
|
`Строка(200)`, `Число(15,2)`, `Булево`, `Дата`, `ДатаВремя`, `ХранилищеЗначения`, `СправочникСсылка.XXX`, `ДокументСсылка.XXX`, `ПеречислениеСсылка.XXX`, `ОпределяемыйТип.XXX`.
|
||||||
|
|||||||
@@ -269,6 +269,17 @@ function Build-TypeContentXml {
|
|||||||
param([string]$indent, [string]$typeStr)
|
param([string]$indent, [string]$typeStr)
|
||||||
if (-not $typeStr) { return "" }
|
if (-not $typeStr) { return "" }
|
||||||
|
|
||||||
|
# Composite type: "Type1 + Type2 + Type3"
|
||||||
|
if ($typeStr.Contains(' + ')) {
|
||||||
|
$parts = $typeStr -split '\s*\+\s*'
|
||||||
|
$sb = New-Object System.Text.StringBuilder
|
||||||
|
foreach ($part in $parts) {
|
||||||
|
$inner = Build-TypeContentXml $indent $part.Trim()
|
||||||
|
if ($inner) { $sb.AppendLine($inner) | Out-Null }
|
||||||
|
}
|
||||||
|
return $sb.ToString().TrimEnd("`r","`n")
|
||||||
|
}
|
||||||
|
|
||||||
$typeStr = Resolve-TypeStr $typeStr
|
$typeStr = Resolve-TypeStr $typeStr
|
||||||
$sb = New-Object System.Text.StringBuilder
|
$sb = New-Object System.Text.StringBuilder
|
||||||
|
|
||||||
@@ -342,9 +353,9 @@ function Build-TypeContentXml {
|
|||||||
return $sb.ToString().TrimEnd("`r","`n")
|
return $sb.ToString().TrimEnd("`r","`n")
|
||||||
}
|
}
|
||||||
|
|
||||||
# Reference types
|
# Reference types — use local xmlns declaration for 1C compatibility
|
||||||
if ($typeStr -match '^(CatalogRef|DocumentRef|EnumRef|ChartOfAccountsRef|ChartOfCharacteristicTypesRef|ChartOfCalculationTypesRef|ExchangePlanRef|BusinessProcessRef|TaskRef)\.(.+)$') {
|
if ($typeStr -match '^(CatalogRef|DocumentRef|EnumRef|ChartOfAccountsRef|ChartOfCharacteristicTypesRef|ChartOfCalculationTypesRef|ExchangePlanRef|BusinessProcessRef|TaskRef)\.(.+)$') {
|
||||||
$sb.AppendLine("$indent<v8:Type>cfg:$typeStr</v8:Type>") | Out-Null
|
$sb.AppendLine("$indent<v8:Type xmlns:d5p1=`"http://v8.1c.ru/8.1/data/enterprise/current-config`">d5p1:$typeStr</v8:Type>") | Out-Null
|
||||||
return $sb.ToString().TrimEnd("`r","`n")
|
return $sb.ToString().TrimEnd("`r","`n")
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -624,7 +635,7 @@ function Parse-AttributeShorthand {
|
|||||||
$name = "$($val.name)"
|
$name = "$($val.name)"
|
||||||
$result = @{
|
$result = @{
|
||||||
name = $name
|
name = $name
|
||||||
type = if ($val.type) { "$($val.type)" } else { "" }
|
type = if ($val.type -is [array]) { ($val.type | ForEach-Object { "$_" }) -join ' + ' } elseif ($val.type) { "$($val.type)" } else { "" }
|
||||||
synonym = if ($val.synonym) { "$($val.synonym)" } else { Split-CamelCase $name }
|
synonym = if ($val.synonym) { "$($val.synonym)" } else { Split-CamelCase $name }
|
||||||
comment = if ($val.comment) { "$($val.comment)" } else { "" }
|
comment = if ($val.comment) { "$($val.comment)" } else { "" }
|
||||||
flags = @(if ($val.flags) { $val.flags } else { @() })
|
flags = @(if ($val.flags) { $val.flags } else { @() })
|
||||||
|
|||||||
@@ -188,6 +188,16 @@ def build_type_content_xml(indent, type_str):
|
|||||||
if not type_str:
|
if not type_str:
|
||||||
return ""
|
return ""
|
||||||
|
|
||||||
|
# Composite type: "Type1 + Type2 + Type3"
|
||||||
|
if " + " in type_str:
|
||||||
|
parts = [p.strip() for p in type_str.split("+")]
|
||||||
|
results = []
|
||||||
|
for part in parts:
|
||||||
|
inner = build_type_content_xml(indent, part)
|
||||||
|
if inner:
|
||||||
|
results.append(inner)
|
||||||
|
return "\r\n".join(results)
|
||||||
|
|
||||||
type_str = resolve_type_str(type_str)
|
type_str = resolve_type_str(type_str)
|
||||||
lines = []
|
lines = []
|
||||||
|
|
||||||
@@ -258,14 +268,14 @@ def build_type_content_xml(indent, type_str):
|
|||||||
lines.append(f"{indent}<v8:TypeSet>cfg:DefinedType.{dt_name}</v8:TypeSet>")
|
lines.append(f"{indent}<v8:TypeSet>cfg:DefinedType.{dt_name}</v8:TypeSet>")
|
||||||
return "\r\n".join(lines)
|
return "\r\n".join(lines)
|
||||||
|
|
||||||
# Reference types
|
# Reference types — use local xmlns declaration for 1C compatibility
|
||||||
m = re.match(
|
m = re.match(
|
||||||
r"^(CatalogRef|DocumentRef|EnumRef|ChartOfAccountsRef|ChartOfCharacteristicTypesRef|"
|
r"^(CatalogRef|DocumentRef|EnumRef|ChartOfAccountsRef|ChartOfCharacteristicTypesRef|"
|
||||||
r"ChartOfCalculationTypesRef|ExchangePlanRef|BusinessProcessRef|TaskRef)\.(.+)$",
|
r"ChartOfCalculationTypesRef|ExchangePlanRef|BusinessProcessRef|TaskRef)\.(.+)$",
|
||||||
type_str,
|
type_str,
|
||||||
)
|
)
|
||||||
if m:
|
if m:
|
||||||
lines.append(f"{indent}<v8:Type>cfg:{type_str}</v8:Type>")
|
lines.append(f'{indent}<v8:Type xmlns:d5p1="http://v8.1c.ru/8.1/data/enterprise/current-config">d5p1:{type_str}</v8:Type>')
|
||||||
return "\r\n".join(lines)
|
return "\r\n".join(lines)
|
||||||
|
|
||||||
# Fallback
|
# Fallback
|
||||||
@@ -538,7 +548,7 @@ def parse_attribute_shorthand(val):
|
|||||||
name = str(val.get("name", ""))
|
name = str(val.get("name", ""))
|
||||||
result = {
|
result = {
|
||||||
"name": name,
|
"name": name,
|
||||||
"type": str(val.get("type", "")),
|
"type": " + ".join(str(t) for t in val["type"]) if isinstance(val.get("type"), list) else str(val.get("type", "")),
|
||||||
"synonym": str(val.get("synonym", "")) if val.get("synonym") else split_camel_case(name),
|
"synonym": str(val.get("synonym", "")) if val.get("synonym") else split_camel_case(name),
|
||||||
"comment": str(val.get("comment", "")),
|
"comment": str(val.get("comment", "")),
|
||||||
"flags": list(val.get("flags", [])),
|
"flags": list(val.get("flags", [])),
|
||||||
@@ -1961,6 +1971,13 @@ def save_xml(tree, path):
|
|||||||
xml_bytes = etree.tostring(tree, xml_declaration=True, encoding="UTF-8")
|
xml_bytes = etree.tostring(tree, xml_declaration=True, encoding="UTF-8")
|
||||||
# Fix encoding quotes: encoding='UTF-8' -> encoding="UTF-8"
|
# Fix encoding quotes: encoding='UTF-8' -> encoding="UTF-8"
|
||||||
xml_bytes = xml_bytes.replace(b"encoding='UTF-8'", b'encoding="UTF-8"')
|
xml_bytes = xml_bytes.replace(b"encoding='UTF-8'", b'encoding="UTF-8"')
|
||||||
|
# Fix d5p1 namespace declarations stripped by lxml (it treats them as unused
|
||||||
|
# because d5p1: appears only in text content, not in element/attribute names)
|
||||||
|
xml_bytes = re.sub(
|
||||||
|
b'(<v8:Type)(?! xmlns:d5p1)(>d5p1:)',
|
||||||
|
b'\\1 xmlns:d5p1="http://v8.1c.ru/8.1/data/enterprise/current-config"\\2',
|
||||||
|
xml_bytes
|
||||||
|
)
|
||||||
with open(path, "wb") as f:
|
with open(path, "wb") as f:
|
||||||
f.write(b"\xef\xbb\xbf")
|
f.write(b"\xef\xbb\xbf")
|
||||||
f.write(xml_bytes)
|
f.write(xml_bytes)
|
||||||
|
|||||||
@@ -223,6 +223,8 @@ function Format-SingleType([string]$raw, $parentNode) {
|
|||||||
"v8:UUID" { return "УникальныйИдентификатор" }
|
"v8:UUID" { return "УникальныйИдентификатор" }
|
||||||
"v8:Null" { return "Null" }
|
"v8:Null" { return "Null" }
|
||||||
default {
|
default {
|
||||||
|
# Normalize d5p1:/dNpN: -> cfg:
|
||||||
|
$raw = $raw -replace '^d\d+p\d+:', 'cfg:'
|
||||||
# cfg:CatalogRef.Xxx -> СправочникСсылка.Xxx
|
# cfg:CatalogRef.Xxx -> СправочникСсылка.Xxx
|
||||||
if ($raw -match '^cfg:(\w+)Ref\.(.+)$') {
|
if ($raw -match '^cfg:(\w+)Ref\.(.+)$') {
|
||||||
$prefix = "$($Matches[1])Ref"
|
$prefix = "$($Matches[1])Ref"
|
||||||
@@ -356,6 +358,7 @@ function Decline-Cols([int]$n) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function Format-SourceType([string]$raw) {
|
function Format-SourceType([string]$raw) {
|
||||||
|
$raw = $raw -replace '^d\d+p\d+:', 'cfg:'
|
||||||
if ($raw -match '^cfg:(\w+)\.(.+)$') {
|
if ($raw -match '^cfg:(\w+)\.(.+)$') {
|
||||||
$prefix = $Matches[1]; $name = $Matches[2]
|
$prefix = $Matches[1]; $name = $Matches[2]
|
||||||
if ($objectTypeMap.ContainsKey($prefix)) { return "$($objectTypeMap[$prefix]).$name" }
|
if ($objectTypeMap.ContainsKey($prefix)) { return "$($objectTypeMap[$prefix]).$name" }
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ import sys
|
|||||||
from lxml import etree
|
from lxml import etree
|
||||||
|
|
||||||
sys.stdout.reconfigure(encoding="utf-8")
|
sys.stdout.reconfigure(encoding="utf-8")
|
||||||
sys.stderr.reconfigure(encoding="utf-8")
|
sys.stderr.reconfigure(encoding="utf-8")
|
||||||
|
|
||||||
# ── arg parsing ──────────────────────────────────────────────
|
# ── arg parsing ──────────────────────────────────────────────
|
||||||
|
|
||||||
@@ -282,6 +282,8 @@ def format_single_type(raw, parent_node):
|
|||||||
return "УникальныйИдентификатор"
|
return "УникальныйИдентификатор"
|
||||||
if raw == "v8:Null":
|
if raw == "v8:Null":
|
||||||
return "Null"
|
return "Null"
|
||||||
|
# Normalize d5p1:/dNpN: → cfg: (both map to same namespace)
|
||||||
|
raw = re.sub(r'^d\d+p\d+:', 'cfg:', raw)
|
||||||
# cfg:CatalogRef.Xxx -> СправочникСсылка.Xxx
|
# cfg:CatalogRef.Xxx -> СправочникСсылка.Xxx
|
||||||
m = re.match(r'^cfg:(\w+)Ref\.(.+)$', raw)
|
m = re.match(r'^cfg:(\w+)Ref\.(.+)$', raw)
|
||||||
if m:
|
if m:
|
||||||
@@ -410,6 +412,7 @@ def decline_cols(n):
|
|||||||
|
|
||||||
|
|
||||||
def format_source_type(raw):
|
def format_source_type(raw):
|
||||||
|
raw = re.sub(r'^d\d+p\d+:', 'cfg:', raw)
|
||||||
m = re.match(r'^cfg:(\w+)\.(.+)$', raw)
|
m = re.match(r'^cfg:(\w+)\.(.+)$', raw)
|
||||||
if m:
|
if m:
|
||||||
prefix = m.group(1)
|
prefix = m.group(1)
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ import sys
|
|||||||
from lxml import etree
|
from lxml import etree
|
||||||
|
|
||||||
sys.stdout.reconfigure(encoding="utf-8")
|
sys.stdout.reconfigure(encoding="utf-8")
|
||||||
sys.stderr.reconfigure(encoding="utf-8")
|
sys.stderr.reconfigure(encoding="utf-8")
|
||||||
|
|
||||||
# ── arg parsing ──────────────────────────────────────────────
|
# ── arg parsing ──────────────────────────────────────────────
|
||||||
|
|
||||||
|
|||||||
@@ -10,7 +10,7 @@ import sys
|
|||||||
from lxml import etree
|
from lxml import etree
|
||||||
|
|
||||||
sys.stdout.reconfigure(encoding="utf-8")
|
sys.stdout.reconfigure(encoding="utf-8")
|
||||||
sys.stderr.reconfigure(encoding="utf-8")
|
sys.stderr.reconfigure(encoding="utf-8")
|
||||||
|
|
||||||
# --- Argument parsing ---
|
# --- Argument parsing ---
|
||||||
parser = argparse.ArgumentParser(description="Analyze 1C spreadsheet (MXL) structure", allow_abbrev=False)
|
parser = argparse.ArgumentParser(description="Analyze 1C spreadsheet (MXL) structure", allow_abbrev=False)
|
||||||
|
|||||||
@@ -9,7 +9,7 @@ from collections import OrderedDict
|
|||||||
from lxml import etree
|
from lxml import etree
|
||||||
|
|
||||||
sys.stdout.reconfigure(encoding="utf-8")
|
sys.stdout.reconfigure(encoding="utf-8")
|
||||||
sys.stderr.reconfigure(encoding="utf-8")
|
sys.stderr.reconfigure(encoding="utf-8")
|
||||||
|
|
||||||
# --- Argument parsing ---
|
# --- Argument parsing ---
|
||||||
parser = argparse.ArgumentParser(description="Analyze 1C role rights", allow_abbrev=False)
|
parser = argparse.ArgumentParser(description="Analyze 1C role rights", allow_abbrev=False)
|
||||||
|
|||||||
@@ -9,7 +9,7 @@ import uuid
|
|||||||
from lxml import etree
|
from lxml import etree
|
||||||
|
|
||||||
sys.stdout.reconfigure(encoding="utf-8")
|
sys.stdout.reconfigure(encoding="utf-8")
|
||||||
sys.stderr.reconfigure(encoding="utf-8")
|
sys.stderr.reconfigure(encoding="utf-8")
|
||||||
|
|
||||||
# ── arg parsing ──────────────────────────────────────────────
|
# ── arg parsing ──────────────────────────────────────────────
|
||||||
|
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ import sys
|
|||||||
from lxml import etree
|
from lxml import etree
|
||||||
|
|
||||||
sys.stdout.reconfigure(encoding="utf-8")
|
sys.stdout.reconfigure(encoding="utf-8")
|
||||||
sys.stderr.reconfigure(encoding="utf-8")
|
sys.stderr.reconfigure(encoding="utf-8")
|
||||||
|
|
||||||
# ── arg parsing ──────────────────────────────────────────────
|
# ── arg parsing ──────────────────────────────────────────────
|
||||||
|
|
||||||
|
|||||||
@@ -10,7 +10,7 @@ from collections import OrderedDict
|
|||||||
from lxml import etree
|
from lxml import etree
|
||||||
|
|
||||||
sys.stdout.reconfigure(encoding="utf-8")
|
sys.stdout.reconfigure(encoding="utf-8")
|
||||||
sys.stderr.reconfigure(encoding="utf-8")
|
sys.stderr.reconfigure(encoding="utf-8")
|
||||||
|
|
||||||
# --- Argument parsing ---
|
# --- Argument parsing ---
|
||||||
parser = argparse.ArgumentParser(description="Analyze 1C subsystem structure", allow_abbrev=False)
|
parser = argparse.ArgumentParser(description="Analyze 1C subsystem structure", allow_abbrev=False)
|
||||||
|
|||||||
Reference in New Issue
Block a user