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.
Input content merged with set variable assignment
-
Not sure how to explain this bug (?). When I run a series of python scripts within Editorial and then try to set a variable I get content from the Input variable IN ADDITION to what I'm setting the variable to. At first I thought it was the result of some buffering so added several Alerts between the variable assignments, no go. It's almost as if Editorial is forcing content from the previous event into my variable assignment. Anyone else see/report this behavior?
...dave
-
Posting a small snippet of code that exhibits this behavior might help us to debug.
-
Okay, Not sure exactly how I'd copy/paste 12 chaining Editorial workflows (or even one workflow) into this reply, so I've created sample workflows of what I'm talking about and made them public for any/all to test.
Install the following:
dtTestVariableCorruption1:
http://www.editorial-workflows.com/workflow/5834706159403008/IujcOpb4G4g
dtTestVariableCorruption2:
http://www.editorial-workflows.com/workflow/5906930329452544/7WUEzjL2pXA
Then add these three documents into your directory:
document1.md
document2.md
document3.mdContent can be anything. Run the script, change the data in any of the documents, run it again. You'll see what I mean.
(The first workflow calls the second workflow and counts characters and repeats for each of the files.)
Thanks in advance for any help.
...dave
-
Hi @daveterry
I looked at what you have, but I didn't actually install the workflows to try it.Could you elaborate on what the goal of the workflow is? Are you just trying to count the characters in several documents, append the count to the document text, and then have all of that in one document?
If so - I think there are some easier ways to accomplish that. Let us know!
(I can't speak about if there is a bug...didn't try the workflows yet...)
-
@daveterry
I don't know if you know Python or not, but here is a simple Python script that does what your two workflows do. (As I was saying I think there are easier ways to accomplish what you're trying to do).To use it, follow the instructions in the script. I've put that on lines starting with a
#
(in Python that's a comment line)You will need to make some file name changes in the script and
As for the workflow, you just need a
Run Python Script
It's possible that if your documents are on Dropbox this won't work. Didn't try but I'm sure it won't. (Because of the path to those files)
#coding: utf-8 import workflow import os #the output of this script into the workflow will be the all the files in the list with their character count. #this document_list is a comma separated list of documents names+extension in single quotes. document_list = ['document1.md', 'document2.md', 'document3.md'] #if the files are all in the same directory thats good. set the director_for_files here: #it should end with a / and will start with 'Documents' #example: Documents/MyFiles/ directory_for_files = 'Documents/' def get_document_contents(document_list, document_root): output = '' for i in document_list: with open(document_root + i, 'r') as file: document_text = file.read() output += document_text + '\n#chars: ' + str(len(document_text)) + '\n\n' workflow.set_output(output) document_root = os.getcwd().split('Library')[0] + directory_for_files get_document_contents(document_list, document_root)
-
@daveterry I also just tested out your workflows etc as you have above. Works as expected here.
Document 1 text Document 1 char count Document 2 text Document 2 char count Document 3 text Document 3 char count
If that's not what you expected then the workflow is actually written wrong rather than a bug. I still have a hard time understanding your first explanation for the post. But, if you have something else going on please explain more. I suggest some examples :
- document text
- the outcome of what you expect from your workflow
- an example of the output from your workflow that is wrong.
-
@cook, did you...
Run the script, change the data in any of the documents, run it again. You'll see what I mean.
-
@ccc I didn't. But now I see what was meant.
So I tried again and indeed there is a bug.Even with the Python script the effect is still the same. Seems to be an issue with the file saving.
If I change the text in document3 and then go to document1 and change something - the changes are okay in document3 but not in document1. It's as if Editorial hasn't had enough time to figure out that something changed yet. (If I wait about 10 seconds and run the script it works)