python: samba.getopt: Port module to Python 3 compatible form
authorLumir Balhar <lbalhar@redhat.com>
Tue, 17 Jan 2017 10:03:17 +0000 (11:03 +0100)
committerAndrew Bartlett <abartlet@samba.org>
Fri, 10 Mar 2017 06:31:12 +0000 (07:31 +0100)
Port samba.getopt module to Python 3 compatible form.

Remove unused and untested `get_hostconfig()` function. Andrew Bartlett
suggested this removal because it is the simpliest way how to break
a long dependency line of Python modules which have to be ported
at once.
More info: https://lists.samba.org/archive/samba-technical/2017-January/118150.html

Signed-off-by: Lumir Balhar <lbalhar@redhat.com>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
Reviewed-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
python/samba/getopt.py

index 13139b27006fafb6c1437bb5b79fed40283910ae..4da75ce0266f1c6a47cd98071f2eb5f03f71edf6 100644 (file)
@@ -27,7 +27,6 @@ from samba.credentials import (
     DONT_USE_KERBEROS,
     MUST_USE_KERBEROS,
     )
-from samba.hostconfig import Hostconfig
 import sys
 
 
@@ -78,7 +77,7 @@ class SambaOptions(optparse.OptionGroup):
         a = arg.split('=')
         try:
             self._lp.set(a[0], a[1])
-        except Exception, e:
+        except Exception as e:
             raise optparse.OptionValueError(
                 "invalid --option option value %r: %s" % (arg, e))
 
@@ -92,9 +91,6 @@ class SambaOptions(optparse.OptionGroup):
             self._lp.load_default()
         return self._lp
 
-    def get_hostconfig(self):
-        return Hostconfig(self.get_loadparm())
-
 
 class VersionOptions(optparse.OptionGroup):
     """Command line option for printing Samba version."""
@@ -106,7 +102,7 @@ class VersionOptions(optparse.OptionGroup):
 
     def _display_version(self, option, opt_str, arg, parser):
         import samba
-        print samba.version
+        print(samba.version)
         sys.exit(0)