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.
Share variable input between workflows
-
I'm using workflows to simplify report writing, where much of the report has standard text. I'm writing one workflow per section/paragraph, which lets me edit each section as needed. It also keeps the workflow from getting so large I can't remember how everything is supposed to fit together for tweaking in the future.
Is there a way to save a variable and it's input
so it could be used by the next or a later workflow? For example the first workflow will fill out a client's name throughout the whole document, but a later paragraph might or might not need a specific sentence that needs to include the client's first name... so, I can leave the place holder, but the first workflow wouldn't be able to fill it out yet.I can copy the output of one variable to the clipboard, but there are three or four variables that would be helpful to have available for later workflows.
-
Is this similar to what I'm trying to accomplish?
http://www.editorial-workflows.com/workflow/5821470613700608/6nojLZbs11w
-
@NikkiSchwartzVB You could abuse the "Get/Set File Contents" actions for storing variables that should persist after a workflow has finished. You'll want to use a local file with a unique name, and you might want to use a name that starts with
.
because it won't show up in the file list that way. -
@omz ty! that will do just fine. I set up three actions to put that data for each of three variables in three files. I'll have later workflows pull from those files.
One Other question... @ccc wrote a great script that included birthdate and age math, as part of a larger script... does that exist anywhere by itself? I've tried to play with it, but without coding experience and no real knowledge of python, I'm getting invalid syntax (surprise, surprise). I want to limit how many pieces of data I am entering myself or buttons I'm pushing, and hoping as much as possible can be automated.
-
Instead of one variable per file, you could also try putting multiple variables into a single file. Check out the workflows
Write yaml
andRead yaml
at http://www.editorial-workflows.com/workflows/recentIn Write yaml the Generate Text and Set File Contents steps are the key ones. In the Generate Text step, we are just creating lines of text that are
variable_name: variable_value
pairs. The key and value are separated by a colon (':'). You can tell your buddies that you are working on a Python persistent key, value store. The Set File Contents step just writes those lines of text to a local file. We now have a poor man's database. Naming is always a thorny issue in computer science. I thought about NikkiBase and SchwartzStore but settled on the far more humble VBDB.From there, creating Read yaml was a cakewalk because these
key: value
formatted lines (which are very human readable) can be understood by the yaml module that @omz has provided for us in Editorial.#coding: utf-8 import workflow import yaml with open('vbdb.yaml') as in_file: data_dict = yaml.load(in_file) for key, value in data_dict.items(): workflow.set_variable(key, value) workflow.set_output(workflow.get_input()) # passthru
This will read in your .yaml file (yaml.load()) and set up all the external variables for you. For each line in the file, it does a
workflow.set_variable(key, value)
.My sense is that you could even create a .yaml file for each client, like
Donald_Trump.yaml
. Your scripts could then do a Read yaml do set all the workflow variables for that client and you are off to the races.YAML stands for Yet Another Markup Language which again proves my point about naming being a thorny issue.
-
Feature request to @omz: When I click on .yml, .yaml, .json files in Editorial, please open these human readable files as text.
-
@NikkiSchwartzVB If you do create a .yaml file per client then consider creating a folder in Editorial called
clients
and the changeDonald_Trump.yaml
toclients/Donald_Trump.yaml
in your read and write logic. This will keep your clients out of your Documents folder.