[pygobject: 2/23] dsextras.py: rearrange imports



commit 819a21cea831c3892040390e9446b78a91d1cbbe
Author: Dieter Verfaillie <dieterv optionexplicit be>
Date:   Wed Nov 3 06:28:04 2010 +0100

    dsextras.py: rearrange imports
    
    Signed-off-by: Dieter Verfaillie <dieterv optionexplicit be>

 dsextras.py |   58 +++++++++++++++++++++++++++++++---------------------------
 1 files changed, 31 insertions(+), 27 deletions(-)
---
diff --git a/dsextras.py b/dsextras.py
index c90b82e..3effa75 100644
--- a/dsextras.py
+++ b/dsextras.py
@@ -1,22 +1,43 @@
+# -*- coding: utf-8 -*-
 #
-# dsextras.py - Extra classes and utilities for distutils, adding
-#               pkg-config support
+# dsextras.py - Extra classes and utilities for distutils,
+#               adding pkg-config support
 
 
+import os
+import sys
+import fnmatch
+import re
+import string
+
+import distutils.dep_util
 from distutils.command.build_ext import build_ext
 from distutils.command.install_lib import install_lib
 from distutils.command.install_data import install_data
 from distutils.extension import Extension
-import distutils.dep_util
-import fnmatch
-import os
-import re
-import string
-import sys
+
+try:
+    import codegen.createdefs
+    from codegen.override import Overrides
+    from codegen.defsparser import DefsParser
+    from codegen.codegen import register_types, SourceWriter, FileOutput
+except ImportError:
+    template_classes_enabled = False
+else:
+    template_classes_enabled = True
+
 
 GLOBAL_INC = []
 GLOBAL_MACROS = []
 
+codegen_error_message='''
+***************************************************************************
+Codegen could not be found on your system and is required by the
+dsextras.Template and dsextras.TemplateExtension classes.
+***************************************************************************
+'''
+
+
 def get_m4_define(varname):
     """Return the value of a m4_define variable as set in configure.in."""
     pattern = re.compile("m4_define\(" + varname + "\,\s*(.+)\)")
@@ -322,27 +343,10 @@ class PkgConfigExtension(Extension):
     def generate(self):
         pass
 
-# The Template and TemplateExtension classes require codegen
-
-template_classes_enabled=True
-codegen_error_message="""
-***************************************************************************
-Codegen could not be found on your system and is required by the
-dsextras.Template and dsextras.TemplateExtension classes.
-***************************************************************************
-"""
-try:
-    from codegen.override import Overrides
-    from codegen.defsparser import DefsParser
-    from codegen.codegen import register_types, SourceWriter, \
-         FileOutput
-    import codegen.createdefs
-except ImportError:
-    (etype, e) = sys.exc_info()[:2]    
-    template_classes_enabled=False
 
 class Template(object):
-    def __new__(cls,*args, **kwds):
+    def __new__(cls, *args, **kwds):
+        # The Template and TemplateExtension classes require codegen
         if not template_classes_enabled:
             raise NameError("'%s' is not defined\n" % cls.__name__
                             + codegen_error_message)    



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]