diff --git a/photoshop/api/action_manager/_main_types/action_descriptor.py b/photoshop/api/action_manager/_main_types/action_descriptor.py index f27d5098..eafd4772 100644 --- a/photoshop/api/action_manager/_main_types/action_descriptor.py +++ b/photoshop/api/action_manager/_main_types/action_descriptor.py @@ -1,6 +1,7 @@ # Import built-in modules from abc import ABC from abc import abstractclassmethod +import sys from typing import Any from ..utils import str2id @@ -53,7 +54,9 @@ def dump(self) -> dict: """Convert an ActionDescriptor to a python object.""" # This is a dict comprehension. ddict = {"_classID": self.classID} - ddict.update({key: (value.dump() if hasattr(value := self.uget(key), "dump") else value) for key in self}) # noqa + ddict.update( + {key: (value.dump() if hasattr(value := self.uget(key), "dump") else value) for key in self} + ) # noqa return ddict def _unpacker(self) -> tuple: @@ -65,9 +68,10 @@ def _unpacker(self) -> tuple: # Monkey patching for py37 -import sys -if sys.version.split('(')[0].split('.')[1] <= 7: + +if sys.version.split("(")[0].split(".")[1] <= 7: + @abstractclassmethod def load(cls, adict: dict, namespace: dict): # pass globals() for namespace clsid = adict["_classID"] if "_classID" in adict else None @@ -83,7 +87,10 @@ def dump(self) -> dict: """Convert an ActionDescriptor to a python object.""" # This is a dict comprehension. ddict = {"_classID": self.classID} - ddict.update({key: (self.uget(key).dump() if hasattr(self.uget(key), "dump") else self.uget(key)) for key in self}) - return ddict + ddict.update( + {key: (self.uget(key).dump() if hasattr(self.uget(key), "dump") else self.uget(key)) for key in self} + ) + return ddict + ActionDescriptor.load = load - ActionDescriptor.dump = dump \ No newline at end of file + ActionDescriptor.dump = dump diff --git a/photoshop/api/action_manager/_main_types/action_list.py b/photoshop/api/action_manager/_main_types/action_list.py index aa22fa3b..61bbbf3b 100644 --- a/photoshop/api/action_manager/_main_types/action_list.py +++ b/photoshop/api/action_manager/_main_types/action_list.py @@ -1,6 +1,7 @@ # Import built-in modules from abc import ABC from abc import abstractclassmethod +import sys from typing import Any from ._type_mapper import pack @@ -59,9 +60,10 @@ def dump(self) -> list: # Monkey patching for py37 -import sys -if sys.version.split('(')[0].split('.')[1] <= 7: + +if sys.version.split("(")[0].split(".")[1] <= 7: + @abstractclassmethod def load(cls, alist: list, namespace: dict): # pass globals() for namespace new = cls() diff --git a/photoshop/api/action_manager/js_converter/convert.py b/photoshop/api/action_manager/js_converter/convert.py index e96df83f..683bd3d8 100644 --- a/photoshop/api/action_manager/js_converter/convert.py +++ b/photoshop/api/action_manager/js_converter/convert.py @@ -5,6 +5,7 @@ # Import built-in modules import json +import sys from ..desc_value_types import Enumerated from ..desc_value_types import TypeID @@ -82,27 +83,36 @@ def parseref(tdict): plist = ["!ref"] plist.extend( [ - (str2refgetpacker[val["type"]](e) if type(val := e["Value"]) == dict else str2refgetpacker["default"](e)) # noqa + ( + str2refgetpacker[val["type"]](e) if type(val := e["Value"]) == dict else str2refgetpacker["default"](e) + ) # noqa for e in d2l ] ) return plist + # Monkey patching for py37 -import sys -if sys.version.split('(')[0].split('.')[1] <= 7: + +if sys.version.split("(")[0].split(".")[1] <= 7: + def parseref(tdict): d2l = [tdict[str(i)] for i in range(tdict["len"])] plist = ["!ref"] plist.extend( [ - (str2refgetpacker[e["Value"]["type"]](e) if type(e["Value"]) == dict else str2refgetpacker["default"](e)) + ( + str2refgetpacker[e["Value"]["type"]](e) + if type(e["Value"]) == dict + else str2refgetpacker["default"](e) + ) for e in d2l ] ) return plist + def json2obj(jsont): obj_init = json.loads(jsont) obj_desc = parsedict(obj_init["ActionDescriptor"]) if "ActionDescriptor" in obj_init else None