File: subcom.py

package info (click to toggle)
condor 23.9.6%2Bdfsg-2.1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 60,012 kB
  • sloc: cpp: 528,272; perl: 87,066; python: 42,650; ansic: 29,558; sh: 11,271; javascript: 3,479; ada: 2,319; java: 619; makefile: 615; xml: 613; awk: 268; yacc: 78; fortran: 54; csh: 24
file content (43 lines) | stat: -rw-r--r-- 1,610 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
import os
import sys

from docutils import nodes
from docutils.parsers.rst import Directive
from sphinx import addnodes
from sphinx.errors import SphinxError
from sphinx.util.nodes import split_explicit_title, process_index_entry, set_role_source_info
from htc_helpers import *

SUBMIT_CMDS = []

def find_submit_cmds(dir: str):
    subcoms = []
    submit_man = os.path.join(dir, "man-pages", "condor_submit.rst")
    with open(submit_man, "r", encoding="utf-8") as f:
        for line in f:
            line = line.strip()
            for subcom in get_all_defined_role("subcom-def", line):
                if subcom not in subcoms:
                    subcoms.append(subcom)
    subcoms.sort()
    return subcoms

def dump(obj):
    for attr in dir(obj):
        print("obj.%s = %r" % (attr, getattr(obj, attr)))

def subcom_role(name, rawtext, text, lineno, inliner, options={}, content=[]):
    root_dir = root_dir = get_rel_path_to_root_dir(inliner)[:-1]
    subcom_name, subcom_index = custom_ext_parser(text)
    if subcom_name not in SUBMIT_CMDS:
        docname = inliner.document.settings.env.docname
        warn(f"{docname} @ {lineno} | Submit command '{subcom_name}' not found in defined list. Either a typo or not defined.")
    ref_link = f"href=\"{root_dir}/man-pages/condor_submit.html#" + str(subcom_name) + "\""
    return make_ref_and_index_nodes(name, subcom_name, subcom_index,
                                    ref_link, rawtext, inliner, lineno, options)

def setup(app):
    global SUBMIT_CMDS
    SUBMIT_CMDS = find_submit_cmds(app.srcdir)
    app.add_role("subcom", subcom_role)