[Bf-extensions-cvs] [5a2c3d6] master: DXF Exporter: support module reloading

Campbell Barton noreply at git.blender.org
Thu Mar 30 03:28:08 CEST 2017


Commit: 5a2c3d67f7f61caea570f139219ddb760da51325
Author: Campbell Barton
Date:   Wed Mar 29 14:54:36 2017 +1100
Branches: master
https://developer.blender.org/rBA5a2c3d67f7f61caea570f139219ddb760da51325

DXF Exporter: support module reloading

Also remove use of register_module

===================================================================

M	io_export_dxf/__init__.py
M	io_export_dxf/export_dxf.py
M	io_export_dxf/operator.py

===================================================================

diff --git a/io_export_dxf/__init__.py b/io_export_dxf/__init__.py
index ab451bb..254ffda 100644
--- a/io_export_dxf/__init__.py
+++ b/io_export_dxf/__init__.py
@@ -1,9 +1,9 @@
-#  ***** GPL LICENSE BLOCK *****
+# ##### BEGIN GPL LICENSE BLOCK #####
 #
-#  This program is free software: you can redistribute it and/or modify
-#  it under the terms of the GNU General Public License as published by
-#  the Free Software Foundation, either version 3 of the License, or
-#  (at your option) any later version.
+#  This program is free software; you can redistribute it and/or
+#  modify it under the terms of the GNU General Public License
+#  as published by the Free Software Foundation; either version 2
+#  of the License, or (at your option) any later version.
 #
 #  This program is distributed in the hope that it will be useful,
 #  but WITHOUT ANY WARRANTY; without even the implied warranty of
@@ -11,9 +11,10 @@
 #  GNU General Public License for more details.
 #
 #  You should have received a copy of the GNU General Public License
-#  along with this program.  If not, see <http://www.gnu.org/licenses/>.
-#  All rights reserved.
-#  ***** GPL LICENSE BLOCK *****
+#  along with this program; if not, write to the Free Software Foundation,
+#  Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+#
+# ##### END GPL LICENSE BLOCK #####
 
 bl_info = {
     "name": "Export Autocad DXF Format (.dxf)",
@@ -28,20 +29,35 @@ bl_info = {
     "category": "Import-Export",
 }
 
+if "bpy" in locals():
+    from importlib import reload
+    reload(operator)
+    del reload
 
 import bpy
-from .operator import DXFExporter
+from . import operator
 
 def menu_func(self, context):
-    self.layout.operator(DXFExporter.bl_idname, text="Autocad (.dxf)")
+    self.layout.operator(operator.DXFExporter.bl_idname, text="Autocad (.dxf)")
+
+classes = (
+    operator.DXFExporter,
+)
 
 def register():
-    bpy.utils.register_module(__name__)
     bpy.types.INFO_MT_file_export.append(menu_func)
 
+    from bpy.utils import register_class
+    for cls in classes:
+        register_class(cls)
+
+
 def unregister():
-    bpy.utils.unregister_module(__name__)
     bpy.types.INFO_MT_file_export.remove(menu_func)
 
+    from bpy.utils import unregister_class
+    for cls in reversed(classes):
+        unregister_class(cls)
+
 if __name__ == "__main__":
     register()
diff --git a/io_export_dxf/export_dxf.py b/io_export_dxf/export_dxf.py
index a17f50f..b6e5153 100644
--- a/io_export_dxf/export_dxf.py
+++ b/io_export_dxf/export_dxf.py
@@ -1,3 +1,21 @@
+# ##### BEGIN GPL LICENSE BLOCK #####
+#
+#  This program is free software; you can redistribute it and/or
+#  modify it under the terms of the GNU General Public License
+#  as published by the Free Software Foundation; either version 2
+#  of the License, or (at your option) any later version.
+#
+#  This program is distributed in the hope that it will be useful,
+#  but WITHOUT ANY WARRANTY; without even the implied warranty of
+#  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+#  GNU General Public License for more details.
+#
+#  You should have received a copy of the GNU General Public License
+#  along with this program; if not, write to the Free Software Foundation,
+#  Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+#
+# ##### END GPL LICENSE BLOCK #####
+
 import os
 import mathutils
 
diff --git a/io_export_dxf/operator.py b/io_export_dxf/operator.py
index 3ba7de6..a2d9dcf 100644
--- a/io_export_dxf/operator.py
+++ b/io_export_dxf/operator.py
@@ -1,7 +1,27 @@
-
+# ##### BEGIN GPL LICENSE BLOCK #####
+#
+#  This program is free software; you can redistribute it and/or
+#  modify it under the terms of the GNU General Public License
+#  as published by the Free Software Foundation; either version 2
+#  of the License, or (at your option) any later version.
+#
+#  This program is distributed in the hope that it will be useful,
+#  but WITHOUT ANY WARRANTY; without even the implied warranty of
+#  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+#  GNU General Public License for more details.
+#
+#  You should have received a copy of the GNU General Public License
+#  along with this program; if not, write to the Free Software Foundation,
+#  Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+#
+# ##### END GPL LICENSE BLOCK #####
 
 import bpy
-from bpy.props import StringProperty, EnumProperty, BoolProperty
+from bpy.props import (
+    BoolProperty,
+    EnumProperty,
+    StringProperty,
+)
 
 class DXFExporter(bpy.types.Operator):
     """



More information about the Bf-extensions-cvs mailing list