mirror of
https://github.com/Nikolay-Shirokov/cc-1c-skills.git
synced 2026-08-07 20:20:20 +03:00
refactor(эмиттеры): одна формулировка на повторяющийся комментарий
Код нормализации пустого тега повторён в 24 местах, а комментарий к нему за время работы над #57 расплодился в шесть вариантов формулировки. Это то же расхождение копий, что и в коде, только в тексте: читающий не понимает, значима разница или нет. Сведено к одной паре формулировок — про сам тег с гардом и про запись через MemoryStream. Комментарий теперь начинается с ПРАВИЛА, а не с причины: раньше верхняя строка рассказывала, что here-string наследует LF от .ps1, и читалось это как «переводы строк берём из скрипта навыка» — тогда как правило обратное: создаём файл — пишем канон, правим существующий — наследуем его стиль. Два пояснения в cfe-borrow унификация чуть не стёрла, они возвращены: источником там служит OuterXml, а не XmlWriter, и нормализация стоит после вставки реквизитов, чтобы накрыть и их. Это причина местного отличия, а не дубль. Ссылки на ишью прорежены: #44/#46/#47 осталась по одной на файл — там, где правило формулируется, — и убрана оттуда, где была эхом. #57 в скриптах не было вовсе. Заодно выровнены две мелочи, найденные той же сверкой копий: interface-edit в py-порте не обрезал хвостовой перевод там, где PS обрезает (поведение совпадало, код — нет), а cf-edit нормализовал EOL инлайном вместо общей двухшаговой формы. Версии подняты в ОБОИХ портах всех затронутых навыков, включая те, где текстуально менялся только .ps1: номер версии в этом проекте читается как «одно и то же поведение», и разводить его из-за комментария нельзя. Паритет проверен — 69 пар, ноль расхождений. Windows 641/641 обоими портами. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 5
parent
4c64b97cec
commit
750ba3bb13
@@ -1,4 +1,4 @@
|
|||||||
# cf-edit v1.14 — Edit 1C configuration root (Configuration.xml)
|
# cf-edit v1.15 — Edit 1C configuration root (Configuration.xml)
|
||||||
# Source: https://github.com/Nikolay-Shirokov/cc-1c-skills
|
# Source: https://github.com/Nikolay-Shirokov/cc-1c-skills
|
||||||
param(
|
param(
|
||||||
[Parameter(Mandatory)][Alias('Path')][string]$ConfigPath,
|
[Parameter(Mandatory)][Alias('Path')][string]$ConfigPath,
|
||||||
@@ -697,7 +697,8 @@ $bodyBlock$declarations
|
|||||||
$caiPath = Join-Path $extDir "ClientApplicationInterface.xml"
|
$caiPath = Join-Path $extDir "ClientApplicationInterface.xml"
|
||||||
$utf8Bom = New-Object System.Text.UTF8Encoding($true)
|
$utf8Bom = New-Object System.Text.UTF8Encoding($true)
|
||||||
# Файл создаём мы — канон: CRLF в разделителях, без перевода строки в конце.
|
# Файл создаём мы — канон: CRLF в разделителях, без перевода строки в конце.
|
||||||
[System.IO.File]::WriteAllText($caiPath, (($caiXml -replace "`r`n", "`n") -replace "`n", "`r`n").TrimEnd("`r", "`n"), $utf8Bom)
|
$caiXml = ($caiXml -replace "`r`n", "`n") -replace "`n", "`r`n"
|
||||||
|
[System.IO.File]::WriteAllText($caiPath, $caiXml.TrimEnd("`r", "`n"), $utf8Bom)
|
||||||
$script:modifyCount++
|
$script:modifyCount++
|
||||||
Info "Wrote panel layout: $caiPath"
|
Info "Wrote panel layout: $caiPath"
|
||||||
}
|
}
|
||||||
@@ -887,7 +888,8 @@ $rightXml
|
|||||||
$hpPath = Join-Path $extDir "HomePageWorkArea.xml"
|
$hpPath = Join-Path $extDir "HomePageWorkArea.xml"
|
||||||
$utf8Bom = New-Object System.Text.UTF8Encoding($true)
|
$utf8Bom = New-Object System.Text.UTF8Encoding($true)
|
||||||
# Файл создаём мы — канон: CRLF в разделителях, без перевода строки в конце.
|
# Файл создаём мы — канон: CRLF в разделителях, без перевода строки в конце.
|
||||||
[System.IO.File]::WriteAllText($hpPath, (($hpXml -replace "`r`n", "`n") -replace "`n", "`r`n").TrimEnd("`r", "`n"), $utf8Bom)
|
$hpXml = ($hpXml -replace "`r`n", "`n") -replace "`n", "`r`n"
|
||||||
|
[System.IO.File]::WriteAllText($hpPath, $hpXml.TrimEnd("`r", "`n"), $utf8Bom)
|
||||||
$script:modifyCount++
|
$script:modifyCount++
|
||||||
Info "Wrote home page layout: $hpPath"
|
Info "Wrote home page layout: $hpPath"
|
||||||
}
|
}
|
||||||
@@ -989,8 +991,9 @@ $memStream.Close()
|
|||||||
$text = [System.Text.Encoding]::UTF8.GetString($bytes)
|
$text = [System.Text.Encoding]::UTF8.GetString($bytes)
|
||||||
if ($text.Length -gt 0 -and $text[0] -eq [char]0xFEFF) { $text = $text.Substring(1) }
|
if ($text.Length -gt 0 -and $text[0] -eq [char]0xFEFF) { $text = $text.Substring(1) }
|
||||||
$text = $text.Replace('encoding="utf-8"', 'encoding="UTF-8"')
|
$text = $text.Replace('encoding="utf-8"', 'encoding="UTF-8"')
|
||||||
# Пустой элемент: XmlWriter пишет `<a />`, Конфигуратор — `<a/>`. Гард на CDATA/комментарии:
|
# Пустой элемент: XmlWriter отдаёт `<a />`, Конфигуратор пишет `<a/>`. Гард на
|
||||||
# только там `>` не экранируется, и ` />` может быть содержимым, а не концом тега.
|
# CDATA/комментарии: только там `>` не экранируется, и ` />` может быть
|
||||||
|
# содержимым, а не концом тега.
|
||||||
if ($text -notmatch '<!\[CDATA\[|<!--') { $text = [regex]::Replace($text, '(?<=\S) />', '/>') }
|
if ($text -notmatch '<!\[CDATA\[|<!--') { $text = [regex]::Replace($text, '(?<=\S) />', '/>') }
|
||||||
# Возвращаем EOL исходного файла: вставки собраны с CRLF, а сам документ мог быть LF.
|
# Возвращаем EOL исходного файла: вставки собраны с CRLF, а сам документ мог быть LF.
|
||||||
$text = ($text -replace "`r`n", "`n") -replace "`n", $script:srcEol
|
$text = ($text -replace "`r`n", "`n") -replace "`n", $script:srcEol
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
#!/usr/bin/env python3
|
#!/usr/bin/env python3
|
||||||
# cf-edit v1.14 — Edit 1C configuration root (Configuration.xml)
|
# cf-edit v1.15 — Edit 1C configuration root (Configuration.xml)
|
||||||
# Source: https://github.com/Nikolay-Shirokov/cc-1c-skills
|
# Source: https://github.com/Nikolay-Shirokov/cc-1c-skills
|
||||||
|
|
||||||
import argparse
|
import argparse
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
# cfe-borrow v1.13 — Borrow objects from configuration into extension (CFE)
|
# cfe-borrow v1.14 — Borrow objects from configuration into extension (CFE)
|
||||||
# Source: https://github.com/Nikolay-Shirokov/cc-1c-skills
|
# Source: https://github.com/Nikolay-Shirokov/cc-1c-skills
|
||||||
param(
|
param(
|
||||||
[Parameter(Mandatory)][string]$ExtensionPath,
|
[Parameter(Mandatory)][string]$ExtensionPath,
|
||||||
@@ -917,9 +917,10 @@ function Borrow-Form {
|
|||||||
New-Item -ItemType Directory -Path $formXmlDir -Force | Out-Null
|
New-Item -ItemType Directory -Path $formXmlDir -Force | Out-Null
|
||||||
}
|
}
|
||||||
$formXmlFile = Join-Path $formXmlDir "Form.xml"
|
$formXmlFile = Join-Path $formXmlDir "Form.xml"
|
||||||
# Куски формы берутся из OuterXml исходного документа, а он — как и XmlWriter —
|
# Пустой элемент: XmlWriter отдаёт `<a />`, Конфигуратор пишет `<a/>`. Гард на
|
||||||
# отдаёт `<a />`; Конфигуратор пишет `<a/>`. Гард на CDATA/комментарии: только там
|
# CDATA/комментарии: только там `>` не экранируется, и ` />` может быть
|
||||||
# `>` не экранируется, и ` />` может быть содержимым, а не концом тега.
|
# содержимым, а не концом тега.
|
||||||
|
# Здесь источник не XmlWriter, а OuterXml исходного документа — спацовывает так же.
|
||||||
$formXmlText = $formXmlSb.ToString()
|
$formXmlText = $formXmlSb.ToString()
|
||||||
if ($formXmlText -notmatch '<!\[CDATA\[|<!--') { $formXmlText = [regex]::Replace($formXmlText, '(?<=\S) />', '/>') }
|
if ($formXmlText -notmatch '<!\[CDATA\[|<!--') { $formXmlText = [regex]::Replace($formXmlText, '(?<=\S) />', '/>') }
|
||||||
[System.IO.File]::WriteAllText($formXmlFile, $formXmlText, $enc)
|
[System.IO.File]::WriteAllText($formXmlFile, $formXmlText, $enc)
|
||||||
@@ -1028,8 +1029,9 @@ function Register-FormInObject {
|
|||||||
$text2 = [System.Text.Encoding]::UTF8.GetString($bytes2)
|
$text2 = [System.Text.Encoding]::UTF8.GetString($bytes2)
|
||||||
if ($text2.Length -gt 0 -and $text2[0] -eq [char]0xFEFF) { $text2 = $text2.Substring(1) }
|
if ($text2.Length -gt 0 -and $text2[0] -eq [char]0xFEFF) { $text2 = $text2.Substring(1) }
|
||||||
$text2 = $text2.Replace('encoding="utf-8"', 'encoding="UTF-8"')
|
$text2 = $text2.Replace('encoding="utf-8"', 'encoding="UTF-8"')
|
||||||
# Пустой элемент: XmlWriter пишет `<a />`, Конфигуратор — `<a/>`. Гард на CDATA/комментарии:
|
# Пустой элемент: XmlWriter отдаёт `<a />`, Конфигуратор пишет `<a/>`. Гард на
|
||||||
# только там `>` не экранируется, и ` />` может быть содержимым, а не концом тега.
|
# CDATA/комментарии: только там `>` не экранируется, и ` />` может быть
|
||||||
|
# содержимым, а не концом тега.
|
||||||
if ($text2 -notmatch '<!\[CDATA\[|<!--') { $text2 = [regex]::Replace($text2, '(?<=\S) />', '/>') }
|
if ($text2 -notmatch '<!\[CDATA\[|<!--') { $text2 = [regex]::Replace($text2, '(?<=\S) />', '/>') }
|
||||||
|
|
||||||
$utf8Bom2 = New-Object System.Text.UTF8Encoding($true)
|
$utf8Bom2 = New-Object System.Text.UTF8Encoding($true)
|
||||||
@@ -1421,8 +1423,10 @@ function Merge-AttributesIntoObject {
|
|||||||
# Insert attributes before </ChildObjects>
|
# Insert attributes before </ChildObjects>
|
||||||
$text3 = $text3 -replace '</ChildObjects>', "${allAttrXml}`r`n`t`t</ChildObjects>"
|
$text3 = $text3 -replace '</ChildObjects>', "${allAttrXml}`r`n`t`t</ChildObjects>"
|
||||||
|
|
||||||
# Пустой элемент: XmlWriter пишет `<a />`, Конфигуратор — `<a/>`. После вставки реквизитов,
|
# Пустой элемент: XmlWriter отдаёт `<a />`, Конфигуратор пишет `<a/>`. Гард на
|
||||||
# чтобы накрыть и их. Гард на CDATA/комментарии: только там ` />` может быть содержимым.
|
# CDATA/комментарии: только там `>` не экранируется, и ` />` может быть
|
||||||
|
# содержимым, а не концом тега.
|
||||||
|
# Стоит ПОСЛЕ вставки реквизитов, чтобы накрыть и их.
|
||||||
if ($text3 -notmatch '<!\[CDATA\[|<!--') { $text3 = [regex]::Replace($text3, '(?<=\S) />', '/>') }
|
if ($text3 -notmatch '<!\[CDATA\[|<!--') { $text3 = [regex]::Replace($text3, '(?<=\S) />', '/>') }
|
||||||
|
|
||||||
$utf8Bom3 = New-Object System.Text.UTF8Encoding($true)
|
$utf8Bom3 = New-Object System.Text.UTF8Encoding($true)
|
||||||
@@ -1889,8 +1893,9 @@ $memStream.Close()
|
|||||||
$text = [System.Text.Encoding]::UTF8.GetString($bytes)
|
$text = [System.Text.Encoding]::UTF8.GetString($bytes)
|
||||||
if ($text.Length -gt 0 -and $text[0] -eq [char]0xFEFF) { $text = $text.Substring(1) }
|
if ($text.Length -gt 0 -and $text[0] -eq [char]0xFEFF) { $text = $text.Substring(1) }
|
||||||
$text = $text.Replace('encoding="utf-8"', 'encoding="UTF-8"')
|
$text = $text.Replace('encoding="utf-8"', 'encoding="UTF-8"')
|
||||||
# Пустой элемент: XmlWriter пишет `<a />`, Конфигуратор — `<a/>`. Гард на CDATA/комментарии:
|
# Пустой элемент: XmlWriter отдаёт `<a />`, Конфигуратор пишет `<a/>`. Гард на
|
||||||
# только там `>` не экранируется, и ` />` может быть содержимым, а не концом тега.
|
# CDATA/комментарии: только там `>` не экранируется, и ` />` может быть
|
||||||
|
# содержимым, а не концом тега.
|
||||||
if ($text -notmatch '<!\[CDATA\[|<!--') { $text = [regex]::Replace($text, '(?<=\S) />', '/>') }
|
if ($text -notmatch '<!\[CDATA\[|<!--') { $text = [regex]::Replace($text, '(?<=\S) />', '/>') }
|
||||||
|
|
||||||
$utf8Bom = New-Object System.Text.UTF8Encoding($true)
|
$utf8Bom = New-Object System.Text.UTF8Encoding($true)
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
#!/usr/bin/env python3
|
#!/usr/bin/env python3
|
||||||
# cfe-borrow v1.13 — Borrow objects from configuration into extension (CFE)
|
# cfe-borrow v1.14 — Borrow objects from configuration into extension (CFE)
|
||||||
# Source: https://github.com/Nikolay-Shirokov/cc-1c-skills
|
# Source: https://github.com/Nikolay-Shirokov/cc-1c-skills
|
||||||
|
|
||||||
import argparse
|
import argparse
|
||||||
@@ -1017,7 +1017,7 @@ def main():
|
|||||||
return
|
return
|
||||||
|
|
||||||
# newline="" => без трансляции: иначе CRLF молча схлопнется в LF при чтении
|
# newline="" => без трансляции: иначе CRLF молча схлопнется в LF при чтении
|
||||||
# и файл будет переписан в LF (#44/#46/#47).
|
# и файл будет переписан в LF.
|
||||||
with open(obj_file, "r", encoding="utf-8-sig", newline="") as fh:
|
with open(obj_file, "r", encoding="utf-8-sig", newline="") as fh:
|
||||||
obj_content = fh.read()
|
obj_content = fh.read()
|
||||||
|
|
||||||
@@ -1078,7 +1078,7 @@ def main():
|
|||||||
|
|
||||||
# Read existing object XML (needed for dedup + enrichment)
|
# Read existing object XML (needed for dedup + enrichment)
|
||||||
# newline="" => без трансляции: иначе CRLF молча схлопнется в LF при чтении
|
# newline="" => без трансляции: иначе CRLF молча схлопнется в LF при чтении
|
||||||
# и файл будет переписан в LF (#44/#46/#47).
|
# и файл будет переписан в LF.
|
||||||
with open(obj_file, "r", encoding="utf-8-sig", newline="") as fh:
|
with open(obj_file, "r", encoding="utf-8-sig", newline="") as fh:
|
||||||
obj_content = fh.read()
|
obj_content = fh.read()
|
||||||
|
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
# form-add v1.17 — Add managed form to 1C config object
|
# form-add v1.18 — Add managed form to 1C config object
|
||||||
# Source: https://github.com/Nikolay-Shirokov/cc-1c-skills
|
# Source: https://github.com/Nikolay-Shirokov/cc-1c-skills
|
||||||
param(
|
param(
|
||||||
[Parameter(Mandatory)]
|
[Parameter(Mandatory)]
|
||||||
@@ -602,8 +602,7 @@ $settings = New-Object System.Xml.XmlWriterSettings
|
|||||||
$settings.Encoding = $encBom
|
$settings.Encoding = $encBom
|
||||||
$settings.Indent = $false
|
$settings.Indent = $false
|
||||||
|
|
||||||
# Через MemoryStream, а не прямо в файл: нужен шаг пост-обработки строки — XmlWriter
|
# Через MemoryStream, а не прямо в файл: нужен шаг пост-обработки строки.
|
||||||
# отдаёт `encoding="utf-8"` и `<a />`, Конфигуратор пишет `encoding="UTF-8"` и `<a/>`.
|
|
||||||
$memStream = New-Object System.IO.MemoryStream
|
$memStream = New-Object System.IO.MemoryStream
|
||||||
$writer = [System.Xml.XmlWriter]::Create($memStream, $settings)
|
$writer = [System.Xml.XmlWriter]::Create($memStream, $settings)
|
||||||
$xmlDoc.Save($writer)
|
$xmlDoc.Save($writer)
|
||||||
@@ -613,7 +612,9 @@ $xmlText = [System.Text.Encoding]::UTF8.GetString($memStream.ToArray())
|
|||||||
$memStream.Close()
|
$memStream.Close()
|
||||||
if ($xmlText.Length -gt 0 -and $xmlText[0] -eq [char]0xFEFF) { $xmlText = $xmlText.Substring(1) }
|
if ($xmlText.Length -gt 0 -and $xmlText[0] -eq [char]0xFEFF) { $xmlText = $xmlText.Substring(1) }
|
||||||
$xmlText = $xmlText.Replace('encoding="utf-8"', 'encoding="UTF-8"')
|
$xmlText = $xmlText.Replace('encoding="utf-8"', 'encoding="UTF-8"')
|
||||||
# Гард на CDATA/комментарии: только там `>` не экранируется, и ` />` может быть содержимым.
|
# Пустой элемент: XmlWriter отдаёт `<a />`, Конфигуратор пишет `<a/>`. Гард на
|
||||||
|
# CDATA/комментарии: только там `>` не экранируется, и ` />` может быть
|
||||||
|
# содержимым, а не концом тега.
|
||||||
if ($xmlText -notmatch '<!\[CDATA\[|<!--') { $xmlText = [regex]::Replace($xmlText, '(?<=\S) />', '/>') }
|
if ($xmlText -notmatch '<!\[CDATA\[|<!--') { $xmlText = [regex]::Replace($xmlText, '(?<=\S) />', '/>') }
|
||||||
[System.IO.File]::WriteAllText($objectXmlFull.Path, $xmlText, $encBom)
|
[System.IO.File]::WriteAllText($objectXmlFull.Path, $xmlText, $encBom)
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
#!/usr/bin/env python3
|
#!/usr/bin/env python3
|
||||||
# form-add v1.17 — Add managed form to 1C config object
|
# form-add v1.18 — Add managed form to 1C config object
|
||||||
# Source: https://github.com/Nikolay-Shirokov/cc-1c-skills
|
# Source: https://github.com/Nikolay-Shirokov/cc-1c-skills
|
||||||
|
|
||||||
import argparse
|
import argparse
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
# form-compile v1.180 — Compile 1C managed form from JSON or object metadata
|
# form-compile v1.181 — Compile 1C managed form from JSON or object metadata
|
||||||
# Source: https://github.com/Nikolay-Shirokov/cc-1c-skills
|
# Source: https://github.com/Nikolay-Shirokov/cc-1c-skills
|
||||||
param(
|
param(
|
||||||
[string]$JsonPath,
|
[string]$JsonPath,
|
||||||
@@ -6677,8 +6677,7 @@ if ($formsLeaf -eq 'Forms') {
|
|||||||
$regSettings = New-Object System.Xml.XmlWriterSettings
|
$regSettings = New-Object System.Xml.XmlWriterSettings
|
||||||
$regSettings.Encoding = $regEnc
|
$regSettings.Encoding = $regEnc
|
||||||
$regSettings.Indent = $false
|
$regSettings.Indent = $false
|
||||||
# Через MemoryStream: нужен шаг пост-обработки строки — XmlWriter отдаёт
|
# Через MemoryStream, а не прямо в файл: нужен шаг пост-обработки строки.
|
||||||
# `encoding="utf-8"` и `<a />`, Конфигуратор пишет `encoding="UTF-8"` и `<a/>`.
|
|
||||||
$regMem = New-Object System.IO.MemoryStream
|
$regMem = New-Object System.IO.MemoryStream
|
||||||
$regWriter = [System.Xml.XmlWriter]::Create($regMem, $regSettings)
|
$regWriter = [System.Xml.XmlWriter]::Create($regMem, $regSettings)
|
||||||
$objDoc.Save($regWriter)
|
$objDoc.Save($regWriter)
|
||||||
@@ -6688,7 +6687,9 @@ if ($formsLeaf -eq 'Forms') {
|
|||||||
$regMem.Close()
|
$regMem.Close()
|
||||||
if ($regText.Length -gt 0 -and $regText[0] -eq [char]0xFEFF) { $regText = $regText.Substring(1) }
|
if ($regText.Length -gt 0 -and $regText[0] -eq [char]0xFEFF) { $regText = $regText.Substring(1) }
|
||||||
$regText = $regText.Replace('encoding="utf-8"', 'encoding="UTF-8"')
|
$regText = $regText.Replace('encoding="utf-8"', 'encoding="UTF-8"')
|
||||||
# Гард на CDATA/комментарии: только там ` />` может быть содержимым.
|
# Пустой элемент: XmlWriter отдаёт `<a />`, Конфигуратор пишет `<a/>`. Гард на
|
||||||
|
# CDATA/комментарии: только там `>` не экранируется, и ` />` может быть
|
||||||
|
# содержимым, а не концом тега.
|
||||||
if ($regText -notmatch '<!\[CDATA\[|<!--') { $regText = [regex]::Replace($regText, '(?<=\S) />', '/>') }
|
if ($regText -notmatch '<!\[CDATA\[|<!--') { $regText = [regex]::Replace($regText, '(?<=\S) />', '/>') }
|
||||||
[System.IO.File]::WriteAllText($objectXmlPath, $regText, $regEnc)
|
[System.IO.File]::WriteAllText($objectXmlPath, $regText, $regEnc)
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
#!/usr/bin/env python3
|
#!/usr/bin/env python3
|
||||||
# form-compile v1.180 — Compile 1C managed form from JSON or object metadata
|
# form-compile v1.181 — Compile 1C managed form from JSON or object metadata
|
||||||
# Source: https://github.com/Nikolay-Shirokov/cc-1c-skills
|
# Source: https://github.com/Nikolay-Shirokov/cc-1c-skills
|
||||||
import argparse
|
import argparse
|
||||||
import copy
|
import copy
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
# form-edit v1.7 — Edit 1C managed form elements
|
# form-edit v1.8 — Edit 1C managed form elements
|
||||||
# Source: https://github.com/Nikolay-Shirokov/cc-1c-skills
|
# Source: https://github.com/Nikolay-Shirokov/cc-1c-skills
|
||||||
param(
|
param(
|
||||||
[Parameter(Mandatory)]
|
[Parameter(Mandatory)]
|
||||||
@@ -1387,8 +1387,9 @@ if ($def.elementEvents -and $def.elementEvents.Count -gt 0) {
|
|||||||
$content = $xmlDoc.OuterXml
|
$content = $xmlDoc.OuterXml
|
||||||
# Ensure encoding declaration is uppercase UTF-8
|
# Ensure encoding declaration is uppercase UTF-8
|
||||||
$content = $content -replace '^<\?xml version="1.0" encoding="utf-8"\?>', '<?xml version="1.0" encoding="UTF-8"?>'
|
$content = $content -replace '^<\?xml version="1.0" encoding="utf-8"\?>', '<?xml version="1.0" encoding="UTF-8"?>'
|
||||||
# Пустой элемент: OuterXml (как и XmlWriter) пишет `<a />`, Конфигуратор — `<a/>`.
|
# Пустой элемент: XmlWriter отдаёт `<a />`, Конфигуратор пишет `<a/>`. Гард на
|
||||||
# Гард на CDATA/комментарии: только там ` />` может быть содержимым, а не концом тега.
|
# CDATA/комментарии: только там `>` не экранируется, и ` />` может быть
|
||||||
|
# содержимым, а не концом тега.
|
||||||
if ($content -notmatch '<!\[CDATA\[|<!--') { $content = [regex]::Replace($content, '(?<=\S) />', '/>') }
|
if ($content -notmatch '<!\[CDATA\[|<!--') { $content = [regex]::Replace($content, '(?<=\S) />', '/>') }
|
||||||
|
|
||||||
$enc = New-Object System.Text.UTF8Encoding($true)
|
$enc = New-Object System.Text.UTF8Encoding($true)
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
# form-edit v1.7 — Edit 1C managed form elements (Python port)
|
# form-edit v1.8 — Edit 1C managed form elements (Python port)
|
||||||
# Source: https://github.com/Nikolay-Shirokov/cc-1c-skills
|
# Source: https://github.com/Nikolay-Shirokov/cc-1c-skills
|
||||||
import argparse
|
import argparse
|
||||||
import json
|
import json
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
# form-remove v1.5 — Remove form from 1C object
|
# form-remove v1.6 — Remove form from 1C object
|
||||||
# Source: https://github.com/Nikolay-Shirokov/cc-1c-skills
|
# Source: https://github.com/Nikolay-Shirokov/cc-1c-skills
|
||||||
param(
|
param(
|
||||||
[Parameter(Mandatory)]
|
[Parameter(Mandatory)]
|
||||||
@@ -84,8 +84,7 @@ $settings = New-Object System.Xml.XmlWriterSettings
|
|||||||
$settings.Encoding = $encBom
|
$settings.Encoding = $encBom
|
||||||
$settings.Indent = $false
|
$settings.Indent = $false
|
||||||
|
|
||||||
# Через MemoryStream, а не прямо в файл: нужен шаг пост-обработки строки — XmlWriter
|
# Через MemoryStream, а не прямо в файл: нужен шаг пост-обработки строки.
|
||||||
# отдаёт `encoding="utf-8"` и `<a />`, Конфигуратор пишет `encoding="UTF-8"` и `<a/>`.
|
|
||||||
$memStream = New-Object System.IO.MemoryStream
|
$memStream = New-Object System.IO.MemoryStream
|
||||||
$writer = [System.Xml.XmlWriter]::Create($memStream, $settings)
|
$writer = [System.Xml.XmlWriter]::Create($memStream, $settings)
|
||||||
$xmlDoc.Save($writer)
|
$xmlDoc.Save($writer)
|
||||||
@@ -95,7 +94,9 @@ $xmlText = [System.Text.Encoding]::UTF8.GetString($memStream.ToArray())
|
|||||||
$memStream.Close()
|
$memStream.Close()
|
||||||
if ($xmlText.Length -gt 0 -and $xmlText[0] -eq [char]0xFEFF) { $xmlText = $xmlText.Substring(1) }
|
if ($xmlText.Length -gt 0 -and $xmlText[0] -eq [char]0xFEFF) { $xmlText = $xmlText.Substring(1) }
|
||||||
$xmlText = $xmlText.Replace('encoding="utf-8"', 'encoding="UTF-8"')
|
$xmlText = $xmlText.Replace('encoding="utf-8"', 'encoding="UTF-8"')
|
||||||
# Гард на CDATA/комментарии: только там `>` не экранируется, и ` />` может быть содержимым.
|
# Пустой элемент: XmlWriter отдаёт `<a />`, Конфигуратор пишет `<a/>`. Гард на
|
||||||
|
# CDATA/комментарии: только там `>` не экранируется, и ` />` может быть
|
||||||
|
# содержимым, а не концом тега.
|
||||||
if ($xmlText -notmatch '<!\[CDATA\[|<!--') { $xmlText = [regex]::Replace($xmlText, '(?<=\S) />', '/>') }
|
if ($xmlText -notmatch '<!\[CDATA\[|<!--') { $xmlText = [regex]::Replace($xmlText, '(?<=\S) />', '/>') }
|
||||||
[System.IO.File]::WriteAllText($rootXmlFull.Path, $xmlText, $encBom)
|
[System.IO.File]::WriteAllText($rootXmlFull.Path, $xmlText, $encBom)
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
#!/usr/bin/env python3
|
#!/usr/bin/env python3
|
||||||
# form-remove v1.5 — Remove form from 1C object
|
# form-remove v1.6 — Remove form from 1C object
|
||||||
# Source: https://github.com/Nikolay-Shirokov/cc-1c-skills
|
# Source: https://github.com/Nikolay-Shirokov/cc-1c-skills
|
||||||
|
|
||||||
import argparse
|
import argparse
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
# help-add v1.13 — Add built-in help to 1C object
|
# help-add v1.14 — Add built-in help to 1C object
|
||||||
# Source: https://github.com/Nikolay-Shirokov/cc-1c-skills
|
# Source: https://github.com/Nikolay-Shirokov/cc-1c-skills
|
||||||
param(
|
param(
|
||||||
[Parameter(Mandatory)]
|
[Parameter(Mandatory)]
|
||||||
@@ -266,8 +266,7 @@ if (Test-Path $formsDir) {
|
|||||||
$settings = New-Object System.Xml.XmlWriterSettings
|
$settings = New-Object System.Xml.XmlWriterSettings
|
||||||
$settings.Encoding = $encBom
|
$settings.Encoding = $encBom
|
||||||
$settings.Indent = $false
|
$settings.Indent = $false
|
||||||
# Через MemoryStream: нужен шаг пост-обработки строки — XmlWriter отдаёт
|
# Через MemoryStream, а не прямо в файл: нужен шаг пост-обработки строки.
|
||||||
# `encoding="utf-8"` и `<a />`, Конфигуратор пишет `encoding="UTF-8"` и `<a/>`.
|
|
||||||
$memStream = New-Object System.IO.MemoryStream
|
$memStream = New-Object System.IO.MemoryStream
|
||||||
$writer = [System.Xml.XmlWriter]::Create($memStream, $settings)
|
$writer = [System.Xml.XmlWriter]::Create($memStream, $settings)
|
||||||
$xmlDoc.Save($writer)
|
$xmlDoc.Save($writer)
|
||||||
@@ -277,7 +276,9 @@ if (Test-Path $formsDir) {
|
|||||||
$memStream.Close()
|
$memStream.Close()
|
||||||
if ($xmlText.Length -gt 0 -and $xmlText[0] -eq [char]0xFEFF) { $xmlText = $xmlText.Substring(1) }
|
if ($xmlText.Length -gt 0 -and $xmlText[0] -eq [char]0xFEFF) { $xmlText = $xmlText.Substring(1) }
|
||||||
$xmlText = $xmlText.Replace('encoding="utf-8"', 'encoding="UTF-8"')
|
$xmlText = $xmlText.Replace('encoding="utf-8"', 'encoding="UTF-8"')
|
||||||
# Гард на CDATA/комментарии: только там ` />` может быть содержимым.
|
# Пустой элемент: XmlWriter отдаёт `<a />`, Конфигуратор пишет `<a/>`. Гард на
|
||||||
|
# CDATA/комментарии: только там `>` не экранируется, и ` />` может быть
|
||||||
|
# содержимым, а не концом тега.
|
||||||
if ($xmlText -notmatch '<!\[CDATA\[|<!--') { $xmlText = [regex]::Replace($xmlText, '(?<=\S) />', '/>') }
|
if ($xmlText -notmatch '<!\[CDATA\[|<!--') { $xmlText = [regex]::Replace($xmlText, '(?<=\S) />', '/>') }
|
||||||
[System.IO.File]::WriteAllText($formMeta.FullName, $xmlText, $encBom)
|
[System.IO.File]::WriteAllText($formMeta.FullName, $xmlText, $encBom)
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
#!/usr/bin/env python3
|
#!/usr/bin/env python3
|
||||||
# help-add v1.13 — Add built-in help to 1C object
|
# help-add v1.14 — Add built-in help to 1C object
|
||||||
# Source: https://github.com/Nikolay-Shirokov/cc-1c-skills
|
# Source: https://github.com/Nikolay-Shirokov/cc-1c-skills
|
||||||
|
|
||||||
import argparse
|
import argparse
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
# interface-edit v1.11 — Edit 1C CommandInterface.xml
|
# interface-edit v1.12 — Edit 1C CommandInterface.xml
|
||||||
# Source: https://github.com/Nikolay-Shirokov/cc-1c-skills
|
# Source: https://github.com/Nikolay-Shirokov/cc-1c-skills
|
||||||
param(
|
param(
|
||||||
[Parameter(Mandatory)][Alias('Path')][string]$CIPath,
|
[Parameter(Mandatory)][Alias('Path')][string]$CIPath,
|
||||||
@@ -679,8 +679,9 @@ $memStream.Close()
|
|||||||
$text = [System.Text.Encoding]::UTF8.GetString($bytes)
|
$text = [System.Text.Encoding]::UTF8.GetString($bytes)
|
||||||
if ($text.Length -gt 0 -and $text[0] -eq [char]0xFEFF) { $text = $text.Substring(1) }
|
if ($text.Length -gt 0 -and $text[0] -eq [char]0xFEFF) { $text = $text.Substring(1) }
|
||||||
$text = $text.Replace('encoding="utf-8"', 'encoding="UTF-8"')
|
$text = $text.Replace('encoding="utf-8"', 'encoding="UTF-8"')
|
||||||
# Пустой элемент: XmlWriter пишет `<a />`, Конфигуратор — `<a/>`. Гард на CDATA/комментарии:
|
# Пустой элемент: XmlWriter отдаёт `<a />`, Конфигуратор пишет `<a/>`. Гард на
|
||||||
# только там `>` не экранируется, и ` />` может быть содержимым, а не концом тега.
|
# CDATA/комментарии: только там `>` не экранируется, и ` />` может быть
|
||||||
|
# содержимым, а не концом тега.
|
||||||
if ($text -notmatch '<!\[CDATA\[|<!--') { $text = [regex]::Replace($text, '(?<=\S) />', '/>') }
|
if ($text -notmatch '<!\[CDATA\[|<!--') { $text = [regex]::Replace($text, '(?<=\S) />', '/>') }
|
||||||
|
|
||||||
$utf8Bom = New-Object System.Text.UTF8Encoding($true)
|
$utf8Bom = New-Object System.Text.UTF8Encoding($true)
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
#!/usr/bin/env python3
|
#!/usr/bin/env python3
|
||||||
# interface-edit v1.11 — Edit 1C CommandInterface.xml
|
# interface-edit v1.12 — Edit 1C CommandInterface.xml
|
||||||
# Source: https://github.com/Nikolay-Shirokov/cc-1c-skills
|
# Source: https://github.com/Nikolay-Shirokov/cc-1c-skills
|
||||||
|
|
||||||
import argparse
|
import argparse
|
||||||
@@ -442,7 +442,7 @@ def main():
|
|||||||
# существующего файла, наоборот, наследует его стиль — это делает
|
# существующего файла, наоборот, наследует его стиль — это делает
|
||||||
# save_xml_bom через _detect_xml_style.) newline="" обязателен: без него
|
# save_xml_bom через _detect_xml_style.) newline="" обязателен: без него
|
||||||
# текстовый режим дал бы CRLF на Windows и LF на macOS.
|
# текстовый режим дал бы CRLF на Windows и LF на macOS.
|
||||||
empty_ci = empty_ci.replace("\r\n", "\n").replace("\n", "\r\n")
|
empty_ci = empty_ci.replace("\r\n", "\n").replace("\n", "\r\n").rstrip("\r\n")
|
||||||
with open(ci_path, "w", encoding="utf-8-sig", newline="") as fh:
|
with open(ci_path, "w", encoding="utf-8-sig", newline="") as fh:
|
||||||
fh.write(empty_ci)
|
fh.write(empty_ci)
|
||||||
print(f"[INFO] Created new CommandInterface.xml: {ci_path}")
|
print(f"[INFO] Created new CommandInterface.xml: {ci_path}")
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
# meta-compile v1.81 — Compile 1C metadata object from JSON
|
# meta-compile v1.82 — Compile 1C metadata object from JSON
|
||||||
# Source: https://github.com/Nikolay-Shirokov/cc-1c-skills
|
# Source: https://github.com/Nikolay-Shirokov/cc-1c-skills
|
||||||
param(
|
param(
|
||||||
[Parameter(Mandatory)]
|
[Parameter(Mandatory)]
|
||||||
@@ -5024,8 +5024,9 @@ if (Test-Path $configXmlPath) {
|
|||||||
$memStream.Close()
|
$memStream.Close()
|
||||||
if ($cfgText.Length -gt 0 -and $cfgText[0] -eq [char]0xFEFF) { $cfgText = $cfgText.Substring(1) }
|
if ($cfgText.Length -gt 0 -and $cfgText[0] -eq [char]0xFEFF) { $cfgText = $cfgText.Substring(1) }
|
||||||
$cfgText = $cfgText.Replace('encoding="utf-8"', 'encoding="UTF-8"')
|
$cfgText = $cfgText.Replace('encoding="utf-8"', 'encoding="UTF-8"')
|
||||||
# Гард на CDATA/комментарии: только там `>` не экранируется, и ` />` может
|
# Пустой элемент: XmlWriter отдаёт `<a />`, Конфигуратор пишет `<a/>`. Гард на
|
||||||
# быть содержимым, а не концом тега.
|
# CDATA/комментарии: только там `>` не экранируется, и ` />` может быть
|
||||||
|
# содержимым, а не концом тега.
|
||||||
if ($cfgText -notmatch '<!\[CDATA\[|<!--') { $cfgText = [regex]::Replace($cfgText, '(?<=\S) />', '/>') }
|
if ($cfgText -notmatch '<!\[CDATA\[|<!--') { $cfgText = [regex]::Replace($cfgText, '(?<=\S) />', '/>') }
|
||||||
[System.IO.File]::WriteAllText($configXmlPath, $cfgText, (New-Object System.Text.UTF8Encoding($true)))
|
[System.IO.File]::WriteAllText($configXmlPath, $cfgText, (New-Object System.Text.UTF8Encoding($true)))
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
#!/usr/bin/env python3
|
#!/usr/bin/env python3
|
||||||
# meta-compile v1.81 — Compile 1C metadata object from JSON
|
# meta-compile v1.82 — Compile 1C metadata object from JSON
|
||||||
# Source: https://github.com/Nikolay-Shirokov/cc-1c-skills
|
# Source: https://github.com/Nikolay-Shirokov/cc-1c-skills
|
||||||
|
|
||||||
import argparse
|
import argparse
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
# meta-edit v1.27 — Edit existing 1C metadata object XML
|
# meta-edit v1.28 — Edit existing 1C metadata object XML
|
||||||
# Source: https://github.com/Nikolay-Shirokov/cc-1c-skills
|
# Source: https://github.com/Nikolay-Shirokov/cc-1c-skills
|
||||||
param(
|
param(
|
||||||
[string]$DefinitionFile,
|
[string]$DefinitionFile,
|
||||||
@@ -3209,8 +3209,9 @@ if ($text.Length -gt 0 -and $text[0] -eq [char]0xFEFF) {
|
|||||||
$text = $text.Substring(1)
|
$text = $text.Substring(1)
|
||||||
}
|
}
|
||||||
$text = $text.Replace('encoding="utf-8"', 'encoding="UTF-8"')
|
$text = $text.Replace('encoding="utf-8"', 'encoding="UTF-8"')
|
||||||
# Пустой элемент: XmlWriter пишет `<a />`, Конфигуратор — `<a/>`. Гард на CDATA/комментарии:
|
# Пустой элемент: XmlWriter отдаёт `<a />`, Конфигуратор пишет `<a/>`. Гард на
|
||||||
# только там `>` не экранируется, и ` />` может быть содержимым, а не концом тега.
|
# CDATA/комментарии: только там `>` не экранируется, и ` />` может быть
|
||||||
|
# содержимым, а не концом тега.
|
||||||
if ($text -notmatch '<!\[CDATA\[|<!--') { $text = [regex]::Replace($text, '(?<=\S) />', '/>') }
|
if ($text -notmatch '<!\[CDATA\[|<!--') { $text = [regex]::Replace($text, '(?<=\S) />', '/>') }
|
||||||
|
|
||||||
# Write with BOM
|
# Write with BOM
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
#!/usr/bin/env python3
|
#!/usr/bin/env python3
|
||||||
# meta-edit v1.27 — Edit existing 1C metadata object XML
|
# meta-edit v1.28 — Edit existing 1C metadata object XML
|
||||||
# Source: https://github.com/Nikolay-Shirokov/cc-1c-skills
|
# Source: https://github.com/Nikolay-Shirokov/cc-1c-skills
|
||||||
|
|
||||||
import argparse
|
import argparse
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
# meta-remove v1.6 — Remove metadata object from 1C configuration dump
|
# meta-remove v1.7 — Remove metadata object from 1C configuration dump
|
||||||
# Source: https://github.com/Nikolay-Shirokov/cc-1c-skills
|
# Source: https://github.com/Nikolay-Shirokov/cc-1c-skills
|
||||||
param(
|
param(
|
||||||
[Parameter(Mandatory)]
|
[Parameter(Mandatory)]
|
||||||
@@ -493,9 +493,7 @@ if (-not $cfgNode) {
|
|||||||
# Save Configuration.xml
|
# Save Configuration.xml
|
||||||
if ($actions -gt 0 -and -not $DryRun) {
|
if ($actions -gt 0 -and -not $DryRun) {
|
||||||
$enc = New-Object System.Text.UTF8Encoding $true
|
$enc = New-Object System.Text.UTF8Encoding $true
|
||||||
# Через MemoryStream, а не прямо в файл: нужен шаг пост-обработки строки —
|
# Через MemoryStream, а не прямо в файл: нужен шаг пост-обработки строки.
|
||||||
# XmlWriter отдаёт `encoding="utf-8"` и `<a />`, Конфигуратор пишет
|
|
||||||
# `encoding="UTF-8"` и `<a/>`.
|
|
||||||
$settings = New-Object System.Xml.XmlWriterSettings
|
$settings = New-Object System.Xml.XmlWriterSettings
|
||||||
$settings.Encoding = $enc
|
$settings.Encoding = $enc
|
||||||
$settings.Indent = $false
|
$settings.Indent = $false
|
||||||
@@ -508,7 +506,9 @@ if (-not $cfgNode) {
|
|||||||
$memStream.Close()
|
$memStream.Close()
|
||||||
if ($xmlText.Length -gt 0 -and $xmlText[0] -eq [char]0xFEFF) { $xmlText = $xmlText.Substring(1) }
|
if ($xmlText.Length -gt 0 -and $xmlText[0] -eq [char]0xFEFF) { $xmlText = $xmlText.Substring(1) }
|
||||||
$xmlText = $xmlText.Replace('encoding="utf-8"', 'encoding="UTF-8"')
|
$xmlText = $xmlText.Replace('encoding="utf-8"', 'encoding="UTF-8"')
|
||||||
# Гард на CDATA/комментарии: только там ` />` может быть содержимым.
|
# Пустой элемент: XmlWriter отдаёт `<a />`, Конфигуратор пишет `<a/>`. Гард на
|
||||||
|
# CDATA/комментарии: только там `>` не экранируется, и ` />` может быть
|
||||||
|
# содержимым, а не концом тега.
|
||||||
if ($xmlText -notmatch '<!\[CDATA\[|<!--') { $xmlText = [regex]::Replace($xmlText, '(?<=\S) />', '/>') }
|
if ($xmlText -notmatch '<!\[CDATA\[|<!--') { $xmlText = [regex]::Replace($xmlText, '(?<=\S) />', '/>') }
|
||||||
[System.IO.File]::WriteAllText($configXml, $xmlText, $enc)
|
[System.IO.File]::WriteAllText($configXml, $xmlText, $enc)
|
||||||
Write-Host "[OK] Configuration.xml saved"
|
Write-Host "[OK] Configuration.xml saved"
|
||||||
@@ -574,8 +574,7 @@ function Remove-FromSubsystems {
|
|||||||
|
|
||||||
if ($modified -and -not $DryRun) {
|
if ($modified -and -not $DryRun) {
|
||||||
$enc = New-Object System.Text.UTF8Encoding $true
|
$enc = New-Object System.Text.UTF8Encoding $true
|
||||||
# Через MemoryStream: нужен шаг пост-обработки строки — XmlWriter отдаёт
|
# Через MemoryStream, а не прямо в файл: нужен шаг пост-обработки строки.
|
||||||
# `encoding="utf-8"` и `<a />`, Конфигуратор пишет `encoding="UTF-8"` и `<a/>`.
|
|
||||||
$settings = New-Object System.Xml.XmlWriterSettings
|
$settings = New-Object System.Xml.XmlWriterSettings
|
||||||
$settings.Encoding = $enc
|
$settings.Encoding = $enc
|
||||||
$settings.Indent = $false
|
$settings.Indent = $false
|
||||||
@@ -588,7 +587,9 @@ function Remove-FromSubsystems {
|
|||||||
$memStream.Close()
|
$memStream.Close()
|
||||||
if ($xmlText.Length -gt 0 -and $xmlText[0] -eq [char]0xFEFF) { $xmlText = $xmlText.Substring(1) }
|
if ($xmlText.Length -gt 0 -and $xmlText[0] -eq [char]0xFEFF) { $xmlText = $xmlText.Substring(1) }
|
||||||
$xmlText = $xmlText.Replace('encoding="utf-8"', 'encoding="UTF-8"')
|
$xmlText = $xmlText.Replace('encoding="utf-8"', 'encoding="UTF-8"')
|
||||||
# Гард на CDATA/комментарии: только там ` />` может быть содержимым.
|
# Пустой элемент: XmlWriter отдаёт `<a />`, Конфигуратор пишет `<a/>`. Гард на
|
||||||
|
# CDATA/комментарии: только там `>` не экранируется, и ` />` может быть
|
||||||
|
# содержимым, а не концом тега.
|
||||||
if ($xmlText -notmatch '<!\[CDATA\[|<!--') { $xmlText = [regex]::Replace($xmlText, '(?<=\S) />', '/>') }
|
if ($xmlText -notmatch '<!\[CDATA\[|<!--') { $xmlText = [regex]::Replace($xmlText, '(?<=\S) />', '/>') }
|
||||||
[System.IO.File]::WriteAllText($xmlFile.FullName, $xmlText, $enc)
|
[System.IO.File]::WriteAllText($xmlFile.FullName, $xmlText, $enc)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
#!/usr/bin/env python3
|
#!/usr/bin/env python3
|
||||||
# meta-remove v1.6 — Remove metadata object from 1C configuration dump
|
# meta-remove v1.7 — Remove metadata object from 1C configuration dump
|
||||||
# Source: https://github.com/Nikolay-Shirokov/cc-1c-skills
|
# Source: https://github.com/Nikolay-Shirokov/cc-1c-skills
|
||||||
|
|
||||||
import argparse
|
import argparse
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
# role-compile v1.14 — Compile 1C role from JSON
|
# role-compile v1.15 — Compile 1C role from JSON
|
||||||
# Source: https://github.com/Nikolay-Shirokov/cc-1c-skills
|
# Source: https://github.com/Nikolay-Shirokov/cc-1c-skills
|
||||||
param(
|
param(
|
||||||
[Parameter(Mandatory)]
|
[Parameter(Mandatory)]
|
||||||
@@ -856,9 +856,7 @@ if (Test-Path $configXmlPath) {
|
|||||||
$cfgSettings = New-Object System.Xml.XmlWriterSettings
|
$cfgSettings = New-Object System.Xml.XmlWriterSettings
|
||||||
$cfgSettings.Encoding = New-Object System.Text.UTF8Encoding($true)
|
$cfgSettings.Encoding = New-Object System.Text.UTF8Encoding($true)
|
||||||
$cfgSettings.Indent = $false
|
$cfgSettings.Indent = $false
|
||||||
# Через MemoryStream, а не прямо в файл: нужен шаг пост-обработки строки —
|
# Через MemoryStream, а не прямо в файл: нужен шаг пост-обработки строки.
|
||||||
# XmlWriter отдаёт `encoding="utf-8"` и `<a />`, Конфигуратор пишет
|
|
||||||
# `encoding="UTF-8"` и `<a/>`.
|
|
||||||
$memStream = New-Object System.IO.MemoryStream
|
$memStream = New-Object System.IO.MemoryStream
|
||||||
$writer = [System.Xml.XmlWriter]::Create($memStream, $cfgSettings)
|
$writer = [System.Xml.XmlWriter]::Create($memStream, $cfgSettings)
|
||||||
$configDoc.Save($writer)
|
$configDoc.Save($writer)
|
||||||
@@ -868,7 +866,9 @@ if (Test-Path $configXmlPath) {
|
|||||||
$memStream.Close()
|
$memStream.Close()
|
||||||
if ($cfgText.Length -gt 0 -and $cfgText[0] -eq [char]0xFEFF) { $cfgText = $cfgText.Substring(1) }
|
if ($cfgText.Length -gt 0 -and $cfgText[0] -eq [char]0xFEFF) { $cfgText = $cfgText.Substring(1) }
|
||||||
$cfgText = $cfgText.Replace('encoding="utf-8"', 'encoding="UTF-8"')
|
$cfgText = $cfgText.Replace('encoding="utf-8"', 'encoding="UTF-8"')
|
||||||
# Гард на CDATA/комментарии: только там ` />` может быть содержимым.
|
# Пустой элемент: XmlWriter отдаёт `<a />`, Конфигуратор пишет `<a/>`. Гард на
|
||||||
|
# CDATA/комментарии: только там `>` не экранируется, и ` />` может быть
|
||||||
|
# содержимым, а не концом тега.
|
||||||
if ($cfgText -notmatch '<!\[CDATA\[|<!--') { $cfgText = [regex]::Replace($cfgText, '(?<=\S) />', '/>') }
|
if ($cfgText -notmatch '<!\[CDATA\[|<!--') { $cfgText = [regex]::Replace($cfgText, '(?<=\S) />', '/>') }
|
||||||
[System.IO.File]::WriteAllText($configXmlPath, $cfgText, (New-Object System.Text.UTF8Encoding($true)))
|
[System.IO.File]::WriteAllText($configXmlPath, $cfgText, (New-Object System.Text.UTF8Encoding($true)))
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
#!/usr/bin/env python3
|
#!/usr/bin/env python3
|
||||||
# role-compile v1.14 — Compile 1C role from JSON
|
# role-compile v1.15 — Compile 1C role from JSON
|
||||||
# Source: https://github.com/Nikolay-Shirokov/cc-1c-skills
|
# Source: https://github.com/Nikolay-Shirokov/cc-1c-skills
|
||||||
import argparse
|
import argparse
|
||||||
import json
|
import json
|
||||||
@@ -798,7 +798,7 @@ def main():
|
|||||||
|
|
||||||
if os.path.exists(config_xml_path):
|
if os.path.exists(config_xml_path):
|
||||||
# newline='' => без трансляции переводов строк: иначе CRLF молча схлопнется
|
# newline='' => без трансляции переводов строк: иначе CRLF молча схлопнется
|
||||||
# в LF при чтении и файл будет переписан в LF (#44/#46/#47).
|
# в LF при чтении и файл будет переписан в LF.
|
||||||
with open(config_xml_path, 'r', encoding='utf-8-sig', newline='') as f:
|
with open(config_xml_path, 'r', encoding='utf-8-sig', newline='') as f:
|
||||||
raw_text = f.read()
|
raw_text = f.read()
|
||||||
|
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
# subsystem-compile v1.15 — Create 1C subsystem from JSON definition
|
# subsystem-compile v1.16 — Create 1C subsystem from JSON definition
|
||||||
# Source: https://github.com/Nikolay-Shirokov/cc-1c-skills
|
# Source: https://github.com/Nikolay-Shirokov/cc-1c-skills
|
||||||
param(
|
param(
|
||||||
[string]$DefinitionFile,
|
[string]$DefinitionFile,
|
||||||
@@ -657,8 +657,9 @@ if ($parentXmlPath -and (Test-Path $parentXmlPath)) {
|
|||||||
$text = [System.Text.Encoding]::UTF8.GetString($bytes)
|
$text = [System.Text.Encoding]::UTF8.GetString($bytes)
|
||||||
if ($text.Length -gt 0 -and $text[0] -eq [char]0xFEFF) { $text = $text.Substring(1) }
|
if ($text.Length -gt 0 -and $text[0] -eq [char]0xFEFF) { $text = $text.Substring(1) }
|
||||||
$text = $text.Replace('encoding="utf-8"', 'encoding="UTF-8"')
|
$text = $text.Replace('encoding="utf-8"', 'encoding="UTF-8"')
|
||||||
# Пустой элемент: XmlWriter пишет `<a />`, Конфигуратор — `<a/>`. Гард на CDATA/комментарии:
|
# Пустой элемент: XmlWriter отдаёт `<a />`, Конфигуратор пишет `<a/>`. Гард на
|
||||||
# только там `>` не экранируется, и ` />` может быть содержимым, а не концом тега.
|
# CDATA/комментарии: только там `>` не экранируется, и ` />` может быть
|
||||||
|
# содержимым, а не концом тега.
|
||||||
if ($text -notmatch '<!\[CDATA\[|<!--') { $text = [regex]::Replace($text, '(?<=\S) />', '/>') }
|
if ($text -notmatch '<!\[CDATA\[|<!--') { $text = [regex]::Replace($text, '(?<=\S) />', '/>') }
|
||||||
[System.IO.File]::WriteAllText($parentXmlPath, $text, $utf8Bom)
|
[System.IO.File]::WriteAllText($parentXmlPath, $text, $utf8Bom)
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
#!/usr/bin/env python3
|
#!/usr/bin/env python3
|
||||||
# subsystem-compile v1.15 — Create 1C subsystem from JSON definition
|
# subsystem-compile v1.16 — Create 1C subsystem from JSON definition
|
||||||
# Source: https://github.com/Nikolay-Shirokov/cc-1c-skills
|
# Source: https://github.com/Nikolay-Shirokov/cc-1c-skills
|
||||||
import argparse
|
import argparse
|
||||||
import json
|
import json
|
||||||
@@ -562,7 +562,7 @@ def main():
|
|||||||
|
|
||||||
if parent_xml_path and os.path.exists(parent_xml_path):
|
if parent_xml_path and os.path.exists(parent_xml_path):
|
||||||
# newline='' => без трансляции переводов строк: иначе CRLF молча схлопнется
|
# newline='' => без трансляции переводов строк: иначе CRLF молча схлопнется
|
||||||
# в LF при чтении и файл будет переписан в LF (#44/#46/#47).
|
# в LF при чтении и файл будет переписан в LF.
|
||||||
with open(parent_xml_path, 'r', encoding='utf-8-sig', newline='') as f:
|
with open(parent_xml_path, 'r', encoding='utf-8-sig', newline='') as f:
|
||||||
raw_text = f.read()
|
raw_text = f.read()
|
||||||
|
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
# subsystem-edit v1.11 — Edit existing 1C subsystem XML
|
# subsystem-edit v1.12 — Edit existing 1C subsystem XML
|
||||||
# Source: https://github.com/Nikolay-Shirokov/cc-1c-skills
|
# Source: https://github.com/Nikolay-Shirokov/cc-1c-skills
|
||||||
param(
|
param(
|
||||||
[Parameter(Mandatory)][Alias('Path')][string]$SubsystemPath,
|
[Parameter(Mandatory)][Alias('Path')][string]$SubsystemPath,
|
||||||
@@ -655,8 +655,9 @@ $memStream.Close()
|
|||||||
$text = [System.Text.Encoding]::UTF8.GetString($bytes)
|
$text = [System.Text.Encoding]::UTF8.GetString($bytes)
|
||||||
if ($text.Length -gt 0 -and $text[0] -eq [char]0xFEFF) { $text = $text.Substring(1) }
|
if ($text.Length -gt 0 -and $text[0] -eq [char]0xFEFF) { $text = $text.Substring(1) }
|
||||||
$text = $text.Replace('encoding="utf-8"', 'encoding="UTF-8"')
|
$text = $text.Replace('encoding="utf-8"', 'encoding="UTF-8"')
|
||||||
# Пустой элемент: XmlWriter пишет `<a />`, Конфигуратор — `<a/>`. Гард на CDATA/комментарии:
|
# Пустой элемент: XmlWriter отдаёт `<a />`, Конфигуратор пишет `<a/>`. Гард на
|
||||||
# только там `>` не экранируется, и ` />` может быть содержимым, а не концом тега.
|
# CDATA/комментарии: только там `>` не экранируется, и ` />` может быть
|
||||||
|
# содержимым, а не концом тега.
|
||||||
if ($text -notmatch '<!\[CDATA\[|<!--') { $text = [regex]::Replace($text, '(?<=\S) />', '/>') }
|
if ($text -notmatch '<!\[CDATA\[|<!--') { $text = [regex]::Replace($text, '(?<=\S) />', '/>') }
|
||||||
|
|
||||||
$utf8Bom = New-Object System.Text.UTF8Encoding($true)
|
$utf8Bom = New-Object System.Text.UTF8Encoding($true)
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
#!/usr/bin/env python3
|
#!/usr/bin/env python3
|
||||||
# subsystem-edit v1.11 — Edit existing 1C subsystem XML
|
# subsystem-edit v1.12 — Edit existing 1C subsystem XML
|
||||||
# Source: https://github.com/Nikolay-Shirokov/cc-1c-skills
|
# Source: https://github.com/Nikolay-Shirokov/cc-1c-skills
|
||||||
|
|
||||||
import argparse
|
import argparse
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
# template-add v1.15 — Add template to 1C object
|
# template-add v1.16 — Add template to 1C object
|
||||||
# Source: https://github.com/Nikolay-Shirokov/cc-1c-skills
|
# Source: https://github.com/Nikolay-Shirokov/cc-1c-skills
|
||||||
param(
|
param(
|
||||||
[Parameter(Mandatory)]
|
[Parameter(Mandatory)]
|
||||||
@@ -403,8 +403,7 @@ $settings = New-Object System.Xml.XmlWriterSettings
|
|||||||
$settings.Encoding = $encBom
|
$settings.Encoding = $encBom
|
||||||
$settings.Indent = $false
|
$settings.Indent = $false
|
||||||
|
|
||||||
# Через MemoryStream, а не прямо в файл: нужен шаг пост-обработки строки — XmlWriter
|
# Через MemoryStream, а не прямо в файл: нужен шаг пост-обработки строки.
|
||||||
# отдаёт `encoding="utf-8"` и `<a />`, Конфигуратор пишет `encoding="UTF-8"` и `<a/>`.
|
|
||||||
$memStream = New-Object System.IO.MemoryStream
|
$memStream = New-Object System.IO.MemoryStream
|
||||||
$writer = [System.Xml.XmlWriter]::Create($memStream, $settings)
|
$writer = [System.Xml.XmlWriter]::Create($memStream, $settings)
|
||||||
$xmlDoc.Save($writer)
|
$xmlDoc.Save($writer)
|
||||||
@@ -414,7 +413,9 @@ $xmlText = [System.Text.Encoding]::UTF8.GetString($memStream.ToArray())
|
|||||||
$memStream.Close()
|
$memStream.Close()
|
||||||
if ($xmlText.Length -gt 0 -and $xmlText[0] -eq [char]0xFEFF) { $xmlText = $xmlText.Substring(1) }
|
if ($xmlText.Length -gt 0 -and $xmlText[0] -eq [char]0xFEFF) { $xmlText = $xmlText.Substring(1) }
|
||||||
$xmlText = $xmlText.Replace('encoding="utf-8"', 'encoding="UTF-8"')
|
$xmlText = $xmlText.Replace('encoding="utf-8"', 'encoding="UTF-8"')
|
||||||
# Гард на CDATA/комментарии: только там `>` не экранируется, и ` />` может быть содержимым.
|
# Пустой элемент: XmlWriter отдаёт `<a />`, Конфигуратор пишет `<a/>`. Гард на
|
||||||
|
# CDATA/комментарии: только там `>` не экранируется, и ` />` может быть
|
||||||
|
# содержимым, а не концом тега.
|
||||||
if ($xmlText -notmatch '<!\[CDATA\[|<!--') { $xmlText = [regex]::Replace($xmlText, '(?<=\S) />', '/>') }
|
if ($xmlText -notmatch '<!\[CDATA\[|<!--') { $xmlText = [regex]::Replace($xmlText, '(?<=\S) />', '/>') }
|
||||||
[System.IO.File]::WriteAllText($rootXmlFull.Path, $xmlText, $encBom)
|
[System.IO.File]::WriteAllText($rootXmlFull.Path, $xmlText, $encBom)
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
#!/usr/bin/env python3
|
#!/usr/bin/env python3
|
||||||
# template-add v1.15 — Add template to 1C object
|
# template-add v1.16 — Add template to 1C object
|
||||||
# Source: https://github.com/Nikolay-Shirokov/cc-1c-skills
|
# Source: https://github.com/Nikolay-Shirokov/cc-1c-skills
|
||||||
|
|
||||||
import argparse
|
import argparse
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
# template-remove v1.4 — Remove template from 1C object
|
# template-remove v1.5 — Remove template from 1C object
|
||||||
# Source: https://github.com/Nikolay-Shirokov/cc-1c-skills
|
# Source: https://github.com/Nikolay-Shirokov/cc-1c-skills
|
||||||
param(
|
param(
|
||||||
[Parameter(Mandatory)]
|
[Parameter(Mandatory)]
|
||||||
@@ -81,8 +81,7 @@ $settings = New-Object System.Xml.XmlWriterSettings
|
|||||||
$settings.Encoding = $encBom
|
$settings.Encoding = $encBom
|
||||||
$settings.Indent = $false
|
$settings.Indent = $false
|
||||||
|
|
||||||
# Через MemoryStream, а не прямо в файл: нужен шаг пост-обработки строки — XmlWriter
|
# Через MemoryStream, а не прямо в файл: нужен шаг пост-обработки строки.
|
||||||
# отдаёт `encoding="utf-8"` и `<a />`, Конфигуратор пишет `encoding="UTF-8"` и `<a/>`.
|
|
||||||
$memStream = New-Object System.IO.MemoryStream
|
$memStream = New-Object System.IO.MemoryStream
|
||||||
$writer = [System.Xml.XmlWriter]::Create($memStream, $settings)
|
$writer = [System.Xml.XmlWriter]::Create($memStream, $settings)
|
||||||
$xmlDoc.Save($writer)
|
$xmlDoc.Save($writer)
|
||||||
@@ -92,7 +91,9 @@ $xmlText = [System.Text.Encoding]::UTF8.GetString($memStream.ToArray())
|
|||||||
$memStream.Close()
|
$memStream.Close()
|
||||||
if ($xmlText.Length -gt 0 -and $xmlText[0] -eq [char]0xFEFF) { $xmlText = $xmlText.Substring(1) }
|
if ($xmlText.Length -gt 0 -and $xmlText[0] -eq [char]0xFEFF) { $xmlText = $xmlText.Substring(1) }
|
||||||
$xmlText = $xmlText.Replace('encoding="utf-8"', 'encoding="UTF-8"')
|
$xmlText = $xmlText.Replace('encoding="utf-8"', 'encoding="UTF-8"')
|
||||||
# Гард на CDATA/комментарии: только там `>` не экранируется, и ` />` может быть содержимым.
|
# Пустой элемент: XmlWriter отдаёт `<a />`, Конфигуратор пишет `<a/>`. Гард на
|
||||||
|
# CDATA/комментарии: только там `>` не экранируется, и ` />` может быть
|
||||||
|
# содержимым, а не концом тега.
|
||||||
if ($xmlText -notmatch '<!\[CDATA\[|<!--') { $xmlText = [regex]::Replace($xmlText, '(?<=\S) />', '/>') }
|
if ($xmlText -notmatch '<!\[CDATA\[|<!--') { $xmlText = [regex]::Replace($xmlText, '(?<=\S) />', '/>') }
|
||||||
[System.IO.File]::WriteAllText($rootXmlFull.Path, $xmlText, $encBom)
|
[System.IO.File]::WriteAllText($rootXmlFull.Path, $xmlText, $encBom)
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
#!/usr/bin/env python3
|
#!/usr/bin/env python3
|
||||||
# template-remove v1.4 — Remove template from 1C object
|
# template-remove v1.5 — Remove template from 1C object
|
||||||
# Source: https://github.com/Nikolay-Shirokov/cc-1c-skills
|
# Source: https://github.com/Nikolay-Shirokov/cc-1c-skills
|
||||||
|
|
||||||
import argparse
|
import argparse
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
# xdto-compile v1.4 — Build a 1C XDTO package from an XML Schema (XSD)
|
# xdto-compile v1.5 — Build a 1C XDTO package from an XML Schema (XSD)
|
||||||
# Source: https://github.com/Nikolay-Shirokov/cc-1c-skills
|
# Source: https://github.com/Nikolay-Shirokov/cc-1c-skills
|
||||||
param(
|
param(
|
||||||
[Parameter(Mandatory=$true, ParameterSetName='File')]
|
[Parameter(Mandatory=$true, ParameterSetName='File')]
|
||||||
@@ -948,9 +948,7 @@ if (Test-Path $configXmlPath) {
|
|||||||
$cfgSettings = New-Object System.Xml.XmlWriterSettings
|
$cfgSettings = New-Object System.Xml.XmlWriterSettings
|
||||||
$cfgSettings.Encoding = New-Object System.Text.UTF8Encoding($true)
|
$cfgSettings.Encoding = New-Object System.Text.UTF8Encoding($true)
|
||||||
$cfgSettings.Indent = $false
|
$cfgSettings.Indent = $false
|
||||||
# Через MemoryStream, а не прямо в файл: нужен шаг пост-обработки строки —
|
# Через MemoryStream, а не прямо в файл: нужен шаг пост-обработки строки.
|
||||||
# XmlWriter отдаёт `encoding="utf-8"` и `<a />`, Конфигуратор пишет
|
|
||||||
# `encoding="UTF-8"` и `<a/>`.
|
|
||||||
$memStream = New-Object System.IO.MemoryStream
|
$memStream = New-Object System.IO.MemoryStream
|
||||||
$writer = [System.Xml.XmlWriter]::Create($memStream, $cfgSettings)
|
$writer = [System.Xml.XmlWriter]::Create($memStream, $cfgSettings)
|
||||||
$configDoc.Save($writer)
|
$configDoc.Save($writer)
|
||||||
@@ -960,7 +958,9 @@ if (Test-Path $configXmlPath) {
|
|||||||
$memStream.Close()
|
$memStream.Close()
|
||||||
if ($cfgText.Length -gt 0 -and $cfgText[0] -eq [char]0xFEFF) { $cfgText = $cfgText.Substring(1) }
|
if ($cfgText.Length -gt 0 -and $cfgText[0] -eq [char]0xFEFF) { $cfgText = $cfgText.Substring(1) }
|
||||||
$cfgText = $cfgText.Replace('encoding="utf-8"', 'encoding="UTF-8"')
|
$cfgText = $cfgText.Replace('encoding="utf-8"', 'encoding="UTF-8"')
|
||||||
# Гард на CDATA/комментарии: только там ` />` может быть содержимым.
|
# Пустой элемент: XmlWriter отдаёт `<a />`, Конфигуратор пишет `<a/>`. Гард на
|
||||||
|
# CDATA/комментарии: только там `>` не экранируется, и ` />` может быть
|
||||||
|
# содержимым, а не концом тега.
|
||||||
if ($cfgText -notmatch '<!\[CDATA\[|<!--') { $cfgText = [regex]::Replace($cfgText, '(?<=\S) />', '/>') }
|
if ($cfgText -notmatch '<!\[CDATA\[|<!--') { $cfgText = [regex]::Replace($cfgText, '(?<=\S) />', '/>') }
|
||||||
[System.IO.File]::WriteAllText($configXmlPath, $cfgText, (New-Object System.Text.UTF8Encoding($true)))
|
[System.IO.File]::WriteAllText($configXmlPath, $cfgText, (New-Object System.Text.UTF8Encoding($true)))
|
||||||
$regResult = "added"
|
$regResult = "added"
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
# xdto-compile v1.4 — Build a 1C XDTO package from an XML Schema (XSD) (Python port)
|
# xdto-compile v1.5 — Build a 1C XDTO package from an XML Schema (XSD) (Python port)
|
||||||
# Source: https://github.com/Nikolay-Shirokov/cc-1c-skills
|
# Source: https://github.com/Nikolay-Shirokov/cc-1c-skills
|
||||||
import argparse
|
import argparse
|
||||||
import json
|
import json
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
# xdto-edit v1.2 — Point edits of a 1C XDTO package
|
# xdto-edit v1.3 — Point edits of a 1C XDTO package
|
||||||
# Source: https://github.com/Nikolay-Shirokov/cc-1c-skills
|
# Source: https://github.com/Nikolay-Shirokov/cc-1c-skills
|
||||||
param(
|
param(
|
||||||
[Parameter(Mandatory=$true)]
|
[Parameter(Mandatory=$true)]
|
||||||
@@ -221,9 +221,7 @@ function Edit-Metadata([string]$field, [string]$newValue) {
|
|||||||
$settings = New-Object System.Xml.XmlWriterSettings
|
$settings = New-Object System.Xml.XmlWriterSettings
|
||||||
$settings.Encoding = $encBom
|
$settings.Encoding = $encBom
|
||||||
$settings.Indent = $false
|
$settings.Indent = $false
|
||||||
# Через MemoryStream, а не прямо в файл: нужен шаг пост-обработки строки —
|
# Через MemoryStream, а не прямо в файл: нужен шаг пост-обработки строки.
|
||||||
# XmlWriter отдаёт `encoding="utf-8"` и `<a />`, Конфигуратор пишет
|
|
||||||
# `encoding="UTF-8"` и `<a/>`.
|
|
||||||
$memStream = New-Object System.IO.MemoryStream
|
$memStream = New-Object System.IO.MemoryStream
|
||||||
$writer = [System.Xml.XmlWriter]::Create($memStream, $settings)
|
$writer = [System.Xml.XmlWriter]::Create($memStream, $settings)
|
||||||
$doc.Save($writer)
|
$doc.Save($writer)
|
||||||
@@ -233,7 +231,9 @@ function Edit-Metadata([string]$field, [string]$newValue) {
|
|||||||
$memStream.Close()
|
$memStream.Close()
|
||||||
if ($mdText.Length -gt 0 -and $mdText[0] -eq [char]0xFEFF) { $mdText = $mdText.Substring(1) }
|
if ($mdText.Length -gt 0 -and $mdText[0] -eq [char]0xFEFF) { $mdText = $mdText.Substring(1) }
|
||||||
$mdText = $mdText.Replace('encoding="utf-8"', 'encoding="UTF-8"')
|
$mdText = $mdText.Replace('encoding="utf-8"', 'encoding="UTF-8"')
|
||||||
# Гард на CDATA/комментарии: только там ` />` может быть содержимым.
|
# Пустой элемент: XmlWriter отдаёт `<a />`, Конфигуратор пишет `<a/>`. Гард на
|
||||||
|
# CDATA/комментарии: только там `>` не экранируется, и ` />` может быть
|
||||||
|
# содержимым, а не концом тега.
|
||||||
if ($mdText -notmatch '<!\[CDATA\[|<!--') { $mdText = [regex]::Replace($mdText, '(?<=\S) />', '/>') }
|
if ($mdText -notmatch '<!\[CDATA\[|<!--') { $mdText = [regex]::Replace($mdText, '(?<=\S) />', '/>') }
|
||||||
[System.IO.File]::WriteAllText($mdFile, $mdText, $encBom)
|
[System.IO.File]::WriteAllText($mdFile, $mdText, $encBom)
|
||||||
}
|
}
|
||||||
@@ -263,8 +263,7 @@ function Rename-Package([string]$newName) {
|
|||||||
if ($found) {
|
if ($found) {
|
||||||
$s = New-Object System.Xml.XmlWriterSettings
|
$s = New-Object System.Xml.XmlWriterSettings
|
||||||
$s.Encoding = $encBom; $s.Indent = $false
|
$s.Encoding = $encBom; $s.Indent = $false
|
||||||
# Через MemoryStream: нужен шаг пост-обработки строки — XmlWriter отдаёт
|
# Через MemoryStream, а не прямо в файл: нужен шаг пост-обработки строки.
|
||||||
# `encoding="utf-8"` и `<a />`, Конфигуратор пишет `encoding="UTF-8"` и `<a/>`.
|
|
||||||
$mem = New-Object System.IO.MemoryStream
|
$mem = New-Object System.IO.MemoryStream
|
||||||
$w = [System.Xml.XmlWriter]::Create($mem, $s)
|
$w = [System.Xml.XmlWriter]::Create($mem, $s)
|
||||||
$cfg.Save($w); $w.Flush(); $w.Close()
|
$cfg.Save($w); $w.Flush(); $w.Close()
|
||||||
@@ -272,7 +271,9 @@ function Rename-Package([string]$newName) {
|
|||||||
$mem.Close()
|
$mem.Close()
|
||||||
if ($cfgText.Length -gt 0 -and $cfgText[0] -eq [char]0xFEFF) { $cfgText = $cfgText.Substring(1) }
|
if ($cfgText.Length -gt 0 -and $cfgText[0] -eq [char]0xFEFF) { $cfgText = $cfgText.Substring(1) }
|
||||||
$cfgText = $cfgText.Replace('encoding="utf-8"', 'encoding="UTF-8"')
|
$cfgText = $cfgText.Replace('encoding="utf-8"', 'encoding="UTF-8"')
|
||||||
# Гард на CDATA/комментарии: только там ` />` может быть содержимым.
|
# Пустой элемент: XmlWriter отдаёт `<a />`, Конфигуратор пишет `<a/>`. Гард на
|
||||||
|
# CDATA/комментарии: только там `>` не экранируется, и ` />` может быть
|
||||||
|
# содержимым, а не концом тега.
|
||||||
if ($cfgText -notmatch '<!\[CDATA\[|<!--') { $cfgText = [regex]::Replace($cfgText, '(?<=\S) />', '/>') }
|
if ($cfgText -notmatch '<!\[CDATA\[|<!--') { $cfgText = [regex]::Replace($cfgText, '(?<=\S) />', '/>') }
|
||||||
[System.IO.File]::WriteAllText($configXml, $cfgText, $encBom)
|
[System.IO.File]::WriteAllText($configXml, $cfgText, $encBom)
|
||||||
Write-Host " Configuration.xml: <XDTOPackage> переименован в $newName"
|
Write-Host " Configuration.xml: <XDTOPackage> переименован в $newName"
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
# xdto-edit v1.2 — Point edits of a 1C XDTO package (Python port)
|
# xdto-edit v1.3 — Point edits of a 1C XDTO package (Python port)
|
||||||
# Source: https://github.com/Nikolay-Shirokov/cc-1c-skills
|
# Source: https://github.com/Nikolay-Shirokov/cc-1c-skills
|
||||||
import argparse
|
import argparse
|
||||||
import json
|
import json
|
||||||
|
|||||||
Reference in New Issue
Block a user