Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
manager: CliManager = ctx.obj.m
limit = 10
pkg = manager.get_pkg(addon)
if not pkg:
Report([(addon, E.PkgNotInstalled())]).generate_and_exit()
return # noop
resolver = manager.resolvers[pkg.source]
if not resolver.supports_rollback:
Report(
[(addon, E.PkgFileUnavailable('source does not support rollback'))]
).generate_and_exit()
if undo:
Report(
chain(
manager.run(manager.remove([addon])).items(),
manager.run(manager.install([addon], replace=False)).items(),
)
).generate_and_exit()
versions: List[models.PkgVersionLog] = (
manager.db_session.query(models.PkgVersionLog)
.filter(
models.PkgVersionLog.pkg_source == pkg.source, models.PkgVersionLog.pkg_id == pkg.id
)
.order_by(models.PkgVersionLog.install_time.desc())
.limit(limit)
.all()
)
if len(versions) <= 1:
if list_unreconciled:
table_rows = [('unreconciled',), *((f.name,) for f in sorted(leftovers))]
click.echo(tabulate(table_rows))
return
elif not leftovers:
click.echo('No add-ons left to reconcile.')
return
elif not auto:
click.echo(preamble)
matcher = match_all()
for _ in matcher: # Skip over consumer yields
selections = matcher.send(leftovers)
if selections and (auto or confirm('Install selected add-ons?').unsafe_ask()):
results = manager.run(manager.install(selections, replace=True))
Report(results.items()).generate()
leftovers = get_folders(manager)
if leftovers:
click.echo()
table_rows = [('unreconciled',), *((f.name,) for f in sorted(leftovers))]
click.echo(tabulate(table_rows))