The Omni Group Forums

The Omni Group Forums (http://forums.omnigroup.com/index.php)
-   OmniFocus Extras (http://forums.omnigroup.com/forumdisplay.php?f=44)
-   -   Script: Filtered export to iThoughtsHD & OPML (& .txt) (http://forums.omnigroup.com/showthread.php?t=25965)

RobTrew 2012-09-29 07:05 AM

Script: Filtered export to iThoughtsHD & OPML (& .txt)
 
1 Attachment(s)
[COLOR="White"]--[/COLOR]
A rough draft of a script which builds on the earlier [URL="http://forums.omnigroup.com/showthread.php?t=25421"]OF to OPML exporter[/URL] adding:
[LIST=1][*]Export to the iThoughts formats .itmz and .itm, and to plain tab-indented .txt, as well as to Markdown and [URL="http://mac.appstorm.net/reviews/productivity-review/foldingtext-a-swiss-army-knife-for-plain-text-lovers/"]FoldingText[/URL] .todo mode,[*]some scope for customising (filtering) the set of OmniFocus data which is exported,[*]some basic options for customising the colors, expansion pattern, etc in iThoughtsHD.[/LIST]
If you create a small and simple iThoughtsHD file (.itmz or unzipped .itm), consisting [B]only of a root node and some coloured top-level branches[/B] (anything bigger will slow things down) you can give its pathname in the pstrTemplate property in the header of the script, which should then pick up the main formatting settings of the template, and the set of colours used in its top-level branches.

I attach a sample pastel.itm template, and a bright.itmz template (.itmz files are zipped 'map.itm' files).

Anyone prepared to dip cautiously into SQL (unsupported and at their own risk) should be able to customise the set of data exported by adjusting some properties at the head of the script.

For iThoughtsHD exports, the [I]-c [I]or [/I]--collapse[/I] switch allows you to specify which levels of the diagram (root=1) are collapsed.

The script is attached, with templates, below.

[B]Note: requires OS X 10.7 and above (Python 2.7)[/B]

For reference, its header looks like this:

[CODE]-- Copyright (C) 2012 Robin Trew
--
-- Permission is hereby granted, free of charge,
-- to any person obtaining a copy of this software
-- and associated documentation files (the "Software"),
-- to deal in the Software without restriction,
-- including without limitation the rights to use, copy,
-- modify, merge, publish, distribute, sublicense,
-- and/or sell copies of the Software, and to permit persons
-- to whom the Software is furnished to do so,
-- subject to the following conditions:

-- *******
-- The above copyright notice and this permission notice
-- shall be included in ALL copies
-- or substantial portions of the Software.
-- *******

-- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-- EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
-- OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
-- IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
-- DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
-- TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE
-- OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

property pTitle : "Export OmniFocus data"
property pVer : "0.021"
property pAuthor : "Robin Trew"
property pSite : "Orginally published on http://forums.omnigroup.com"


property plstFormats : {"OPML", "ITM", "ITMZ", "TXT", "MD", "FT"}

-- OPTION STRINGS, including SQL filter strings
property pstrCollapseLevels : "4"
property pstrTemplate : "" -- Filename of small .itm or .itmz template to look for in same folder as script (for colors etc)
property pstrOutFolder : (path to desktop)

-- SQL filter notes
-- 1. Comma will be translated to AND
-- 2. Neither OR nor bracketing is supported
-- 3. Status strings should not be quoted - ie status = [active|done|inactive|dropped]
-- 4. As usual, the [ = | != ] operators can not be used with null. Use [is null | is not null]
-- 5. For ALL use the simple filter 1, and for none, use 0
-- No Inbox tasks would be: property psqlInboxFilter : 0

property psqlFolderFilter : "effectiveActive = 1"
property psqlSinglesHoldersFilter : "folderEffectiveActive = 1, status = active, dateCompleted is null"
property psqlProjectFilter : "folderEffectiveActive = 1, status = active, dateCompleted is null"
property psqlTaskFilter : "effectiveContainingProjectInfoActive = 1, dateCompleted is null"
property psqlInboxFilter : "1" -- edit this to "1" for ALL inbox entries, or sth like "dateCompleted is null" to filter

-- SOME ALTERNATIVES
-- Don't show Inbox:
-- property psqlInboxFilter : 0

-- Exclude taskless projects
-- property psqlProjectFilter : "numberOfRemainingTasks > 0, folderEffectiveActive = 1, status = active, dateCompleted is null"

-- Exclude Projects and tasks with future start dates
-- property psqlProjectFilter : "taskBlockedByFutureStartDate=0, folderEffectiveActive = 1, status = active, dateCompleted is null"
-- property psqlTaskFilter : "BlockedByFutureStartDate=0, effectiveContainingProjectInfoActive = 1, dateCompleted is null"

-- OPTION FLAGS
property pblnIncludeOFLinks : false
property pblnIncludeNotes : true
property pblnRecurInfo : false -- prepend any Task Recurrence info to note
[/CODE]

RobTrew 2012-09-29 02:06 PM

Ver 011 above fixes the choice between exporting [B]al[/B]l filtered data, and only exporting the selected node and all its descendants.

Ver 012 now works with Keyboard Maestro

Ver 014 added info on defaults to all options in help page. (As below)

Running the python file without any arguments at all would export all active data (without links or notes) to a file called current_tasks.itm in the same directory as the script.

Adding the switches -n -l -r for example, would include notes and links back to the original OmniFocus object, and prepend the notes with any recurrence info.

[CODE]Usage: ofoc_to_mindmap_021.py [options]

Options:
-h, --help show this help message and exit
-a ROOT, --root=ROOT Specify a sub-tree by the OmniFocus id of its root
node. Defaults to None.
-x FORMAT, --format=FORMAT
Set the export format [itmz | itm | opml | txt | md |
ft]. Defaults to tab-indented txt. md is simple
Markdown, ft is Markdown with the addition of
FoldingText's .todo mode tags for checkboxes and
struck-through done items
-o OUTPUT, --output=OUTPUT
Set the export filepath. Defaults to file named
current_tasks
-c COLLAPSE, --collapse=COLLAPSE
List the outline levels to collapse. Defaults to 2,4
-m TEMPLATE, --template=TEMPLATE
The pathname of an .itm or .itmz template for
iThoughtsHD. Defaults to same directory as script.
-l, --links Include OmniFocus task/folder links. Defaults to false
-n, --notes Include OmniFocus notes. Defaults to false
-r, --recurinfo Add any repetition information to start of notes.
Defaults to false
-f FOLDER_SQL, --folders=FOLDER_SQL
SQL clause[s] to limit which FOLDERS are exported.
Defaults to effectiveActive=1
-s SINGLES_SQL, --singlelists=SINGLES_SQL
SQL clause[s] to limit which SINGLE ACTION LISTS
are exported. Defaults to status=active,
folderEffectiveActive=1, dateCompleted is null
-p PROJECT_SQL, --projects=PROJECT_SQL
SQL clause[s] to limit which PROJECTS are exported.
Defaults to status=active, folderEffectiveActive=1,
dateCompleted is null Use a comma for AND (OR is not
supported) e.g. -p 'childrenCount > 0,
blockedByFutureStartDate = 0'
-t TASK_SQL, --tasks=TASK_SQL
SQL clause[s] to limit which TASKS are exported.
Defaults to dateCompleted is null,
effectiveContainingProjectInfoActive=1
-i INBOX_SQL, --inbox=INBOX_SQL
SQL clause[s] to limit which INBOX TASKS are exported.
Defaults to all inbox tasks[/CODE]

[COLOR="White"]--[/COLOR]

RobTrew 2012-09-30 06:10 AM

For command line, or shell script use, you could make a copy of the python file in the Resources folder of the .scptd package, and use some variant of:

[CODE]#!/bin/sh
python $HOME/ofoc_to_mindmap_012.py --format=itm --output=$HOME/Desktop/ActiveTasks -m $HOME/Template.itm -l -n -c '2,4' -f 'effectiveActive = 1' -s 'folderEffectiveActive = 1, status = active, dateCompleted is null' -p 'folderEffectiveActive = 1, status = active, dateCompleted is null' -t 'effectiveContainingProjectInfoActive = 1, dateCompleted is null' -i '1'
[/CODE]

Which assumes, for the sake of illustration, that the python script, and a small [I]Template.itm[/I] file (containing an example of your preferred formatting and colours for iThoughtsHD) are both in your home directory.

(The help option in the script menu of the Applescript wrapper places a listing of the command line options into the clipboard).

[COLOR="White"]--[/COLOR]

viticci 2012-09-30 11:35 AM

[QUOTE=RobTrew;115378]For command line, or shell script use, you could make a copy of the python file in the Resources folder of the .scptd package, and use some variant of:

[CODE]#!/bin/sh
python $HOME/ofoc_to_mindmap_012.py --format=itm --output=$HOME/Desktop/ActiveTasks -m $HOME/Template.itm -l -n -c '2,4' -f 'effectiveActive = 1' -s 'folderEffectiveActive = 1, status = active, dateCompleted is null' -p 'folderEffectiveActive = 1, status = active, dateCompleted is null' -t 'effectiveContainingProjectInfoActive = 1, dateCompleted is null' -i '1'
[/CODE]

Which assumes, for the sake of illustration, that the python script, and a small [I]Template.itm[/I] file (containing an example of your preferred formatting and colours for iThoughtsHD) are both in your home directory.

(The help option in the script menu of the Applescript wrapper places a listing of the command line options into the clipboard).

[COLOR="White"]--[/COLOR][/QUOTE]

Thanks for the awesome script, Rob.

I am having an issue with running it as shell script. In iThoughtsHD, I create a test map as template, and I save it as Template.itmz. From Hazel on the Mac, I set the shell script to have .itm as output and Template.itmz as template file for colors and shapes.

However, the ActiveTasks.itm file that is generated by the script doesn't open with the color and shape settings of Template.itmz. For instance, I set wireframe and right-angle link styles, and the .itm file opens with S Bend and a different background.

The Template.itmz is in the correct location, as requested by the shell script.

Thanks again!

RobTrew 2012-09-30 11:43 AM

Thanks for the feedback.

The help page should read [I]filename[/I] rather than [I]pathname[/I] i.e. in the current version any template file needs to be in the same folder as the script. Specifying a full path (rather than just a filename) for the [I]--template[/I] option wouldn't work.

(I'll make a note for a future version to allow for templates located in other folders, as specified by a full path given to the [I]--template[/I] option.

viticci 2012-09-30 12:04 PM

Yes, but I am already specifying a filename for a template file in the same folder of the script.

It's just that when I open the generated .itm file, the styles aren't retained.

viticci 2012-09-30 12:40 PM

Oh, and by the way, I have tried both the shell script version and the full AppleScript file. In both cases, the .itm that is created doesn't have the colors and styles of the Template.

RobTrew 2012-09-30 12:52 PM

[QUOTE=viticci;115392]Oh, and by the way, I have tried both the shell script version and the full AppleScript file. In both cases, the .itm that is created doesn't have the colors and styles of the Template.[/QUOTE]

Thanks - my first response was wrong - first of all, it turns out that the script does actually pick up the pathname, as the help page suggests.

For me this kind of thing is working:

-m '/Users/[I]username[/I]/Library/Scripts/Applications/Omnifocus/Bright.itmz'

Could I ask you to experiment with trying this with the Bright.itmz and pastel.itm templates in the .zip, to see if they are making a difference on your system ?

(I take it that the script is not reporting failure to find the template ?)

The script does two things with the template:
1. it adopts the plist wrapping of the data
2. it reads the colours just from the top level branches

It may be worth studying the two supplied examples in a text editor (you'll need to unzip the .itmz file and look at the map.itm file which it contains) and comparing them with the template you are using.

[COLOR="White"]--[/COLOR]

viticci 2012-09-30 01:27 PM

[QUOTE=RobTrew;115393]Thanks - my first response was wrong - first of all, it turns out that the script does actually pick up the pathname, as the help page suggests.

For me this kind of thing is working:

-m '/Users/[I]username[/I]/Library/Scripts/Applications/Omnifocus/Bright.itmz'

Could I ask you to experiment with trying this with the Bright.itmz and pastel.itm templates in the .zip, to see if they are making a difference on your system ?

(I take it that the script is not reporting failure to find the template ?)

The script does two things with the template:
1. it adopts the plist wrapping of the data
2. it reads the colours just from the top level branches

It may be worth studying the two supplied examples in a text editor (you'll need to unzip the .itmz file and look at the map.itm file which it contains) and comparing them with the template you are using.

[COLOR="White"]--[/COLOR][/QUOTE]

Ok, my bad. I wasn't unzipping the .itmz file so that's why the script wasn't picking up the styles.

It looks like you can't set shapes in the current version. Maybe there's a workaround for this?

For instance, here's the template, and the file based on it.

Template

[IMG]http://dl.dropbox.com/u/490969/itm%20template.PNG[/IMG]

OF export

[IMG]http://dl.dropbox.com/u/490969/of%20export.PNG[/IMG]

RobTrew 2012-09-30 02:37 PM

[QUOTE=viticci;115394]Ok, my bad. I wasn't unzipping the .itmz file so that's why the script wasn't picking up the styles.[/QUOTE]

Shouldn't really have to unzip them - zipped (.itmz) templates seem to be working here.

[QUOTE=viticci;115394]It looks like you can't set shapes in the current version. Maybe there's a workaround for this?[/QUOTE]

Good catch. It seems that the [I]Inherit Shape[/I] setting kicks in from the top-level branches rather than from the root node.

Ver 015 now reads the shapes, as well as the colors, from the top level branches of the template, and if [I]Inherit Shape[/I] is set, that should cascade down through the diagram.

(Doesn't yet read the root node colour/shape though - I'll get round to that at some point - busy week ahead :-)


All times are GMT -8. The time now is 09:31 PM.

Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2024, vBulletin Solutions, Inc.