Commit f3002fb7 authored by Michael Vogt's avatar Michael Vogt

Fix the remaining pep8 erorrs

With this testmanual_pep8.py is happy again.
parent f165ed73
......@@ -139,7 +139,8 @@ def add_key_from_keyserver(keyid, keyserver):
def _add_key_from_keyserver(keyid, keyserver, tmp_keyring_dir):
if len(keyid.replace(" ", "").replace("0x", "")) < (160 / 4):
raise AptKeyIDTooShortError("Only fingerprints (v4, 160bit) are supported")
raise AptKeyIDTooShortError(
"Only fingerprints (v4, 160bit) are supported")
# create a temp keyring dir
tmp_secret_keyring = os.path.join(tmp_keyring_dir, "secring.gpg")
tmp_keyring = os.path.join(tmp_keyring_dir, "pubring.gpg")
......@@ -275,6 +276,7 @@ def list_keys():
res.append(key)
return res
if __name__ == "__main__":
# Add some known keys we would like to see translated so that they get
# picked up by gettext
......
......@@ -859,5 +859,7 @@ def _test():
assert pkgname == filtered[pkgname].name
print(len(filtered))
if __name__ == '__main__':
_test()
......@@ -804,5 +804,6 @@ def _test():
d = "libc6 (>= 2.3.2), libaio (>= 0.3.96) | libaio1 (>= 0.3.96)"
print(s._satisfy_depends(apt_pkg.parse_depends(d, False)))
if __name__ == "__main__":
_test()
......@@ -1397,6 +1397,7 @@ def _test():
print("Broken: %s " % cache._depcache.broken_count)
print("DelCount: %s " % cache._depcache.del_count)
# self-test
if __name__ == "__main__":
_test()
......@@ -207,9 +207,9 @@ class Distribution(object):
Customize for different distributions '''
country = None
i = server.find("://")
l = server.find(".archive.ubuntu.com")
if i != -1 and l != -1:
country = server[i + len("://"):l]
li = server.find(".archive.ubuntu.com")
if i != -1 and li != -1:
country = server[i + len("://"):li]
if country in self.countries:
# TRANSLATORS: %s is a country
return _("Server for %s") % self.countries[country]
......@@ -438,9 +438,9 @@ class DebianDistribution(Distribution):
Debian specific '''
country = None
i = server.find("://ftp.")
l = server.find(".debian.org")
if i != -1 and l != -1:
country = server[i + len("://ftp."):l]
li = server.find(".debian.org")
if i != -1 and li != -1:
country = server[i + len("://ftp."):li]
if country in self.countries:
# TRANSLATORS: %s is a country
return _("Server for %s") % gettext.dgettext(
......@@ -508,6 +508,7 @@ def _system_image_channel():
'system-image-cli failed, using defaults: %s' % exc)
return None
class _OSRelease:
DEFAULT_OS_RELEASE_FILE = '/etc/os-release'
......@@ -547,7 +548,7 @@ class _OSRelease:
f.close()
def parse_entry(self, key, value):
value = self.parse_value(value) # Values can be shell strings...
value = self.parse_value(value) # Values can be shell strings...
if key == "ID_LIKE" and isinstance(value, str):
# ID_LIKE is specified as quoted space-separated list. This will
# be parsed as string that we need to split manually.
......@@ -560,7 +561,9 @@ class _OSRelease:
return values[0]
return values
def get_distro(id=None, codename=None, description=None, release=None, is_like=[]):
def get_distro(id=None, codename=None, description=None, release=None,
is_like=[]):
"""
Check the currently used distribution and return the corresponding
distriubtion class that supports distro specific features.
......@@ -582,7 +585,8 @@ def get_distro(id=None, codename=None, description=None, release=None, is_like=[
# a behavior break a which point lsb_release support should be
# fully removed.
# This in particular is a problem for template matching, as this
# matches against Distribution objects and depends on string case.
# matches against Distribution objects and depends on string
# case.
lsb_result = _lsb_release()
id = lsb_result['Distributor ID']
codename = lsb_result['Codename']
......@@ -600,7 +604,8 @@ def get_distro(id=None, codename=None, description=None, release=None, is_like=[
if id == "Ubuntu":
return UbuntuDistribution(id, codename, description, release, is_like)
if id == "Ubuntu-RTM":
return UbuntuRTMDistribution(id, codename, description, release, is_like)
return UbuntuRTMDistribution(
id, codename, description, release, is_like)
elif id == "Debian":
return DebianDistribution(id, codename, description, release, is_like)
else:
......
......@@ -15,6 +15,7 @@ def get_file(fetcher, uri, destfile):
return False
return True
apt_pkg.init()
#apt_pkg.config.set("Debug::pkgDPkgPM","1");
......
......@@ -67,5 +67,6 @@ def main(args):
sys.stderr.write('E: Invalid operation %s\n' % arguments[0])
return 1
if __name__ == '__main__':
sys.exit(main(sys.argv))
......@@ -18,5 +18,6 @@ def main():
if pkg.important:
print(" ", pkg.name)
if __name__ == "__main__":
main()
......@@ -25,5 +25,6 @@ def main():
print('Automatic: Yes')
print()
if __name__ == '__main__':
main()
......@@ -63,5 +63,6 @@ def main():
finally:
fobj.close()
if __name__ == "__main__":
main()
......@@ -25,5 +25,6 @@ def main():
finally:
fobj.close()
if __name__ == "__main__":
main()
......@@ -19,5 +19,6 @@ def main():
finally:
fobj.close()
if __name__ == '__main__':
main()
......@@ -48,5 +48,6 @@ def main():
check_version(version)
break
if __name__ == "__main__":
main()
......@@ -19,5 +19,6 @@ def main():
for item in acquire.items:
print(item.desc_uri)
if __name__ == '__main__':
main()
......@@ -117,9 +117,9 @@ class TestAptCache(testcommon.TestCase):
"skipping test_get_provided_packages, cache empty?!?")
return
# a true virtual pkg
l = cache.get_providing_packages("mail-transport-agent")
self.assertTrue(len(l) > 0)
self.assertTrue("postfix" in [p.name for p in l])
li = cache.get_providing_packages("mail-transport-agent")
self.assertTrue(len(li) > 0)
self.assertTrue("postfix" in [p.name for p in li])
self.assertTrue(
"mail-transport-agent" in cache["postfix"].candidate.provides)
......@@ -133,10 +133,10 @@ class TestAptCache(testcommon.TestCase):
return
# low level cache provides list of the pkg
cache = highlevel_cache._cache
l = cache["mail-transport-agent"].provides_list
li = cache["mail-transport-agent"].provides_list
# arbitrary number, just needs to be higher enough
self.assertEqual(len(l), 2)
for (providesname, providesver, version) in l:
self.assertEqual(len(li), 2)
for (providesname, providesver, version) in li:
self.assertEqual(providesname, "mail-transport-agent")
if version.parent_pkg.name == "postfix":
break
......@@ -231,12 +231,12 @@ class TestAptCache(testcommon.TestCase):
def test_package_cmp(self):
cache = apt.Cache(rootdir="/")
l = []
l.append(cache["intltool"])
l.append(cache["python3"])
l.append(cache["apt"])
l.sort()
self.assertEqual([p.name for p in l],
li = []
li.append(cache["intltool"])
li.append(cache["python3"])
li.append(cache["apt"])
li.sort()
self.assertEqual([p.name for p in li],
["apt", "intltool", "python3"])
def test_get_architectures(self):
......
......@@ -262,7 +262,8 @@ class TestAptSources(testcommon.TestCase):
aptsources.distro._OSRelease.OS_RELEASE_FILE = \
os.path.abspath("./data/aptsources/os-release")
distro = aptsources.distro.get_distro()
# Everything but is_like comes from lsb_release, see TODO in get_distro.
# Everything but is_like comes from lsb_release, see TODO in
# get_distro.
self.assertEqual('Ubuntu', distro.id)
self.assertEqual('xenial', distro.codename)
self.assertEqual('Ubuntu 16.04.1 LTS', distro.description)
......@@ -284,6 +285,7 @@ class TestAptSources(testcommon.TestCase):
self.assertEqual(disabled, enabled)
self.assertFalse(disabled.disabled)
if __name__ == "__main__":
os.chdir(os.path.dirname(__file__))
unittest.main()
......@@ -204,13 +204,16 @@ class TestAuthKeys(testcommon.TestCase):
WHEEZY_KEYID, "hkp://localhost:19191")
with self.assertRaises(apt.auth.AptKeyIDTooShortError):
apt.auth.add_key_from_keyserver(
"0101010178F7FE5C3E65D8AF8B48AD624692555", "hkp://localhost:19191")
"0101010178F7FE5C3E65D8AF8B48AD624692555",
"hkp://localhost:19191")
with self.assertRaises(apt.auth.AptKeyIDTooShortError):
apt.auth.add_key_from_keyserver(
"0x0101010178F7FE5C3E65D8AF8B48AD624692555", "hkp://localhost:19191")
"0x0101010178F7FE5C3E65D8AF8B48AD624692555",
"hkp://localhost:19191")
with self.assertRaises(apt.auth.AptKeyIDTooShortError):
apt.auth.add_key_from_keyserver(
"0101 0101 78F7 FE5C 3E65 D8AF 8B48 AD62 4692 555", "hkp://localhost:19191")
"0101 0101 78F7 FE5C 3E65 D8AF 8B48 AD62 4692 555",
"hkp://localhost:19191")
def test_add_key_from_server_mitm(self):
"""Verify that the key fingerprint is verified after download"""
......@@ -306,5 +309,6 @@ class TestAuthKeys(testcommon.TestCase):
if self.orig_proxy is not None:
os.environ['http_proxy'] = self.orig_proxy
if __name__ == "__main__":
unittest.main()
......@@ -25,5 +25,6 @@ class TestCache(testcommon.TestCase):
apt_depcache = apt_pkg.DepCache(apt_cache)
self.assertNotEqual(apt_depcache, None)
if __name__ == "__main__":
unittest.main()
......@@ -140,5 +140,6 @@ class TestDependencies(testcommon.TestCase):
self.assertEqual(">=", apt_pkg.ParseDepends("p1 (> 1)")[0][0][2])
self.assertEqual(">>", apt_pkg.ParseDepends("p1 (>> 1)")[0][0][2])
if __name__ == "__main__":
unittest.main()
......@@ -237,5 +237,6 @@ class TestHashStringList(testcommon.TestCase):
self.assertGreater(len(hsl2), 0)
self.assertTrue(hsl2.verify_file(apt_pkg.__file__))
if __name__ == "__main__":
unittest.main()
......@@ -21,5 +21,6 @@ class testHashes(testcommon.TestCase):
self.assertRaises(MemoryError, deb.data.extractdata, "large-file")
if __name__ == "__main__":
unittest.main()
......@@ -74,6 +74,7 @@ Architecture: all""")
# this should be 82324L but python3.2 gets unhappy about the "L"
self.assertEqual(self.cache.required_download, 82324)
if __name__ == "__main__":
unittest.main()
......
......@@ -145,5 +145,6 @@ class TestPath(testcommon.TestCase):
self.assertRaises(StopIteration, next, tag1)
self.assertRaises(StopIteration, next, tag2)
if __name__ == '__main__':
unittest.main()
......@@ -157,5 +157,6 @@ class TestTagFile(testcommon.TestCase):
self.assertEqual(
value.encode("ISO-8859-1"), tagfile.section["Maintainer"])
if __name__ == "__main__":
unittest.main()
......@@ -67,5 +67,6 @@ class TestUtils(testcommon.TestCase):
#d = datetime.timedelta(18*30)
#print "end date: ", release_date + d
if __name__ == "__main__":
unittest.main()
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment