mirror of
https://github.com/Nikolay-Shirokov/cc-1c-skills.git
synced 2026-09-05 17:50:53 +03:00
feat(skd-info): auto-resolve object directory path to DCS template
When model passes report/dataprocessor path instead of template path, scan Templates/*.xml metadata for DataCompositionSchema type and auto-resolve. Single match → resolve with [i] hint, multiple → list. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 4.6
parent
afdfc97fb1
commit
e30b518935
@@ -1,5 +1,5 @@
|
||||
#!/usr/bin/env python3
|
||||
# skd-info v1.0 — Analyze 1C DCS structure
|
||||
# skd-info v1.1 — Analyze 1C DCS structure
|
||||
# Source: https://github.com/Nikolay-Shirokov/cc-1c-skills
|
||||
|
||||
import argparse
|
||||
@@ -281,12 +281,48 @@ def main():
|
||||
args = parser.parse_args()
|
||||
|
||||
# --- Resolve path ---
|
||||
template_path = args.TemplatePath
|
||||
original_path = args.TemplatePath
|
||||
template_path = original_path
|
||||
if not template_path.endswith(".xml"):
|
||||
candidate = os.path.join(template_path, "Ext", "Template.xml")
|
||||
if os.path.isfile(candidate):
|
||||
template_path = candidate
|
||||
|
||||
# If still not found, try resolving from object directory (Reports/X, DataProcessors/X)
|
||||
if not os.path.isfile(template_path) and not template_path.endswith(".xml"):
|
||||
templates_dir = os.path.join(original_path, "Templates")
|
||||
if os.path.isdir(templates_dir):
|
||||
dcs_templates = []
|
||||
for fname in os.listdir(templates_dir):
|
||||
if not fname.endswith(".xml"):
|
||||
continue
|
||||
meta_path = os.path.join(templates_dir, fname)
|
||||
if not os.path.isfile(meta_path):
|
||||
continue
|
||||
try:
|
||||
meta_tree = etree.parse(meta_path, etree.XMLParser(remove_blank_text=True))
|
||||
tt_nodes = meta_tree.xpath("//*[local-name()='TemplateType']")
|
||||
if tt_nodes and (tt_nodes[0].text or "").strip() == "DataCompositionSchema":
|
||||
tpl_name = os.path.splitext(fname)[0]
|
||||
tpl_path = os.path.join(templates_dir, tpl_name, "Ext", "Template.xml")
|
||||
if os.path.isfile(tpl_path):
|
||||
dcs_templates.append(tpl_path)
|
||||
except Exception:
|
||||
continue
|
||||
if len(dcs_templates) == 1:
|
||||
template_path = dcs_templates[0]
|
||||
resolved_display = os.path.relpath(os.path.abspath(template_path))
|
||||
print(f"[i] Resolved: {resolved_display}")
|
||||
elif len(dcs_templates) > 1:
|
||||
print(f"Multiple DCS templates found in: {original_path}")
|
||||
for i, p in enumerate(dcs_templates):
|
||||
print(f" {i+1}. {os.path.relpath(os.path.abspath(p))}")
|
||||
print("Specify the template path.")
|
||||
sys.exit(1)
|
||||
else:
|
||||
print(f"No DCS templates found in: {original_path}", file=sys.stderr)
|
||||
sys.exit(1)
|
||||
|
||||
if not os.path.isabs(template_path):
|
||||
template_path = os.path.join(os.getcwd(), template_path)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user