summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJonah BrĂ¼chert <jbb@kaidan.im>2024-04-16 17:32:42 +0200
committerJonah BrĂ¼chert <jbb@kaidan.im>2024-04-16 18:41:34 +0200
commit15f2aab7f1053a46d6d87a7c7f193767516c16cc (patch)
treeb8a11a33bfed2625b688f83ad6d7be7d362807a2
parente35a1ac2926b22ae412636a6ac6090741d6cbc01 (diff)
downloadtools-15f2aab7f1053a46d6d87a7c7f193767516c16cc.tar.gz
tools-15f2aab7f1053a46d6d87a7c7f193767516c16cc.tar.bz2
tools-15f2aab7f1053a46d6d87a7c7f193767516c16cc.zip
2to3
-rwxr-xr-xbin/hostinfo20
-rw-r--r--hostinfo/prefix.py2
-rw-r--r--hostinfo/printer.py9
-rw-r--r--version.py2
4 files changed, 18 insertions, 15 deletions
diff --git a/bin/hostinfo b/bin/hostinfo
index 8700be7..a97a8d8 100755
--- a/bin/hostinfo
+++ b/bin/hostinfo
@@ -110,7 +110,7 @@ def print_search(basepath, flags, search, filter_key=None):
key, result = _match(data, search_key, search_value, negate)
if result is not None:
if flags.only_names:
- print(_get_label(host))
+ print((_get_label(host)))
continue
p = printer.Printer(data, flags)
@@ -119,7 +119,7 @@ def print_search(basepath, flags, search, filter_key=None):
maxlength=max(length), force=True)
else:
if key is None:
- print(_get_label(host))
+ print((_get_label(host)))
else:
p.info(key, label=_get_label(host),
maxlength=max(length), force=True)
@@ -134,15 +134,15 @@ def print_keys(path):
if isinstance(data, str):
return
- for key in data.keys():
- print "%s%s" % (prefix, key)
+ for key in list(data.keys()):
+ print("%s%s" % (prefix, key))
if key == 'addresses':
- for k in utils.group_by(data[key], 'interface').keys():
- print "%s%s.%s" % (prefix, key, k)
+ for k in list(utils.group_by(data[key], 'interface').keys()):
+ print("%s%s.%s" % (prefix, key, k))
elif key == 'ports':
- for k in utils.group_by(data[key], 'process', 'UNKNOWN').keys():
- print "%s%s.%s" % (prefix, key, k)
+ for k in list(utils.group_by(data[key], 'process', 'UNKNOWN').keys()):
+ print("%s%s.%s" % (prefix, key, k))
elif isinstance(data[key], dict):
_print_keys(data[key], "%s%s." % (prefix, key))
elif isinstance(data[key], list):
@@ -159,7 +159,7 @@ def print_hosts(path, short):
if 'hosts' in hosts:
for host in hosts['hosts']:
if short:
- print(host.replace('.spline.inf.fu-berlin.de',''))
+ print((host.replace('.spline.inf.fu-berlin.de','')))
else:
print(host)
return True
@@ -202,7 +202,7 @@ def print_version_and_exit():
if ver is None:
sys.stderr.write('Unable to identify the version information.')
sys.exit(1)
- print("hostinfo-tools %s" % ver)
+ print(("hostinfo-tools %s" % ver))
sys.exit(0)
def main():
diff --git a/hostinfo/prefix.py b/hostinfo/prefix.py
index e1b72b5..8271d67 100644
--- a/hostinfo/prefix.py
+++ b/hostinfo/prefix.py
@@ -1,6 +1,6 @@
# -*- coding: utf-8 -*-
-from __future__ import print_function
+
class Printer:
flags = list()
diff --git a/hostinfo/printer.py b/hostinfo/printer.py
index ea612a5..e467afe 100644
--- a/hostinfo/printer.py
+++ b/hostinfo/printer.py
@@ -1,14 +1,16 @@
# -*- coding: utf-8 -*-
-from __future__ import absolute_import
+
from hostinfo import prefix
from hostinfo import utils
+
def _get_full_key(prev_key, key):
if prev_key == '':
return key
return "%s.%s" % (prev_key, key)
+
def _sort_with_list(iterable, sort):
def helper(value):
if sort is None:
@@ -21,6 +23,7 @@ def _sort_with_list(iterable, sort):
return sorted(iterable, key=helper)
+
def _space(filter_key, full_key, printer, force=False):
if filter_key is None and full_key == '':
printer.space(force)
@@ -121,14 +124,14 @@ class Printer:
def _print_list(self, values, printer, filter_key):
for value in values:
- if isinstance(value, basestring):
+ if isinstance(value, str):
self._print_value(value, printer, filter_key)
else:
self._print(value, printer, filter_key)
def _print_dict(self, value, printer, filter_key, sort, force):
keys = _sort_with_list(
- [(key, full_key) for key in value.keys()
+ [(key, full_key) for key in list(value.keys())
for full_key in [_get_full_key(printer.full_key, key)]
if self._should_display(full_key, filter_key)],
sort)
diff --git a/version.py b/version.py
index a4c7ed6..583ed0d 100644
--- a/version.py
+++ b/version.py
@@ -38,4 +38,4 @@ def get_git_version(abbrev=4):
return re.sub('^debian/', '', version)
if __name__ == "__main__":
- print get_git_version()
+ print(get_git_version())