Example #1
0
    def run(self):

        self.init(database = True, write = False)

        if not self.args:
            self.help()
            return

        lang = ctx.get_option('language')
        repo = ctx.get_option('repository')

        if ctx.get_option('installdb'):
            db = pisi.db.installdb.InstallDB()
            pkgs = db.search_package(self.args, lang)
            get_info = db.get_package
            get_name_sum = lambda pkg:(pkg.name, pkg.summary)
        elif ctx.get_option('sourcedb'):
            db = pisi.db.sourcedb.SourceDB()
            pkgs = db.search_spec(self.args, lang, repo)
            get_info = db.get_spec
            get_name_sum = lambda pkg:(pkg.source.name, pkg.source.summary)
        else:
            db = pisi.db.packagedb.PackageDB()
            pkgs = db.search_package(self.args, lang, repo)
            get_info = db.get_package
            get_name_sum = lambda pkg:(pkg.name, pkg.summary)

        for pkg in pkgs:
            pkg_info = get_info(pkg)
            name, summary = get_name_sum(pkg_info)
            if lang and summary.has_key(lang):
                print "%s - %s" % (name, summary[lang])
            else:
                print "%s - %s" % (name, summary)
Example #2
0
    def run(self):

        self.init(database=True, write=False)

        if not self.args:
            self.help()
            return

        replace = re.compile("(%s)" % "|".join(self.args), re.I)
        lang = ctx.get_option('language')
        repo = ctx.get_option('repository')
        name = ctx.get_option('name')
        summary = ctx.get_option('summary')
        desc = ctx.get_option('description')
        fields = None
        if name or summary or desc:
            fields = {'name': name, 'summary': summary, 'desc': desc}

        if ctx.get_option('installdb'):
            db = pisi.db.installdb.InstallDB()
            pkgs = db.search_package(self.args, lang, fields)
            get_info = db.get_package
            get_name_sum = lambda pkg: (pkg.name, pkg.summary)
        elif ctx.get_option('sourcedb'):
            db = pisi.db.sourcedb.SourceDB()
            pkgs = db.search_spec(self.args, lang, repo, fields)
            get_info = db.get_spec
            get_name_sum = lambda pkg: (pkg.source.name, pkg.source.summary)
        else:
            db = pisi.db.packagedb.PackageDB()
            pkgs = db.search_package(self.args, lang, repo, fields)
            get_info = db.get_package
            get_name_sum = lambda pkg: (pkg.name, pkg.summary)

        if pkgs:
            maxlen = max([len(_pkg) for _pkg in pkgs])

        for pkg in pkgs:
            pkg_info = get_info(pkg)

            name, summary = get_name_sum(pkg_info)
            lenp = len(name)

            name = replace.sub(pisi.util.colorize(r"\1", "brightred"), name)
            if lang and lang in summary:
                summary = replace.sub(pisi.util.colorize(r"\1", "brightred"),
                                      str(summary[lang]))
            else:
                summary = replace.sub(pisi.util.colorize(r"\1", "brightred"),
                                      str(summary))

            name += ' ' * max(0, maxlen - lenp)

            ctx.ui.info('%s - %s' % (name, summary))
Example #3
0
    def run(self):

        self.init(database=True, write=False)

        if not self.args:
            self.help()
            return

        cs = ctx.get_option("case_sensitive")
        replace = re.compile("(%s)" % "|".join(self.args), 0 if cs else re.I)
        lang = ctx.get_option("language")
        repo = ctx.get_option("repository")
        name = ctx.get_option("name")
        summary = ctx.get_option("summary")
        desc = ctx.get_option("description")
        fields = None
        if name or summary or desc:
            fields = {"name": name, "summary": summary, "desc": desc}

        if ctx.get_option("installdb"):
            db = pisi.db.installdb.InstallDB()
            pkgs = db.search_package(self.args, lang, fields, cs)
            get_info = db.get_package
            get_name_sum = lambda pkg: (pkg.name, pkg.summary)
        elif ctx.get_option("sourcedb"):
            db = pisi.db.sourcedb.SourceDB()
            pkgs = db.search_spec(self.args, lang, repo, fields, cs)
            get_info = db.get_spec
            get_name_sum = lambda pkg: (pkg.source.name, pkg.source.summary)
        else:
            db = pisi.db.packagedb.PackageDB()
            pkgs = db.search_package(self.args, lang, repo, fields, cs)
            get_info = db.get_package
            get_name_sum = lambda pkg: (pkg.name, pkg.summary)

        if pkgs:
            maxlen = max([len(_pkg) for _pkg in pkgs])

        for pkg in pkgs:
            pkg_info = get_info(pkg)

            name, summary = get_name_sum(pkg_info)
            lenp = len(name)

            name = replace.sub(pisi.util.colorize(r"\1", "brightred"), name)
            if lang and summary.has_key(lang):
                summary = replace.sub(pisi.util.colorize(r"\1", "brightred"), str(summary[lang]))
            else:
                summary = replace.sub(pisi.util.colorize(r"\1", "brightred"), str(summary))

            name += " " * max(0, maxlen - lenp)

            ctx.ui.info("%s - %s" % (name, summary))
Example #4
0
    def run(self):

        self.init(database = True, write = False)

        if not self.args:
            self.help()
            return

        replace = re.compile("(%s)" % "|".join(self.args), re.I)
        lang = ctx.get_option('language')
        repo = ctx.get_option('repository')
        name = ctx.get_option('name')
        summary = ctx.get_option('summary')
        desc = ctx.get_option('description')
        fields = None
        if name or summary or desc:
            fields = {'name': name, 'summary': summary, 'desc': desc}

        if ctx.get_option('installdb'):
            db = pisi.db.installdb.InstallDB()
            pkgs = db.search_package(self.args, lang, fields)
            get_info = db.get_package
            get_name_sum = lambda pkg:(pkg.name, pkg.summary)
        elif ctx.get_option('sourcedb'):
            db = pisi.db.sourcedb.SourceDB()
            pkgs = db.search_spec(self.args, lang, repo, fields)
            get_info = db.get_spec
            get_name_sum = lambda pkg:(pkg.source.name, pkg.source.summary)
        else:
            db = pisi.db.packagedb.PackageDB()
            pkgs = db.search_package(self.args, lang, repo, fields)
            get_info = db.get_package
            get_name_sum = lambda pkg:(pkg.name, pkg.summary)

        if pkgs:
            maxlen = max([len(_pkg) for _pkg in pkgs])

        for pkg in pkgs:
            pkg_info = get_info(pkg)

            name, summary = get_name_sum(pkg_info)
            lenp = len(name)

            name = replace.sub(pisi.util.colorize(r"\1", "brightred"), name)
            if lang and summary.has_key(lang):
                summary = replace.sub(pisi.util.colorize(r"\1", "brightred"), str(summary[lang]))
            else:
                summary = replace.sub(pisi.util.colorize(r"\1", "brightred"), str(summary))

            name += ' ' * max(0, maxlen - lenp)

            ctx.ui.info('%s - %s' % (name, summary))
Example #5
0
    def run(self):

        self.init(database = True, write = False)

        if not self.args:
            self.help()
            return

        replace = re.compile("(%s)" % "|".join(self.args), re.I)
        lang = ctx.get_option('language')
        repo = ctx.get_option('repository')

        if ctx.get_option('installdb'):
            db = pisi.db.installdb.InstallDB()
            pkgs = db.search_package(self.args, lang)
            get_info = db.get_package
            get_name_sum = lambda pkg:(pkg.name, pkg.summary)
        elif ctx.get_option('sourcedb'):
            db = pisi.db.sourcedb.SourceDB()
            pkgs = db.search_spec(self.args, lang, repo)
            get_info = db.get_spec
            get_name_sum = lambda pkg:(pkg.source.name, pkg.source.summary)
        else:
            db = pisi.db.packagedb.PackageDB()
            pkgs = db.search_package(self.args, lang, repo)
            get_info = db.get_package
            get_name_sum = lambda pkg:(pkg.name, pkg.summary)

        for pkg in pkgs:
            pkg_info = get_info(pkg)
            name, summary = get_name_sum(pkg_info)
            name = replace.sub(pisi.util.colorize(r"\1", "brightred"), name)
            if lang and summary.has_key(lang):
                summary = replace.sub(pisi.util.colorize(r"\1", "brightred"), str(summary[lang]))
            else:
                summary = replace.sub(pisi.util.colorize(r"\1", "brightred"), str(summary))

            print "%s - %s" % (name, summary)