def emitEntitlement(serverName, className = None, key = None, timeout = None,
                    retryOnTimeout = None):

    # XXX This probably should be emitted using a real XML DOM writer,
    # but this will probably do for now. And yes, all that mess is required
    # to be well-formed and valid XML.
    if className is None:
        classInfo = ""
    else:
        classInfo = "<class>%s</class>" % className

    s = """<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<!DOCTYPE entitlement [
    <!ELEMENT entitlement (server, class, key)>
    <!ELEMENT server (#PCDATA)>
    <!ELEMENT class (#PCDATA)>
    <!ELEMENT key (#PCDATA)>
    <!ELEMENT timeout EMPTY>
    <!ATTLIST
    timeout retry (True|False) "True"
    val CDATA #IMPLIED>
]>
<entitlement>
    <server>%s</server>
    %s
    <key>%s</key>
""" % (serverName, classInfo, key)

    if timeout is not None or retryOnTimeout is not None:
        s += "    <timeout "
        if timeout is not None:
            s += 'val="%d" ' % timeout
        if retryOnTimeout:
            s += 'retry="True" '
        elif retryOnTimeout is not None:
            s += 'retry="False" '

        s += '/>\n'

    s += "</entitlement>\n"

    return s
dataset/ETHPy150Open sassoftware/conary/conary/conarycfg.py/emitEntitlement/original