summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Coles <dcoles@gaikai.com>2011-04-08 16:49:30 -0700
committerJulien Danjou <julien@danjou.info>2011-05-03 10:21:55 +0200
commitf877a6f34c16bc73bccc18073b3512318d49e92c (patch)
treea0cc93cff1911e1052a482f9bbc70a3ca27fa010
parentc4497cdbf0640c376cdebb0a9e5ea62458e6ba51 (diff)
Use absolute imports in xcbgen for Python 3 compatibility
Python 3 has stricter syntax for relative imports. Use absolute imports to ensure compatibility with all versions of Python. Also break cyclical module import between state.py and matcher.py by deferring import. Signed-off-by: David Coles <dcoles@gaikai.com> Signed-off-by: Julien Danjou <julien@danjou.info>
-rw-r--r--xcbgen/matcher.py5
-rw-r--r--xcbgen/state.py6
-rw-r--r--xcbgen/xtypes.py2
3 files changed, 7 insertions, 6 deletions
diff --git a/xcbgen/matcher.py b/xcbgen/matcher.py
index e7958fa..6e45b23 100644
--- a/xcbgen/matcher.py
+++ b/xcbgen/matcher.py
@@ -9,14 +9,15 @@ we do not create a new type object, we just record the existing one under a new
from os.path import join
from xml.etree.cElementTree import parse
-import state
-from xtypes import *
+from xcbgen.xtypes import *
def import_(node, module, namespace):
'''
For imports, we load the file, create a new namespace object,
execute recursively, then record the import (for header files, etc.)
'''
+ # To avoid circular import error
+ from xcbgen import state
new_file = join(namespace.dir, '%s.xml' % node.text)
new_root = parse(new_file).getroot()
new_namespace = state.Namespace(new_file)
diff --git a/xcbgen/state.py b/xcbgen/state.py
index 51efc94..ae3d2d4 100644
--- a/xcbgen/state.py
+++ b/xcbgen/state.py
@@ -4,9 +4,9 @@ This module contains the namespace class and the singleton module class.
from os.path import dirname, basename
from xml.etree.cElementTree import parse
-import matcher
-from error import *
-from xtypes import *
+from xcbgen import matcher
+from xcbgen.error import *
+from xcbgen.xtypes import *
import __main__
diff --git a/xcbgen/xtypes.py b/xcbgen/xtypes.py
index 1a6c7ce..14c318a 100644
--- a/xcbgen/xtypes.py
+++ b/xcbgen/xtypes.py
@@ -1,7 +1,7 @@
'''
This module contains the classes which represent XCB data types.
'''
-from expr import Field, Expression
+from xcbgen.expr import Field, Expression
import __main__
class Type(object):