Editorial Workflows

Save as Python...

public workflow

Install Workflow...

This workflow contains at least one Python script. Only use it if you trust the person who shared this with you, and if you know exactly what it does.

I understand, install the workflow!

This is a workflow for Editorial, a Markdown and plain text editor for iOS. To download it, you need to view this page on a device that has the app installed.

Description: Save the Editor text into a Python file which you can import into Python snippets in your workflows. This workflow is paired with "Edit Python...".

See: http://omz-forums.appspot.com/editorial/post/5265481661415424

Shared by: @cclauss

Comments: Comment Feed (RSS)

There are no comments yet.

+ Add Comment

Workflow Preview
Document Text ?
Folded Text
  • Include
  • Replace with:
If… ?
Run the block if
Input
  • is Equal to
  • is Not Equal to
  • Contains
  • Doesn't Contain
  • Matches Regular Expression
Stop ?
Stop
  • This Workflow
  • Repeat Block
Show HUD Alert
ON
Message
There is no text in the Editor!
…End If
Request Text Input ?
Title
Enter a filename for your Python file.
Initial Text
  • Single Line
  • Multiple Lines
Keyboard Options:
If… ?
Run the block if
Input
  • is Equal to
  • is Not Equal to
  • Contains
  • Doesn't Contain
  • Matches Regular Expression
Stop ?
Stop
  • This Workflow
  • Repeat Block
Show HUD Alert
ON
Message
No filename was provided!
…End If
Run Python Script ?
Source Code
#coding: utf-8
import editor, os, workflow

action_in = workflow.get_input()

#TODO: Generate the output...
filename = action_in.strip()
root, ext = os.path.splitext(filename)
filename = (root if ext.lower() == '.py' else filename) + '.py'
with open(filename, 'w') as out_file:
    out_file.write(editor.get_text().lstrip())
action_out = filename

workflow.set_output(action_out)
Show HUD ?
HUD Text
The Editor text was written to file "Input".
Duration
  • 1 Second
  • 2 Seconds
  • 3 Seconds
Icon
  • "Success"
  • "Error"