blob: 09c2c433a9c3a7710e21a7a42275c16963fb233b [file] [log] [blame]
Patrick Williams07ce0de2020-04-01 10:15:29 -05001From 8729226fb79d49129c8349645e0f8ec381f14be8 Mon Sep 17 00:00:00 2001
2From: Patrick Williams <patrick@stwcx.xyz>
3Date: Wed, 1 Apr 2020 08:48:05 -0500
4Subject: [PATCH] Revert "sdbus++: switch to python3"
5
6This reverts commit 18ce803d1e2a6a1779d38f7bf5279901b02583e0.
7---
8 configure.ac | 2 +-
9 tools/sdbus++ | 8 ++++++--
10 tools/sdbusplus/namedelement.py | 4 ++--
11 3 files changed, 9 insertions(+), 5 deletions(-)
12
13diff --git a/configure.ac b/configure.ac
14index ec65562..11c189b 100644
15--- a/configure.ac
16+++ b/configure.ac
17@@ -29,7 +29,7 @@ AC_PROG_INSTALL
18 AC_PROG_MAKE_SET
19
20 # setup sdbus++
21-AM_PATH_PYTHON([3.0], [AC_SUBST([PYTHON], [echo "$PYTHON"])])
22+AM_PATH_PYTHON([2.7], [AC_SUBST([PYTHON], [echo "$PYTHON"])])
23 AC_SUBST([PYTHONDIR], ${pythondir})
24 AS_IF([test "$PYTHON" != :], [have_python=yes], [have_python=no])
25
26diff --git a/tools/sdbus++ b/tools/sdbus++
27index fa12677..6cfcb9e 100755
28--- a/tools/sdbus++
29+++ b/tools/sdbus++
30@@ -1,4 +1,4 @@
31-#!/usr/bin/env python3
32+#!/usr/bin/env python
33 import sdbusplus
34 import mako.lookup
35 import argparse
36@@ -35,7 +35,11 @@ def main():
37
38 args = parser.parse_args()
39
40- lookup = mako.lookup.TemplateLookup(directories=[args.templatedir])
41+ if sys.version_info < (3, 0):
42+ lookup = mako.lookup.TemplateLookup(directories=[args.templatedir],
43+ disable_unicode=True)
44+ else:
45+ lookup = mako.lookup.TemplateLookup(directories=[args.templatedir])
46
47 instance = valid_types[args.typeName].load(args.item, args.rootdir)
48 function = getattr(instance, valid_processes[args.process])
49diff --git a/tools/sdbusplus/namedelement.py b/tools/sdbusplus/namedelement.py
50index 1548ef0..5048654 100644
51--- a/tools/sdbusplus/namedelement.py
52+++ b/tools/sdbusplus/namedelement.py
53@@ -7,7 +7,7 @@ class NamedElement(object):
54 self.name = kwargs.pop('name', "unnamed")
55 self.description = kwargs.pop('description', "")
56
57- def __getattribute__(self, name):
58+ def __getattr__(self, name):
59 l = {'CamelCase': lambda: inflection.camelize(self.name),
60 'camelCase': lambda: inflection.camelize(self.name, False),
61 'snake_case': lambda: inflection.underscore(self.name)}\
62@@ -16,7 +16,7 @@ class NamedElement(object):
63 if l:
64 return NamedElement.__fixup_name(l())
65 try:
66- return super(NamedElement, self).__getattribute__(name)
67+ return super(NamedElement, self).__getattr__(name)
68 except:
69 raise AttributeError("Attribute '%s' not found in %s.NamedElement"
70 % (name, self.__module__))
71--
722.24.1
73