File: jira.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 (39 lines) | stat: -rw-r--r-- 1,327 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
import os
import sys

from docutils import nodes
from docutils.parsers.rst import Directive

def make_link_node(rawtext, app, type, slug, options):
    """Create a link to a JIRA ticket.

    :param rawtext: Text being replaced with link node.
    :param app: Sphinx application context
    :param type: Link type (issue, changeset, etc.)
    :param slug: ID of the ticket to link to
    :param options: Options dictionary passed to role func.
    """
    base = "https://opensciencegrid.atlassian.net/browse/HTCONDOR-"
    ref = base + slug
    # set_classes(options)
    node = nodes.reference(rawtext, "(HTCONDOR-" + slug + ")", refuri=ref, **options)
    return node

def ticket_role(name, rawtext, text, lineno, inliner, options={}, content=[]):
    try:
        ticket_id = int(text)
        if ticket_id > 10000:
            raise ValueError
    except ValueError:
        msg = inliner.reporter.error(
            'HTCondor ticket number must be a number less than or equal to 10000; '
            '"%s" is invalid.' % text, line=lineno)
        prb = inliner.problematic(rawtext, rawtext, msg)
        return [prb], [msg]
    app = inliner.document.settings.env.app
    node = make_link_node(rawtext, app, 'issue', str(ticket_id), options)
    return [node], []

def setup(app):
    app.add_role("jira", ticket_role)