Example #1
0
def displayTroves(
        db,
        cfg,
        troveSpecs=[],
        pathList=[],
        whatProvidesList=[],
        # trove options
        info=False,
        digSigs=False,
        showBuildReqs=False,
        showDeps=False,
        # file options
        ls=False,
        lsl=False,
        ids=False,
        sha1s=False,
        tags=False,
        fileDeps=False,
        fileVersions=False,
        fileFlavors=False,
        capsules=False,
        # collection options
        showTroves=False,
        recurse=None,
        showAllTroves=False,
        weakRefs=False,
        showTroveFlags=False,
        pristine=True,
        alwaysDisplayHeaders=False,
        exactFlavors=False):
    """Displays troves after finding them on the local system

       @param db: Database instance to search for troves in
       @type db: local.database.Database
       @param cfg: conary config
       @type cfg: conarycfg.ConaryConfiguration
       @param troveSpecs: troves to search for
       @type troveSpecs: list of troveSpecs (n[=v][[f]])
       @param pathList: paths to match up to troves
       @type pathList: list of strings
       @param whatProvidesList: list of dependencies to find provides for
       @type whatProvidesList: list of strings
       @param info: If true, display general information about the trove
       @type info: bool
       @param digSigs: If true, display digital signatures for a trove.
       @type digSigs: bool
       @param showBuildReqs: If true, display the versions and flavors of the
       build requirements that were used to build the given troves
       @type showBuildReqs: bool
       @param showDeps: If true, display provides and requires information
       for the trove.
       @type showDeps: bool
       @param ls: If true, list files in the trove
       @type ls: bool
       @param lsl: If true, list files in the trove + ls -l information
       @type lsl: bool
       @param ids: If true, list pathIds for files in the troves
       @type ids: bool
       @param sha1s: If true, list sha1s for files in the troves
       @type sha1s: bool
       @param tags: If true, list tags for files in the troves
       @type tags: bool
       @param fileDeps: If true, print file-level dependencies
       @type fileDeps: bool
       @param fileVersions: If true, print fileversions
       @type fileVersions: bool
       @param showTroves: If true, display byDefault True child troves of this
       trove
       @type showTroves: bool
       @param recurse: display child troves of this trove, recursively
       @type recurse: bool
       @param showAllTroves: If true, display all byDefault False child troves
       of this trove
       @type showAllTroves: bool
       @param weakRefs: display both weak and strong references of this trove.
       @type weakRefs: bool
       @param showTroveFlags: display [<flags>] list with information about
       the given troves.
       @type showTroveFlags: bool
       @param pristine: If true, display the pristine version of this trove
       @type pristine: bool
       @param alwaysDisplayHeaders: If true, display headers even when listing
       files.
       @type alwaysDisplayHeaders: bool
       @rtype: None
    """

    whatProvidesList = [deps.parseDep(x) for x in whatProvidesList]

    troveTups, primary = getTrovesToDisplay(db,
                                            troveSpecs,
                                            pathList,
                                            whatProvidesList,
                                            exactFlavors=exactFlavors)

    dcfg = LocalDisplayConfig(db, affinityDb=db)
    # it might seem weird to use the same source we're querying as
    # a source for affinity info, but it makes sure that all troves with a
    # particular name are looked at for flavor info

    dcfg.setTroveDisplay(deps=showDeps,
                         info=info,
                         showBuildReqs=showBuildReqs,
                         digSigs=digSigs,
                         fullVersions=cfg.fullVersions,
                         showLabels=cfg.showLabels,
                         fullFlavors=cfg.fullFlavors,
                         showComponents=cfg.showComponents,
                         baseFlavors=cfg.flavor)

    dcfg.setFileDisplay(ls=ls,
                        lsl=lsl,
                        ids=ids,
                        sha1s=sha1s,
                        tags=tags,
                        fileDeps=fileDeps,
                        fileVersions=fileVersions,
                        fileFlavors=fileFlavors,
                        capsules=capsules)

    recurseOne = showTroves or showAllTroves or weakRefs or showTroveFlags

    if recurse is None and not recurseOne and primary:
        # if we didn't explicitly set recurse and we're not recursing one
        # level explicitly and we specified troves (so everything won't
        # show up at the top level anyway), guess at whether to recurse
        recurse = True in (ls, lsl, ids, sha1s, tags, showDeps, fileDeps,
                           fileVersions, fileFlavors)

    displayHeaders = alwaysDisplayHeaders or showTroveFlags

    dcfg.setChildDisplay(recurseAll=recurse,
                         recurseOne=recurseOne,
                         showNotByDefault=True,
                         showNotExists=showAllTroves,
                         showWeakRefs=weakRefs,
                         showTroveFlags=showTroveFlags,
                         displayHeaders=displayHeaders,
                         checkExists=True)
    dcfg.setShowPristine(pristine)

    if primary:
        dcfg.setPrimaryTroves(set(troveTups))

    formatter = LocalTroveFormatter(dcfg)

    display.displayTroves(dcfg, formatter, troveTups)
Example #2
0
def displayTroves(cfg, troveSpecs=[], pathList = [], whatProvidesList=[],
                  # query options
                  versionFilter=VERSION_FILTER_LATEST,
                  flavorFilter=FLAVOR_FILTER_BEST,
                  useAffinity = False,
                  # trove options
                  info = False, digSigs = False, showDeps = False,
                  showBuildReqs = False, showBuildLog = False, filesToShow = [],
                  # file options
                  ls = False, lsl = False, ids = False, sha1s = False,
                  tags = False, fileDeps = False, fileVersions = False,
                  fileFlavors = False, capsules = False,
                  # collection options
                  showTroves = False, recurse = None, showAllTroves = False,
                  weakRefs = False, showTroveFlags = False,
                  alwaysDisplayHeaders = False,
                  troveTypes=trovesource.TROVE_QUERY_PRESENT):
    """
       Displays information about troves found in repositories

       @param cfg: conary config
       @type cfg: conarycfg.ConaryConfiguration
       @param troveSpecs: troves to search for
       @type troveSpecs: list of troveSpecs (n[=v][[f]])
       @param versionFilter: add documentation here.  Check man page for
       general description
       @type versionFilter: bool
       @param flavorFilter: add documentation here.  Check man page for
       general description.
       @type flavorFilter: bool
       @param useAffinity: If False, disallow affinity database use.
       @type useAffinity: bool
       @param info: If true, display general information about the trove
       @type info: bool
       @param digSigs: If true, display digital signatures for a trove.
       @type digSigs: bool
       @param showBuildReqs: If true, display the versions and flavors of the
       build requirements that were used to build the given troves
       @type showBuildReqs: bool
       @param showDeps: If true, display provides and requires information
       for the trove.
       @type showDeps: bool
       @param ls: If true, list files in the trove
       @type ls: bool
       @param lsl: If true, list files in the trove + ls -l information
       @type lsl: bool
       @param ids: If true, list pathIds for files in the troves
       @type ids: bool
       @param sha1s: If true, list sha1s for files in the troves
       @type sha1s: bool
       @param tags: If true, list tags for files in the troves
       @type tags: bool
       @param fileDeps: If true, print file-level dependencies
       @type fileDeps: bool
       @param fileVersions: If true, print fileversions
       @type fileVersions: bool
       @param showTroves: If true, display byDefault True child troves of this
       trove
       @type showTroves: bool
       @param recurse: display child troves of this trove, recursively
       @type recurse: bool
       @param showAllTroves: If true, display all byDefault False child troves
       of this trove
       @type showAllTroves: bool
       @param weakRefs: display both weak and strong references of this trove.
       @type weakRefs: bool
       @param showTroveFlags: display [<flags>] list with information about
       the given troves.
       @type showTroveFlags: bool
       @param alwaysDisplayHeaders: If true, display headers even when listing
       files.
       @type alwaysDisplayHeaders: bool
       @rtype: None
    """

    if showBuildLog and len(troveSpecs)>1:
        raise ConaryError('Error: can not show build log for several packages. Please specify one')
    if filesToShow and len(troveSpecs)>1:
        raise ConaryError('Error: can not show files log for several packages. Please specify one')

    client = conaryclient.ConaryClient(cfg)
    repos = client.getRepos()

    if useAffinity:
        affinityDb = client.db
    else:
        affinityDb = None

    whatProvidesList = [ deps.parseDep(x) for x in whatProvidesList ]

    troveTups = getTrovesToDisplay(repos, troveSpecs, pathList,
                                   whatProvidesList,
                                   versionFilter, flavorFilter,
                                   cfg.installLabelPath, cfg.flavor,
                                   affinityDb,
                                   troveTypes=troveTypes)

    if (filesToShow or showBuildLog) and len(troveTups)>1:
        raise ConaryError('Error: %s is ambigious. Please specify one of: \n%s' % \
                    (troveSpecs[0],
                    "\n".join([x[0]+"="+str(x[1].trailingLabel()) for x in troveTups]) ))

    dcfg = display.DisplayConfig(repos, affinityDb)

    dcfg.setTroveDisplay(deps=showDeps, info=info,
                         showBuildReqs=showBuildReqs, showBuildLog=showBuildLog, filesToShow = filesToShow,
                         digSigs=digSigs, fullVersions=cfg.fullVersions,
                         showLabels=cfg.showLabels, fullFlavors=cfg.fullFlavors,
                         showComponents = cfg.showComponents,
                         baseFlavors = cfg.flavor)

    dcfg.setFileDisplay(ls=ls, lsl=lsl, ids=ids, sha1s=sha1s, tags=tags,
                        fileDeps=fileDeps, fileVersions=fileVersions,
                        fileFlavors=fileFlavors, capsules=capsules)

    recurseOne = showTroves or showAllTroves or weakRefs
    if recurse is None and not recurseOne and troveSpecs:
        # if we didn't explicitly set recurse and we're not recursing one
        # level explicitly and we specified troves (so everything won't
        # show up at the top level anyway), guess at whether to recurse
        recurse = True in (ls, lsl, ids, sha1s, tags, showDeps, fileDeps,
                           fileVersions, fileFlavors)
    displayHeaders = alwaysDisplayHeaders or showTroveFlags

    dcfg.setChildDisplay(recurseAll = recurse, recurseOne = recurseOne,
                         showNotByDefault = showAllTroves or showBuildLog,
                         showWeakRefs = weakRefs,
                         showTroveFlags = showTroveFlags,
                         displayHeaders = displayHeaders,
                         checkExists = False)

    if troveSpecs:
        dcfg.setPrimaryTroves(set(troveTups))


    formatter = display.TroveFormatter(dcfg)

    display.displayTroves(dcfg, formatter, troveTups)
def displayChangeSet(
    db,
    cs,
    troveSpecs,
    cfg,
    asDiff=False,
    diffBinaries=False,
    # selection options
    exactFlavors=False,
    # trove options
    info=False,
    digSigs=False,
    deps=False,
    showBuildReqs=False,
    all=False,
    # file options
    ls=False,
    lsl=False,
    ids=False,
    sha1s=False,
    tags=False,
    fileDeps=False,
    fileVersions=False,
    fileFlavors=False,
    capsules=False,
    # collection options
    showTroves=False,
    recurse=None,
    showAllTroves=False,
    weakRefs=False,
    showTroveFlags=False,
    alwaysDisplayHeaders=False,
    recurseRepos=False,
    # job options
    showChanges=False,
    asJob=False,
):

    asDiff = asDiff or diffBinaries

    if all:
        deps = recurse = showTroveFlags = showAllTroves = True
        if ls:
            fileDeps = lsl = tags = True

    if showChanges:
        lsl = True

    if recurseRepos:
        recurse = True

    client = conaryclient.ConaryClient(cfg)
    repos = client.getRepos()

    if asDiff:
        troveSource = trovesource.SourceStack(client.getDatabase(), repos)
        for x in cs.gitDiff(troveSource, diffBinaries=diffBinaries):
            sys.stdout.write(x)
    elif not asJob and not showChanges and cs.isAbsolute():
        changeSetSource = trovesource.ChangesetFilesTroveSource(None)
        changeSetSource.addChangeSet(cs)

        if not troveSpecs:
            troveTups = cs.getPrimaryTroveList()
            primary = True
            if not troveTups:
                log.warning("No primary troves in changeset, listing all troves")
                troveTups = [(x.getName(), x.getNewVersion(), x.getNewFlavor()) for x in cs.iterNewTroveList()]
        else:
            troveTups, primary = query.getTrovesToDisplay(changeSetSource, troveSpecs, exactFlavors=exactFlavors)
        if recurseRepos:
            querySource = trovesource.stack(changeSetSource, client.getRepos())
        else:
            querySource = changeSetSource

        dcfg = display.DisplayConfig(querySource, client.db)
        dcfg.setTroveDisplay(
            deps=deps,
            info=info,
            showBuildReqs=showBuildReqs,
            digSigs=digSigs,
            fullFlavors=cfg.fullFlavors,
            showLabels=cfg.showLabels,
            baseFlavors=cfg.flavor,
            fullVersions=cfg.fullVersions,
        )
        dcfg.setFileDisplay(
            ls=ls,
            lsl=lsl,
            ids=ids,
            sha1s=sha1s,
            tags=tags,
            fileDeps=fileDeps,
            fileVersions=fileVersions,
            fileFlavors=fileFlavors,
            capsules=capsules,
        )

        recurseOne = showTroves or showAllTroves or weakRefs
        if recurse is None and not recurseOne:
            # if we didn't explicitly set recurse and we're not recursing one
            # level explicitly
            recurse = True in (ls, lsl, ids, sha1s, tags, deps, fileDeps, fileVersions, fileFlavors)

        dcfg.setChildDisplay(
            recurseAll=recurse,
            recurseOne=recurseOne,
            showNotByDefault=showAllTroves,
            showWeakRefs=weakRefs,
            checkExists=True,
            showNotExists=True,
            showTroveFlags=showTroveFlags,
            displayHeaders=alwaysDisplayHeaders or showTroveFlags,
        )

        if primary:
            dcfg.setPrimaryTroves(set(troveTups))
        formatter = display.TroveFormatter(dcfg)
        display.displayTroves(dcfg, formatter, troveTups)
    else:
        changeSetSource = trovesource.ChangeSetJobSource(repos, trovesource.stack(db, repos))
        changeSetSource.addChangeSet(cs)

        jobs = getJobsToDisplay(changeSetSource, troveSpecs)

        dcfg = display.JobDisplayConfig(changeSetSource, client.db)

        dcfg.setJobDisplay(showChanges=showChanges, compressJobs=not cfg.showComponents)

        dcfg.setTroveDisplay(
            deps=deps,
            info=info,
            fullFlavors=cfg.fullFlavors,
            showLabels=cfg.showLabels,
            baseFlavors=cfg.flavor,
            fullVersions=cfg.fullVersions,
        )

        dcfg.setFileDisplay(
            ls=ls,
            lsl=lsl,
            ids=ids,
            sha1s=sha1s,
            tags=tags,
            fileDeps=fileDeps,
            fileVersions=fileVersions,
            fileFlavors=fileFlavors,
        )

        recurseOne = showTroves or showAllTroves or weakRefs
        if recurse is None and not recurseOne:
            # if we didn't explicitly set recurse and we're not recursing one
            # level explicitly and we specified troves (so everything won't
            # show up at the top level anyway), guess at whether to recurse
            recurse = True in (ls, lsl, ids, sha1s, tags, deps, fileDeps, fileVersions, fileFlavors)

        dcfg.setChildDisplay(
            recurseAll=recurse,
            recurseOne=recurseOne,
            showNotByDefault=showAllTroves,
            showWeakRefs=weakRefs,
            showTroveFlags=showTroveFlags,
        )

        formatter = display.JobFormatter(dcfg)
        display.displayJobs(dcfg, formatter, jobs)
Example #4
0
def displayChangeSet(
        db,
        cs,
        troveSpecs,
        cfg,
        asDiff=False,
        diffBinaries=False,
        # selection options
        exactFlavors=False,
        # trove options
        info=False,
        digSigs=False,
        deps=False,
        showBuildReqs=False,
        all=False,
        # file options
        ls=False,
        lsl=False,
        ids=False,
        sha1s=False,
        tags=False,
        fileDeps=False,
        fileVersions=False,
        fileFlavors=False,
        capsules=False,
        # collection options
        showTroves=False,
        recurse=None,
        showAllTroves=False,
        weakRefs=False,
        showTroveFlags=False,
        alwaysDisplayHeaders=False,
        recurseRepos=False,
        # job options
        showChanges=False,
        asJob=False):

    asDiff = asDiff or diffBinaries

    if all:
        deps = recurse = showTroveFlags = showAllTroves = True
        if ls:
            fileDeps = lsl = tags = True

    if showChanges:
        lsl = True

    if recurseRepos:
        recurse = True

    client = conaryclient.ConaryClient(cfg)
    repos = client.getRepos()

    if asDiff:
        troveSource = trovesource.SourceStack(client.getDatabase(), repos)
        for x in cs.gitDiff(troveSource, diffBinaries=diffBinaries):
            sys.stdout.write(x)
    elif not asJob and not showChanges and cs.isAbsolute():
        changeSetSource = trovesource.ChangesetFilesTroveSource(None)
        changeSetSource.addChangeSet(cs)

        if not troveSpecs:
            troveTups = cs.getPrimaryTroveList()
            primary = True
            if not troveTups:
                log.warning(
                    'No primary troves in changeset, listing all troves')
                troveTups = [(x.getName(), x.getNewVersion(), x.getNewFlavor())\
                                            for x in cs.iterNewTroveList()]
        else:
            troveTups, primary = query.getTrovesToDisplay(
                changeSetSource, troveSpecs, exactFlavors=exactFlavors)
        if recurseRepos:
            querySource = trovesource.stack(changeSetSource, client.getRepos())
        else:
            querySource = changeSetSource

        dcfg = display.DisplayConfig(querySource, client.db)
        dcfg.setTroveDisplay(
            deps=deps,
            info=info,
            showBuildReqs=showBuildReqs,
            digSigs=digSigs,
            fullFlavors=cfg.fullFlavors,
            showLabels=cfg.showLabels,
            baseFlavors=cfg.flavor,
            fullVersions=cfg.fullVersions,
        )
        dcfg.setFileDisplay(ls=ls,
                            lsl=lsl,
                            ids=ids,
                            sha1s=sha1s,
                            tags=tags,
                            fileDeps=fileDeps,
                            fileVersions=fileVersions,
                            fileFlavors=fileFlavors,
                            capsules=capsules)

        recurseOne = showTroves or showAllTroves or weakRefs
        if recurse is None and not recurseOne:
            # if we didn't explicitly set recurse and we're not recursing one
            # level explicitly
            recurse = True in (ls, lsl, ids, sha1s, tags, deps, fileDeps,
                               fileVersions, fileFlavors)

        dcfg.setChildDisplay(recurseAll=recurse,
                             recurseOne=recurseOne,
                             showNotByDefault=showAllTroves,
                             showWeakRefs=weakRefs,
                             checkExists=True,
                             showNotExists=True,
                             showTroveFlags=showTroveFlags,
                             displayHeaders=alwaysDisplayHeaders
                             or showTroveFlags)

        if primary:
            dcfg.setPrimaryTroves(set(troveTups))
        formatter = display.TroveFormatter(dcfg)
        display.displayTroves(dcfg, formatter, troveTups)
    else:
        changeSetSource = trovesource.ChangeSetJobSource(
            repos, trovesource.stack(db, repos))
        changeSetSource.addChangeSet(cs)

        jobs = getJobsToDisplay(changeSetSource, troveSpecs)

        dcfg = display.JobDisplayConfig(changeSetSource, client.db)

        dcfg.setJobDisplay(showChanges=showChanges,
                           compressJobs=not cfg.showComponents)

        dcfg.setTroveDisplay(deps=deps,
                             info=info,
                             fullFlavors=cfg.fullFlavors,
                             showLabels=cfg.showLabels,
                             baseFlavors=cfg.flavor,
                             fullVersions=cfg.fullVersions)

        dcfg.setFileDisplay(ls=ls,
                            lsl=lsl,
                            ids=ids,
                            sha1s=sha1s,
                            tags=tags,
                            fileDeps=fileDeps,
                            fileVersions=fileVersions,
                            fileFlavors=fileFlavors)

        recurseOne = showTroves or showAllTroves or weakRefs
        if recurse is None and not recurseOne:
            # if we didn't explicitly set recurse and we're not recursing one
            # level explicitly and we specified troves (so everything won't
            # show up at the top level anyway), guess at whether to recurse
            recurse = True in (ls, lsl, ids, sha1s, tags, deps, fileDeps,
                               fileVersions, fileFlavors)

        dcfg.setChildDisplay(recurseAll=recurse,
                             recurseOne=recurseOne,
                             showNotByDefault=showAllTroves,
                             showWeakRefs=weakRefs,
                             showTroveFlags=showTroveFlags)

        formatter = display.JobFormatter(dcfg)
        display.displayJobs(dcfg, formatter, jobs)
Example #5
0
def displayTroves(
        cfg,
        troveSpecs=[],
        pathList=[],
        whatProvidesList=[],
        # query options
        versionFilter=VERSION_FILTER_LATEST,
        flavorFilter=FLAVOR_FILTER_BEST,
        useAffinity=False,
        # trove options
        info=False,
        digSigs=False,
        showDeps=False,
        showBuildReqs=False,
        showBuildLog=False,
        filesToShow=[],
        # file options
        ls=False,
        lsl=False,
        ids=False,
        sha1s=False,
        tags=False,
        fileDeps=False,
        fileVersions=False,
        fileFlavors=False,
        capsules=False,
        # collection options
        showTroves=False,
        recurse=None,
        showAllTroves=False,
        weakRefs=False,
        showTroveFlags=False,
        alwaysDisplayHeaders=False,
        troveTypes=trovesource.TROVE_QUERY_PRESENT):
    """
       Displays information about troves found in repositories

       @param cfg: conary config
       @type cfg: conarycfg.ConaryConfiguration
       @param troveSpecs: troves to search for
       @type troveSpecs: list of troveSpecs (n[=v][[f]])
       @param versionFilter: add documentation here.  Check man page for
       general description
       @type versionFilter: bool
       @param flavorFilter: add documentation here.  Check man page for
       general description.
       @type flavorFilter: bool
       @param useAffinity: If False, disallow affinity database use.
       @type useAffinity: bool
       @param info: If true, display general information about the trove
       @type info: bool
       @param digSigs: If true, display digital signatures for a trove.
       @type digSigs: bool
       @param showBuildReqs: If true, display the versions and flavors of the
       build requirements that were used to build the given troves
       @type showBuildReqs: bool
       @param showDeps: If true, display provides and requires information
       for the trove.
       @type showDeps: bool
       @param ls: If true, list files in the trove
       @type ls: bool
       @param lsl: If true, list files in the trove + ls -l information
       @type lsl: bool
       @param ids: If true, list pathIds for files in the troves
       @type ids: bool
       @param sha1s: If true, list sha1s for files in the troves
       @type sha1s: bool
       @param tags: If true, list tags for files in the troves
       @type tags: bool
       @param fileDeps: If true, print file-level dependencies
       @type fileDeps: bool
       @param fileVersions: If true, print fileversions
       @type fileVersions: bool
       @param showTroves: If true, display byDefault True child troves of this
       trove
       @type showTroves: bool
       @param recurse: display child troves of this trove, recursively
       @type recurse: bool
       @param showAllTroves: If true, display all byDefault False child troves
       of this trove
       @type showAllTroves: bool
       @param weakRefs: display both weak and strong references of this trove.
       @type weakRefs: bool
       @param showTroveFlags: display [<flags>] list with information about
       the given troves.
       @type showTroveFlags: bool
       @param alwaysDisplayHeaders: If true, display headers even when listing
       files.
       @type alwaysDisplayHeaders: bool
       @rtype: None
    """

    if showBuildLog and len(troveSpecs) > 1:
        raise ConaryError(
            'Error: can not show build log for several packages. Please specify one'
        )
    if filesToShow and len(troveSpecs) > 1:
        raise ConaryError(
            'Error: can not show files log for several packages. Please specify one'
        )

    client = conaryclient.ConaryClient(cfg)
    repos = client.getRepos()

    if useAffinity:
        affinityDb = client.db
    else:
        affinityDb = None

    whatProvidesList = [deps.parseDep(x) for x in whatProvidesList]

    troveTups = getTrovesToDisplay(repos,
                                   troveSpecs,
                                   pathList,
                                   whatProvidesList,
                                   versionFilter,
                                   flavorFilter,
                                   cfg.installLabelPath,
                                   cfg.flavor,
                                   affinityDb,
                                   troveTypes=troveTypes)

    if (filesToShow or showBuildLog) and len(troveTups) > 1:
        raise ConaryError('Error: %s is ambigious. Please specify one of: \n%s' % \
                    (troveSpecs[0],
                    "\n".join([x[0]+"="+str(x[1].trailingLabel()) for x in troveTups]) ))

    dcfg = display.DisplayConfig(repos, affinityDb)

    dcfg.setTroveDisplay(deps=showDeps,
                         info=info,
                         showBuildReqs=showBuildReqs,
                         showBuildLog=showBuildLog,
                         filesToShow=filesToShow,
                         digSigs=digSigs,
                         fullVersions=cfg.fullVersions,
                         showLabels=cfg.showLabels,
                         fullFlavors=cfg.fullFlavors,
                         showComponents=cfg.showComponents,
                         baseFlavors=cfg.flavor)

    dcfg.setFileDisplay(ls=ls,
                        lsl=lsl,
                        ids=ids,
                        sha1s=sha1s,
                        tags=tags,
                        fileDeps=fileDeps,
                        fileVersions=fileVersions,
                        fileFlavors=fileFlavors,
                        capsules=capsules)

    recurseOne = showTroves or showAllTroves or weakRefs
    if recurse is None and not recurseOne and troveSpecs:
        # if we didn't explicitly set recurse and we're not recursing one
        # level explicitly and we specified troves (so everything won't
        # show up at the top level anyway), guess at whether to recurse
        recurse = True in (ls, lsl, ids, sha1s, tags, showDeps, fileDeps,
                           fileVersions, fileFlavors)
    displayHeaders = alwaysDisplayHeaders or showTroveFlags

    dcfg.setChildDisplay(recurseAll=recurse,
                         recurseOne=recurseOne,
                         showNotByDefault=showAllTroves or showBuildLog,
                         showWeakRefs=weakRefs,
                         showTroveFlags=showTroveFlags,
                         displayHeaders=displayHeaders,
                         checkExists=False)

    if troveSpecs:
        dcfg.setPrimaryTroves(set(troveTups))

    formatter = display.TroveFormatter(dcfg)

    display.displayTroves(dcfg, formatter, troveTups)
Example #6
0
def displayTroves(db, cfg, troveSpecs = [], pathList = [],
                  whatProvidesList = [],
                  # trove options
                  info = False, digSigs = False, showBuildReqs = False,
                  showDeps = False,
                  # file options
                  ls = False, lsl = False, ids = False, sha1s = False,
                  tags = False, fileDeps = False, fileVersions = False,
                  fileFlavors = False, capsules = False,
                  # collection options
                  showTroves = False, recurse = None, showAllTroves = False,
                  weakRefs = False, showTroveFlags = False,
                  pristine = True, alwaysDisplayHeaders = False,
                  exactFlavors = False):
    """Displays troves after finding them on the local system

       @param db: Database instance to search for troves in
       @type db: local.database.Database
       @param cfg: conary config
       @type cfg: conarycfg.ConaryConfiguration
       @param troveSpecs: troves to search for
       @type troveSpecs: list of troveSpecs (n[=v][[f]])
       @param pathList: paths to match up to troves
       @type pathList: list of strings
       @param whatProvidesList: list of dependencies to find provides for
       @type whatProvidesList: list of strings
       @param info: If true, display general information about the trove
       @type info: bool
       @param digSigs: If true, display digital signatures for a trove.
       @type digSigs: bool
       @param showBuildReqs: If true, display the versions and flavors of the
       build requirements that were used to build the given troves
       @type showBuildReqs: bool
       @param showDeps: If true, display provides and requires information
       for the trove.
       @type showDeps: bool
       @param ls: If true, list files in the trove
       @type ls: bool
       @param lsl: If true, list files in the trove + ls -l information
       @type lsl: bool
       @param ids: If true, list pathIds for files in the troves
       @type ids: bool
       @param sha1s: If true, list sha1s for files in the troves
       @type sha1s: bool
       @param tags: If true, list tags for files in the troves
       @type tags: bool
       @param fileDeps: If true, print file-level dependencies
       @type fileDeps: bool
       @param fileVersions: If true, print fileversions
       @type fileVersions: bool
       @param showTroves: If true, display byDefault True child troves of this
       trove
       @type showTroves: bool
       @param recurse: display child troves of this trove, recursively
       @type recurse: bool
       @param showAllTroves: If true, display all byDefault False child troves
       of this trove
       @type showAllTroves: bool
       @param weakRefs: display both weak and strong references of this trove.
       @type weakRefs: bool
       @param showTroveFlags: display [<flags>] list with information about
       the given troves.
       @type showTroveFlags: bool
       @param pristine: If true, display the pristine version of this trove
       @type pristine: bool
       @param alwaysDisplayHeaders: If true, display headers even when listing
       files.
       @type alwaysDisplayHeaders: bool
       @rtype: None
    """

    whatProvidesList = [ deps.parseDep(x) for x in whatProvidesList ]

    troveTups, primary = getTrovesToDisplay(db, troveSpecs, pathList,
                                            whatProvidesList,
                                            exactFlavors=exactFlavors)

    dcfg = LocalDisplayConfig(db, affinityDb=db)
    # it might seem weird to use the same source we're querying as
    # a source for affinity info, but it makes sure that all troves with a
    # particular name are looked at for flavor info

    dcfg.setTroveDisplay(deps=showDeps, info=info,
                         showBuildReqs=showBuildReqs,
                         digSigs=digSigs, fullVersions=cfg.fullVersions,
                         showLabels=cfg.showLabels, fullFlavors=cfg.fullFlavors,
                         showComponents = cfg.showComponents,
                         baseFlavors = cfg.flavor)

    dcfg.setFileDisplay(ls=ls, lsl=lsl, ids=ids, sha1s=sha1s, tags=tags,
                        fileDeps=fileDeps, fileVersions=fileVersions,
                        fileFlavors=fileFlavors, capsules=capsules)


    recurseOne = showTroves or showAllTroves or weakRefs or showTroveFlags

    if recurse is None and not recurseOne and primary:
        # if we didn't explicitly set recurse and we're not recursing one
        # level explicitly and we specified troves (so everything won't
        # show up at the top level anyway), guess at whether to recurse
        recurse = True in (ls, lsl, ids, sha1s, tags, showDeps, fileDeps,
                           fileVersions, fileFlavors)

    displayHeaders = alwaysDisplayHeaders or showTroveFlags

    dcfg.setChildDisplay(recurseAll = recurse, recurseOne = recurseOne,
                         showNotByDefault = True,
                         showNotExists = showAllTroves,
                         showWeakRefs = weakRefs,
                         showTroveFlags = showTroveFlags,
                         displayHeaders = displayHeaders,
                         checkExists = True)
    dcfg.setShowPristine(pristine)

    if primary:
        dcfg.setPrimaryTroves(set(troveTups))

    formatter = LocalTroveFormatter(dcfg)

    display.displayTroves(dcfg, formatter, troveTups)