Skip to content

Commit

Permalink
Replace autoconf metaclass magic
Browse files Browse the repository at this point in the history
By using an "empty" intermediary class with the actual bases as the parent for the child class we can use the Python 2 and 3 compatible syntax

IntermediaryClass = JoinedMetaclass(IntermediaryClass, (BaseClass1, BaseClass2), {})
  • Loading branch information
cschramm committed Apr 9, 2015
1 parent 9abbd9a commit c75112c
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 14 deletions.
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ aclocal.m4
install-sh
.deps
Constants.py
/blueman/main/applet/BluezAgent.py
/blueman/plugins/mechanism/Rfcomm.py
_blueman.c
po/Makefile.in.in
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,13 @@ def __init__(self):
dbus.DBusException.__init__(self, name="org.bluez.Error.Canceled")


class DummyGObjectMeta(dbus.service.InterfaceType, GObjectMeta):
class _GDbusObjectType(dbus.service.InterfaceType, GObjectMeta):
pass

_GObjectAgent = _GDbusObjectType('_GObjectAgent', (Agent, GObject.GObject), {})

class CommonAgent(GObject.GObject, Agent@BLUEZ_AGENT_META@):
__metaclass__ = DummyGObjectMeta

class CommonAgent(_GObjectAgent):
__gsignals__ = {
'released': (GObject.SignalFlags.NO_HOOKS, None, ()),
}
Expand Down
2 changes: 0 additions & 2 deletions blueman/main/applet/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@ blueman_PYTHON = \
Transfer.py \
__init__.py

EXTRA_DIST = BluezAgent.py.in

CLEANFILES = \
BluezAgent.py \
$(BUILT_SOURCES)
Expand Down
8 changes: 0 additions & 8 deletions configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,6 @@ PKG_CHECK_MODULES([PYTHON], [python-${PYTHON_VERSION}])
AC_SUBST(PYTHON_LIBS)
AC_SUBST(PYTHON_CFLAGS)

dnl Work around for Python3 metaclass class argument
PYTHON_MAJOR_VERSION=`echo $PYTHON_VERSION | cut -c1`
if test [$PYTHON_MAJOR_VERSION] = [3]; then
BLUEZ_AGENT_META=", metaclass=DummyGObjectMeta"
AC_SUBST(BLUEZ_AGENT_META)
fi

AC_ENABLE_SHARED(yes)
AC_ENABLE_STATIC(no)

Expand Down Expand Up @@ -201,7 +194,6 @@ blueman/plugins/mechanism/Makefile
blueman/plugins/mechanism/Rfcomm.py
blueman/plugins/manager/Makefile
blueman/main/Makefile
blueman/main/applet/BluezAgent.py
blueman/main/applet/Makefile
blueman/ods/Makefile
blueman/services/Makefile
Expand Down

2 comments on commit c75112c

@infirit
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice, much cleaner.

ps: Don't forget to update POTFILES.{in,skip} 😉

@cschramm
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Gnarf, translations my ass. 😉

I should also have removed BluezAgent.py from the Makefile's CLEANFILES...

Please sign in to comment.