def main():
	arg = workflow.get_input().encode('utf-8')
	tag_pattern = re.compile("((?!.*@done).*" + TAG +".*(\n*\t*(?!\w.*:$)\w.*)*)", re.M)
	task_pattern = re.compile('\s{1}@\w+(\(\d{4}-\d{2}-\d{2}\s*((|\d{2}:\d{2}))\)|)', re.M)
	notes_pattern = re.compile("^-.*\n*|\t")
	
	# Isolate tasks with @remind tag
	tp_remind = re.findall(tag_pattern, arg)

	# Iterate over every task tagged and process it.
	url_str = ''
	for match in tp_remind:
		
		# Process Task
		src_task = re.sub("- ","",re.search("^-.*", match[0].strip()).group())
		task = re.sub(task_pattern,'',src_task)
			
		# Process task time
		dt =  taskTime(src_task)
		
		# Prepate notes if Notes == True, else ommit notes from Reminder.
		if ADD_NOTES:
			# Get list of tags from task without remind tag
			tag_str = ' '.join([tag for tag in stripTags(src_task) if stripTags(src_task)])
			
			# Prepare Notes
			notes = (re.sub(notes_pattern,"", match[0].strip())).strip()
			
			# Create body of task
			if tag_str and notes:
				notes_str = notes.strip()+'\n'+tag_str.strip()
			elif tag_str and not notes:
				notes_str = tag_str.strip()
			elif notes and not tag_str:
				notes_str = notes.strip()
			else:
				notes_str = ''
				
		else:
			notes_str = ''

		# Add the task to Reminders.
		task_str = task + ' on ' + str(dt[0]) + ' at ' + str(dt[1]) + ' /' + DEFAULT_LIST

		if url_str == '':
			url_str += 'fantastical2://x-callback-url/parse?sentence='+urllib2.quote(task_str,'')+'&notes='+urllib2.quote(notes_str)+'&reminder=1'

		else:
			url_str = 'fantastical2://x-callback-url/parse?sentence='+urllib2.quote(task_str,'')+'&notes='+urllib2.quote(notes_str,'')+'&reminder=1&x-success='+urllib2.quote(url_str,'')

	workflow.set_output(url_str)
# I can't figure out how to grab Custom UI elements from Editorial, so I'm making this simple. I'm putting them in as text in the input to the workflow as a string, splitting them up into separate values, and using those as the variables.

import workflow

values = workflow.get_input() #value order = "find-type,find-text,replace-text,case_switch"
split_values = values.split(',')

replace_cancel = bool(split_values[4])
find_type = split_values[0]
find_text  = split_values[1]
replace_text = split_values[2]
case_switch = int(split_values[3])

if replace_cancel = True:
    workflow.stop()
else:
    
Example #3
0
# Assuming the alarm format is:
# name of alarm @alarm(yyyy-mm-dd, HH:MM)
# Then create a new workflow with the two items.
# First One is the get document text element
# Second one is to run the python code:

from __future__ import print_function
import re
import editor
import dialogs
import datetime
import workflow
import reminders

action_in = workflow.get_input()
for line in action_in.split('\n'):
    for name, s_time in re.findall(r'(.*)@alarm\((.*)\)', line):
        date, time = s_time.split(', ')
        d_yyyy, d_mm, d_dd = [int(x) for x in date.split('-')]
        t_hh, t_mm = [int(x) for x in time.split(':')]
        rem = reminders.Reminder()
        rem.title = name
        due = datetime.datetime(d_yyyy, d_mm, d_dd, t_hh, t_mm)
        rem.due_date = due
        a = reminders.Alarm()
        a.date = due
        rem.alarms = [a]
        try:
            res = dialogs.alert(
                'The Reminder Was Set',
Example #4
0
import linguistictagger
import re
import workflow

def capitalize_(s):
	if re.search(r"[A-Z]", s):
		return s
	else:
		return s.capitalize()

articles = ["a", "an", "the"]
coordinating_conjunctions = ["and", "but", "for", "nor", "or"]
general_exceptions = articles + coordinating_conjunctions + ["to", "n’t", "n't"]

input = workflow.get_input()
input_prefix = re.sub(r"^([^A-z]*).*", "\\1", input)
title = re.sub(r"^[^A-z]*([A-z].*)", "\\1", input)
title_tagged = linguistictagger.tag_string(title, linguistictagger.SCHEME_LEXICAL_CLASS)
last_word = len(title_tagged) - 1
output = []

while True:
	if re.search(r"[ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0-9]", title_tagged[last_word][1]): # `r"[A-z]"`/`r"\w"` matches `_`!?
		break
	last_word -= 1

for i, v in enumerate(title_tagged):
	w = re.sub(r"^[*_]*([^*_]*)", "\\1", v[1])
	w_prefix = re.sub(r"^([*_]*)[^*_]*", "\\1", v[1])
	if i == 0 or i == last_word:
# |-----------------|--------:|
# | Title1          |     0.0 |
# | Title2          |     0.0 |
def create_md_table (headers, titles, stats):
    line_template = '| {:<14} | {:>5} |\n'
    header_line = line_template.format(*headers)
    entry_lines = map(lambda t: line_template.format(*t), zip(titles, stats))
    table_break = '|{0:-<16}|{0:->6}:|\n'.format('')
    return header_line + table_break + ''.join(entry_lines)

headers = ('Daily Stats', '')
titles = [
        'Medication',
        'Alcohol',
        'Caffeine',
        'Anxiety',
        'Energy',
        'Happiness',
        'Sleep Hours',
        'Sleep Quality',
        'Systolic',
        'Diastolic'
        # 'Word Count',
]

stats = get_stats(workflow.get_input())
# print process_stats(workflow.get_input())
workflow.set_variable('journal_entry_stats',create_md_table(headers, titles, stats))
workflow.set_variable('csv_entry', ", ".join(map(str,stats)))
###
Example #6
0
import workflow
import re

##get url from previous action
url = workflow.get_input()
match = re.search(r"youtube\.com/.*v=([^&]*)", url)
if match:
  action_out = match.group(1)
else:
  action_out = 'error'

#print action_out

workflow.set_output(action_out)
def main():
    arg = workflow.get_input().encode('utf-8')
    tag_pattern = re.compile(
        "((?!.*@done).*" + TAG + ".*(\n*\t*(?!\w.*:$)\w.*)*)", re.M)
    task_pattern = re.compile(
        '\s{1}@\w+(\(\d{4}-\d{2}-\d{2}\s*((|\d{2}:\d{2}))\)|)', re.M)
    notes_pattern = re.compile("^-.*\n*|\t")

    # Isolate tasks with @remind tag
    tp_remind = re.findall(tag_pattern, arg)

    # Iterate over every task tagged and process it.
    url_str = ''
    for match in tp_remind:

        # Process Task
        src_task = re.sub("- ", "",
                          re.search("^-.*", match[0].strip()).group())
        task = re.sub(task_pattern, '', src_task)

        # Process task time
        dt = taskTime(src_task)

        # Prepate notes if Notes == True, else ommit notes from Reminder.
        if ADD_NOTES:
            # Get list of tags from task without remind tag
            tag_str = ' '.join(
                [tag for tag in stripTags(src_task) if stripTags(src_task)])

            # Prepare Notes
            notes = (re.sub(notes_pattern, "", match[0].strip())).strip()

            # Create body of task
            if tag_str and notes:
                notes_str = notes.strip() + '\n' + tag_str.strip()
            elif tag_str and not notes:
                notes_str = tag_str.strip()
            elif notes and not tag_str:
                notes_str = notes.strip()
            else:
                notes_str = ''

        else:
            notes_str = ''

        # Add the task to Reminders.
        task_str = task + ' on ' + str(dt[0]) + ' at ' + str(
            dt[1]) + ' /' + DEFAULT_LIST

        if url_str == '':
            url_str += 'fantastical2://x-callback-url/parse?sentence=' + urllib2.quote(
                task_str,
                '') + '&notes=' + urllib2.quote(notes_str) + '&reminder=1'

        else:
            url_str = 'fantastical2://x-callback-url/parse?sentence=' + urllib2.quote(
                task_str, '') + '&notes=' + urllib2.quote(
                    notes_str, '') + '&reminder=1&x-success=' + urllib2.quote(
                        url_str, '')

    workflow.set_output(url_str)
Example #8
0

def capitalize_(s):
    if re.search(r"[A-Z]", s):
        return s
    else:
        return s.capitalize()


articles = ["a", "an", "the"]
coordinating_conjunctions = ["and", "but", "for", "nor", "or"]
general_exceptions = articles + coordinating_conjunctions + [
    "to", "n’t", "n't"
]

input = workflow.get_input()
input_prefix = re.sub(r"^([^A-z]*).*", "\\1", input)
title = re.sub(r"^[^A-z]*([A-z].*)", "\\1", input)
title_tagged = linguistictagger.tag_string(
    title, linguistictagger.SCHEME_LEXICAL_CLASS)
last_word = len(title_tagged) - 1
output = []

while True:
    if re.search(
            r"[ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0-9]",
            title_tagged[last_word][1]):  # `r"[A-z]"`/`r"\w"` matches `_`!?
        break
    last_word -= 1

for i, v in enumerate(title_tagged):
print('\n'.join(sorted(my_list, key=len)))   #Line 10
print('=' * 5)

#print('\n'.join(reversed(sorted(my_list, key=len))))
#print('=' * 5)

###==============================

Line 10: TypeError: 'builtin_function_or_method' object is not iterable

###==============================

#coding: utf-8
import workflow

action_in = workflow.get_input()
my_list = action_in.splitlines()

print('\n'.join(my_list))
print('=' * 5)
print('\n'.join(sorted(my_list)))
print('=' * 5)
print('\n'.join(sorted(my_list, key=len)))
print('=' * 5)
print('\n'.join(reversed(sorted(my_list, key=len))))
print('=' * 5)

#: Generate the output...
action_out = '\n'.join(reversed(sorted(my_list, key=len)))
workflow.set_output(action_out)