コード例 #1
0
def run(addon):
    """Show a dialog box that contains a lot of information (all there
    is to know) about the addon.

    @param An addons.Addon object.
    """
    ident = addon.getId()

    dialog, area = sb.util.dialog.createButtonDialog('addon-inspector-dialog',
                                                     ['ok'],
                                                     'ok',
                                                     size=(570, 450))

    msg = ""

    msg += '<h3>' + language.translate(ident) + '</h3>'
    if language.isDefined(ident + '-readme'):
        msg += "<p>" + language.translate(ident + '-readme')

    def makeField(header, content):
        return '<tr><td width="20%" bgcolor="#E8E8E8" align="right"><b>' + header + \
               '</b></td><td width="80%">' + content + '</td></tr>'

    beginTable = '<p><table width="100%" border=0 cellpadding=6 cellspacing=0>'
    endTable = '</table>'

    #
    # General Information
    #
    msg += beginTable
    msg += makeField('Summary:', language.translate(ident + '-summary', '-'))
    msg += makeField('Version:', language.translate(ident + '-version', '-'))
    msg += makeField(
        'Last Modified:',
        time.strftime("%a, %d %b %Y %H:%M:%S",
                      time.localtime(addon.getLastModified())))
    msg += makeField('Author(s):', language.translate(ident + '-author', '-'))
    msg += makeField('Contact:', language.translate(ident + '-contact', '-'))
    msg += makeField('Copyright:', language.translate(ident + '-copyright',
                                                      '-'))
    msg += makeField('License:', language.translate(ident + '-license', '-'))
    msg += makeField('Category:', addon.getCategory().getPath())
    msg += makeField('Format:', language.translate(addon.getType()))
    msg += makeField('Identifier:', addon.getId())
    msg += endTable

    #
    # Raw Dependencies
    #
    msg += '<h3>Dependencies</h3>' + beginTable
    allDeps = []

    # Excluded categories.
    dep = []
    for category in addon.getExcludedCategories():
        dep.append(category.getPath())
    allDeps.append(('Excluded Categories:', dep))

    # Keywords.
    for type, label in [(sb.addon.EXCLUDES, 'Excludes:'),
                        (sb.addon.REQUIRES, 'Requires:'),
                        (sb.addon.PROVIDES, 'Provides:'),
                        (sb.addon.OFFERS, 'Offers:')]:
        # Make a copy of the list so we can modify it.
        dep = []
        for kw in addon.getKeywords(type):
            dep.append(kw)
        allDeps.append((label, dep))

    # Create a table out of each dependency type.
    for heading, listing in allDeps:
        msg += makeField(heading, string.join(listing, '<br>'))

    msg += endTable

    #
    # Content Analysis
    #
    msg += '<h3>Contents</h3>' + beginTable
    msg += makeField('Content Path:', addon.getContentPath())
    msg += endTable

    #msg += "<p>format-specific data"
    #msg += "<br>content analysis, size"
    #msg += "<br>list of files, if a bundle"

    #msg += '<h3>Identifiers</h3>'
    #msg += "<br>all internal identifiers used by the addon"

    #msg += '<h3>Metadata</h3>'
    #msg += "<br>metadata analysis, source"

    text = area.createFormattedText()
    text.setMinSize(500, 200)
    text.setText(msg)
    dialog.run()
コード例 #2
0
ファイル: help.py プロジェクト: cmbruns/Doomsday-Engine
def showAddonInfo(addon):
    """Display a summary of an addon in the help panel.

    @param addon An addons.Addon object.
    """
    global currentAddon, currentSetting

    # No longer showing a setting.
    currentSetting = None

    # The current addon that is displayed in the help.
    currentAddon = addon

    oneLiners = (detailedAddonMode == False)
    ident = addon.getId()
    
    # Begin the page with a table that contains the basic info.
    msg = '<html>'

    def optLink(id, isLink):
        if isLink:
            return '<a href="%s">%s</a>' % (id, language.translate(id))
        else:
            return language.translate(id)

    # The detail selection links.
    msg += '<center><font size="-1">'
    msg += optLink('help-addon-mode-brief', detailedAddonMode) + ' | '
    msg += optLink('help-addon-mode-detailed', not detailedAddonMode)
    msg += '</font></center><br>'

    # Summary table.
    msg += tableBegin

    msg += '<tr><td colspan="2"><b><font size="+1">' + \
           language.translate(ident) + \
           '</font></b>'

    def makeField(msg, fieldId, oneLiner=True):
        title = language.translate('help-addon-' + fieldId)
        contentId = ident + '-' + fieldId

        text = ''
        if language.isDefined(contentId):
            # This information has been defined.
            text = language.translate(contentId)
        elif detailedAddonMode:
            # Force all fields to show.
            text = '-'

        if text:
            if oneLiner:
                msg += tableRow + entryHeader(title) + entryContent(text)
            else:
                msg += tableRow + entryHeader(title, 2) + \
                       tableRow + entryContent(text, 2)

        return msg

    msg = makeField(msg, 'version')

    if detailedAddonMode:
        # Get the last modification time from the addon.
        modTime = time.localtime(addon.getLastModified())
        msg += tableRow + entryHeader(language.translate('help-addon-date')) \
               + entryContent(time.strftime("%d %b %Y", modTime))
    
    msg = makeField(msg, 'summary', oneLiners)

    if detailedAddonMode:
        msg = makeField(msg, 'contact', oneLiners)
        msg = makeField(msg, 'author', oneLiners)
        msg = makeField(msg, 'copyright', oneLiners)
        msg = makeField(msg, 'license', oneLiners)

    # Dependencies.
    deps = []
    
    exCats = addon.getExcludedCategories()
    if len(exCats):
        deps.append((language.translate('help-addon-excluded-categories'),
                     map(lambda c: language.translate(c.getLongId()), exCats)))

    for type, label in [(sb.addon.EXCLUDES, 'help-addon-excludes'),
                        (sb.addon.REQUIRES, 'help-addon-requires'),
                        (sb.addon.PROVIDES, 'help-addon-provides'),
                        (sb.addon.OFFERS, 'help-addon-offers')]:
        # Make a copy of the list so we can modify it.
        keywords = [kw for kw in addon.getKeywords(type)]

        # In the Brief mode, hide the identifier of the addon in the
        # Provides field.
        if not detailedAddonMode and type == sb.addon.PROVIDES:
            keywords.remove(addon.getId())            
        
        if len(keywords) > 0:
            # Include this in the info.
            def xlate(key):
                if ao.exists(key):
                    return '<a href="%s">%s</a>' % \
                           (key, language.translate(key))
                else:
                    return key
            deps.append((language.translate(label), map(xlate, keywords)))

    if len(deps):
        # Print a dependencies table.
        msg += tableRow + entryHeader(
            language.translate('help-addon-dependencies'), 2)

        content = ""

        for dep in deps:
            if dep is not deps[0]:
                content += '<br>'
            content += "<b>" + dep[0] + ":</b><ul><li>"
            content += string.join(dep[1], '<li>')
            content += '</ul>'

        msg += tableRow + entryContent(content, 2)            

    msg += tableEnd

    # Inside a box?
    if addon.getBox():
        box = addon.getBox()
        msg += language.expand(
            language.translate('help-addon-part-of-box'),
            box.getId(), language.translate(box.getId())) + '<p>'

    # The overview.
    if language.isDefined(ident + '-readme'):
        msg += language.translate(ident + '-readme')

    msg += '</html>'

    helpText.setText(msg)
    showLogo(False)
コード例 #3
0
ファイル: help.py プロジェクト: RomanHargrave/Doomsday-Engine
def showAddonInfo(addon):
    """Display a summary of an addon in the help panel.

    @param addon An addons.Addon object.
    """
    global currentAddon, currentSetting

    # No longer showing a setting.
    currentSetting = None

    # The current addon that is displayed in the help.
    currentAddon = addon

    oneLiners = (detailedAddonMode == False)
    ident = addon.getId()

    # Begin the page with a table that contains the basic info.
    msg = '<html>'

    def optLink(id, isLink):
        if isLink:
            return '<a href="%s">%s</a>' % (id, language.translate(id))
        else:
            return language.translate(id)

    # The detail selection links.
    msg += '<center><font size="-1">'
    msg += optLink('help-addon-mode-brief', detailedAddonMode) + ' | '
    msg += optLink('help-addon-mode-detailed', not detailedAddonMode)
    msg += '</font></center><br>'

    # Summary table.
    msg += tableBegin

    msg += '<tr><td colspan="2"><b><font size="+1">' + \
           language.translate(ident) + \
           '</font></b>'

    def makeField(msg, fieldId, oneLiner=True):
        title = language.translate('help-addon-' + fieldId)
        contentId = ident + '-' + fieldId

        text = ''
        if language.isDefined(contentId):
            # This information has been defined.
            text = language.translate(contentId)
        elif detailedAddonMode:
            # Force all fields to show.
            text = '-'

        if text:
            if oneLiner:
                msg += tableRow + entryHeader(title) + entryContent(text)
            else:
                msg += tableRow + entryHeader(title, 2) + \
                       tableRow + entryContent(text, 2)

        return msg

    msg = makeField(msg, 'version')

    if detailedAddonMode:
        # Get the last modification time from the addon.
        modTime = time.localtime(addon.getLastModified())
        msg += tableRow + entryHeader(language.translate('help-addon-date')) \
               + entryContent(time.strftime("%d %b %Y", modTime))

    msg = makeField(msg, 'summary', oneLiners)

    if detailedAddonMode:
        msg = makeField(msg, 'contact', oneLiners)
        msg = makeField(msg, 'author', oneLiners)
        msg = makeField(msg, 'copyright', oneLiners)
        msg = makeField(msg, 'license', oneLiners)

    # Dependencies.
    deps = []

    exCats = addon.getExcludedCategories()
    if len(exCats):
        deps.append((language.translate('help-addon-excluded-categories'),
                     map(lambda c: language.translate(c.getLongId()), exCats)))

    for type, label in [(sb.addon.EXCLUDES, 'help-addon-excludes'),
                        (sb.addon.REQUIRES, 'help-addon-requires'),
                        (sb.addon.PROVIDES, 'help-addon-provides'),
                        (sb.addon.OFFERS, 'help-addon-offers')]:
        # Make a copy of the list so we can modify it.
        keywords = [kw for kw in addon.getKeywords(type)]

        # In the Brief mode, hide the identifier of the addon in the
        # Provides field.
        if not detailedAddonMode and type == sb.addon.PROVIDES:
            keywords.remove(addon.getId())

        if len(keywords) > 0:
            # Include this in the info.
            def xlate(key):
                if ao.exists(key):
                    return '<a href="%s">%s</a>' % \
                           (key, language.translate(key))
                else:
                    return key

            deps.append((language.translate(label), map(xlate, keywords)))

    if len(deps):
        # Print a dependencies table.
        msg += tableRow + entryHeader(
            language.translate('help-addon-dependencies'), 2)

        content = ""

        for dep in deps:
            if dep is not deps[0]:
                content += '<br>'
            content += "<b>" + dep[0] + ":</b><ul><li>"
            content += string.join(dep[1], '<li>')
            content += '</ul>'

        msg += tableRow + entryContent(content, 2)

    msg += tableEnd

    # Inside a box?
    if addon.getBox():
        box = addon.getBox()
        msg += language.expand(language.translate('help-addon-part-of-box'),
                               box.getId(), language.translate(
                                   box.getId())) + '<p>'

    # The overview.
    if language.isDefined(ident + '-readme'):
        msg += language.translate(ident + '-readme')

    msg += '</html>'

    helpText.setText(msg)
    showLogo(False)
コード例 #4
0
ファイル: inspector.py プロジェクト: cmbruns/Doomsday-Engine
def run(addon):
    """Show a dialog box that contains a lot of information (all there
    is to know) about the addon.

    @param An addons.Addon object.
    """
    ident = addon.getId()
    
    dialog, area = sb.util.dialog.createButtonDialog(
        'addon-inspector-dialog',
         ['ok'], 'ok', size=(570, 450))

    msg = ""

    msg += '<h3>' + language.translate(ident) + '</h3>'
    if language.isDefined(ident + '-readme'):
        msg += "<p>" + language.translate(ident + '-readme')

    def makeField(header, content):
        return '<tr><td width="20%" bgcolor="#E8E8E8" align="right"><b>' + header + \
               '</b></td><td width="80%">' + content + '</td></tr>'

    beginTable = '<p><table width="100%" border=0 cellpadding=6 cellspacing=0>'
    endTable = '</table>'

    #
    # General Information
    #
    msg += beginTable
    msg += makeField('Summary:', language.translate(ident + '-summary', '-'))
    msg += makeField('Version:', language.translate(ident + '-version', '-'))
    msg += makeField('Last Modified:',
                     time.strftime("%a, %d %b %Y %H:%M:%S",
                                   time.localtime(addon.getLastModified())))
    msg += makeField('Author(s):', language.translate(ident + '-author', '-'))
    msg += makeField('Contact:', language.translate(ident + '-contact', '-'))
    msg += makeField('Copyright:',
                     language.translate(ident + '-copyright', '-'))
    msg += makeField('License:', language.translate(ident + '-license', '-'))
    msg += makeField('Category:', addon.getCategory().getPath())
    msg += makeField('Format:', language.translate(addon.getType()))
    msg += makeField('Identifier:', addon.getId())
    msg += endTable

    #
    # Raw Dependencies
    #
    msg += '<h3>Dependencies</h3>' + beginTable
    allDeps = []
    
    # Excluded categories.
    dep = []
    for category in addon.getExcludedCategories():
        dep.append(category.getPath())
    allDeps.append(('Excluded Categories:', dep))

    # Keywords.
    for type, label in [(sb.addon.EXCLUDES, 'Excludes:'),
                        (sb.addon.REQUIRES, 'Requires:'),
                        (sb.addon.PROVIDES, 'Provides:'),
                        (sb.addon.OFFERS, 'Offers:')]:
        # Make a copy of the list so we can modify it.
        dep = []
        for kw in addon.getKeywords(type):
            dep.append(kw)
        allDeps.append((label, dep))

    # Create a table out of each dependency type.
    for heading, listing in allDeps:
        msg += makeField(heading, string.join(listing, '<br>'))

    msg += endTable

    #
    # Content Analysis
    # 
    msg += '<h3>Contents</h3>' + beginTable
    msg += makeField('Content Path:', addon.getContentPath())
    msg += endTable
    
    #msg += "<p>format-specific data"
    #msg += "<br>content analysis, size"
    #msg += "<br>list of files, if a bundle"

    #msg += '<h3>Identifiers</h3>'
    #msg += "<br>all internal identifiers used by the addon"

    #msg += '<h3>Metadata</h3>'
    #msg += "<br>metadata analysis, source"

    text = area.createFormattedText()
    text.setMinSize(500, 200)
    text.setText(msg)
    dialog.run()