diff --git a/README.md b/README.md index 8715f932..bd999444 100644 --- a/README.md +++ b/README.md @@ -41,7 +41,7 @@ [![All Contributors](https://img.shields.io/badge/all_contributors-18-orange.svg?style=flat-square)](#contributors-) - +
Python API for Photoshop.
@@ -70,7 +70,7 @@ pip install photoshop_python_api ``` -Since it uses COM (Component Object Model) connect Photoshop, it can be used +Since it uses COM (Component Object Model) connect Photoshop, it can be used in any DCC software with a python interpreter. @@ -181,8 +181,8 @@ Contributions of any kind are welcome! how to get Photoshop program ID ------------------------------- ```PS> -Get-ChildItem "HKLM:\SOFTWARE\Classes" | - ?{ ($_.PSChildName -match "^[a-z]+\.[a-z]+(\.\d+)?$") -and ($_.GetSubKeyNames() -contains "CLSID") } | +Get-ChildItem "HKLM:\SOFTWARE\Classes" | + ?{ ($_.PSChildName -match "^[a-z]+\.[a-z]+(\.\d+)?$") -and ($_.GetSubKeyNames() -contains "CLSID") } | ?{ $_.PSChildName -match "Photoshop.Application" } | ft PSChildName ``` ![get_program_id](https://i.imgur.com/UwPN7qq.png) diff --git a/docs/gen_api_nav.py b/docs/gen_api_nav.py index 7b89f535..69c55d9c 100644 --- a/docs/gen_api_nav.py +++ b/docs/gen_api_nav.py @@ -1,10 +1,9 @@ """Plugin for generate API docs.""" - # Import built-in modules from pathlib import Path -# Import third-party modules import mkdocs_gen_files +# Import third-party modules def main(): diff --git a/docs/gen_examples.py b/docs/gen_examples.py index 04602901..45a110d6 100644 --- a/docs/gen_examples.py +++ b/docs/gen_examples.py @@ -1,13 +1,12 @@ """Plugin for generate API docs.""" - # Import built-in modules import os from pathlib import Path -# Import third-party modules -from jinja2 import Template import mkdocs_gen_files import stringcase +from jinja2 import Template +# Import third-party modules template = Template( @@ -22,11 +21,11 @@ ``` {% endfor %} -""" +""", ) -class Examples(object): +class Examples: def __init__(self, root: Path): self._root = root diff --git a/docs/index.md b/docs/index.md index 570681eb..a9478b81 100644 --- a/docs/index.md +++ b/docs/index.md @@ -1,3 +1,3 @@ {% include-markdown ".././README.md" -%} \ No newline at end of file +%} diff --git a/docs/requirements.txt b/docs/requirements.txt index 4c4e111c..e3d0d499 100644 --- a/docs/requirements.txt +++ b/docs/requirements.txt @@ -1,11 +1,11 @@ -stringcase -mkdocs-material = "^8.2.5" -mkdocstrings-python = "^0.6.6" -mkdocs-pymdownx-material-extras = "^1.6" -mkdocs-same-dir = "^0.1.1" -mkdocs-include-markdown-plugin = "^3.3.0" -mkdocs-gen-files = "^0.3.4" mkdocs-autolinks-plugin = "^0.4.0" -mkdocs-minify-plugin = "^0.5.0" +mkdocs-gen-files = "^0.3.4" mkdocs-git-revision-date-localized-plugin = "^1.0.0" +mkdocs-include-markdown-plugin = "^3.3.0" mkdocs-literate-nav +mkdocs-material = "^8.2.5" +mkdocs-minify-plugin = "^0.5.0" +mkdocs-pymdownx-material-extras = "^1.6" +mkdocs-same-dir = "^0.1.1" +mkdocstrings-python = "^0.6.6" +stringcase diff --git a/examples/active_layer.py b/examples/active_layer.py index 1421281e..b64ae625 100644 --- a/examples/active_layer.py +++ b/examples/active_layer.py @@ -1,6 +1,5 @@ # Set the active layer to the last art layer of the active document, or the # first if the last is already active. - # Import local modules from photoshop import Session diff --git a/examples/add_metadata.py b/examples/add_metadata.py index 63d471bd..9ed91483 100644 --- a/examples/add_metadata.py +++ b/examples/add_metadata.py @@ -1,10 +1,9 @@ """Add metadata to current active document.""" - # Import built-in modules import os -# Import local modules from photoshop import Session +# Import local modules with Session(action="new_document") as ps: diff --git a/examples/add_slate.py b/examples/add_slate.py index 85dc514e..77337c0c 100644 --- a/examples/add_slate.py +++ b/examples/add_slate.py @@ -6,17 +6,15 @@ - Close current document. """ - # Import built-in modules -from datetime import datetime import os +from datetime import datetime from tempfile import mkdtemp -# Import third-party modules import examples._psd_files as psd # Import from examples. - -# Import local modules from photoshop import Session +# Import third-party modules +# Import local modules PSD_FILE = psd.get_psd_files() diff --git a/examples/add_start_application_event.py b/examples/add_start_application_event.py index 3f28ec41..e698575a 100644 --- a/examples/add_start_application_event.py +++ b/examples/add_start_application_event.py @@ -6,13 +6,12 @@ Just like you manually in Script> Script Events Manager to enable the event. """ - # Import built-in modules import os from tempfile import mkdtemp -# Import local modules from photoshop import Session +# Import local modules with Session() as ps: diff --git a/examples/apply_crystallize_filter_action.py b/examples/apply_crystallize_filter_action.py index a22bf274..7136a141 100644 --- a/examples/apply_crystallize_filter_action.py +++ b/examples/apply_crystallize_filter_action.py @@ -8,12 +8,10 @@ https://github.com/lohriialo/photoshop-scripting-python/blob/master/ApplyCrystallizeFilterAction.py """ - # Import third-party modules import examples._psd_files as psd # Import from examples. - -# Import local modules from photoshop import Session +# Import local modules PSD_FILE = psd.get_psd_files() diff --git a/examples/apply_filters.py b/examples/apply_filters.py index bdaeedb3..b3195722 100644 --- a/examples/apply_filters.py +++ b/examples/apply_filters.py @@ -5,10 +5,9 @@ """ # Import third-party modules import examples._psd_files as psd # Import from examples. - +import photoshop.api as ps # Import local modules # selections in the open document. -import photoshop.api as ps PSD_FILE = psd.get_psd_files() diff --git a/examples/convert_smartobject_to_layer.py b/examples/convert_smartobject_to_layer.py index a0022d9a..f2658d5e 100644 --- a/examples/convert_smartobject_to_layer.py +++ b/examples/convert_smartobject_to_layer.py @@ -1,5 +1,4 @@ """Convert Smart object to artLayer.""" - # Import local modules from photoshop import Session diff --git a/examples/copy_and_paste.py b/examples/copy_and_paste.py index 3db42a1f..7c380454 100644 --- a/examples/copy_and_paste.py +++ b/examples/copy_and_paste.py @@ -3,7 +3,6 @@ https://github.com/lohriialo/photoshop-scripting-python/blob/master/CopyAndPaste.py """ - # Import local modules import photoshop.api as ps diff --git a/examples/create_new_document.py b/examples/create_new_document.py index 3f1cd953..bf61ba1e 100644 --- a/examples/create_new_document.py +++ b/examples/create_new_document.py @@ -1,5 +1,4 @@ """Create a new document.""" - # Import local modules from photoshop import Session diff --git a/examples/create_thumbnail.py b/examples/create_thumbnail.py index 1897e61b..1ef6b2b5 100644 --- a/examples/create_thumbnail.py +++ b/examples/create_thumbnail.py @@ -3,13 +3,12 @@ You can use the thumbnail image to upload to Shotgun or Ftrack. """ - # Import built-in modules import os from tempfile import mkdtemp -# Import local modules from photoshop import Session +# Import local modules def create_thumbnail(output_path=None, max_resolution=512): diff --git a/examples/creating_a_layer.py b/examples/creating_a_layer.py index 214499c6..ba3650fb 100644 --- a/examples/creating_a_layer.py +++ b/examples/creating_a_layer.py @@ -4,7 +4,6 @@ layer and then fill it with a color. """ - # Import local modules from photoshop import Session diff --git a/examples/cropping.py b/examples/cropping.py index 92d1f4c1..b147774d 100644 --- a/examples/cropping.py +++ b/examples/cropping.py @@ -1,5 +1,4 @@ """A cropping example.""" - # Import local modules from photoshop import Session diff --git a/examples/export_document.py b/examples/export_document.py index 4b975951..166d58ef 100644 --- a/examples/export_document.py +++ b/examples/export_document.py @@ -2,11 +2,10 @@ import os from tempfile import mkdtemp -# Import third-party modules import examples._psd_files as psd # Import from examples. - -# Import local modules from photoshop import Session +# Import third-party modules +# Import local modules PSD_FILE = psd.get_psd_files() diff --git a/examples/export_layers_as_png.py b/examples/export_layers_as_png.py index 3f2b730f..f1c7d3e0 100644 --- a/examples/export_layers_as_png.py +++ b/examples/export_layers_as_png.py @@ -2,11 +2,10 @@ # Import built-in modules import os -# Import third-party modules import examples._psd_files as psd # Import from examples. - -# Import local modules from photoshop import Session +# Import third-party modules +# Import local modules PSD_FILE = psd.get_psd_files() diff --git a/examples/export_layers_use_export_options_saveforweb.py b/examples/export_layers_use_export_options_saveforweb.py index aa84ecc2..8d167da9 100644 --- a/examples/export_layers_use_export_options_saveforweb.py +++ b/examples/export_layers_use_export_options_saveforweb.py @@ -2,11 +2,10 @@ # Import built-in modules import os -# Import third-party modules import examples._psd_files as psd # Import from examples. - -# Import local modules from photoshop import Session +# Import third-party modules +# Import local modules PSD_FILE = psd.get_psd_files() diff --git a/examples/fill_selection.py b/examples/fill_selection.py index 25111f0c..ff1b66f2 100644 --- a/examples/fill_selection.py +++ b/examples/fill_selection.py @@ -1,6 +1,4 @@ # Fill the current selection with an RGB color. - - # Import local modules from photoshop import Session diff --git a/examples/fit_on_screen.py b/examples/fit_on_screen.py index 8f6401be..5fca6885 100644 --- a/examples/fit_on_screen.py +++ b/examples/fit_on_screen.py @@ -1,5 +1,4 @@ """Let the current document Fit on screen.""" - # Import local modules from photoshop import Session diff --git a/examples/get_document_by_name.py b/examples/get_document_by_name.py index 7b9d04fc..502512ca 100644 --- a/examples/get_document_by_name.py +++ b/examples/get_document_by_name.py @@ -1,10 +1,8 @@ """Get document by document name from documents.""" - # Import third-party modules import examples._psd_files as psd # Import from examples. - -# Import local modules from photoshop import Session +# Import local modules PSD_FILE = psd.get_psd_files() diff --git a/examples/get_layer_by_name.py b/examples/get_layer_by_name.py index 2bb618eb..ae4e3e92 100644 --- a/examples/get_layer_by_name.py +++ b/examples/get_layer_by_name.py @@ -1,8 +1,7 @@ # Import third-party modules import examples._psd_files as psd # Import from examples. - -# Import local modules from photoshop import Session +# Import local modules PSD_FILE = psd.get_psd_files() diff --git a/examples/hello_world.py b/examples/hello_world.py index c27c48b4..2263c595 100644 --- a/examples/hello_world.py +++ b/examples/hello_world.py @@ -2,8 +2,8 @@ import os from tempfile import mkdtemp -# Import local modules import photoshop.api as ps +# Import local modules def hello_world(): diff --git a/examples/import_image_as_layer.py b/examples/import_image_as_layer.py index ed027ee1..2f0f61d8 100644 --- a/examples/import_image_as_layer.py +++ b/examples/import_image_as_layer.py @@ -1,5 +1,4 @@ """Import a image as a artLayer.""" - # Import local modules from photoshop import Session diff --git a/examples/list_documents.py b/examples/list_documents.py index 2d09f4db..c875ff8c 100644 --- a/examples/list_documents.py +++ b/examples/list_documents.py @@ -1,5 +1,4 @@ """List current photoshop all documents.""" - # Import local modules import photoshop.api as ps diff --git a/examples/load_selection.py b/examples/load_selection.py index 6f21a910..86c4858e 100644 --- a/examples/load_selection.py +++ b/examples/load_selection.py @@ -1,6 +1,5 @@ # This script will demonstrate how to load a selection from a saved alpha # channel. - # Import local modules from photoshop import Session diff --git a/examples/open_psd.py b/examples/open_psd.py index ac03d4d7..7aab88a9 100644 --- a/examples/open_psd.py +++ b/examples/open_psd.py @@ -1,6 +1,6 @@ # Import local modules -from photoshop import Session import photoshop.api as ps +from photoshop import Session # style 1 diff --git a/examples/operate_channels.py b/examples/operate_channels.py index 727334bd..b6ff6110 100644 --- a/examples/operate_channels.py +++ b/examples/operate_channels.py @@ -1,5 +1,4 @@ """A examples to show you how to operate active document channels.""" - # Import local modules from photoshop import Session diff --git a/examples/operate_layerSet.py b/examples/operate_layerSet.py index 6fbe4166..7e5e2b0a 100644 --- a/examples/operate_layerSet.py +++ b/examples/operate_layerSet.py @@ -1,5 +1,4 @@ """A examples to show you how to operate layerSet.""" - # Import local modules from photoshop import Session diff --git a/examples/photoshop_session.py b/examples/photoshop_session.py index f7672c95..50baa220 100644 --- a/examples/photoshop_session.py +++ b/examples/photoshop_session.py @@ -1,15 +1,13 @@ """Add slate information dynamically.""" - # Import built-in modules -from datetime import datetime import os +from datetime import datetime from tempfile import mkdtemp -# Import third-party modules import examples._psd_files as psd # Import from examples. - -# Import local modules from photoshop import Session +# Import third-party modules +# Import local modules PSD_FILE = psd.get_psd_files() diff --git a/examples/replace_images.py b/examples/replace_images.py index 24642cdb..5582bf44 100644 --- a/examples/replace_images.py +++ b/examples/replace_images.py @@ -1,10 +1,8 @@ """Replace the image of the current active layer with a new image.""" - # Import third-party modules import examples._psd_files as psd # Import from examples. - -# Import local modules from photoshop import Session +# Import local modules PSD_FILE = psd.get_psd_files() diff --git a/examples/revert_changes.py b/examples/revert_changes.py index d5463a58..28b4b88b 100644 --- a/examples/revert_changes.py +++ b/examples/revert_changes.py @@ -1,5 +1,4 @@ """This example demonstrates how to roll back history.""" - # Import local modules from photoshop import Session diff --git a/examples/rotate_layer.py b/examples/rotate_layer.py index 942244bb..a62d522c 100644 --- a/examples/rotate_layer.py +++ b/examples/rotate_layer.py @@ -4,7 +4,6 @@ https://github.com/lohriialo/photoshop-scripting-python/blob/master/RotateLayer.py """ - # Import local modules import photoshop.api as ps diff --git a/examples/run_batch.py b/examples/run_batch.py index 5e791397..2f044442 100644 --- a/examples/run_batch.py +++ b/examples/run_batch.py @@ -1,8 +1,8 @@ # Import built-in modules import os -# Import local modules from photoshop import Session +# Import local modules root = "your/images/root" diff --git a/examples/save_as_pdf.py b/examples/save_as_pdf.py index 03096bc9..b6b08666 100644 --- a/examples/save_as_pdf.py +++ b/examples/save_as_pdf.py @@ -3,8 +3,8 @@ import os from tempfile import mkdtemp -# Import local modules from photoshop import Session +# Import local modules with Session() as ps: diff --git a/examples/save_as_tga.py b/examples/save_as_tga.py index 8eddf213..3663d75d 100644 --- a/examples/save_as_tga.py +++ b/examples/save_as_tga.py @@ -2,8 +2,8 @@ import os from tempfile import mkdtemp -# Import local modules from photoshop import Session +# Import local modules with Session(action="new_document") as ps: diff --git a/examples/selection_stroke.py b/examples/selection_stroke.py index ae2b5df4..2ebff004 100644 --- a/examples/selection_stroke.py +++ b/examples/selection_stroke.py @@ -5,7 +5,6 @@ https://github.com/lohriialo/photoshop-scripting-python/blob/master/SelectionStroke.py """ - # Import local modules import photoshop.api as ps diff --git a/examples/session_hello_world.py b/examples/session_hello_world.py index 308b3201..c2eec9b5 100644 --- a/examples/session_hello_world.py +++ b/examples/session_hello_world.py @@ -1,11 +1,10 @@ """Add slate information dynamically.""" - # Import built-in modules import os from tempfile import mkdtemp -# Import local modules from photoshop import Session +# Import local modules with Session() as adobe: diff --git a/examples/session_smart_sharpen.py b/examples/session_smart_sharpen.py index 0e2c29ab..0f0094da 100644 --- a/examples/session_smart_sharpen.py +++ b/examples/session_smart_sharpen.py @@ -5,12 +5,10 @@ https://github.com/lohriialo/photoshop-scripting-python/blob/master/SmartSharpen.py """ - # Import third-party modules import examples._psd_files as psd # Import from examples. - -# Import local modules from photoshop import Session +# Import local modules PSD_FILE = psd.get_psd_files() diff --git a/examples/smart_sharpen.py b/examples/smart_sharpen.py index 9fc3e5b3..1af552f8 100644 --- a/examples/smart_sharpen.py +++ b/examples/smart_sharpen.py @@ -5,12 +5,10 @@ https://github.com/lohriialo/photoshop-scripting-python/blob/master/SmartSharpen.py """ - # Import third-party modules import examples._psd_files as psd # Import from examples. - -# Import local modules import photoshop.api as ps +# Import local modules app = ps.Application() diff --git a/examples/trim.py b/examples/trim.py index d9e7c116..27c6e9a0 100644 --- a/examples/trim.py +++ b/examples/trim.py @@ -1,10 +1,8 @@ """A trim example.""" - # Import third-party modules import examples._psd_files as psd # Import from examples. - -# Import local modules from photoshop import Session +# Import local modules PSD_FILE = psd.get_psd_files() diff --git a/photoshop/api/__init__.py b/photoshop/api/__init__.py index 4bfddeb3..b0eddf9c 100644 --- a/photoshop/api/__init__.py +++ b/photoshop/api/__init__.py @@ -22,8 +22,8 @@ from photoshop.api.save_options import GIFSaveOptions from photoshop.api.save_options import JPEGSaveOptions from photoshop.api.save_options import PDFSaveOptions -from photoshop.api.save_options import PNGSaveOptions from photoshop.api.save_options import PhotoshopSaveOptions +from photoshop.api.save_options import PNGSaveOptions from photoshop.api.save_options import TargaSaveOptions from photoshop.api.save_options import TiffSaveOptions from photoshop.api.solid_color import SolidColor diff --git a/photoshop/api/_artlayer.py b/photoshop/api/_artlayer.py index ae1b84ec..7455033a 100644 --- a/photoshop/api/_artlayer.py +++ b/photoshop/api/_artlayer.py @@ -1,11 +1,11 @@ # Import built-in modules from typing import Any -# Import local modules from photoshop.api._core import Photoshop from photoshop.api.enumerations import LayerKind from photoshop.api.enumerations import RasterizeType from photoshop.api.text_item import TextItem +# Import local modules # pylint: disable=too-many-public-methods, too-many-arguments diff --git a/photoshop/api/_artlayers.py b/photoshop/api/_artlayers.py index dddb7fa7..5774cff7 100644 --- a/photoshop/api/_artlayers.py +++ b/photoshop/api/_artlayers.py @@ -1,10 +1,10 @@ # Import third-party modules from comtypes import ArgumentError -# Import local modules from photoshop.api._artlayer import ArtLayer from photoshop.api._core import Photoshop from photoshop.api.errors import PhotoshopPythonAPIError +# Import local modules # pylint: disable=too-many-public-methods @@ -25,8 +25,7 @@ def __len__(self): return self.length def __iter__(self): - for layer in self.app: - yield layer + yield from self.app def __getitem__(self, key: str): """Access a given ArtLayer using dictionary key lookup.""" diff --git a/photoshop/api/_channels.py b/photoshop/api/_channels.py index 00b3b6a2..ebfde6c1 100644 --- a/photoshop/api/_channels.py +++ b/photoshop/api/_channels.py @@ -21,8 +21,7 @@ def __len__(self): return self.length def __iter__(self): - for layer in self.app: - yield layer + yield from self.app def __getitem__(self, item): return self.app[item] diff --git a/photoshop/api/_core.py b/photoshop/api/_core.py index 28be680a..ffa0b84d 100644 --- a/photoshop/api/_core.py +++ b/photoshop/api/_core.py @@ -1,26 +1,26 @@ """This class provides all photoshop API core functions.""" # Import built-in modules +import os +import platform from contextlib import suppress from functools import cached_property from logging import CRITICAL from logging import DEBUG -from logging import Logger from logging import getLogger -import os -import platform +from logging import Logger from typing import Any from typing import List from typing import Optional -import winreg -# Import third-party modules +import winreg from comtypes.client import CreateObject from comtypes.client.dynamic import _Dispatch as FullyDynamicDispatch from comtypes.client.lazybind import Dispatch -# Import local modules from photoshop.api.constants import PHOTOSHOP_VERSION_MAPPINGS from photoshop.api.errors import PhotoshopPythonAPIError +# Import third-party modules +# Import local modules class Photoshop: @@ -53,7 +53,7 @@ def __init__(self, ps_version: Optional[str] = None, parent: Any = None): if not self.app: # Attempt unsuccessful self._logger.debug( - f"Unable to retrieve Photoshop object '{self.typename}' using version '{ps_version}'." + f"Unable to retrieve Photoshop object '{self.typename}' using version '{ps_version}'.", ) # Look for version ID in registry data @@ -242,5 +242,5 @@ def _open_key(key: str) -> winreg.HKEYType: except FileNotFoundError as err: raise OSError( "Failed to read the registration: <{path}>\n" - "Please check if you have Photoshop installed correctly.".format(path=f"HKEY_LOCAL_MACHINE\\{key}") + "Please check if you have Photoshop installed correctly.".format(path=f"HKEY_LOCAL_MACHINE\\{key}"), ) from err diff --git a/photoshop/api/_document.py b/photoshop/api/_document.py index ff8cd36c..da7d6ee9 100644 --- a/photoshop/api/_document.py +++ b/photoshop/api/_document.py @@ -12,7 +12,6 @@ """ - # Import built-in modules from pathlib import Path from typing import List @@ -21,25 +20,25 @@ from typing import TypeVar from typing import Union -# Import third-party modules from comtypes import COMError -# Import local modules from photoshop.api._artlayer import ArtLayer from photoshop.api._artlayers import ArtLayers from photoshop.api._channels import Channels from photoshop.api._core import Photoshop from photoshop.api._documentinfo import DocumentInfo from photoshop.api._layerComps import LayerComps +from photoshop.api._layers import Layers from photoshop.api._layerSet import LayerSet from photoshop.api._layerSets import LayerSets -from photoshop.api._layers import Layers from photoshop.api._selection import Selection from photoshop.api.enumerations import ExportType from photoshop.api.enumerations import ExtensionType from photoshop.api.enumerations import SaveOptions from photoshop.api.enumerations import TrimType from photoshop.api.save_options import ExportOptionsSaveForWeb +# Import third-party modules +# Import local modules # Custom types. diff --git a/photoshop/api/_documentinfo.py b/photoshop/api/_documentinfo.py index c24068cd..3fcdf6c6 100644 --- a/photoshop/api/_documentinfo.py +++ b/photoshop/api/_documentinfo.py @@ -4,12 +4,11 @@ application. """ - # Import built-in modules from pprint import pformat -# Import local modules from photoshop.api._core import Photoshop +# Import local modules # pylint: disable=too-many-public-methods @@ -45,7 +44,7 @@ def __str__(self): "title": self.title, "transmissionReference": self.transmissionReference, "urgency": self.urgency, - } + }, ) @property diff --git a/photoshop/api/_documents.py b/photoshop/api/_documents.py index 365aaefc..ca51ccbd 100644 --- a/photoshop/api/_documents.py +++ b/photoshop/api/_documents.py @@ -59,7 +59,7 @@ def add( pixelAspectRatio, bitsPerChannel, colorProfileName, - ) + ), ) def __iter__(self) -> Document: diff --git a/photoshop/api/_layerSet.py b/photoshop/api/_layerSet.py index 3351da61..4515fc13 100644 --- a/photoshop/api/_layerSet.py +++ b/photoshop/api/_layerSet.py @@ -140,5 +140,4 @@ def unlink(self): self.app.unlink() def __iter__(self): - for layer in self.app: - yield layer + yield from self.app diff --git a/photoshop/api/_layerSets.py b/photoshop/api/_layerSets.py index 8b5b3aef..b1265ffe 100644 --- a/photoshop/api/_layerSets.py +++ b/photoshop/api/_layerSets.py @@ -1,10 +1,10 @@ # Import third-party modules from comtypes import ArgumentError -# Import local modules from photoshop.api._core import Photoshop from photoshop.api._layerSet import LayerSet from photoshop.api.errors import PhotoshopPythonAPIError +# Import local modules class LayerSets(Photoshop): @@ -22,8 +22,7 @@ def __len__(self): return self.length def __iter__(self): - for layer_set in self.app: - yield layer_set + yield from self.app def __getitem__(self, key: str): """Access a given LayerSet using dictionary key lookup.""" diff --git a/photoshop/api/_notifier.py b/photoshop/api/_notifier.py index e0f651de..f7415005 100644 --- a/photoshop/api/_notifier.py +++ b/photoshop/api/_notifier.py @@ -8,8 +8,8 @@ # Import built-in modules from pathlib import Path -# Import local modules from photoshop.api._core import Photoshop +# Import local modules class Notifier(Photoshop): diff --git a/photoshop/api/_notifiers.py b/photoshop/api/_notifiers.py index 3ecbcdc3..564e32c2 100644 --- a/photoshop/api/_notifiers.py +++ b/photoshop/api/_notifiers.py @@ -9,14 +9,13 @@ ``` """ - # Import built-in modules from typing import Any from typing import Optional -# Import local modules from photoshop.api._core import Photoshop from photoshop.api._notifier import Notifier +# Import local modules class Notifiers(Photoshop): @@ -37,8 +36,7 @@ def __len__(self): return self.length def __iter__(self): - for app in self.app: - yield app + yield from self.app def __getitem__(self, item): return self._notifiers[item] diff --git a/photoshop/api/_preferences.py b/photoshop/api/_preferences.py index c4d57356..cf34bbc6 100644 --- a/photoshop/api/_preferences.py +++ b/photoshop/api/_preferences.py @@ -1,8 +1,8 @@ # Import built-in modules from pathlib import Path -# Import local modules from photoshop.api._core import Photoshop +# Import local modules class Preferences(Photoshop): diff --git a/photoshop/api/_selection.py b/photoshop/api/_selection.py index 63e19e14..3b479ce2 100644 --- a/photoshop/api/_selection.py +++ b/photoshop/api/_selection.py @@ -1,5 +1,4 @@ """The selected area of the document or layer.""" - # Import local modules from photoshop.api._core import Photoshop from photoshop.api.enumerations import ColorBlendMode diff --git a/photoshop/api/_text_fonts.py b/photoshop/api/_text_fonts.py index dbe43d63..d5bb2683 100644 --- a/photoshop/api/_text_fonts.py +++ b/photoshop/api/_text_fonts.py @@ -2,14 +2,14 @@ from typing import Any from typing import Union -# Import third-party modules from comtypes import ArgumentError from comtypes import COMError -# Import local modules from photoshop.api._core import Photoshop from photoshop.api.errors import PhotoshopPythonAPIError from photoshop.api.text_font import TextFont +# Import third-party modules +# Import local modules class TextFonts(Photoshop): diff --git a/photoshop/api/action_descriptor.py b/photoshop/api/action_descriptor.py index 6ecd4b0b..c7184a62 100644 --- a/photoshop/api/action_descriptor.py +++ b/photoshop/api/action_descriptor.py @@ -6,15 +6,14 @@ see the Photoshop Scripting Guide. """ - # Import built-in modules from pathlib import Path -# Import local modules from photoshop.api._core import Photoshop from photoshop.api.action_list import ActionList from photoshop.api.action_reference import ActionReference from photoshop.api.enumerations import DescValueType +# Import local modules class ActionDescriptor(Photoshop): diff --git a/photoshop/api/application.py b/photoshop/api/application.py index 57032323..5ff3314e 100644 --- a/photoshop/api/application.py +++ b/photoshop/api/application.py @@ -12,16 +12,13 @@ """ # Import built-in modules import os -from pathlib import Path import time +from _ctypes import COMError +from pathlib import Path from typing import List from typing import Optional from typing import Union -# Import third-party modules -from _ctypes import COMError - -# Import local modules from photoshop.api._artlayer import ArtLayer from photoshop.api._core import Photoshop from photoshop.api._document import Document @@ -35,6 +32,8 @@ from photoshop.api.enumerations import PurgeTarget from photoshop.api.errors import PhotoshopPythonAPIError from photoshop.api.solid_color import SolidColor +# Import third-party modules +# Import local modules class Application(Photoshop): @@ -465,7 +464,8 @@ def refreshFonts(self): def runMenuItem(self, menu_id): """Run a menu item given the menu ID.""" return self.eval_javascript( - f"app.runMenuItem({menu_id})", + f"app.runMenuItem({menu_id}, + )", ) def showColorPicker(self): diff --git a/photoshop/api/colors/cmyk.py b/photoshop/api/colors/cmyk.py index dbe260b8..4aacfc5a 100644 --- a/photoshop/api/colors/cmyk.py +++ b/photoshop/api/colors/cmyk.py @@ -1,5 +1,4 @@ """Defines a CMYK color, used in the `SolidColor` object.""" - # Import local modules from photoshop.api._core import Photoshop diff --git a/photoshop/api/colors/gray.py b/photoshop/api/colors/gray.py index b2321a02..6c61f85a 100644 --- a/photoshop/api/colors/gray.py +++ b/photoshop/api/colors/gray.py @@ -1,5 +1,4 @@ """Defines a gray color, used in the `SolidColor` object.""" - # Import local modules from photoshop.api._core import Photoshop diff --git a/photoshop/api/colors/hsb.py b/photoshop/api/colors/hsb.py index 76ead8c8..fb6b20ef 100644 --- a/photoshop/api/colors/hsb.py +++ b/photoshop/api/colors/hsb.py @@ -1,5 +1,4 @@ """Defines an HSB color, used in the `SolidColor` object.""" - # Import local modules from photoshop.api._core import Photoshop diff --git a/photoshop/api/save_options/bmp.py b/photoshop/api/save_options/bmp.py index 8a1c1ae8..aa26e666 100644 --- a/photoshop/api/save_options/bmp.py +++ b/photoshop/api/save_options/bmp.py @@ -1,5 +1,4 @@ """Options for saving a document in BMO format.""" - # Import local modules from photoshop.api._core import Photoshop diff --git a/photoshop/api/save_options/pdf.py b/photoshop/api/save_options/pdf.py index fdc4fb18..b662df2b 100644 --- a/photoshop/api/save_options/pdf.py +++ b/photoshop/api/save_options/pdf.py @@ -3,7 +3,6 @@ using the Document.saveAs() method. """ - # Import local modules from photoshop.api._core import Photoshop from photoshop.api.enumerations import PDFEncodingType @@ -97,7 +96,7 @@ def destinationProfile(self): return self.app.destinationProfile except COMError: raise ValueError( - "Should set value first. " "This parameter can only be read after the " "value has been set." + "Should set value first. " "This parameter can only be read after the " "value has been set.", ) @destinationProfile.setter @@ -124,7 +123,7 @@ def downSampleSize(self): return self.app.downSampleSize except COMError: raise ValueError( - "Should set value first. " "This parameter can only be read after the " "value has been set." + "Should set value first. " "This parameter can only be read after the " "value has been set.", ) @downSampleSize.setter @@ -141,7 +140,7 @@ def downSampleSizeLimit(self): return self.app.downSampleSizeLimit except COMError: raise ValueError( - "Should set value first. " "This parameter can only be read after the " "value has been set." + "Should set value first. " "This parameter can only be read after the " "value has been set.", ) @downSampleSizeLimit.setter @@ -236,7 +235,7 @@ def outputConditionID(self): return self.app.outputConditionID except COMError: raise ValueError( - "Should set value first. " "This parameter can only be read after the " "value has been set." + "Should set value first. " "This parameter can only be read after the " "value has been set.", ) @outputConditionID.setter @@ -252,7 +251,7 @@ def preserveEditing(self): return self.app.preserveEditing except COMError: raise ValueError( - "Should set value first. " "This parameter can only be read after the " "value has been set." + "Should set value first. " "This parameter can only be read after the " "value has been set.", ) @preserveEditing.setter @@ -268,7 +267,7 @@ def presetFile(self): return self.app.presetFile except COMError: raise ValueError( - "Should set value first. " "This parameter can only be read after the " "value has been set." + "Should set value first. " "This parameter can only be read after the " "value has been set.", ) @presetFile.setter @@ -283,7 +282,7 @@ def profileInclusionPolicy(self): return self.app.profileInclusionPolicy except COMError: raise ValueError( - "Should set value first. " "This parameter can only be read after the " "value has been set." + "Should set value first. " "This parameter can only be read after the " "value has been set.", ) @profileInclusionPolicy.setter @@ -298,7 +297,7 @@ def registryName(self): return self.app.registryName except COMError: raise ValueError( - "Should set value first. " "This parameter can only be read after the " "value has been set." + "Should set value first. " "This parameter can only be read after the " "value has been set.", ) @registryName.setter @@ -313,7 +312,7 @@ def spotColors(self): return self.app.spotColors except COMError: raise ValueError( - "Should set value first. " "This parameter can only be read after the " "value has been set." + "Should set value first. " "This parameter can only be read after the " "value has been set.", ) @spotColors.setter @@ -328,7 +327,7 @@ def tileSize(self): return self.app.tileSize except COMError: raise ValueError( - "Should set value first. " "This parameter can only be read after the " "value has been set." + "Should set value first. " "This parameter can only be read after the " "value has been set.", ) @tileSize.setter diff --git a/photoshop/api/solid_color.py b/photoshop/api/solid_color.py index c0ed302c..6c7e5c0c 100644 --- a/photoshop/api/solid_color.py +++ b/photoshop/api/solid_color.py @@ -7,7 +7,6 @@ - Passed to `PathItem.fillPath()`, `Selection.fill()`, and `Selection.stroke()`. """ - # Import local modules from photoshop.api._core import Photoshop from photoshop.api.colors.cmyk import CMYKColor diff --git a/photoshop/session.py b/photoshop/session.py index d5976e1b..78cdb9e5 100644 --- a/photoshop/session.py +++ b/photoshop/session.py @@ -25,19 +25,19 @@ ``` """ - # Import built-in modules from typing import Any -# Import local modules from photoshop.api import ActionDescriptor from photoshop.api import ActionList from photoshop.api import ActionReference from photoshop.api import Application -from photoshop.api import BMPSaveOptions from photoshop.api import BatchOptions +from photoshop.api import BMPSaveOptions from photoshop.api import CMYKColor +from photoshop.api import enumerations from photoshop.api import EPSSaveOptions +from photoshop.api import errors from photoshop.api import EventID from photoshop.api import ExportOptionsSaveForWeb from photoshop.api import GIFSaveOptions @@ -46,15 +46,14 @@ from photoshop.api import JPEGSaveOptions from photoshop.api import LabColor from photoshop.api import PDFSaveOptions -from photoshop.api import PNGSaveOptions from photoshop.api import PhotoshopSaveOptions +from photoshop.api import PNGSaveOptions from photoshop.api import RGBColor from photoshop.api import SolidColor from photoshop.api import TargaSaveOptions from photoshop.api import TextItem from photoshop.api import TiffSaveOptions -from photoshop.api import enumerations -from photoshop.api import errors +# Import local modules # pylint: disable=too-many-arguments diff --git a/poetry.lock b/poetry.lock index 126c91b9..39306808 100644 --- a/poetry.lock +++ b/poetry.lock @@ -762,13 +762,13 @@ mkdocs = ">=1.0.3" [[package]] name = "mkdocs-git-revision-date-localized-plugin" -version = "1.2.1" +version = "1.2.5" description = "Mkdocs plugin that enables displaying the localized date of the last git modification of a markdown file." optional = false -python-versions = ">=3.6" +python-versions = ">=3.8" files = [ - {file = "mkdocs-git-revision-date-localized-plugin-1.2.1.tar.gz", hash = "sha256:fc5b23a9d572cbba0114e9e17152001d01724990cb308830e58291fa614faf73"}, - {file = "mkdocs_git_revision_date_localized_plugin-1.2.1-py3-none-any.whl", hash = "sha256:d57dc99d67af917899e69c392f1ebccd1779fa243d641255469b03f8a3596b96"}, + {file = "mkdocs_git_revision_date_localized_plugin-1.2.5-py3-none-any.whl", hash = "sha256:d796a18b07cfcdb154c133e3ec099d2bb5f38389e4fd54d3eb516a8a736815b8"}, + {file = "mkdocs_git_revision_date_localized_plugin-1.2.5.tar.gz", hash = "sha256:0c439816d9d0dba48e027d9d074b2b9f1d7cd179f74ba46b51e4da7bb3dc4b9b"}, ] [package.dependencies] @@ -1267,6 +1267,7 @@ files = [ {file = "PyYAML-6.0.1-cp311-cp311-win_amd64.whl", hash = "sha256:bf07ee2fef7014951eeb99f56f39c9bb4af143d8aa3c21b1677805985307da34"}, {file = "PyYAML-6.0.1-cp312-cp312-macosx_10_9_x86_64.whl", hash = "sha256:855fb52b0dc35af121542a76b9a84f8d1cd886ea97c84703eaa6d88e37a2ad28"}, {file = "PyYAML-6.0.1-cp312-cp312-macosx_11_0_arm64.whl", hash = "sha256:40df9b996c2b73138957fe23a16a4f0ba614f4c0efce1e9406a184b6d07fa3a9"}, + {file = "PyYAML-6.0.1-cp312-cp312-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:a08c6f0fe150303c1c6b71ebcd7213c2858041a7e01975da3a99aed1e7a378ef"}, {file = "PyYAML-6.0.1-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:6c22bec3fbe2524cde73d7ada88f6566758a8f7227bfbf93a408a9d86bcc12a0"}, {file = "PyYAML-6.0.1-cp312-cp312-musllinux_1_1_x86_64.whl", hash = "sha256:8d4e9c88387b0f5c7d5f281e55304de64cf7f9c0021a3525bd3b1c542da3b0e4"}, {file = "PyYAML-6.0.1-cp312-cp312-win32.whl", hash = "sha256:d483d2cdf104e7c9fa60c544d92981f12ad66a457afae824d146093b8c294c54"}, diff --git a/test/conftest.py b/test/conftest.py index 4c3929bf..19c20813 100644 --- a/test/conftest.py +++ b/test/conftest.py @@ -1,8 +1,8 @@ # Import built-in modules import os -# Import third-party modules import pytest +# Import third-party modules @pytest.fixture() diff --git a/test/manual_test/manual_test_all_examples.py b/test/manual_test/manual_test_all_examples.py index a21a0190..64eea271 100644 --- a/test/manual_test/manual_test_all_examples.py +++ b/test/manual_test/manual_test_all_examples.py @@ -1,10 +1,9 @@ """Manual test all examples.""" - # Import built-in modules from pathlib import Path -# Import local modules from photoshop.api import Application +# Import local modules root = Path(__file__).parent.parent.parent.joinpath("examples") diff --git a/test/manual_test/manual_test_application.py b/test/manual_test/manual_test_application.py index 26296062..d0acddc2 100644 --- a/test/manual_test/manual_test_application.py +++ b/test/manual_test/manual_test_application.py @@ -2,10 +2,10 @@ # Import third-party modules import pytest -# Import local modules from photoshop.api import Application from photoshop.api import EventID from photoshop.api import SolidColor +# Import local modules class TestApplication: diff --git a/test/manual_test/manual_test_layer_comps.py b/test/manual_test/manual_test_layer_comps.py index efc269de..e5a8e515 100644 --- a/test/manual_test/manual_test_layer_comps.py +++ b/test/manual_test/manual_test_layer_comps.py @@ -2,8 +2,8 @@ # Import third-party modules import pytest -# Import local modules from photoshop import Session +# Import local modules class TestTextItem: diff --git a/test/manual_test/manual_test_solid_color.py b/test/manual_test/manual_test_solid_color.py index 20229302..7e1575ea 100644 --- a/test/manual_test/manual_test_solid_color.py +++ b/test/manual_test/manual_test_solid_color.py @@ -2,8 +2,8 @@ # Import third-party modules import pytest -# Import local modules from photoshop import Session +# Import local modules class TestSolidColor: diff --git a/test/manual_test/manual_test_text_item.py b/test/manual_test/manual_test_text_item.py index 08f1b120..62021f8c 100644 --- a/test/manual_test/manual_test_text_item.py +++ b/test/manual_test/manual_test_text_item.py @@ -2,9 +2,9 @@ # Import third-party modules import pytest -# Import local modules from photoshop import Session from photoshop.api.enumerations import TextType +# Import local modules class TestTextItem: diff --git a/test/test_imports.py b/test/test_imports.py index 1888151f..d79e77b5 100644 --- a/test/test_imports.py +++ b/test/test_imports.py @@ -1,21 +1,16 @@ """Import Test.""" - # Import future modules -from __future__ import absolute_import -from __future__ import division -from __future__ import print_function - # Import built-in modules import importlib import pkgutil -# Import local modules import photoshop +# Import local modules def test_imports(): """Test import modules.""" - prefix = "{}.".format(photoshop.__name__) + prefix = f"{photoshop.__name__}." iter_packages = pkgutil.walk_packages( photoshop.__path__, # noqa: WPS609 prefix,