def print_details(self, spec): data = self._get_dist_data(spec.name) ver = self.get_best_version(data, spec, quiet=True) data = self.api.meta(spec.name, ver) for k in u""" name abstract description maintainer license release_status version date sha1 """.split(): try: v = data[k] except KeyError: logger.warning(_("data key '%s' not found"), k) continue if isinstance(v, list): for vv in v: emit("%s: %s" % (k, vv)) elif isinstance(v, dict): for kk, vv in v.items(): emit("%s: %s: %s" % (k, kk, vv)) else: emit("%s: %s" % (k, v)) k = 'provides' for ext, dext in data[k].items(): emit("%s: %s: %s" % (k, ext, dext['version'])) k = 'prereqs' if k in data: for phase, rels in data[k].items(): for rel, pkgs in rels.items(): for pkg, ver in pkgs.items(): emit("%s: %s: %s %s" % (phase, rel, pkg, ver))
def print_versions(self, spec): data = self._get_dist_data(spec.name) name = data['name'] vs = [(SemVer(d['version']), s) for s, ds in data['releases'].items() for d in ds] vs = [(v, s) for v, s in vs if spec.accepted(v)] vs.sort(reverse=True) for v, s in vs: emit("%s %s %s" % (name, v, s))
def _get_exec(cmd): fn = find_script('pgxn-' + cmd) if not fn: emit( "pgxn: unknown command: '%s'. See 'pgxn --help'" % cmd, file=sys.stderr, ) sys.exit(2) return fn
def print_versions(self, spec): data = self._get_dist_data(spec.name) name = data['name'] vs = [ (SemVer(d['version']), s) for s, ds in data['releases'].items() for d in ds ] vs = [(v, s) for v, s in vs if spec.accepted(v)] vs.sort(reverse=True) for v, s in vs: emit("%s %s %s" % (name, v, s))
def print_all_commands(self): cmds = self.find_all_commands() title = _("Available PGXN Client commands") emit(title) emit("-" * len(title)) for cmd in cmds: emit(" " + cmd)
def run(self): data = self.api.search(self.opts.where, self.opts.query) for hit in data['hits']: emit("%s %s" % (hit['dist'], hit['version'])) if 'excerpt' in hit: excerpt = self.clean_excerpt(hit['excerpt']) for line in textwrap.wrap(excerpt, 72): emit(" " + line) emit()
def run(self): data = self.api.mirrors() if self.opts.uri: detailed = True data = [d for d in data if d['uri'] == self.opts.uri] if not data: raise ResourceNotFound( _('mirror not found: %s') % self.opts.uri) else: detailed = self.opts.detailed for i, d in enumerate(data): if not detailed: emit(d['uri']) else: for k in u""" uri frequency location bandwidth organization email timezone src rsync notes """.split(): emit("%s: %s" % (k, d.get(k, ''))) emit()
def run(self): data = self.api.mirrors() if self.opts.uri: detailed = True data = [d for d in data if d['uri'] == self.opts.uri] if not data: raise ResourceNotFound( _('mirror not found: %s') % self.opts.uri ) else: detailed = self.opts.detailed for i, d in enumerate(data): if not detailed: emit(d['uri']) else: for k in u""" uri frequency location bandwidth organization email timezone src rsync notes """.split(): emit("%s: %s" % (k, d.get(k, ''))) emit()
def print_libexec(self): emit(get_public_scripts_dir())
def print_readme(self, spec): data = self._get_dist_data(spec.name) ver = self.get_best_version(data, spec, quiet=True) emit(self.api.readme(spec.name, ver))
def print_meta(self, spec): data = self._get_dist_data(spec.name) ver = self.get_best_version(data, spec, quiet=True) emit(self.api.meta(spec.name, ver, as_json=False))