Some more changes for the code formatting audit.

This commit is contained in:
Pedro Algarvio 2012-09-22 12:13:17 +01:00
parent 6173bedfa7
commit 5e1b85ffb2
2 changed files with 11 additions and 7 deletions

View File

@ -171,7 +171,7 @@ def _cidr_to_ipv4_netmask(cidr_bits):
netmask += '255'
cidr_bits -= 8
else:
netmask += '%d' % (256-(2**(8-cidr_bits)))
netmask += '{0:d}'.format(256-(2**(8-cidr_bits)))
cidr_bits = 0
return netmask

View File

@ -3,6 +3,7 @@ import sys
__version_info__ = (0, 10, 3, 'd')
__version__ = '.'.join(map(str, __version_info__))
def versions_report():
libs = (
("Jinja2", "jinja2", "__version__"),
@ -12,14 +13,17 @@ def versions_report():
("pycrypto", "Crypto", "__version__"),
("PyYAML", "yaml", "__version__"),
("PyZMQ", "zmq", "__version__"),
)
fmt = "{0:>%d}: {1}" % (len(max([lib[0] for lib in libs], key=len)) + 1)
padding = len(max([lib[0] for lib in libs], key=len)) + 1
yield fmt.format("Salt", __version__)
fmt = '{0:>{pad}}: {1}'
yield fmt.format("Python", sys.version.rsplit('\n')[0].strip())
yield fmt.format("Salt", __version__, pad=padding)
yield fmt.format(
"Python", sys.version.rsplit('\n')[0].strip(), pad=padding
)
for name, imp, attr in libs:
try:
@ -27,9 +31,9 @@ def versions_report():
version = getattr(imp, attr)
if not isinstance(version, basestring):
version = '.'.join(map(str, version))
yield fmt.format(name, version)
yield fmt.format(name, version, pad=padding)
except ImportError:
yield fmt.format(name, "not installed")
yield fmt.format(name, "not installed", pad=padding)
if __name__ == '__main__':