diff --git a/operators/osl_ops.py b/operators/osl_ops.py index f5cb23a6..fab154f3 100644 --- a/operators/osl_ops.py +++ b/operators/osl_ops.py @@ -51,7 +51,7 @@ def execute(self, context): if node.script is not None: # Save existing connections and parameters - for key, value in node.items(): + for key, value in list(node.items()): temp_values[key] = value for input_iter in node.inputs: if input_iter.is_linked: @@ -91,12 +91,12 @@ def execute(self, context): setattr(new_node, "node_type", "osl_script") # Copy variables to new node - for variable, value in temp_values.items(): + for variable, value in list(temp_values.items()): if variable in dir(new_node): setattr(new_node, variable, value) # Recreate node connections - for connection, sockets in output_connections.items(): + for connection, sockets in list(output_connections.items()): for output in new_node.outputs: if output.bl_idname == connection: output_socket_class = output @@ -104,7 +104,7 @@ def execute(self, context): for output_connection in sockets: node_tree.links.new(output_socket_class, output_connection) - for connection, sockets in input_connections.items(): + for connection, sockets in list(input_connections.items()): for in_socket in new_node.inputs: if in_socket.bl_idname == connection: input_socket_class = in_socket @@ -129,3 +129,4 @@ def register(): def unregister(): util.safe_unregister_class(ASMAT_OT_compile_script) + diff --git a/preferences.py b/preferences.py index 959732c2..75ff1582 100644 --- a/preferences.py +++ b/preferences.py @@ -112,7 +112,7 @@ def draw(self, context): lib_info = asr.get_third_parties_versions() - for key, item in lib_info.items(): + for key, item in list(lib_info.items()): box.label(text=f"{key} version {item}") diff --git a/properties/nodes.py b/properties/nodes.py index bcc09784..b02ee4bb 100644 --- a/properties/nodes.py +++ b/properties/nodes.py @@ -75,9 +75,9 @@ def draw_buttons(self, context, layout): param_section = "" for x in self.input_params: if x['type'] != 'pointer': - if 'hide_ui' in x.keys() and x['hide_ui'] is True: + if 'hide_ui' in list(x.keys()) and x['hide_ui'] is True: continue - if 'section' in x.keys(): + if 'section' in list(x.keys()): if x['section'] != param_section and x['section'] is not None: param_section = x['section'] icon = 'DISCLOSURE_TRI_DOWN' if getattr(self, param_section) else 'DISCLOSURE_TRI_RIGHT' @@ -111,7 +111,7 @@ def draw_buttons(self, context, layout): def draw_buttons_ext(self, context, layout): for x in self.input_params: if x['type'] != 'pointer': - if 'hide_ui' in x.keys() and x['hide_ui'] is True: + if 'hide_ui' in list(x.keys()) and x['hide_ui'] is True: continue elif x['name'] in self.filepaths: layout.template_ID_preview(self, x['name'], open="image.open") @@ -153,9 +153,9 @@ def draw_buttons(self, context, layout): if hasattr(self, "input_params"): for x in self.input_params: if x['type'] != 'pointer': - if 'hide_ui' in x.keys() and x['hide_ui'] is True: + if 'hide_ui' in list(x.keys()) and x['hide_ui'] is True: continue - if 'section' in x.keys(): + if 'section' in list(x.keys()): if x['section'] != param_section and x['section'] is not None: param_section = x['section'] icon = 'DISCLOSURE_TRI_DOWN' if getattr(self, param_section) else 'DISCLOSURE_TRI_RIGHT' @@ -187,7 +187,7 @@ def draw_buttons_ext(self, context, layout): if hasattr(self, "input_params"): for x in self.input_params: if x['type'] != 'pointer': - if 'hide_ui' in x.keys() and x['hide_ui'] is True: + if 'hide_ui' in list(x.keys()) and x['hide_ui'] is True: continue elif x['name'] in self.filepaths: layout.template_ID_preview(self, x['name'], open="image.open") @@ -249,7 +249,7 @@ def node_categories(osl_nodes): from ..translators.cycles_shaders import cycles_nodes - cyc_nodes = [nodeitems_utils.NodeItem(key) for key in cycles_nodes.keys()] + cyc_nodes = [nodeitems_utils.NodeItem(key) for key in list(cycles_nodes.keys())] for node in osl_nodes: node_item = nodeitems_utils.NodeItem(node[0]) @@ -327,7 +327,7 @@ def register(): def unregister(): - for pcoll in preview_collections.values(): + for pcoll in list(preview_collections.values()): bpy.utils.previews.remove(pcoll) preview_collections.clear() @@ -337,3 +337,4 @@ def unregister(): for cls in reversed(classes): util.safe_unregister_class(cls) + diff --git a/properties/scene.py b/properties/scene.py index 6b30461b..e5a6f5ce 100644 --- a/properties/scene.py +++ b/properties/scene.py @@ -785,3 +785,4 @@ def unregister(): for cls in reversed(classes): util.safe_unregister_class(cls) + diff --git a/render/__init__.py b/render/__init__.py index 652e9063..e082ecbe 100644 --- a/render/__init__.py +++ b/render/__init__.py @@ -147,7 +147,7 @@ def view_draw(self, context, depsgraph): # Check if view camera model has changes updates = self.__interactive_scene_translator.check_view_window(depsgraph, context) - if True in updates.values(): + if True in list(updates.values()): self.__pause_rendering() self.__interactive_scene_translator.update_view_window(updates, depsgraph) self.__restart_interactive_render() @@ -445,3 +445,4 @@ def register(): def unregister(): safe_unregister_class(RenderAppleseed) + diff --git a/scripts/blenderseed.package.py b/scripts/blenderseed.package.py index 540db6a0..d5ac83ee 100644 --- a/scripts/blenderseed.package.py +++ b/scripts/blenderseed.package.py @@ -27,7 +27,7 @@ # THE SOFTWARE. # -from __future__ import print_function + from distutils import archive_util, dir_util from xml.etree.ElementTree import ElementTree import argparse @@ -43,7 +43,7 @@ import sys import time import traceback -import urllib +import urllib.request, urllib.parse, urllib.error #-------------------------------------------------------------------------------------------------- @@ -57,30 +57,33 @@ #-------------------------------------------------------------------------------------------------- # Utility functions. #-------------------------------------------------------------------------------------------------- - -GREEN_CHECKMARK = u"{0}\u2713{1}".format(colorama.Style.BRIGHT + colorama.Fore.GREEN, colorama.Style.RESET_ALL) -RED_CROSSMARK = u"{0}\u2717{1}".format(colorama.Style.BRIGHT + colorama.Fore.RED, colorama.Style.RESET_ALL) +GREEN_CHECKMARK = f"{colorama.Style.BRIGHT}{colorama.Fore.GREEN}\u2713{colorama.Style.RESET_ALL}" +RED_CROSSMARK = f"{colorama.Style.BRIGHT}{colorama.Fore.RED}\u2717{colorama.Style.RESET_ALL}" def trace(message): # encode('utf-8') is required to support output redirection to files or pipes. - print(u" {0}{1}{2}".format(colorama.Style.DIM + colorama.Fore.WHITE, message, colorama.Style.RESET_ALL).encode('utf-8')) + print(f" {colorama.Style.DIM}{colorama.Fore.WHITE}{message}{colorama.Style.RESET_ALL}".encode('utf-8')) + def info(message): - print(u" {0}".format(message).encode('utf-8')) + print(f" {message}".encode('utf-8')) + def progress(message): - print(u" {0}...".format(message).encode('utf-8')) + print(f" {message}...".encode('utf-8')) + def warning(message): - print(u" {0}Warning: {1}.{2}".format(colorama.Style.BRIGHT + colorama.Fore.MAGENTA, message, colorama.Style.RESET_ALL).encode('utf-8')) + print(f" {colorama.Style.BRIGHT}{colorama.Fore.MAGENTA}{message}{colorama.Style.RESET_ALL}Warning: {message}.{colorama.Style.RESET_ALL}".encode('utf-8')) + def fatal(message): - print(u"{0}Fatal: {1}. Aborting.{2}".format(colorama.Style.BRIGHT + colorama.Fore.RED, message, colorama.Style.RESET_ALL).encode('utf-8')) + print(f"{colorama.Style.BRIGHT}{colorama.Fore.RED}Fatal: {message}. Aborting.{colorama.Style.RESET_ALL}".encode('utf-8')) if sys.exc_info()[0]: print(traceback.format_exc()) sys.exit(1) @@ -190,7 +193,7 @@ def __load_values(self, tree): def __get_required(self, tree, key): value = tree.findtext(key) if value is None: - fatal("Missing value \"{0}\" in configuration file".format(key)) + fatal(f"Missing value \"{key}\" in configuration file") return value @@ -291,7 +294,7 @@ def download_settings_files(self): safe_make_directory(settings_dir) for file in ["appleseed.cli.xml"]: - urllib.urlretrieve( + urllib.request.urlretrieve( "https://raw.githubusercontent.com/appleseedhq/appleseed/master/sandbox/settings/{0}".format(file), os.path.join(settings_dir, file)) @@ -319,17 +322,17 @@ def clean_stage(self): def build_final_zip_file(self): progress("Building final zip file from staging directory") - package_name = "blenderseed-{0}-{1}-{2}".format(self.package_version, self.settings.platform, self.build_date) + package_name = f"blenderseed-{self.package_version}-{self.settings.platform}-{self.build_date}" package_path = os.path.join(self.settings.output_dir, package_name) archive_util.make_zipfile(package_path, "blenderseed") - info("Package path: {0}".format(package_path + ".zip")) + info(f"Package path: {package_path}.zip") def remove_stage(self): progress("Deleting staging directory") safe_delete_directory("blenderseed") def run(self, cmdline): - trace("Running command line: {0}".format(cmdline)) + trace(f"Running command line: {cmdline}") os.system(cmdline) def run_subprocess(self, cmdline): @@ -406,12 +409,12 @@ def copy_dependencies(self): # Print dependencies. trace(" Dependencies:") for lib in all_libs: - trace(" {0}".format(lib)) + trace(f" {lib}") # Copy needed libs to lib directory. for lib in all_libs: if True: - trace(" Copying {0} to {1}...".format(lib, lib_dir)) + trace(f" Copying {lib} to {lib_dir}...") shutil.copy(lib, lib_dir) def post_process_package(self): @@ -453,7 +456,7 @@ def __change_library_paths_in_executables(self): # Can be used on executables and dynamic libraries. def __change_library_paths_in_binary(self, bin_path): - progress("Patching {0}".format(bin_path)) + progress(f"Patching {bin_path}") bin_dir = os.path.dirname(bin_path) lib_dir = os.path.join(self.settings.root_dir, "appleseed", "lib") path_to_appleseed_lib = os.path.relpath(lib_dir, bin_dir) @@ -461,15 +464,17 @@ def __change_library_paths_in_binary(self, bin_path): for lib_path in self.__get_dependencies_for_file(bin_path, fix_paths=False): lib_name = os.path.basename(lib_path) if path_to_appleseed_lib == ".": - self.__change_library_path(bin_path, lib_path, "@loader_path/{0}".format(lib_name)) + self.__change_library_path(bin_path, lib_path, f"@loader_path/{lib_name}") else: - self.__change_library_path(bin_path, lib_path, "@loader_path/{0}/{1}".format(path_to_appleseed_lib, lib_name)) + self.__change_library_path(bin_path, lib_path, f"@loader_path/{path_to_appleseed_lib}/{lib_name}") + def __set_library_id(self, target, name): - self.run('install_name_tool -id "{0}" {1}'.format(name, target)) + self.run(f'install_name_tool -id "{name}" {target}') def __change_library_path(self, target, old, new): - self.run('install_name_tool -change "{0}" "{1}" {2}'.format(old, new, target)) + self.run(f'install_name_tool -change "{old}" "{new}" {target}') + def __get_dependencies_for_file(self, filepath, fix_paths=True): filename = os.path.basename(filepath) @@ -479,15 +484,17 @@ def __get_dependencies_for_file(self, filepath, fix_paths=True): if True: trace("Gathering dependencies for file") - trace(" {0}".format(filepath)) + trace(f" {filepath}") trace("with @loader_path set to") - trace(" {0}".format(loader_path)) + trace(f" {loader_path}") trace("and @rpath hardcoded to") - trace(" {0}".format(rpath)) + trace(f" {rpath}") + returncode, out, err = self.run_subprocess(["otool", "-L", filepath]) if returncode != 0: - fatal("Failed to invoke otool(1) to get dependencies for {0}: {1}".format(filepath, err)) + fatal(f"Failed to invoke otool(1) to get dependencies for {filepath}: {err}") + libs = set() @@ -501,7 +508,7 @@ def __get_dependencies_for_file(self, filepath, fix_paths=True): # Parse the line. m = re.match(r"(.*) \(compatibility version .*, current version .*\)", line) if not m: - fatal("Failed to parse line from otool(1) output: " + line) + fatal(f"Failed to parse line from otool(1) output: {line}") lib = m.group(1) # Ignore self-references (why do these happen?). @@ -530,24 +537,25 @@ def __get_dependencies_for_file(self, filepath, fix_paths=True): if not os.path.exists(candidate): candidate = os.path.join("/usr/local/lib/", lib) if os.path.exists(candidate): - info("Resolved relative dependency {0} as {1}".format(lib, candidate)) + info(f"Resolved relative dependency {lib} as {candidate}") lib = candidate libs.add(lib) if True: - trace("Dependencies for file {0}:".format(filepath)) + trace(f"Dependencies for file {filepath}:") for lib in libs: if os.path.isfile(lib): - trace(u" {0} {1}".format(GREEN_CHECKMARK, lib)) + trace(f" {GREEN_CHECKMARK} {lib}") else: - trace(u" {0} {1}".format(RED_CROSSMARK, lib)) + trace(f" {RED_CROSSMARK} {lib}") + # Don't check for missing dependencies if we didn't attempt to fix them. if fix_paths: for lib in libs: if not os.path.isfile(lib): - fatal("Dependency {0} could not be found on disk".format(lib)) + fatal(f"Dependency {lib} could not be found on disk") return libs @@ -652,7 +660,7 @@ def __is_system_lib(self, lib): def __get_dependencies_for_file(self, filepath): returncode, out, err = self.run_subprocess(["ldd", filepath]) if returncode != 0: - fatal("Failed to invoke ldd(1) to get dependencies for {0}: {1}".format(filepath, err)) + fatal(f"Failed to invoke ldd(1) to get dependencies for {filepath}: {err}") libs = set() diff --git a/scripts/runtestsuite/png.py b/scripts/runtestsuite/png.py index f80923aa..0378f697 100644 --- a/scripts/runtestsuite/png.py +++ b/scripts/runtestsuite/png.py @@ -143,11 +143,12 @@ """ # http://www.python.org/doc/2.2.3/whatsnew/node5.html -from __future__ import generators + __version__ = "0.0.16" from array import array +from functools import reduce try: # See :pyver:old import itertools except ImportError: @@ -188,7 +189,7 @@ def group(s, n): # See http://www.python.org/doc/2.6/library/functions.html#zip - return zip(*[iter(s)]*n) + return list(zip(*[iter(s)]*n)) def isarray(x): """Same as ``isinstance(x, array)`` except on Python 2.2, where it @@ -746,15 +747,15 @@ def extend(sl): a.extend([0]*int(extra)) # Pack into bytes l = group(a, spb) - l = map(lambda e: reduce(lambda x,y: - (x << self.bitdepth) + y, e), l) + l = [reduce(lambda x,y: + (x << self.bitdepth) + y, e) for e in l] data.extend(l) if self.rescale: oldextend = extend factor = \ float(2**self.rescale[1]-1) / float(2**self.rescale[0]-1) def extend(sl): - oldextend(map(lambda x: int(round(factor*x)), sl)) + oldextend([int(round(factor*x)) for x in sl]) # Build the first row, testing mostly to see if we need to # changed the extend function to cope with NumPy integer types @@ -769,7 +770,7 @@ def extend(sl): # :todo: Certain exceptions in the call to ``.next()`` or the # following try would indicate no row data supplied. # Should catch. - i,row = enumrows.next() + i,row = next(enumrows) try: # If this fails... extend(row) @@ -779,7 +780,7 @@ def extend(sl): # types, there are probably lots of other, unknown, "nearly" # int types it works for. def wrapmapint(f): - return lambda sl: f(map(int, sl)) + return lambda sl: f(list(map(int, sl))) extend = wrapmapint(extend) del wrapmapint extend(row) @@ -1225,7 +1226,7 @@ def from_array(a, mode=None, info={}): # first row, which requires that we take a copy of its iterator. # We may also need the first row to derive width and bitdepth. a,t = itertools.tee(a) - row = t.next() + row = next(t) del t try: row[0][0] @@ -1626,12 +1627,12 @@ def asvalues(raw): spb = 8//self.bitdepth out = array('B') mask = 2**self.bitdepth - 1 - shifts = map(self.bitdepth.__mul__, reversed(range(spb))) + shifts = list(map(self.bitdepth.__mul__, reversed(list(range(spb))))) for o in raw: - out.extend(map(lambda i: mask&(o>>i), shifts)) + out.extend([mask&(o>>i) for i in shifts]) return out[:width] - return itertools.imap(asvalues, rows) + return map(asvalues, rows) def serialtoflat(self, bytes, width=None): """Convert serial format (byte stream) pixel data to flat row @@ -1651,7 +1652,7 @@ def serialtoflat(self, bytes, width=None): spb = 8//self.bitdepth out = array('B') mask = 2**self.bitdepth - 1 - shifts = map(self.bitdepth.__mul__, reversed(range(spb))) + shifts = list(map(self.bitdepth.__mul__, reversed(list(range(spb))))) l = width for o in bytes: out.extend([(mask&(o>>s)) for s in shifts][:l]) @@ -1882,7 +1883,7 @@ def iteridat(): while True: try: type, data = self.chunk(lenient=lenient) - except ValueError, e: + except ValueError as e: raise ChunkError(e.args[0]) if type == 'IEND': # http://www.w3.org/TR/PNG/#11IEND @@ -1920,7 +1921,7 @@ def iterdecomp(idat): arraycode = 'BH'[self.bitdepth>8] # Like :meth:`group` but producing an array.array object for # each row. - pixels = itertools.imap(lambda *row: array(arraycode, row), + pixels = map(lambda *row: array(arraycode, row), *[iter(self.deinterlace(raw))]*self.width*self.planes) else: pixels = self.iterboxed(self.iterstraight(raw)) @@ -1975,7 +1976,7 @@ def palette(self, alpha='natural'): if self.trns or alpha == 'force': trns = array('B', self.trns or '') trns.extend([255]*(len(plte)-len(trns))) - plte = map(operator.add, plte, group(trns, 1)) + plte = list(map(operator.add, plte, group(trns, 1))) return plte def asDirect(self): @@ -2032,7 +2033,7 @@ def asDirect(self): plte = self.palette() def iterpal(pixels): for row in pixels: - row = map(plte.__getitem__, row) + row = list(map(plte.__getitem__, row)) yield array('B', itertools.chain(*row)) pixels = iterpal(pixels) elif self.trns: @@ -2057,11 +2058,11 @@ def itertrns(pixels): # True/False to 0/maxval (by multiplication), # and add it as the extra channel. row = group(row, planes) - opa = map(it.__ne__, row) - opa = map(maxval.__mul__, opa) - opa = zip(opa) # convert to 1-tuples + opa = list(map(it.__ne__, row)) + opa = list(map(maxval.__mul__, opa)) + opa = list(zip(opa)) # convert to 1-tuples yield array(typecode, - itertools.chain(*map(operator.add, row, opa))) + itertools.chain(*list(map(operator.add, row, opa)))) pixels = itertrns(pixels) targetbitdepth = None if self.sbit: @@ -2079,7 +2080,7 @@ def itertrns(pixels): meta['bitdepth'] = targetbitdepth def itershift(pixels): for row in pixels: - yield map(shift.__rrshift__, row) + yield list(map(shift.__rrshift__, row)) pixels = itershift(pixels) return x,y,pixels,meta @@ -2096,7 +2097,7 @@ def asFloat(self, maxval=1.0): factor = float(maxval)/float(sourcemaxval) def iterfloat(): for row in pixels: - yield map(factor.__mul__, row) + yield list(map(factor.__mul__, row)) return x,y,iterfloat(),info def _as_rescale(self, get, targetbitdepth): @@ -2109,7 +2110,7 @@ def _as_rescale(self, get, targetbitdepth): meta['bitdepth'] = targetbitdepth def iterscale(): for row in pixels: - yield map(lambda x: int(round(x*factor)), row) + yield [int(round(x*factor)) for x in row] if maxval == targetmaxval: return width, height, pixels, meta else: @@ -2310,7 +2311,7 @@ def extend(self, extension): # Expect to get here on Python 2.2 def array(typecode, init=()): if type(init) == str: - return map(ord, init) + return list(map(ord, init)) return list(init) # Further hacks to get it limping along on Python 2.2 @@ -2709,7 +2710,7 @@ def _main(argv): # care about TUPLTYPE. greyscale = depth <= 2 pamalpha = depth in (2,4) - supported = map(lambda x: 2**x-1, range(1,17)) + supported = [2**x-1 for x in range(1,17)] try: mi = supported.index(maxval) except ValueError: @@ -2746,5 +2747,6 @@ def _main(argv): if __name__ == '__main__': try: _main(sys.argv) - except Error, e: - print >>sys.stderr, e + except Error as e: + print(e, file=sys.stderr) + diff --git a/scripts/runtestsuite/runtestsuite.py b/scripts/runtestsuite/runtestsuite.py index 3894bd71..3c001f7d 100644 --- a/scripts/runtestsuite/runtestsuite.py +++ b/scripts/runtestsuite/runtestsuite.py @@ -27,8 +27,8 @@ # THE SOFTWARE. # -from __future__ import division -from __future__ import print_function + + import argparse import colorama import datetime @@ -36,7 +36,7 @@ import png import subprocess import sys -import urllib +import urllib.request, urllib.parse, urllib.error #-------------------------------------------------------------------------------------------------- @@ -76,7 +76,7 @@ def walk(directory, recursive): for dirpath, dirnames, filenames in os.walk(directory): yield dirpath, dirnames, filenames else: - yield os.walk(directory).next() + yield next(os.walk(directory)) def should_skip(path): @@ -201,10 +201,10 @@ def report_simple_failure(self, scene, reference_filepath, output_filepath, log_ self.file.write(self.__render(self.simple_failure_template, {'project-path': scene, - 'ref-image-url': urllib.pathname2url(reference_filepath), - 'output-image-url': urllib.pathname2url(output_filepath), + 'ref-image-url': urllib.request.pathname2url(reference_filepath), + 'output-image-url': urllib.request.pathname2url(output_filepath), 'failure-reason': error_message, - 'log-file-url': urllib.pathname2url(log_filepath), + 'log-file-url': urllib.request.pathname2url(log_filepath), 'log-file-path': os.path.basename(log_filepath), 'update-command': command})) self.file.flush() @@ -217,11 +217,11 @@ def report_detailed_failure(self, scene, reference_filepath, output_filepath, lo self.file.write(self.__render(self.detailed_failure_template, {'project-path': scene, - 'ref-image-url': urllib.pathname2url(reference_filepath), - 'diff-image-url': urllib.pathname2url(diff_filepath) if diff_filepath is not None else "", - 'output-image-url': urllib.pathname2url(output_filepath), + 'ref-image-url': urllib.request.pathname2url(reference_filepath), + 'diff-image-url': urllib.request.pathname2url(diff_filepath) if diff_filepath is not None else "", + 'output-image-url': urllib.request.pathname2url(output_filepath), 'failure-reason': error_message, - 'log-file-url': urllib.pathname2url(log_filepath), + 'log-file-url': urllib.request.pathname2url(log_filepath), 'log-file-path': os.path.basename(log_filepath), 'max-abs-diff': max_diff, 'diff-comps-count': num_diff, @@ -242,7 +242,7 @@ def __write_footer(self): def __render(self, template, variables): html = template - for name, value in variables.iteritems(): + for name, value in variables.items(): html = html.replace('{' + name + '}', str(value)) return html diff --git a/translators/nodetree.py b/translators/nodetree.py index 5d934db8..784a6376 100644 --- a/translators/nodetree.py +++ b/translators/nodetree.py @@ -113,7 +113,7 @@ def __create_shadergroup(self, bl_scene, engine): parameters = dict() parameter_types = node.parameter_types - node_items = node.keys() + node_items = list(node.keys()) for key in node_items: if key in parameter_types: @@ -205,7 +205,7 @@ def __traverse_tree(self, node, tree_list, engine): for socket in node.inputs: if socket.is_linked: linked_node = socket.links[0].from_node - if linked_node.bl_idname in cycles_nodes.keys() or isinstance(linked_node, AppleseedOSLNode): + if linked_node.bl_idname in list(cycles_nodes.keys()) or isinstance(linked_node, AppleseedOSLNode): self.__traverse_tree(linked_node, tree_list, engine) else: logger.error(f"Node {linked_node.name} is not a node compatible with appleseed, stopping traversal") @@ -214,3 +214,4 @@ def __traverse_tree(self, node, tree_list, engine): tree_list.append(node) return tree_list + diff --git a/translators/scene.py b/translators/scene.py index 26ca1e2e..c87852bd 100644 --- a/translators/scene.py +++ b/translators/scene.py @@ -222,9 +222,9 @@ def translate_scene(self, engine, depsgraph, context=None): if self.__as_world_translator is not None: self.__as_world_translator.create_entities(depsgraph) - for obj, trans in materials_to_add.items(): + for obj, trans in list(materials_to_add.items()): trans.create_entities(depsgraph, engine) - for obj, trans in textures_to_add.items(): + for obj, trans in list(textures_to_add.items()): trans.create_entities(depsgraph) # Set initial position of all objects and lamps @@ -236,7 +236,7 @@ def translate_scene(self, engine, depsgraph, context=None): del objects_to_add[translator] # Create 3D entities - for obj, trans in objects_to_add.items(): + for obj, trans in list(objects_to_add.items()): trans.create_entities(depsgraph, len(self.__deform_times)) # Calculate additional steps for motion blur @@ -247,19 +247,19 @@ def translate_scene(self, engine, depsgraph, context=None): if self.__as_world_translator is not None: self.__as_world_translator.flush_entities(self.as_scene, self.as_main_assembly, self.as_project) - for obj, trans in objects_to_add.items(): + for obj, trans in list(objects_to_add.items()): trans.flush_entities(self.as_scene, self.as_main_assembly, self.as_project) - for obj, trans in materials_to_add.items(): + for obj, trans in list(materials_to_add.items()): trans.flush_entities(self.as_scene, self.as_main_assembly, self.as_project) - for obj, trans in textures_to_add.items(): + for obj, trans in list(textures_to_add.items()): trans.flush_entities(self.as_scene, self.as_main_assembly, self.as_project) # Transfer temp translators to main list - for bl_obj, translator in objects_to_add.items(): + for bl_obj, translator in list(objects_to_add.items()): self.__as_object_translators[bl_obj] = translator - for bl_obj, translator in materials_to_add.items(): + for bl_obj, translator in list(materials_to_add.items()): self.__as_material_translators[bl_obj] = translator - for bl_obj, translator in textures_to_add.items(): + for bl_obj, translator in list(textures_to_add.items()): self.__as_texture_translators[bl_obj] = translator self.__load_searchpaths() @@ -295,7 +295,7 @@ def update_scene(self, depsgraph, engine): for update in depsgraph.updates: # This one is easy. if isinstance(update.id, bpy.types.Material): - if update.id.original in self.__as_material_translators.keys(): + if update.id.original in list(self.__as_material_translators.keys()): self.__as_material_translators[update.id.original].update_material(depsgraph, engine) else: materials_to_add[update.id.original] = MaterialTranslator(update.id.original, @@ -303,7 +303,7 @@ def update_scene(self, depsgraph, engine): # Now comes agony and mental anguish. elif isinstance(update.id, bpy.types.Object): if update.id.type == 'MESH': - if update.id.original in self.__as_object_translators.keys(): + if update.id.original in list(self.__as_object_translators.keys()): if update.is_updated_geometry: self.__as_object_translators[update.id.original].update_obj_instance() object_updates.append(update.id.original) @@ -314,7 +314,7 @@ def update_scene(self, depsgraph, engine): self.__export_mode, self.__asset_handler) elif update.id.type == 'LIGHT': - if update.id.original in self.__as_object_translators.keys(): + if update.id.original in list(self.__as_object_translators.keys()): if update.is_updated_geometry: self.__as_object_translators[update.id.original].update_lamp(depsgraph, self.as_main_assembly, @@ -330,7 +330,7 @@ def update_scene(self, depsgraph, engine): self.__asset_handler) elif update.id.type == 'EMPTY' and update.id.appleseed.object_export == "archive_assembly": - if update.id.original in self.__as_object_translators.keys(): + if update.id.original in list(self.__as_object_translators.keys()): if update.is_updated_geometry: self.__as_object_translators[update.id.original].update_archive_ass(depsgraph) object_updates.append(update.id.original) @@ -373,25 +373,25 @@ def update_scene(self, depsgraph, engine): obj, inst_id = self.__get_instance_data(inst) if obj in recreate_instances: self.__as_object_translators[obj].add_instance_step(0.0, inst_id, inst.matrix_world) - elif obj in objects_to_add.keys(): + elif obj in list(objects_to_add.keys()): objects_to_add[obj].add_instance_step(0.0, inst_id, inst.matrix_world) # Create new materials. - for mat in materials_to_add.values(): + for mat in list(materials_to_add.values()): mat.create_entities(depsgraph, engine) # Create new objects. - for trans in objects_to_add.values(): + for trans in list(objects_to_add.values()): trans.create_entities(depsgraph, 0) for obj in recreate_instances: self.__as_object_translators[obj].flush_instances(self.as_main_assembly) - for mat_obj, trans in materials_to_add.items(): + for mat_obj, trans in list(materials_to_add.items()): trans.flush_entities(self.as_scene, self.as_main_assembly, self.as_project) self.__as_material_translators[mat_obj] = trans - for bl_obj, trans in objects_to_add.items(): + for bl_obj, trans in list(objects_to_add.items()): trans.flush_entities(self.as_scene, self.as_main_assembly, self.as_project) self.__as_object_translators[bl_obj] = trans @@ -814,7 +814,7 @@ def __calc_initial_positions(self, depsgraph, engine, objects_to_add): for inst in depsgraph.object_instances: if inst.show_self: obj, inst_id = self.__get_instance_data(inst) - if obj in objects_to_add.keys(): + if obj in list(objects_to_add.keys()): objects_to_add[obj].add_instance_step(0.0, inst_id, inst.matrix_world) def __calc_motion_steps(self, depsgraph, engine, objects_to_add): @@ -836,11 +836,11 @@ def __calc_motion_steps(self, depsgraph, engine, objects_to_add): for inst in depsgraph.object_instances: if inst.show_self: obj, inst_id = self.__get_instance_data(inst) - if obj in objects_to_add.keys(): + if obj in list(objects_to_add.keys()): objects_to_add[obj].add_instance_step(time, inst_id, inst.matrix_world) if time in self.__deform_times: - for translator in objects_to_add.values(): + for translator in list(objects_to_add.values()): translator.set_deform_key(time, depsgraph, index) engine.frame_set(self.__current_frame, subframe=0.0) diff --git a/utils/osl_utils.py b/utils/osl_utils.py index 8daa759e..ed587d6f 100644 --- a/utils/osl_utils.py +++ b/utils/osl_utils.py @@ -97,7 +97,7 @@ def update_sockets(self, context): # create output socket classes for out_socket in output_sockets: socket_name = "Appleseed{0}{1}".format(node['name'], out_socket['name'].capitalize()) - if 'label' in out_socket.keys(): + if 'label' in list(out_socket.keys()): socket_label = "{0}".format(out_socket['label']) else: socket_label = "{0}".format(out_socket['name'].strip("out_")) @@ -132,7 +132,7 @@ def update_sockets(self, context): # create input socket classes for param in input_params: - keys = param.keys() + keys = list(param.keys()) hide_ui = False @@ -205,7 +205,7 @@ def update_sockets(self, context): param_section = str() for param in input_params: - keys = param.keys() + keys = list(param.keys()) widget = "" minimum = None maximum = None @@ -487,3 +487,4 @@ def compile_osl_bytecode(compiler, script_block): code.close() return compiler.compile_buffer(source_code) + diff --git a/utils/path_util.py b/utils/path_util.py index 5acaa884..a36549f5 100644 --- a/utils/path_util.py +++ b/utils/path_util.py @@ -56,14 +56,15 @@ def load_appleseed_python_paths(): python_path = os.environ['APPLESEED_PYTHON_DIR'] else: python_path = os.path.join(get_appleseed_parent_dir_path(), 'lib') + if python_path != "": sys.path.append(python_path) - print("[appleseed] Python path set to: {0}".format(python_path)) + print("[appleseed] Python path set to:", python_path) if platform.system() == 'Windows': bin_dir = get_appleseed_bin_dir_path() os.environ['PATH'] += os.pathsep + bin_dir - print("[appleseed] Path to appleseed.dll is set to: {0}".format(bin_dir)) + print("[appleseed] Path to appleseed.dll is set to:", bin_dir) def get_osl_search_paths():