Created
July 23, 2016 08:43
-
-
Save klashxx/3353e10978f445777cb9248caa9559ab to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
# -*- coding: utf-8 -*- | |
""" | |
Taskwarrior | |
""" | |
__version__ = '0.1' | |
TIMEOUT = 15 | |
import sys | |
import re | |
import json | |
import shlex | |
import select | |
import subprocess | |
def recopila(): | |
"""Recopila los ids a procesar para ``bandeja_id``""" | |
cmd = 'task bandeja_id' | |
for id_tarea in re.findall(r'^\s*(\d+)', | |
subprocess.check_output(shlex.split(cmd)), | |
re.M)[:-1]: | |
procesar_bandeja(id_tarea) | |
return None | |
def procesar_bandeja(id_tarea): | |
"""Procesa la tarea""" | |
cmd = 'task {0} export'.format(id_tarea) | |
tarea_json = json.loads(subprocess.check_output(shlex.split(cmd)))[0] | |
titulo = tarea_json['description'] | |
fecha_entrada = tarea_json['entry'] | |
fecha_modificacion = tarea_json['modified'] | |
try: | |
comentarios = tarea_json['annotations'] | |
except KeyError: | |
comentarios = [] | |
for comentario in comentarios: | |
print comentario['entry'] | |
return None | |
def main(): | |
"""Toma de input y control de flujo""" | |
print 'Procesando la bandeja por orden de entrada' | |
print 'Elementos:' | |
print subprocess.check_output(shlex.split('task')) | |
print '¿Continuas el proceso? [S/N]' | |
continuar, _, _ = select.select([sys.stdin], [], [], TIMEOUT) | |
if continuar: | |
continuar = sys.stdin.readline().strip().upper() | |
if continuar == 'S': | |
recopila() | |
else: | |
print "Saliendo" | |
else: | |
print "¡Eres muy lento!" | |
return None | |
if __name__ == '__main__': | |
main() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment