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 :-)

RobTrew 2012-09-30 04:09 PM

3 Attachment(s)
Took a quick look at it.
Ver 016 should now inherit colours and shapes of both root and level 1 branches from any specified template itm or itmz template.

If your template sets the [I]inherited shapes[/I] option, levels 2 onwards will inherit the level 1 shapes.

(I seem to be getting the effect that you are after by specifying the SquareDarkWire template attached below, and something analogous but lighter with the RedOrthog.itmz template below)

(The image also illustrates why one might prefer to switch off the export of links - jumping to the corresponding OF object can be useful, but those globes are quite distracting )

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

viticci 2012-09-30 06:44 PM

This is perfect Rob, thank you so much. Now shapes and colors are inherited correctly, and like you suggested I removed the links so I don't get the globe icons.

Looking forward to trying a version that writes to .itmz; when you choose "Download and Sync" from iThoughts, you have to put in an additional .itmz file for the app to sync -- apparently, .itm files can be [I]read[/I], but new versions (generated by the script) won't trigger a sync in iThoughts. I think .itmz will do it.

RobTrew 2012-10-01 12:08 AM

[QUOTE=viticci;115399].itm files can be [I]read[/I], but new versions (generated by the script) won't trigger a sync in iThoughts. I think .itmz will do it.[/QUOTE]

That's interesting - thanks for the feedback.

Ver 017 (in first post) adds ITMZ

Ver 018 actually compresses the file, rather than simply storing it uncompressed in a zip (ITMZ) archive.

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

viticci 2012-10-01 02:14 AM

Great. Version 017 indeed generates .itmz files that can be synced without downloading every time. Thanks Rob!

Version 018 working flawlessly as well.

viticci 2012-10-01 04:52 AM

Just noticed -- stuff like "TIM 19" shows up as "TIM €19" when opening the plain text export in the browser (say, a .txt hosted on Dropbox). When you save the file to a Mac, it is converted again to .

Browser is Safari 6.0.1. on Mountain Lion 10.8.2.

RobTrew 2012-10-01 04:54 AM

Thanks - I'll take a look at the UTF encoding options. May need to have two different TXT exports.

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

RobTrew 2012-10-01 05:40 AM

The UTF-8 encoding seems to be fine.

You may be encountering a browser settings issue. In Safari, for example, you could try [B]Preferences > Advanced > Default encoding > Unicode (UTF-8)[/B]

viticci 2012-10-01 06:00 AM

Might be some weird Dropbox.com edge case. If I preview the file from Dropbox.com, I get the encoding error. If I save the file, and re-open it through Safari, it displays correctly. My encoding is set to UTF-8.

Edit: Also happens when viewing the .txt file in the Dropbox app for iOS.

RobTrew 2012-10-01 06:22 AM

Yes, I think the problem is with Dropbox and its default text assumptions.

I'm finding that Safari is immediately able to correctly view the freshly written file in a Dropbox folder, without any need for transformative saving. (As long as Safari's default text encoding is UTF-8)

Viewed through the Dropbox web interface, however, even in Safari, you need to manually choose [B]View > Text Encoding > Unicode[/B] before it is correctly displayed. They seem to be serving up the text with a different default assumption, and perhaps that culture/policy is replicated in their iOS app.

RobTrew 2012-10-01 06:56 AM

As a quick test case - it turns out that the Dropbox web interface similarly fails to correctly display a piece of text saved directly (with UTF-8 encoding), by TextMate …

(Always good to check these things though - thanks for drawing it to my attention).

Mschechter 2012-10-01 07:48 AM

Any reason why this:

[QUOTE]property psqlProjectFilter : "childrenCount > 0, taskBlockedByFutureStartDate=0, folderEffectiveActive = 1, status = active, dateCompleted is null"[/QUOTE]

kills the tasks with future dates, but doesn't kill the projects with no tasks?

RobTrew 2012-10-01 08:01 AM

Well caught - yes there is :-)

In lieu of:
[CODE]childrenCount > 0[/CODE]

try:
[CODE]numberOfRemainingTasks > 0[/CODE]

(the problem with [I]childrenCount[/I] is that it includes, for a start, any completed tasks)

Thanks for my drawing attention to that, I'll update the comments in the script file.

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

RobTrew 2012-10-02 07:55 AM

Added a couple of export formats to Ver 021 in the [URL="http://forums.omnigroup.com/showpost.php?p=115352&postcount=1"]first post[/URL].
[LIST=1][*]MD for simple Markdown[*]FT to enhance the basic MD with tags for [URL="http://www.foldingtext.com"]FoldingText[/URL]'s [URL="http://mac.appstorm.net/reviews/productivity-review/foldingtext-a-swiss-army-knife-for-plain-text-lovers/"]todo mode[/URL], which gives checkboxes to tasks, and provides strike-through for any done items.[/LIST]
Note: you can include done items in your export by adjusting the task (and project) filters to remove the [I]dateCompleted is null[/I] condition.

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

RobTrew 2012-10-04 04:10 AM

MacStories has [URL="http://www.macstories.net/tutorials/visualize-omnifocus-as-ithoughts-map-opml-or-plain-text/"]a good article[/URL] on using this script (through Hazel) to keep an iThoughtsHD mind map automatically updated with changes in your OmniFocus data.

kingsinger 2012-10-09 10:24 AM

Anyone else getting an error when they run the applescript version? Happens both when I run it on a specific folder and when I run it on all filterd data. I'm running Snow Leopard 10.6.8. Here is the error I'm getting. Wondering if maybe my database is corrupted or something.

EDIT: Also I was trying to export as OPML

[CODE]error "SystemUIServer got an error: Traceback (most recent call last):
File \"/Users/REDACTED/Library/Scripts/Applications/Omnifocus/OF2MindMap-022/OF2MindMap-022.scptd/Contents/Resources/ofoc_to_mindmap_022.py\", line 945, in <module>
main()
File \"/Users/REDACTED/Library/Scripts/Applications/Omnifocus/OF2MindMap-022/OF2MindMap-022.scptd/Contents/Resources/ofoc_to_mindmap_022.py\", line 104, in main
lst_tree = build_tree(options.root)
File \"/Users/REDACTED/Library/Scripts/Applications/Omnifocus/OF2MindMap-022/OF2MindMap-022.scptd/Contents/Resources/ofoc_to_mindmap_022.py\", line 270, in build_tree
(var_root_parent, flat_of) = get_flat_omnifocus(var_root)
File \"/Users/REDACTED/Library/Scripts/Applications/Omnifocus/OF2MindMap-022/OF2MindMap-022.scptd/Contents/Resources/ofoc_to_mindmap_022.py\", line 783, in get_flat_omnifocus
WHERE (containsSingletonActions = 1) and ', str_clauses]), tpl)
sqlite3.OperationalError: near \"?\": syntax error" number 1[/CODE]

RobTrew 2012-10-09 10:47 AM

What do you see in the Terminal if you enter:
[CODE]sqlite3 -version ; Python -V[/CODE]
?

( I wonder if there is syntax issue with earlier versions - I haven't tested on OS X 10.6 )

kingsinger 2012-10-09 05:02 PM

I see this:

[CODE]3.6.12
Python 2.6.1
[/CODE]

kingsinger 2012-10-09 10:39 PM

FWIW, when I run the ActiveOF2OPML-011 script, I get this error message (looks like pretty much the same one):

[CODE]error "Traceback (most recent call last):
File \"/Users/Redacted/Downloads/ActiveOF2OPML-011.scptd/Contents/Resources/ofoc_sqlite_to_opml_011.py\", line 253, in <module>
main()
File \"/Users/Redacted/Downloads/ActiveOF2OPML-011.scptd/Contents/Resources/ofoc_sqlite_to_opml_011.py\", line 66, in main
flat_of = get_flat_omnifocus()
File \"/Users/Redacted/Downloads/ActiveOF2OPML-011.scptd/Contents/Resources/ofoc_sqlite_to_opml_011.py\", line 155, in get_flat_omnifocus
and p.folderEffectiveActive = ? and tpl.dateCompleted is ?', tpl)
sqlite3.OperationalError: near \"?\": syntax error" number 1[/CODE]

Don't know if that's helpful at all.

KS

RobTrew 2012-10-09 11:02 PM

OK, something to do with the OS version, I think. I've reproduced the problem on another system running 10.6

I think you'll find that the problems vanish if and when you upgrade your version of OS X. In the meanwhile, thank you for drawing this to my attention, and I'll add a note about the script requiring OS X 10.7 and above.

(I won't advise you to upgrade your Python installation to 2.7, because while it is possible to have two versions of Python installed concurrently, you have to be careful not to replace the version which OS X is using, in case there are any script dependencies in OS X processes. I am also not sure that it is the Python version that is the issue).

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

kingsinger 2012-10-10 02:56 PM

Thanks. No imminent plans to upgrade, so I guess I'll just have do without for now.

Paul_A 2013-01-14 09:55 PM

Hi all.

Rob, thanks for a very useful script.

For some reason, the standalone python version throws a fit when I run it. It tells me that "today" is not defined (line 120)

I've managed to work around by using "time" instead:

str_file = time.strftime('%Y-%h-%d-%Hh%Mm%Ss')

but it seems like a strange error. Its probably my install of python which is wonky.
Anybody faced the same problem?

Cheers

RobTrew 2013-01-15 02:55 AM

Thanks for the report – I haven't see that here. (I'll try to take a look and give it some thought at the weekend).

What, broadly, is your OS X version and Python history ?

splitloop 2013-01-15 03:44 AM

Your workflow on mac
 
Rob, thanks a lot for a great script indeed!
Could you, guys share your workflow on a mac, how do you use this brilliant opportunity to represent your entire life as a map?
I've just exported my OF base to MindNode for the 1st time - looks awesome. Although I'd like to have images representing my main areas of life and I wonder, is there any solution to get them in my mindmap with every export? Maybe to assign them in OF somehow?
And are due dates and other stuff from OF available in iThoughts only? As I've got not iPad, I'd like to find the best solution for Mac. I've also tried Mythoughts, but didnt find due dates there, though notes are there, and another moment is that all branches are of the same color..

Paul_A 2013-01-15 05:07 AM

Sorry, I should've thought to include this.

OS X 10.8.2
Python is basic OS X Python that comes with Mountain Lion
Well, that's not entirely true. I installed Virtual Environments on my MBAir to get the latest Python releases, but I wasn't using them. When the problem appeared, I deactivated them but the problem kept reappearing. However, I haven't kept track of which packages are available where.

As for my own history with python ... let's say I'm dipping my toes in the shallow end of the pool ;-)

Testing this on another machine - will let you know.

Paul_A 2013-01-15 05:11 AM

@splitloop
You can use MindNode (IIRC there is a free version, web is [url]http://mindnode.com[/url]) on the OPML version of the file.
And yes, due dates seem to disappear.

splitloop 2013-01-15 05:33 AM

yeah, thats what I'm using. So is there a program for Mac where start and due dates would work?
Does anyone here use mac for mindmapping from OF?

Paul_A 2013-01-15 05:53 AM

[QUOTE=Paul_A;119282]Sorry, I should've thought to include this.

OS X 10.8.2
Python is basic OS X Python that comes with Mountain Lion
Well, that's not entirely true. I installed Virtual Environments on my MBAir to get the latest Python releases, but I wasn't using them. When the problem appeared, I deactivated them but the problem kept reappearing. However, I haven't kept track of which packages are available where.

As for my own history with python ... let's say I'm dipping my toes in the shallow end of the pool ;-)

Testing this on another machine - will let you know.[/QUOTE]

OK, so other machine exhibits same issue.
If I run the script (with FastScript) everything is smooth.
When I run the embedded python, i get the error.

Pauls-iMac:~ paul$ python ofoc_to_mindmap_022.py --format=itmz --output=$HOME/maps/ -c '0'
Traceback (most recent call last):
File "ofoc_to_mindmap_022.py", line 945, in <module>
main()
File "ofoc_to_mindmap_022.py", line 120, in main
str_file = today.strftime('%Y-%h-%d-%Hh%Mm%Ss')
NameError: global name 'today' is not defined

If I replace with time.strftime ... then it works as advertised ...

RobTrew 2013-01-16 12:36 AM

[QUOTE=Paul_A;119285]OK, so other machine exhibits same issue.
If I run the script (with FastScript) everything is smooth.
When I run the embedded python, i get the error. [/QUOTE]

What is the full command line that you are using ? Might that be the source of the string 'today' ?

(The AS script also just calls the Python script with a set of arguments - if you trace the script you can see exactly what command line it assembles).

Paul_A 2013-01-21 05:10 PM

Sorry to take so long to reply. Extended week-end AFK.

So here's the scary thing: it now works. The only thing I can think of that changed is that I restarted the Mac.
Sorry for sending you on a wild goose chase, and thanks for helping out.

One question for future reference: how do I trace a script?

Cheers

RobTrew 2013-01-22 12:29 AM

Good, I'm glad its working.

You should be able to see the command line that is being assembled by the Applescript by looking at the Event Log in Applescript Editor, or inserting a [CODE]display dialog[/CODE] to show the value of the string.

([URL="http://www.latenightsw.com"]Script Debugger[/URL] is, of course, excellent).

kingsinger 2013-02-19 02:57 PM

[QUOTE=splitloop;119284]yeah, thats what I'm using. So is there a program for Mac where start and due dates would work?
Does anyone here use mac for mindmapping from OF?[/QUOTE]

You could try opening it up in Freeplane. It's free and runs on the mac. It's not the prettiest to look at, but it seems pretty powerful.

I can't test it because the conversion script doesn't work on 10.6.8, which is what my computer runs.

KS

Kazza 2013-03-23 12:08 AM

Fantastic!... just 2 little wrinkles
 
Rob

This is a fantastic script and I appreciate how much work has gone into this. I've got it working beautifully from the terminal prompt as I'm going to do the 'Hazel thing' and make it happen automatically in the background.

There are just two little wrinkles.

1. The start dates I get in iThought are 10 hours behind what I see in OmniF. Now I'm in Australia and 10hours ahead of GMT, which might be relevant. My test task has a start date of 1 June 2013, 11pm, and the entry in the ITM file says
start="010613 130000"

When I load this into iThought it says, unsurprisingly, 1 June 2013 1pm.
So its out by 10 hours.

As Omnifocus defaults all startdates to midnight, effectively every date I see in the MindMap is one day earlier than it really is.


2. The code seems to be hardwired to only look at ACTIVE tasks. No matter what I do with the SQL input parameters, projects on HOLD get ignored. I've looked at the Python code but couldn't see an easy way to fix this. Am I missing something?

My work around here is to take projects off HOLD before running the script, but then I'm less likely to use the HOLD feature which is a really useful way of simplifying what I look at in OMNIF.

(Ideally, I'd love the ON HOLD projects to land in MindMap with a different colour....).

Despite these wrinkles its still a great script.

K

RobTrew 2013-03-23 01:40 PM

[QUOTE=Kazza;121668]The start dates I get in iThought are 10 hours behind what I see in OmniF.[/QUOTE]

Probably worth experimenting with [I]ofoc_year_zero[/I] in line 728 - particularly the value and handling of [I]int_zone[/I] - there must be a simple oversight in the logic let me know if you spot it.


[QUOTE=Kazza;121668]
2. The code seems to be hardwired to only look at ACTIVE tasks.
[/QUOTE]

You should be able to make some adjustments around lines 147-162 and their interconnections. (# DEFAULT DATA TO EXPORT)

Kazza 2013-03-31 08:54 PM

Fixing timezone for dates
 
[QUOTE=RobTrew;121687]Probably worth experimenting with [I]ofoc_year_zero[/I] in line 728 - particularly the value and handling of [I]int_zone[/I] - there must be a simple oversight in the logic let me know if you spot it.


You should be able to make some adjustments around lines 147-162 and their interconnections. (# DEFAULT DATA TO EXPORT)[/QUOTE]


Rob,
I've found a solution, though it feels like a hack. Here's my reasoning: the code
in lines 728-732 for ofoc_year_zero() are actually correct. The error is when you use it, for instance 680-683

[CODE]if (int_start is not None):
str_line = ''.join([str_line, 'start=\"', \
time.strftime('%d%m%y %H%M%S', \
time.gmtime(year_zero + int_start)), '\" '])[/CODE]

I think you should be adding int_zone there to the start date , int_start. But that would be a messy change as it would have to be done in several places.

So my solution is to change 732 to add in the time-zone twice, so it changes from
[CODE]return int(time.mktime(time.strptime("1 Jan 01", "%d %b %y")) + int_zone) [/CODE]
to
[CODE]return int(time.mktime(time.strptime("1 Jan 01", "%d %b %y")) + (2*int_zone))[/CODE]


If I am right I suppose it would be good to rename year_zero to something like year_zero_with_extra_timeChange so there's no confusion.

I'm a bit cautious with all this as there's quite a bit of the code that I really don't understand, and it involves variable year_zero. But I can say that this simple change seems to solve my problem and hasn't created any others, at least not that I've found with my test-cases.

I'll work on getting the non-active tasks on another day.

cheers
k

nickwild 2013-04-05 03:00 AM

The Other Way Round
 
Thanks for this great script Rob.

Is there any way that this can be extended to add any changes / additions in iThoughts to be added to OF?

EDIT: Also is there any way to remove the focus node so it goes straight to the folders?

Thanks

Nick

nickwild 2013-04-16 12:52 PM

Great all sorted - a silly typo.

Thanks for this
Nick

casa 2013-04-18 11:02 AM

Hi
Is it possible for you to make ipad app for this script?
I think many people would by it for $10 for example.

RobTrew 2013-04-18 12:08 PM

Interesting question - not something that I'm likely to do myself, and I don't have a very clear picture of whether the iOS security model (or the iOS implementation of OmniFocus) would allow the same kind of access to the OF cache, but you could try asking the [URL="http://about.me/craigscott"]iThoughtsHD developer[/URL] whether he has considered an import channel from iOS OF.


All times are GMT -8. The time now is 09:56 AM.

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