Files
linux/debian/lib/python/debian_linux/abi.py
Ben Hutchings af0098b10a debian/bin, debian/lib/python: Fix most errors reported by pycodestyle
Fix coding style violations reported by pycodestyle.  This is
mostly a matter of reformatting code, particularly to eliminate
over-long lines.  I also rename one variable ("l" is considered
visually ambiguous) and change a bare "except" to explicitly
catch all exceptions.

There are three types of error or warning remaining:

- debian/bin/...: E402 module level import not at top of file
  Scripts in debian/bin need to modify the import path before
  importing from debian/lib/python.
- E127 continuation line over-indented for visual indent
  This seems to be a false positive.  pycodestyle doesn't seem to be
  happy with any level of indent (including 0) on a continuation line
  in a "with" statement.
- debian/lib/python/debian_linux/debian.py:15:2: W291 trailing whitespace
  This is a false positive.  The trailing spaces are in a long
  string and are intentional.
2018-10-01 21:41:23 +01:00

43 lines
1.3 KiB
Python

class Symbol(object):
def __init__(self, name, module, version, export):
self.name, self.module = name, module
self.version, self.export = version, export
def __eq__(self, other):
if not isinstance(other, Symbol):
return NotImplemented
# Symbols are resolved to modules by depmod at installation/
# upgrade time, not compile time, so moving a symbol between
# modules is not an ABI change. Compare everything else.
if self.name != other.name:
return False
if self.version != other.version:
return False
if self.export != other.export:
return False
return True
def __ne__(self, other):
ret = self.__eq__(other)
if ret is NotImplemented:
return ret
return not ret
class Symbols(dict):
def __init__(self, file=None):
if file:
self.read(file)
def read(self, file):
for line in file:
version, name, module, export = line.strip().split()
self[name] = Symbol(name, module, version, export)
def write(self, file):
for s in sorted(self.values(), key=lambda i: i.name):
file.write("%s %s %s %s\n" %
(s.version, s.name, s.module, s.export))