-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1 from loonghao/master
Implement the first available version
- Loading branch information
Showing
13 changed files
with
325 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
# Byte-compiled / optimized / DLL files | ||
*.py[cod] | ||
|
||
# PyCharm project files | ||
.idea/ | ||
|
||
# Vim / Notepad++ temp files | ||
*~ | ||
.*/ | ||
*.egg-info | ||
# PyInstaller output | ||
build/ | ||
dist/ | ||
*.spec | ||
|
||
# PyBuilder output | ||
.build/ | ||
result/ | ||
|
||
# Coverage output | ||
.coverage | ||
/venv/ | ||
|
||
# Docs | ||
docs/_build/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
python: | ||
enabled: true | ||
|
||
fail_on_violations: true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
# Generated Pylint configuration file that disables default output tables. | ||
|
||
[MESSAGES CONTROL] | ||
disable=RP0001,RP0002,RP0003,RP0101,RP0401,RP0402,RP0701,RP0801,C0103,R0903 | ||
|
||
[REPORTS] | ||
output-format=text |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
|
||
language: python | ||
|
||
python: | ||
- 3.7 | ||
|
||
script: | ||
- pip install file://$(pwd) | ||
|
||
deploy: | ||
provider: pypi | ||
user: mottosso | ||
distributions: "sdist bdist_wheel" | ||
password: | ||
secure: YtlMrnT8XqB3sAm9ludEI3DbW5Warh25+6C2gg3+nDhW7/tTcyh4bfxtaTnzCq28qHOM6hSQpZ5xett/jLW+EFRCBr9O8R78Vd3jMsSEn7VMfRy1+XVwyEwg8yXRltT1810pdXRQfKIarG/63lf+Jikm72ecnRsn7dHPRMAYoJ8= | ||
on: | ||
tags: true | ||
repo: pyblish/pyblish-photoshop |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,56 @@ | ||
# pyblish-photoshop | ||
Pyblish for Photoshop | ||
<p align="center"> | ||
<img src="https://imgur.com/kn8wOQj.png" alt="logo"></a> | ||
</p> | ||
|
||
pyblish-photoshop | ||
================= | ||
Pyblish integration for Adobe Photoshop cs6-2020 (Window only). | ||
|
||
What is included? | ||
---------------- | ||
A set of common plug-ins and functions shared across other integrations - such as getting the current working file. It also visually integrates Pyblish into the File-menu for easy access. | ||
- Common [plug-ins](https://github.com/pyblish/pyblish-photoshop/tree/master/pyblish_photoshop/plugins) | ||
- Common [command line](https://github.com/pyblish/pyblish-photoshop/blob/master/pyblish_photoshop/cli.py) | ||
|
||
<br> | ||
<br> | ||
<br> | ||
|
||
Installation | ||
------------ | ||
Via pip install `pyblish-photoshop` will be installing all depends packages. | ||
|
||
```cmd | ||
pip install pyblish-photoshop | ||
``` | ||
|
||
Install pyblish menu into Photoshop | ||
```cmd | ||
pyblish-photoshop install --app-dir "your/photoshop/install/localtion" | ||
``` | ||
For example: | ||
```cmd | ||
pyblish-photoshop install --app-dir "C:\Program Files\Adobe\Adobe Photoshop 2020" | ||
``` | ||
|
||
Usage | ||
----- | ||
```cmd | ||
pyblish-photoshop --help | ||
``` | ||
```cmd | ||
Usage: pyblish-photoshop [OPTIONS] COMMAND [ARGS]... | ||
Options: | ||
--help Show this message and exit. | ||
Commands: | ||
gui Show Pyblish GUI, Default is to use "pyblish_lite". | ||
install Install pyblish menu into Photoshop. | ||
``` | ||
|
||
Launch UI | ||
--------- | ||
In Photoshop go to the `Filter` menu and you will see the `pyblish` menu. | ||
|
||
<img src="https://imgur.com/nJ5qtkf.gif" alt="UI"></a> |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
# Standard library | ||
import os | ||
|
||
# Pyblish libraries | ||
import pyblish | ||
import pyblish.api | ||
|
||
# Local libraries | ||
from pyblish_photoshop import plugins | ||
|
||
|
||
def register_host(): | ||
"""Register supported hosts""" | ||
pyblish.api.register_host("photoshop") | ||
|
||
|
||
def deregister_host(): | ||
"""Register supported hosts""" | ||
pyblish.api.deregister_host("photoshop") | ||
|
||
|
||
def register_plugins(): | ||
# Register accompanying plugins | ||
plugin_path = os.path.dirname(plugins.__file__) | ||
pyblish.api.register_plugin_path(plugin_path) | ||
print("pyblish: Registered %s" % plugin_path) | ||
|
||
|
||
def deregister_plugins(): | ||
plugin_path = os.path.dirname(plugins.__file__) | ||
pyblish.api.deregister_plugin_path(plugin_path) | ||
|
||
|
||
def _discover_gui(): | ||
"""Return the most desirable of the currently registered GUIs""" | ||
|
||
# Prefer last registered | ||
guis = reversed(pyblish.api.registered_guis()) | ||
|
||
for gui in guis: | ||
try: | ||
gui = __import__(gui) | ||
except (ImportError, AttributeError): | ||
continue | ||
else: | ||
return gui | ||
|
||
|
||
def show(): | ||
"""Try showing the most desirable GUI.""" | ||
app = _discover_gui() | ||
app.settings.WindowTitle = "Pyblish (photoshop)" | ||
app.show() | ||
|
||
|
||
def setup(): | ||
"""Setup integration. | ||
Register plug-ins and integrate into the host | ||
""" | ||
|
||
register_plugins() | ||
register_host() | ||
print("pyblish: Pyblish loaded successfully.") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
# Import built-in modules | ||
import os | ||
|
||
# Import third-party modules | ||
import click | ||
import pyblish.api | ||
|
||
# Import local modules | ||
from pyblish_photoshop import app | ||
|
||
|
||
@click.group() | ||
def cli(): | ||
pass | ||
|
||
|
||
@cli.command("gui", help='Show Pyblish GUI, Default is to use ' | ||
'"pyblish_lite".') | ||
@click.option("package", "--register-gui", | ||
type=click.Choice(["pyblish_qml", "pyblish_lite"]), | ||
default="pyblish_lite") | ||
def pyblish_gui(package): | ||
pyblish.api.register_gui(package) | ||
app.setup() | ||
app.show() | ||
|
||
|
||
@cli.command("install", help="Install pyblish menu into Photoshop.") | ||
@click.option("install_folder", "--app-dir", type=click.Path(exists=True)) | ||
def install_script(install_folder): | ||
template = """/* | ||
// BEGIN__HARVEST_EXCEPTION_ZSTRING | ||
<javascriptresource> | ||
<name>pyblish</name> | ||
<about>Pyblish for Photoshop.</about> | ||
<category>photoshop</category> | ||
<menu>filter</menu> | ||
</javascriptresource> | ||
// END__HARVEST_EXCEPTION_ZSTRING | ||
The item tagged "name" specifies the localized name or ZString that will be displayed in the menu | ||
The item tagged "menu" specifies the menu in which the command will appear: generate, automate, scripts, or filter | ||
The item tagged "enableinfo" specifies the conditions under which the command will be enabled. Too complex to describe here; see plugin sdk. Should usually just be "true", and your command should report a user-comprehensible error when it can't handle things. The problem with disabling the command when it's unsuitable is that there's no hint to the user as to why a command is disabled. | ||
The item tagged "about" specifies the localized text or ZString to be displayed in the about box for the plugin. Optional. | ||
The item tagged "eventid" needs to be a guaranteed unique string for your plugin. Usually generated with a UUID generator like uuidgen on MacOS | ||
*/ | ||
{ | ||
app.system("start pyblish-photoshop gui") | ||
} | ||
""" | ||
script_path = os.path.join(install_folder, "Presets", "Scripts", | ||
"pyblish.jsx") | ||
with open(script_path, "w") as file_obj: | ||
file_obj.write(template) | ||
click.echo("Install Done: {}".format(script_path)) |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
# Import third-party modules | ||
import pyblish.api | ||
|
||
|
||
class CollectPhotoshopCurrentFile(pyblish.api.ContextPlugin): | ||
"""Inject the current active document file path into context.""" | ||
|
||
order = pyblish.api.CollectorOrder - 0.5 | ||
label = "Photoshop current active document" | ||
|
||
hosts = ['photoshop'] | ||
version = (0, 1, 0) | ||
|
||
def process(self, context): | ||
"""Inject the current working file""" | ||
import os | ||
from photoshop.api import Application | ||
app = Application() | ||
|
||
current_file = app.activeDocument.fullName | ||
self.log.info("Find current working file %s", current_file) | ||
normalised = os.path.normpath(current_file) | ||
context.set_data('currentFile', value=normalised) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
|
||
VERSION_MAJOR = 0 | ||
VERSION_MINOR = 1 | ||
VERSION_PATCH = 0 | ||
|
||
version_info = (VERSION_MAJOR, VERSION_MINOR, VERSION_PATCH) | ||
version = '%i.%i.%i' % version_info | ||
__version__ = version | ||
|
||
__all__ = ['version', 'version_info', '__version__'] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
[bdist_wheel] | ||
universal=1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
"""This setup script packages pyblish-photoshop.""" | ||
|
||
# Import built-in modules | ||
import importlib | ||
import os | ||
|
||
# Import third-party modules | ||
from setuptools import setup, find_packages | ||
|
||
with open("README.md", "r") as fh: | ||
long_description = fh.read() | ||
|
||
version_file = os.path.abspath("pyblish_photoshop/version.py") | ||
version_mod = importlib.import_module("pyblish_photoshop.version") | ||
version = version_mod.version | ||
|
||
classifiers = [ | ||
"Development Status :: 4 - Beta", | ||
"Intended Audience :: Developers", | ||
"License :: OSI Approved :: GNU Lesser General Public License v3 (LGPLv3)", | ||
"Operating System :: Microsoft :: Windows", | ||
"Operating System :: Microsoft :: Windows :: Windows 10", | ||
"Programming Language :: Python :: 3 :: Only", | ||
"Programming Language :: Python :: 3.5", | ||
"Programming Language :: Python :: 3.6", | ||
"Programming Language :: Python :: 3.7", | ||
"Programming Language :: Python :: 3.8", | ||
"Topic :: Software Development :: Libraries :: Python Modules", | ||
"Topic :: Utilities" | ||
] | ||
|
||
setup( | ||
name="pyblish-photoshop", | ||
version=version, | ||
packages=find_packages(), | ||
url="https://github.com/pyblish/pyblish-photoshop", | ||
license="LGPL", | ||
author="Abstract Factory and Contributors", | ||
author_email="[email protected]", | ||
description="Pyblish integration for Adobe Photoshop", | ||
long_description=long_description, | ||
long_description_content_type="text/markdown", | ||
zip_safe=False, | ||
classifiers=classifiers, | ||
package_data={"pyblish_photoshop": ["plugins/*.py"]}, | ||
install_requires=[ | ||
"photoshop-python-api>=0.12.0", | ||
"pyblish_base>=1.2.1", | ||
"pyblish_lite>=0.8.0", | ||
"click>=7.0" | ||
], | ||
entry_points={ | ||
"console_scripts": ["pyblish-photoshop = pyblish_photoshop.cli:cli"] | ||
}, | ||
) |