mirror of
https://github.com/GothenburgBitFactory/taskwarrior.git
synced 2025-06-26 10:54:26 +02:00
Import/Export: Relocated add-ons online, removed tests
- The scripts/add-ons/{im,ex}port* examples are relocated online under https://taskwarrior.org/tools/index.html#exts . - The corresponding tests are no longer needed. - The Perl JSON module is no longer required.
This commit is contained in:
parent
7007ab46d6
commit
129aeb1845
17 changed files with 6 additions and 1605 deletions
3
scripts/add-ons/README
Normal file
3
scripts/add-ons/README
Normal file
|
@ -0,0 +1,3 @@
|
|||
The import/export add-on scripts have been relocated online. Please see:
|
||||
|
||||
https://taskwarrior.org/tools/#exts
|
|
@ -1,85 +0,0 @@
|
|||
#! /usr/bin/perl
|
||||
################################################################################
|
||||
##
|
||||
## Copyright 2006 - 2015, Paul Beckingham, Federico Hernandez.
|
||||
##
|
||||
## 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.
|
||||
##
|
||||
## http://www.opensource.org/licenses/mit-license.php
|
||||
##
|
||||
################################################################################
|
||||
|
||||
use strict;
|
||||
use warnings;
|
||||
|
||||
# Give a nice error if the (non-standard) JSON module is not installed.
|
||||
eval "use JSON";
|
||||
if ($@)
|
||||
{
|
||||
print "Error: You need to install the JSON Perl module.\n";
|
||||
exit 1;
|
||||
}
|
||||
|
||||
# Use the taskwarrior 2.0+ export command to filter and return JSON
|
||||
my $command = join (' ', ("env PATH=$ENV{PATH} task rc.verbose=nothing rc.json.array=no export", @ARGV));
|
||||
if ($command =~ /No matches/)
|
||||
{
|
||||
printf STDERR $command;
|
||||
exit 1;
|
||||
}
|
||||
|
||||
# Generate output.
|
||||
print "'uuid','status','tags','entry','start','due','recur','end','project',",
|
||||
"'priority','fg','bg','description'\n";
|
||||
|
||||
for my $task (split "\n", qx{$command})
|
||||
{
|
||||
my $data = from_json ($task);
|
||||
|
||||
my $desc = $data->{'description'};
|
||||
$desc =~ s/'/\\'/g;
|
||||
|
||||
print "'$data->{'uuid'}',",
|
||||
"'$data->{'status'}',",
|
||||
"'", (exists $data->{'tags'} ? join (' ', @{$data->{'tags'}}) : ''), "',",
|
||||
"'$data->{'entry'}',",
|
||||
"'", ($data->{'start'} || ''), "',",
|
||||
"'", ($data->{'due'} || ''), "',",
|
||||
"'", ($data->{'recur'} || ''), "',",
|
||||
"'", ($data->{'end'} || ''), "',",
|
||||
"'", ($data->{'project'} || ''), "',",
|
||||
"'", ($data->{'priority'} || ''), "',",
|
||||
"'", ($data->{'fg'} || ''), "',",
|
||||
"'", ($data->{'bg'} || ''), "',",
|
||||
"'$desc'",
|
||||
"\n";
|
||||
|
||||
# Note that this format ignores:
|
||||
# wait
|
||||
# until
|
||||
# annotations
|
||||
# mask
|
||||
# imask
|
||||
# UDAs
|
||||
}
|
||||
|
||||
exit 0;
|
||||
|
||||
################################################################################
|
||||
|
|
@ -1,90 +0,0 @@
|
|||
#! /usr/bin/perl
|
||||
################################################################################
|
||||
##
|
||||
## Copyright 2006 - 2015, Paul Beckingham, Federico Hernandez.
|
||||
##
|
||||
## 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.
|
||||
##
|
||||
## http://www.opensource.org/licenses/mit-license.php
|
||||
##
|
||||
################################################################################
|
||||
|
||||
use strict;
|
||||
use warnings;
|
||||
|
||||
# Give a nice error if the (non-standard) JSON module is not installed.
|
||||
eval "use JSON";
|
||||
if ($@)
|
||||
{
|
||||
print "Error: You need to install the JSON Perl module.\n";
|
||||
exit 1;
|
||||
}
|
||||
|
||||
# Use the taskwarrior 2.0+ export command to filter and return JSON
|
||||
my $command = join (' ', ("env PATH='$ENV{PATH}' task rc.verbose=nothing rc.json.array=no export", @ARGV));
|
||||
if ($command =~ /No matches/)
|
||||
{
|
||||
printf STDERR $command;
|
||||
exit 1;
|
||||
}
|
||||
|
||||
# Generate output.
|
||||
print "<html>\n",
|
||||
" <body>\n",
|
||||
" <table>\n",
|
||||
" <thead>\n",
|
||||
" <tr>\n",
|
||||
" <td>ID</td>\n",
|
||||
" <td>Pri</td>\n",
|
||||
" <td>Description</td>\n",
|
||||
" <td>Project</td>\n",
|
||||
" <td>Due</td>\n",
|
||||
" </tr>\n",
|
||||
" </thead>\n",
|
||||
" <tbody>\n";
|
||||
|
||||
my $count = 0;
|
||||
for my $task (split "\n", qx{$command})
|
||||
{
|
||||
++$count;
|
||||
my $data = from_json ($task);
|
||||
|
||||
print " <tr>\n",
|
||||
" <td>", ($data->{'id'} || ''), "</td>\n",
|
||||
" <td>", ($data->{'priority'} || ''), "</td>\n",
|
||||
" <td>", ($data->{'description'} || ''), "</td>\n",
|
||||
" <td>", ($data->{'project'} || ''), "</td>\n",
|
||||
" <td>", ($data->{'due'} || ''), "</td>\n",
|
||||
" </tr>\n";
|
||||
}
|
||||
|
||||
print " </tbody>\n",
|
||||
" <tfooter>\n",
|
||||
" <tr>\n",
|
||||
" <td>", $count, " matching tasks</td>\n",
|
||||
" </tr>\n",
|
||||
" </tfooter>\n",
|
||||
" </table>\n",
|
||||
" </body>\n",
|
||||
"</html>\n";
|
||||
|
||||
exit 0;
|
||||
|
||||
################################################################################
|
||||
|
|
@ -1,102 +0,0 @@
|
|||
#! /usr/bin/perl
|
||||
################################################################################
|
||||
##
|
||||
## Copyright 2006 - 2015, Paul Beckingham, Federico Hernandez.
|
||||
##
|
||||
## 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.
|
||||
##
|
||||
## http://www.opensource.org/licenses/mit-license.php
|
||||
##
|
||||
################################################################################
|
||||
|
||||
use strict;
|
||||
use warnings;
|
||||
|
||||
# Give a nice error if the (non-standard) JSON module is not installed.
|
||||
eval "use JSON";
|
||||
if ($@)
|
||||
{
|
||||
print "Error: You need to install the JSON Perl module.\n";
|
||||
exit 1;
|
||||
}
|
||||
|
||||
# Use the taskwarrior 2.0+ export command to filter and return JSON
|
||||
my $command = join (' ', ("env PATH=$ENV{PATH} task rc.verbose=nothing rc.json.array=no export", @ARGV));
|
||||
if ($command =~ /No matches/)
|
||||
{
|
||||
printf STDERR $command;
|
||||
exit 1;
|
||||
}
|
||||
|
||||
# Generate output.
|
||||
print "BEGIN:VCALENDAR\n",
|
||||
"VERSION:2.0\n",
|
||||
"PRODID:=//GBF/taskwarrior 1.9.4//EN\n";
|
||||
|
||||
for my $task (split "\n", qx{$command})
|
||||
{
|
||||
my $data = from_json ($task);
|
||||
|
||||
print "BEGIN:VTODO\n";
|
||||
print "UID:$data->{'uuid'}\n";
|
||||
print "DTSTAMP:$data->{'entry'}\n";
|
||||
print "DTSTART:$data->{'start'}\n" if exists $data->{'start'};
|
||||
print "DUE:$data->{'due'}\n" if exists $data->{'due'};
|
||||
print "COMPLETED:$data->{'end'}\n" if exists $data->{'end'};
|
||||
print "SUMMARY:$data->{'description'}\n";
|
||||
print "CLASS:PRIVATE\n";
|
||||
print "CATEGORIES:", join (',', @{$data->{'tags'}}), "\n" if exists $data->{'tags'};
|
||||
|
||||
# Priorities map to a 1-9 scale.
|
||||
if (exists $data->{'priority'})
|
||||
{
|
||||
print "PRIORITY:", ($data->{'priority'} eq 'H' ? '1' :
|
||||
$data->{'priority'} eq 'M' ? '5' :
|
||||
'9'), "\n";
|
||||
}
|
||||
|
||||
# Status maps differently.
|
||||
my $status = $data->{'status'};
|
||||
if ($status eq 'pending' || $status eq 'waiting')
|
||||
{
|
||||
print "STATUS:", (exists $data->{'start'} ? 'IN-PROCESS' : 'NEEDS-ACTION'), "\n";
|
||||
}
|
||||
elsif ($status eq 'completed')
|
||||
{
|
||||
print "STATUS:COMPLETED\n";
|
||||
}
|
||||
elsif ($status eq 'deleted')
|
||||
{
|
||||
print "STATUS:CANCELLED\n";
|
||||
}
|
||||
|
||||
# Annotations become comments.
|
||||
if (exists $data->{'annotations'})
|
||||
{
|
||||
print "COMMENT:$_->{'description'}\n" for @{$data->{'annotations'}};
|
||||
}
|
||||
|
||||
print "END:VTODO\n";
|
||||
}
|
||||
|
||||
print "END:VCALENDAR\n";
|
||||
exit 0;
|
||||
|
||||
################################################################################
|
||||
|
|
@ -1,170 +0,0 @@
|
|||
#! /usr/bin/python
|
||||
###############################################################################
|
||||
#
|
||||
# Copyright 2006 - 2015, Paul Beckingham, Federico Hernandez.
|
||||
#
|
||||
# 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.
|
||||
#
|
||||
# http://www.opensource.org/licenses/mit-license.php
|
||||
#
|
||||
###############################################################################
|
||||
"""
|
||||
export-sql.py -- Export the taskwarrior database as a series of SQL commands.
|
||||
|
||||
Example usage::
|
||||
|
||||
$ PYTHONIOENCODING=UTF-8 ./export-sql.py | sqlite3 mytasks.db
|
||||
$ /usr/bin/sqlite3 mytasks.db "select * from annotations;"
|
||||
|
||||
This script has only been tested with sqlite3, but in theory, it could be
|
||||
easily modified to supported mysql, postgres or whatever you choose.
|
||||
|
||||
Author: Ralph Bean
|
||||
"""
|
||||
|
||||
import sys
|
||||
import commands
|
||||
import json
|
||||
|
||||
from datetime import datetime
|
||||
|
||||
# Note that you may want to modify the field sizes to suit your usage.
|
||||
table_definitions = """
|
||||
CREATE TABLE tasks (
|
||||
uuid VARCHAR(255) NOT NULL,
|
||||
description VARCHAR(255) NOT NULL,
|
||||
entry DATETIME NOT NULL,
|
||||
end DATETIME,
|
||||
priority VARCHAR(32),
|
||||
project VARCHAR(32),
|
||||
status VARCHAR(32),
|
||||
PRIMARY KEY (uuid)
|
||||
);
|
||||
|
||||
CREATE TABLE annotations (
|
||||
uuid VARCHAR(255) NOT NULL,
|
||||
description VARCHAR(255) NOT NULL,
|
||||
entry DATETIME NOT NULL,
|
||||
FOREIGN KEY(uuid) REFERENCES tasks(uuid)
|
||||
);
|
||||
"""
|
||||
|
||||
|
||||
replacements = {
|
||||
'"': '&dquot;',
|
||||
"'": '"',
|
||||
'[': '&open;',
|
||||
']': '&close;',
|
||||
'/': '\\/',
|
||||
}
|
||||
|
||||
|
||||
def escape(s):
|
||||
""" Escape a string in the taskwarrior style """
|
||||
|
||||
for unsafe, safe in replacements.iteritems():
|
||||
s = s.replace(unsafe, safe)
|
||||
return s
|
||||
|
||||
|
||||
# A lookup table for how to convert various values by type to SQL
|
||||
conversion_lookup = {
|
||||
# Tack on an extra set of quotes
|
||||
unicode: lambda v: "'%s'" % escape(v),
|
||||
# Do the same as for unicode
|
||||
str: lambda v: convert(unicode(v)),
|
||||
# Convert to ISO format and do the same as for unicode
|
||||
datetime: lambda v: convert(v.isoformat(' ')),
|
||||
# Replace python None with SQL NULL
|
||||
type(None): lambda v: 'NULL',
|
||||
}
|
||||
|
||||
# Compose a value with its corresponding function in conversion_lookup
|
||||
convert = lambda v: conversion_lookup.get(type(v), lambda v: v)(v)
|
||||
|
||||
|
||||
def parse_datetime(task):
|
||||
""" Parse the datetime strings given to us by `task export` """
|
||||
|
||||
for key in ['entry', 'end']:
|
||||
if key in task:
|
||||
task[key] = datetime.strptime(task[key], "%Y%m%dT%H%M%SZ")
|
||||
return task
|
||||
|
||||
|
||||
def to_sql(task):
|
||||
""" Create a list of SQL INSERT statements out of a task python dict """
|
||||
|
||||
def make_annotation(annot):
|
||||
""" Create a list of SQL INSERT statements for an annotation """
|
||||
|
||||
annot['uuid'] = task['uuid']
|
||||
template = "{uuid}, {description}, {entry}"
|
||||
annot = dict(zip(annot.keys(), map(convert, annot.values())))
|
||||
values = template.format(**annot)
|
||||
return "INSERT INTO \"annotations\" VALUES(%s)" % values
|
||||
|
||||
template = u"{uuid}, {description}, {entry}, {end}, " + \
|
||||
u"{priority}, {project}, {status}"
|
||||
|
||||
nullables = ['end', 'priority', 'project', 'status']
|
||||
defaults = dict([(key, None) for key in nullables])
|
||||
defaults['annotations'] = []
|
||||
defaults.update(task)
|
||||
|
||||
defaults = dict(zip(defaults.keys(), map(convert, defaults.values())))
|
||||
|
||||
values = template.format(**defaults)
|
||||
annotations = map(make_annotation, defaults['annotations'])
|
||||
|
||||
return ["INSERT INTO \"tasks\" VALUES(%s)" % values] + annotations
|
||||
|
||||
|
||||
def main():
|
||||
""" Return a list of SQL statements. """
|
||||
|
||||
# Use the taskwarrior 2.0+ export command to filter and return JSON
|
||||
command = "task rc.verbose=nothing rc.json.array=yes " + " ".join(sys.argv[1:]) + " export"
|
||||
|
||||
# Load each task from json to a python dict
|
||||
tasks = json.loads(commands.getoutput(command))
|
||||
|
||||
# Mangle datetime strings into python datetime objects
|
||||
tasks = map(parse_datetime, tasks)
|
||||
|
||||
# Produce formatted SQL statements for each task
|
||||
inserts = sum(map(to_sql, tasks), [])
|
||||
|
||||
return inserts
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
# Get the INSERT statements
|
||||
lines = main()
|
||||
|
||||
# Combine them with semicolons
|
||||
sql = table_definitions + ";\n".join(lines) + ';'
|
||||
|
||||
# Print them out, decorated with sqlite3 trappings
|
||||
print u"""
|
||||
BEGIN TRANSACTION;
|
||||
{sql}
|
||||
COMMIT;""".format(sql=sql)
|
||||
|
||||
###############################################################################
|
|
@ -1,82 +0,0 @@
|
|||
#! /usr/bin/perl
|
||||
################################################################################
|
||||
##
|
||||
## Copyright 2006 - 2015, Paul Beckingham, Federico Hernandez.
|
||||
##
|
||||
## 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.
|
||||
##
|
||||
## http://www.opensource.org/licenses/mit-license.php
|
||||
##
|
||||
################################################################################
|
||||
|
||||
use strict;
|
||||
use warnings;
|
||||
|
||||
# Give a nice error if the (non-standard) JSON module is not installed.
|
||||
eval "use JSON";
|
||||
if ($@)
|
||||
{
|
||||
print "Error: You need to install the JSON Perl module.\n";
|
||||
exit 1;
|
||||
}
|
||||
|
||||
# Use the taskwarrior 2.0+ export command to filter and return JSON
|
||||
my $command = join (' ', ("env PATH=$ENV{PATH} task rc.verbose=nothing rc.json.array=no export", @ARGV));
|
||||
if ($command =~ /No matches/)
|
||||
{
|
||||
printf STDERR $command;
|
||||
exit 1;
|
||||
}
|
||||
|
||||
# Generate output.
|
||||
print "uuid\tstatus\ttags\tentry\tstart\tdue\trecur\tend\tproject\t",
|
||||
"priority\tfg\tbg\tdescription\n";
|
||||
|
||||
for my $task (split "\n", qx{$command})
|
||||
{
|
||||
my $data = from_json ($task);
|
||||
|
||||
print "$data->{'uuid'}\t",
|
||||
"$data->{'status'}\t",
|
||||
(exists $data->{'tags'} ? join (' ', @{$data->{'tags'}}) : ''), "\t",
|
||||
"$data->{'entry'}\t",
|
||||
($data->{'start'} || ''), "\t",
|
||||
($data->{'due'} || ''), "\t",
|
||||
($data->{'recur'} || ''), "\t",
|
||||
($data->{'end'} || ''), "\t",
|
||||
($data->{'project'} || ''), "\t",
|
||||
($data->{'priority'} || ''), "\t",
|
||||
($data->{'fg'} || ''), "\t",
|
||||
($data->{'bg'} || ''), "\t",
|
||||
"$data->{'description'}",
|
||||
"\n";
|
||||
|
||||
# Note that this format ignores:
|
||||
# wait
|
||||
# until
|
||||
# annotations
|
||||
# mask
|
||||
# imask
|
||||
# UDAs
|
||||
}
|
||||
|
||||
exit 0;
|
||||
|
||||
################################################################################
|
||||
|
|
@ -1,85 +0,0 @@
|
|||
#! /usr/bin/perl
|
||||
################################################################################
|
||||
##
|
||||
## Copyright 2006 - 2015, Paul Beckingham, Federico Hernandez.
|
||||
##
|
||||
## 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.
|
||||
##
|
||||
## http://www.opensource.org/licenses/mit-license.php
|
||||
##
|
||||
################################################################################
|
||||
|
||||
use strict;
|
||||
use warnings;
|
||||
|
||||
# Give a nice error if the (non-standard) JSON module is not installed.
|
||||
eval "use JSON";
|
||||
if ($@)
|
||||
{
|
||||
print "Error: You need to install the JSON Perl module.\n";
|
||||
exit 1;
|
||||
}
|
||||
|
||||
# Use the taskwarrior 2.0+ export command to filter and return JSON
|
||||
my $command = join (' ', ("env PATH=$ENV{PATH} task rc.verbose=nothing rc.json.array=no export", @ARGV));
|
||||
if ($command =~ /No matches/)
|
||||
{
|
||||
printf STDERR $command;
|
||||
exit 1;
|
||||
}
|
||||
|
||||
# Generate output.
|
||||
print "<tasks>\n";
|
||||
for my $task (split "\n", qx{$command})
|
||||
{
|
||||
my $data = from_json ($task);
|
||||
|
||||
print " <task>\n";
|
||||
for my $key (keys %$data)
|
||||
{
|
||||
if ($key eq 'annotations')
|
||||
{
|
||||
print " <annotations>\n";
|
||||
for my $anno (@{$data->{$key}})
|
||||
{
|
||||
print " <annotation>\n";
|
||||
print " <$_>$anno->{$_}</$_>\n" for keys %$anno;
|
||||
print " </annotation>\n";
|
||||
}
|
||||
print " </annotations>\n";
|
||||
}
|
||||
elsif ($key eq 'tags')
|
||||
{
|
||||
print " <tags>\n";
|
||||
print " <tag>$_</tag>\n" for @{$data->{'tags'}};
|
||||
print " </tags>\n";
|
||||
}
|
||||
else
|
||||
{
|
||||
print " <$key>$data->{$key}</$key>\n";
|
||||
}
|
||||
}
|
||||
print " </task>\n";
|
||||
}
|
||||
|
||||
print "</tasks>\n";
|
||||
exit 0;
|
||||
|
||||
################################################################################
|
||||
|
|
@ -1,61 +0,0 @@
|
|||
#! /usr/bin/python
|
||||
################################################################################
|
||||
##
|
||||
## Copyright 2006 - 2015, Paul Beckingham, Federico Hernandez.
|
||||
##
|
||||
## 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.
|
||||
##
|
||||
## http://www.opensource.org/licenses/mit-license.php
|
||||
##
|
||||
################################################################################
|
||||
|
||||
import sys
|
||||
import commands
|
||||
import json
|
||||
|
||||
# Use the taskwarrior 2.0+ export command to filter and return JSON
|
||||
command = "/usr/local/bin/task rc.verbose=nothing rc.json.array=no export " + " ".join (sys.argv[1:])
|
||||
|
||||
# Generate output.
|
||||
print "<tasks>"
|
||||
for task in commands.getoutput (command).split (",\n"):
|
||||
data = json.loads (task)
|
||||
print " <task>"
|
||||
for name,value in data.items ():
|
||||
if name == "annotations":
|
||||
print " <annotations>"
|
||||
for anno in value:
|
||||
print " <annotation>"
|
||||
for name,value in anno.items ():
|
||||
print " <{0}>{1}</{0}>".format (name, value)
|
||||
print " </annotation>"
|
||||
print " </annotations>"
|
||||
elif name == "tags":
|
||||
print " <tags>"
|
||||
for tag in value:
|
||||
print " <tag>{0}</tag>".format (tag)
|
||||
print " </tags>"
|
||||
else:
|
||||
print " <{0}>{1}</{0}>".format (name, value)
|
||||
print " </task>"
|
||||
print "</tasks>"
|
||||
sys.exit (0)
|
||||
|
||||
################################################################################
|
||||
|
|
@ -1,66 +0,0 @@
|
|||
#! /usr/bin/ruby
|
||||
################################################################################
|
||||
##
|
||||
## Copyright 2006 - 2015, Paul Beckingham, Federico Hernandez.
|
||||
##
|
||||
## 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.
|
||||
##
|
||||
## http://www.opensource.org/licenses/mit-license.php
|
||||
##
|
||||
################################################################################
|
||||
|
||||
require 'rubygems'
|
||||
require 'json'
|
||||
|
||||
# Use the taskwarrior 2.0+ export command to filter and return JSON
|
||||
lines = IO.popen("/usr/local/bin/task rc.verbose=nothing rc.json.array=no export " + ARGV.join(" ")).readlines
|
||||
|
||||
# Generate output.
|
||||
print "<tasks>\n"
|
||||
lines.each do |line|
|
||||
data = JSON.parse(line)
|
||||
print " <task>\n"
|
||||
data.each do |key,value|
|
||||
if key == "annotations"
|
||||
print " <annotations>\n"
|
||||
value.each do |anno|
|
||||
print " <annotation>\n"
|
||||
anno.each do |key,value|
|
||||
print " <#{key}>#{value}</#{key}>\n"
|
||||
end
|
||||
print " </annotation>\n"
|
||||
end
|
||||
print " </annotations>\n"
|
||||
elsif key == "tags"
|
||||
print " <tags>\n"
|
||||
value.each do |tag|
|
||||
print " <tag>#{tag}</tag>\n"
|
||||
end
|
||||
print " </tags>\n"
|
||||
else
|
||||
print " <#{key}>#{value}</#{key}>\n"
|
||||
end
|
||||
end
|
||||
print " </task>\n"
|
||||
end
|
||||
print "</tasks>\n"
|
||||
exit 0
|
||||
|
||||
################################################################################
|
||||
|
|
@ -1,81 +0,0 @@
|
|||
#! /usr/bin/perl
|
||||
################################################################################
|
||||
##
|
||||
## Copyright 2006 - 2015, Paul Beckingham, Federico Hernandez.
|
||||
##
|
||||
## 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.
|
||||
##
|
||||
## http://www.opensource.org/licenses/mit-license.php
|
||||
##
|
||||
################################################################################
|
||||
|
||||
use strict;
|
||||
use warnings;
|
||||
|
||||
# Give a nice error if the (non-standard) JSON module is not installed.
|
||||
eval "use JSON";
|
||||
if ($@)
|
||||
{
|
||||
print "Error: You need to install the JSON Perl module.\n";
|
||||
exit 1;
|
||||
}
|
||||
|
||||
# Use the taskwarrior 2.0+ export command to filter and return JSON
|
||||
my $command = join (' ', ("env PATH=$ENV{PATH} task rc.verbose=nothing rc.json.array=no export", @ARGV));
|
||||
if ($command =~ /No matches/)
|
||||
{
|
||||
printf STDERR $command;
|
||||
exit 1;
|
||||
}
|
||||
|
||||
# Generate output.
|
||||
print "'uuid','status','tags','entry','start','due','recur','end','project',",
|
||||
"'priority','fg','bg','description'\n";
|
||||
|
||||
for my $task (split "\n", qx{$command})
|
||||
{
|
||||
my $data = from_json ($task);
|
||||
|
||||
print "'$data->{'uuid'}',",
|
||||
"'$data->{'status'}',",
|
||||
"'", (exists $data->{'tags'} ? join (' ', @{$data->{'tags'}}) : ''), "',",
|
||||
"'$data->{'entry'}',",
|
||||
"'", ($data->{'start'} || ''), "',",
|
||||
"'", ($data->{'due'} || ''), "',",
|
||||
"'", ($data->{'recur'} || ''), "',",
|
||||
"'", ($data->{'end'} || ''), "',",
|
||||
"'", ($data->{'project'} || ''), "',",
|
||||
"'", ($data->{'priority'} || ''), "',",
|
||||
"'", ($data->{'fg'} || ''), "',",
|
||||
"'", ($data->{'bg'} || ''), "',",
|
||||
"'$data->{'description'}'",
|
||||
"\n";
|
||||
|
||||
# Note that this format ignores:
|
||||
# wait
|
||||
# until
|
||||
# annotations
|
||||
# mask
|
||||
# imask
|
||||
}
|
||||
|
||||
exit 0;
|
||||
|
||||
################################################################################
|
||||
|
|
@ -1,79 +0,0 @@
|
|||
#! /usr/bin/perl
|
||||
################################################################################
|
||||
##
|
||||
## Copyright 2006 - 2015, Paul Beckingham, Federico Hernandez.
|
||||
##
|
||||
## 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.
|
||||
##
|
||||
## http://www.opensource.org/licenses/mit-license.php
|
||||
##
|
||||
################################################################################
|
||||
|
||||
use strict;
|
||||
use warnings;
|
||||
|
||||
# Give a nice error if the (non-standard) JSON module is not installed.
|
||||
eval "use JSON";
|
||||
if ($@)
|
||||
{
|
||||
print "Error: You need to install the JSON Perl module.\n";
|
||||
exit 1;
|
||||
}
|
||||
|
||||
# Generate output.
|
||||
print "%YAML 1.1\n",
|
||||
"---\n";
|
||||
|
||||
while (my $json = <>)
|
||||
{
|
||||
$json =~ s/^\[//;
|
||||
$json =~ s/\]$//;
|
||||
$json =~ s/,$//;
|
||||
next if $json eq '';
|
||||
|
||||
my $data = from_json ($json);
|
||||
|
||||
print " task:\n";
|
||||
for my $key (sort keys %$data)
|
||||
{
|
||||
if ($key eq 'annotations')
|
||||
{
|
||||
print " annotations:\n";
|
||||
for my $anno (@{$data->{$key}})
|
||||
{
|
||||
print " annotation:\n";
|
||||
print " $_: $anno->{$_}\n" for keys %$anno;
|
||||
}
|
||||
}
|
||||
elsif ($key eq 'tags')
|
||||
{
|
||||
print " tags: ", join (',', @{$data->{'tags'}}), "\n";
|
||||
}
|
||||
else
|
||||
{
|
||||
print " $key: $data->{$key}\n";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
print "...\n";
|
||||
exit 0;
|
||||
|
||||
################################################################################
|
||||
|
|
@ -1,162 +0,0 @@
|
|||
#! /usr/bin/perl
|
||||
################################################################################
|
||||
##
|
||||
## Copyright 2006 - 2015, Paul Beckingham, Federico Hernandez.
|
||||
##
|
||||
## 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.
|
||||
##
|
||||
## http://www.opensource.org/licenses/mit-license.php
|
||||
##
|
||||
################################################################################
|
||||
|
||||
use strict;
|
||||
use warnings;
|
||||
use Time::Local;
|
||||
|
||||
# Priority mappings.
|
||||
my %priority_map = (
|
||||
'a' => 'H', 'b' => 'M', 'c' => 'L', 'd' => 'L', 'e' => 'L', 'f' => 'L',
|
||||
'g' => 'L', 'h' => 'L', 'i' => 'L', 'j' => 'L', 'k' => 'L', 'l' => 'L',
|
||||
'm' => 'L', 'n' => 'L', 'o' => 'L', 'p' => 'L', 'q' => 'L', 'r' => 'L',
|
||||
's' => 'L', 't' => 'L', 'u' => 'L', 'v' => 'L', 'w' => 'L', 'x' => 'L',
|
||||
'y' => 'L', 'z' => 'L');
|
||||
|
||||
my @tasks;
|
||||
while (my $todo = <>)
|
||||
{
|
||||
my $status = 'pending';
|
||||
my $priority = '';
|
||||
my $entry = '';
|
||||
my $end = '';
|
||||
my @projects;
|
||||
my @contexts;
|
||||
my $description = '';
|
||||
my $due = '';
|
||||
|
||||
# pending + pri + entry
|
||||
if ($todo =~ /^\(([A-Z])\)\s(\d{4}-\d{2}-\d{2})\s(.+)$/i)
|
||||
{
|
||||
($status, $priority, $entry, $description) = ('pending', $1, epoch ($2), $3);
|
||||
}
|
||||
|
||||
# pending + pri
|
||||
elsif ($todo =~ /^\(([A-Z])\)\s(.+)$/i)
|
||||
{
|
||||
($status, $priority, $description) = ('pending', $1, $2);
|
||||
}
|
||||
|
||||
# pending + entry
|
||||
elsif ($todo =~ /^(\d{4}-\d{2}-\d{2})\s(.+)$/i)
|
||||
{
|
||||
($status, $entry, $description) = ('pending', epoch ($1), $2);
|
||||
}
|
||||
|
||||
# done + end + entry
|
||||
elsif ($todo =~ /^x\s(\d{4}-\d{2}-\d{2})\s(\d{4}-\d{2}-\d{2})\s(.+)$/i)
|
||||
{
|
||||
($status, $end, $entry, $description) = ('completed', epoch ($1), epoch ($2), $3);
|
||||
}
|
||||
|
||||
# done + end
|
||||
elsif ($todo =~ /^x\s(\d{4}-\d{2}-\d{2})\s(.+)$/i)
|
||||
{
|
||||
($status, $end, $description) = ('completed', epoch ($1), $2);
|
||||
}
|
||||
|
||||
# done
|
||||
elsif ($todo =~ /^x\s(.+)$/i)
|
||||
{
|
||||
($status, $description) = ('completed', $1);
|
||||
}
|
||||
|
||||
# pending
|
||||
elsif ($todo =~ /^(.+)$/i)
|
||||
{
|
||||
($status, $description) = ('pending', $1);
|
||||
}
|
||||
|
||||
# Project
|
||||
@projects = $description =~ /\+(\S+)/ig;
|
||||
|
||||
# Contexts
|
||||
@contexts = $description =~ /\@(\S+)/ig;
|
||||
|
||||
# Due
|
||||
$due = epoch ($1) if $todo =~ /\sdue:(\d{4}-\d{2}-\d{2})/i;
|
||||
|
||||
# Map priorities
|
||||
$priority = $priority_map{lc $priority} if $priority ne '';
|
||||
|
||||
# Pick first project
|
||||
my $first_project = shift @projects;
|
||||
|
||||
# Compose the JSON
|
||||
my $json = '';
|
||||
$json .= "{\"status\":\"${status}\"";
|
||||
$json .= ",\"priority\":\"${priority}\"" if defined $priority && $priority ne '';
|
||||
$json .= ",\"project\":\"${first_project}\"" if defined $first_project && $first_project ne '';
|
||||
$json .= ",\"entry\":\"${entry}\"" if $entry ne '';
|
||||
$json .= ",\"end\":\"${end}\"" if $end ne '';
|
||||
$json .= ",\"due\":\"${due}\"" if $due ne '';
|
||||
|
||||
if (@contexts)
|
||||
{
|
||||
$json .= ",\"tags\":[" . join (',', map {"\"$_\""} @contexts) . "]";
|
||||
}
|
||||
|
||||
$json .= ",\"description\":\"${description}\"}";
|
||||
|
||||
push @tasks, $json;
|
||||
}
|
||||
|
||||
print "[\n", join ("\n", @tasks), "\n]\n";
|
||||
exit 0;
|
||||
|
||||
################################################################################
|
||||
sub epoch
|
||||
{
|
||||
my ($input) = @_;
|
||||
|
||||
my ($y, $m, $d) = $input =~ /(\d{4})-(\d{2})-(\d{2})/;
|
||||
return timelocal (0, 0, 0, $d, $m-1, $y-1900);
|
||||
}
|
||||
|
||||
################################################################################
|
||||
|
||||
__DATA__
|
||||
(A) Thank Mom for the meatballs @phone
|
||||
(B) Schedule Goodwill pickup +GarageSale @phone
|
||||
Post signs around the neighborhood +GarageSale
|
||||
@GroceryStore Eskimo pies
|
||||
(A) Thank Mom for the meatballs @phone
|
||||
(B) Schedule Goodwill pickup +GarageSale @phone
|
||||
(B) Schedule Goodwill pickup +GarageSale @phone
|
||||
Post signs around the neighborhood +GarageSale
|
||||
Really gotta call Mom (A) @phone @someday
|
||||
(b) Get back to the boss
|
||||
(B)->Submit TPS report
|
||||
2011-03-02 Document +TodoTxt task format
|
||||
(A) 2011-03-02 Call Mom
|
||||
(A) Call Mom 2011-03-02
|
||||
(A) Call Mom +Family +PeaceLoveAndHappiness @iphone @phone
|
||||
x 2011-03-03 Call Mom
|
||||
xylophone lesson
|
||||
X 2012-01-01 Make resolutions
|
||||
(A) x Find ticket prices
|
||||
x 2011-03-02 2011-03-01 Review Tim's pull request +TodoTxtTouch @github
|
|
@ -1,141 +0,0 @@
|
|||
#! /usr/bin/perl
|
||||
################################################################################
|
||||
##
|
||||
## Copyright 2006 - 2015, Paul Beckingham, Federico Hernandez.
|
||||
##
|
||||
## 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.
|
||||
##
|
||||
## http://www.opensource.org/licenses/mit-license.php
|
||||
##
|
||||
################################################################################
|
||||
|
||||
use strict;
|
||||
use warnings;
|
||||
use Time::Local;
|
||||
|
||||
my @tasks;
|
||||
|
||||
my $status = '';
|
||||
my $uuid = '';
|
||||
my $priority = '';
|
||||
my $entry = '';
|
||||
my $end = '';
|
||||
my $project = '';
|
||||
my $tags = '';
|
||||
my $description = '';
|
||||
my $due = '';
|
||||
|
||||
my %annotations;
|
||||
my $mid_anno = 0;
|
||||
my $anno_entry = '';
|
||||
my $anno_desc = '';
|
||||
|
||||
while (my $yaml = <>)
|
||||
{
|
||||
chomp $yaml;
|
||||
next if $yaml =~ /\sid:/;
|
||||
next if $yaml =~ /\sannotations:/;
|
||||
|
||||
if ($yaml =~ /task:|\.\.\./ && $description ne '')
|
||||
{
|
||||
# Compose the JSON
|
||||
my $json = "{\"status\":\"${status}\"";
|
||||
$json .= ",\"uuid\":\"${uuid}\"" if $uuid ne '';
|
||||
$json .= ",\"priority\":\"${priority}\"" if $priority ne '';
|
||||
$json .= ",\"project\":\"${project}\"" if $project ne '';
|
||||
$json .= ",\"entry\":\"${entry}\"" if $entry ne '';
|
||||
$json .= ",\"end\":\"${end}\"" if $end ne '';
|
||||
$json .= ",\"due\":\"${due}\"" if $due ne '';
|
||||
if ($tags ne '')
|
||||
{
|
||||
$tags =~ s/,/","/g;
|
||||
$json .= ",\"tags\":[\"${tags}\"]";
|
||||
}
|
||||
if (%annotations)
|
||||
{
|
||||
$json .= ",\"annotations\":[";
|
||||
my $pre = "";
|
||||
for my $key (sort keys %annotations) {
|
||||
$json .= "${pre}{\"entry\":\"${key}\",\"description\":\"${annotations{$key}}\"}";
|
||||
$pre = ",";
|
||||
}
|
||||
$json .= "]";
|
||||
}
|
||||
$json .= ",\"description\":\"${description}\"}";
|
||||
|
||||
push @tasks, $json;
|
||||
|
||||
$status = $uuid = $priority = $entry = $end = $project = $tags =
|
||||
$description = $due = $anno_entry = $anno_desc = '';
|
||||
$mid_anno = 0;
|
||||
%annotations = ();
|
||||
$yaml = '';
|
||||
}
|
||||
else
|
||||
{
|
||||
$mid_anno = 1 if $yaml =~ /annotation:/;
|
||||
$anno_entry = $1 if $mid_anno && $yaml =~ /entry:\s*(\S+)/;
|
||||
if ($mid_anno)
|
||||
{
|
||||
if ($yaml =~ /description:\s*(.+)/)
|
||||
{
|
||||
$anno_desc = $1;
|
||||
$mid_anno = 0;
|
||||
|
||||
$annotations{$anno_entry} = $anno_desc;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$entry = $1 if $yaml =~ /entry:\s*(\S+)/;
|
||||
$description = $1 if $yaml =~ /description:\s*(.+)/;
|
||||
}
|
||||
|
||||
$status = $1 if $yaml =~ /status:\s*(\S+)/;
|
||||
$uuid = $1 if $yaml =~ /uuid:\s*(\S+)/;
|
||||
$priority = $1 if $yaml =~ /priority:\s*(\S+)/;
|
||||
$project = $1 if $yaml =~ /project:\s*(\S+)/;
|
||||
$end = $1 if $yaml =~ /end:\s*(\S+)/;
|
||||
$due = $1 if $yaml =~ /due:\s*(\S+)/;
|
||||
$tags = $1 if $yaml =~ /tags:\s*(\S+)/;
|
||||
}
|
||||
}
|
||||
|
||||
print "[\n", join ("\n", @tasks), "\n]\n";
|
||||
exit 0;
|
||||
|
||||
################################################################################
|
||||
|
||||
__DATA__
|
||||
%YAML 1.1
|
||||
---
|
||||
task:
|
||||
annotations:
|
||||
annotation:
|
||||
entry: 20100706T025311Z
|
||||
description: Also needs to ignore control codes
|
||||
description: text.cpp/extractLines needs to calculate string length in a way that supports UTF8
|
||||
entry: 20090319T151633Z
|
||||
id: 9
|
||||
project: task-2.0
|
||||
status: pending
|
||||
tags: bug,utf8,next
|
||||
uuid: 0c4cf066-9413-4862-9dc8-0793f158a649
|
||||
...
|
||||
|
Loading…
Add table
Add a link
Reference in a new issue