From e3dc726c262be19e0c747c02a35207971f9987b6 Mon Sep 17 00:00:00 2001 From: Simon Lusenc Date: Wed, 8 Mar 2017 14:10:20 +0100 Subject: [PATCH] Release - 1.7.3 --- addon/io_scs_tools/__init__.py | 2 +- .../internals/containers/config.py | 4 +- addon/io_scs_tools/operators/scene.py | 7 ++-- addon/io_scs_tools/utils/path.py | 37 +++++++++++++++++++ 4 files changed, 43 insertions(+), 7 deletions(-) diff --git a/addon/io_scs_tools/__init__.py b/addon/io_scs_tools/__init__.py index dda97aa..8ef9ff9 100644 --- a/addon/io_scs_tools/__init__.py +++ b/addon/io_scs_tools/__init__.py @@ -22,7 +22,7 @@ "name": "SCS Tools", "description": "Setup models, Import-Export SCS data format", "author": "Simon Lusenc (50keda), Milos Zajic (4museman)", - "version": (1, 7, "785c749"), + "version": (1, 7, "0bc527c"), "blender": (2, 78, 0), "location": "File > Import-Export", "wiki_url": "http://modding.scssoft.com/wiki/Documentation/Tools/SCS_Blender_Tools", diff --git a/addon/io_scs_tools/internals/containers/config.py b/addon/io_scs_tools/internals/containers/config.py index d9f78b6..161577c 100644 --- a/addon/io_scs_tools/internals/containers/config.py +++ b/addon/io_scs_tools/internals/containers/config.py @@ -575,7 +575,7 @@ def fill_import_section(): """Fills up "Import" section.""" section = _SectionData("Import") section.props.append(("ImportScale", _property_utils.get_by_type(bpy.types.GlobalSCSProps.import_scale))) - section.props.append(("PreservePathForExport", _property_utils.get_by_type(bpy.types.GlobalSCSProps.import_preserve_path_for_export))) + section.props.append(("PreservePathForExport", int(_property_utils.get_by_type(bpy.types.GlobalSCSProps.import_preserve_path_for_export)))) section.props.append(("ImportPimFile", int(_property_utils.get_by_type(bpy.types.GlobalSCSProps.import_pim_file)))) section.props.append(("UseWelding", int(_property_utils.get_by_type(bpy.types.GlobalSCSProps.import_use_welding)))) section.props.append(("WeldingPrecision", int(_property_utils.get_by_type(bpy.types.GlobalSCSProps.import_welding_precision)))) @@ -605,7 +605,7 @@ def fill_export_section(): section.props.append(("ExportVertexColorType7", _property_utils.get_by_type(bpy.types.GlobalSCSProps.export_vertex_color_type_7))) # section.props.append(("ExportAnimFile", info.get_default_prop_value(bpy.types.GlobalSCSProps.export_anim_file))) section.props.append(("ExportPimFile", int(_property_utils.get_by_type(bpy.types.GlobalSCSProps.export_pim_file)))) - section.props.append(("OutputType", _property_utils.get_by_type(bpy.types.GlobalSCSProps.output_type))) + section.props.append(("OutputType", _property_utils.get_by_type(bpy.types.GlobalSCSProps.export_output_type))) section.props.append(("ExportPitFile", int(_property_utils.get_by_type(bpy.types.GlobalSCSProps.export_pit_file)))) section.props.append(("ExportPicFile", int(_property_utils.get_by_type(bpy.types.GlobalSCSProps.export_pic_file)))) section.props.append(("ExportPipFile", int(_property_utils.get_by_type(bpy.types.GlobalSCSProps.export_pip_file)))) diff --git a/addon/io_scs_tools/operators/scene.py b/addon/io_scs_tools/operators/scene.py index 364b93c..79d6784 100644 --- a/addon/io_scs_tools/operators/scene.py +++ b/addon/io_scs_tools/operators/scene.py @@ -21,7 +21,6 @@ import bpy import os import subprocess -from distutils import dir_util from hashlib import sha1 from sys import platform from bpy.props import StringProperty, CollectionProperty, EnumProperty, IntProperty, BoolProperty @@ -872,7 +871,7 @@ def execute(self, context): for root, dirs, files in os.walk(rsrc_path): for folder in dirs: - dir_util.remove_tree(root + os.sep + folder) + _path_utils.rmtree(root + os.sep + folder) for file in files: os.remove(root + os.sep + file) @@ -1271,7 +1270,7 @@ def execute(self, context): # delete mod folder if previously no archive option was used mod_filepath_as_dir = mod_filepath[:-4] if os.path.isdir(mod_filepath_as_dir): - dir_util.remove_tree(mod_filepath_as_dir) + _path_utils.rmtree(mod_filepath_as_dir) # make sure previous ZIP file is not present if os.path.isfile(mod_filepath): @@ -1286,7 +1285,7 @@ def execute(self, context): if not os.path.isdir(curr_dir): continue - dir_util.copy_tree(curr_dir, mod_filepath_as_dir) + _path_utils.copytree(curr_dir, mod_filepath_as_dir) self.report({'INFO'}, "Packing done, mod copied to: '%s'" % mod_filepath_as_dir) diff --git a/addon/io_scs_tools/utils/path.py b/addon/io_scs_tools/utils/path.py index 3a5d9a1..e783610 100644 --- a/addon/io_scs_tools/utils/path.py +++ b/addon/io_scs_tools/utils/path.py @@ -22,6 +22,7 @@ import bpy import os import subprocess +import shutil from sys import platform from io_scs_tools.utils.printout import lprint from io_scs_tools.utils import get_scs_globals as _get_scs_globals @@ -746,3 +747,39 @@ def ensure_symlink(src, dest): subprocess.check_call(["mklink", "/J", dest, src], shell=True) else: os.symlink(src, dest) + + +def rmtree(src): + """Remove directory or file. In case of directory all the content inside will also be removed. + :param src: source path which should be recursively removed + :type src: str + """ + try: + shutil.rmtree(src) + except shutil.Error: + lprint("E Problem removing directory: %r", (readable_norm(src),)) + + +def copytree(src, dest): + """Recursively copy whole tree of given source path to destination path. + If directories doesn't exists they will be created. + If directores/files exists then content will be overwritten. + + :param src: source path to copy from + :type src: str + :param dest: destination path to copy to + :type dest: str + """ + + for root, dirs, files in os.walk(src): + if not os.path.isdir(root): + os.makedirs(root) + + for file in files: + rel_path = root.replace(src, '').lstrip(os.sep) + dest_path = os.path.join(dest, rel_path) + + if not os.path.isdir(dest_path): + os.makedirs(dest_path) + + shutil.copyfile(os.path.join(root, file), os.path.join(dest_path, file))