Welcome!
This is the community forum for my apps Pythonista and Editorial.
For individual support questions, you can also send an email. If you have a very short question or just want to say hello — I'm @olemoritz on Twitter.
Own Python Modules?
-
It's not possible to write Python scripts in Editorial's editor.
So if I need to write a module and import it in a Python action in a workflow – how would I achieve this?
Please don't let the answer be "You cant!"Thanks so much,
Stefan. -
There is a "Run Python Script" action in the action presets. You can export the entire script to the next action if you want to (no syntax correction in the editor.)
I have a workflow called "Modular Python" that let's you use actions as independent scripts.
What is it exactly you want? I'm sure it's possible.
-
You can place a
.py
module in Editorial's Local Storage, and then import it from inside a Run Python Script action. This works, but is cumbersome:- You can't edit a Python file stored in Local Storage. You have to create a
.txt
file, then rename it to.py
with the help of a custom workflow. - If you want to edit this module, you have to repeat the edit-as-txt / rename loop over and over. If you have a ready-to-use module already, this might work for you.
As for me, I wanted to be able to share some code that is common to a number of workflows. Say, one workflow uploads a post to my blog, and another one downloads a post, updating an Editorial document. Obviously I'd like to share the upload/download code, but the approach I described doesn't work as I want to iterate on my upload/download module.
I wish there was a shared storage of Custom Actions, so if I edited the code of a Custom Action in one workflow, all other workflows having the same Custom Action would receive the updated copy of the script. As far as I understand, this is not the case.
Does anyone happen to have any ideas regarding this? I just really hate Copy & Paste for code.
- You can't edit a Python file stored in Local Storage. You have to create a
-
> It's not possible to write Python scripts in Editorial's editor.
It is now.
It seemed like an interesting problem so I created two workflows:
Save as Python...
andEdit Python...
to assist in the creation and editing of Python files that you can import your own Python scripts into your Editorial workflows.Save as Python...
writes the contents of the Editor into a Python file.Edit Python...
reads a Python file and places its contents into the Editor.
You can use
Save to Python...
to putmy_script.py
into place and then your "Run Python Script
" task would be:#coding: utf-8 import my_script, workflow workflow.set_output(my_script.main(workflow.get_input()))
If you are editing Python files then you might want to force a reload to ensure your workflow is really importing your latest and greatest code:
import my_module_a ; reload(my_module_a) import my_module_b ; reload(my_module_b)