1. Marcin Kasperski
  2. mekk.rtm

Commits

Marcin Kasperski  committed 24fbb34

Implemented rtmmove

  • Participants
  • Parent commits 763072f
  • Branches default

Comments (0)

Files changed (3)

File README.txt

View file
 Moving many tasks to another list (`rtmmove`)
 ---------------------------------------------
 
-*Not yet implemented (but planned soon)*
+Moves all tasks fitting given query to list of specified name
+(which will be created if is not present).
+
+Example:
+
+    rtmmove --list='Language learning' \
+            --filter='list:"English Course" or tag:"French" or tag:German"
+
+To verify what the command is to do without actually performing it
+one can add `--dry-run` and `--verbose`. For example:
+
+    rtmmove --list=Family  \
+            --filter='(tag:paul or tag:jane) and status:"incomplete"' \
+            --dry-run --verbose
 
 --------------------------------------------
 Exporting RememberTheMilk data (`rtmexport`)

File src/mekk/rtm/helpers/run_move.py

View file
 
 Destination list is created if not yet present.
 
+Run:
+
+    %prog --help
+
+for all options.
+
 Note: filter is using standard RememberTheMilk language, see
 http://www.rememberthemilk.com/help/answers/search/advanced.rtm
 """
     opt_parser.add_option("-d", "--dry-run",
                           action="store_true", dest="dry_run",
                           help="Don't execute any updates, just check input and (if verbose) print planned actions")
+    opt_parser.add_option("-g", "--debug",
+                          action="store_true", dest="debug",
+                          help="Print debugging information")
                           
-    opt_parser.set_defaults(verbose = False, dry_run = False, add =[], remove =[])
+    opt_parser.set_defaults(verbose = False, dry_run = False, debug=False,
+                            add =[], remove =[])
     (opts, args) = opt_parser.parse_args()
 
     if not opts.filter:
         opt_parser.error("--filter not specified")
     if not opts.list:
         opt_parser.error("--list not specified")
+
+    if opts.debug:
+        import logging
+        logging.basicConfig(level = logging.DEBUG)
+
     return opts
     
 def run():
     opts = parse_options()
     client = create_rtm_client()
 
-    raise Exception("Sorry, this is not yet implemented")
+    move_tasks(client, filter = opts.filter,
+               new_list_name = opts.list,
+               verbose = opts.verbose, dry_run = opts.dry_run)
 
-    print opts.add
-    print opts.remove
-    print opts.filter
+def move_tasks(client, filter, new_list_name,
+               verbose = False, dry_run = False):
 
-# ...
+    new_list = client.find_or_create_list(new_list_name)
 
+    for task in client.find_tasks(filter = filter):
+        if task.key.list_id != new_list.id:
+            if verbose:
+                print "Moving task %s to list %s" % (task.name, new_list.name)
+            if not dry_run:
+                client.move_task(task.key, new_list_id)
+

File src/mekk/rtm/helpers/run_tag.py

View file
 (add tags work and computer and remove tag office to all tasks from
 list named Prepared Reports which are incomplete)
 
+Run:
+
+    %prog --help
+
+for all options.
+
 Note: filter is using standard RememberTheMilk language, see
 http://www.rememberthemilk.com/help/answers/search/advanced.rtm
 """