Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def test_sync_newversion_error():
with pytest.raises(TypeError) as excinfo:
pyalpm.sync_newversion()
assert 'takes a Package and a list of DBs' in str(excinfo.value)
def test_sync_newversion(syncdb, package):
assert pyalpm.sync_newversion(package, [syncdb]) is None
def get_updates():
"""Return a list of package objects in local db which can be updated"""
global do_syncfirst
global list_first
if config.syncfirst:
for name in config.syncfirst:
pkg = config.handle.get_localdb().get_pkg(name)
candidate = pyalpm.sync_newversion(pkg, config.handle.get_syncdbs())
if candidate:
list_first.append(candidate)
if list_first:
do_syncfirst = True
return list_first
result = []
installed_pkglist = config.handle.get_localdb().pkgcache
for pkg in installed_pkglist:
candidate = pyalpm.sync_newversion(pkg, config.handle.get_syncdbs())
if candidate:
result.append(candidate)
return result
"""Return a list of package objects in local db which can be updated"""
global do_syncfirst
global list_first
if config.syncfirst:
for name in config.syncfirst:
pkg = config.handle.get_localdb().get_pkg(name)
candidate = pyalpm.sync_newversion(pkg, config.handle.get_syncdbs())
if candidate:
list_first.append(candidate)
if list_first:
do_syncfirst = True
return list_first
result = []
installed_pkglist = config.handle.get_localdb().pkgcache
for pkg in installed_pkglist:
candidate = pyalpm.sync_newversion(pkg, config.handle.get_syncdbs())
if candidate:
result.append(candidate)
return result
def filter_pkglist(pkglist, options):
result = []
if options.foreign:
syncpkgs = set()
for db in handle.get_syncdbs():
syncpkgs |= set(p.name for p in db.pkgcache)
for pkg in pkglist:
if options.deps and pkg.reason == pyalpm.PKG_REASON_EXPLICIT:
continue
if options.explicit and pkg.reason == pyalpm.PKG_REASON_DEPEND:
continue
if options.unrequired and len(pkg.compute_requiredby()) > 0:
continue
if options.foreign and pkg.name in syncpkgs:
continue
if options.upgrades and pyalpm.sync_newversion(pkg, handle.get_syncdbs()) is None:
continue
result.append(pkg)
return result