Exemplo n.º 1
0
         set_debug_opt (name, value)
     elif opt in ('-?', '-h', '--help'):
         print_help ()
         sys.exit()
 
 if file_name == None:
     fmt = 'txt'
 else:
     assert file_name.find ('.') != -1, "filename has no suffix"
     dot = file_name.index ('.')
     fmt = file_name[dot+1:]
 
 if infile != None:
     root_project, root_context = read_json (infile)
 else:    
     root_project, root_context = build_model (find_database ())
 
 subject = root_project
     
 for opt, arg in opts:
     logger.debug ("executing option %s : %s", opt, arg)
     visitor = None
     if opt in ('--project', '-p'):
         fixed_arg = fix_abbrieviated_expr(PROJECT, arg)
         visitor = make_filter (fixed_arg, include)
     elif opt in ('--task', '-t'):
         fixed_arg = fix_abbrieviated_expr(TASK, arg)
         visitor = make_filter (fixed_arg, include)
     elif opt in ('--context', '-c'):
         fixed_arg = fix_abbrieviated_expr(CONTEXT, arg)
         visitor = make_filter (fixed_arg, include)
Exemplo n.º 2
0
        elif opt in ('-?', '-h', '--help'):
            print_help()
            sys.exit()

    if file_name == None:
        print_help()
        sys.exit()

    dot = file_name.index('.')
    if dot == -1:
        print 'output file name must have suffix'
        sys.exit()

    fmt = file_name[dot + 1:]

    root_projects_and_folders, root_contexts = build_model(find_database())

    if project_mode:
        items = root_projects_and_folders
    else:
        items = root_contexts

    for opt, arg in opts:

        # FOLDER
        if '--fi' == opt:
            visitor = FolderNameFilterVisitor(arg, include=True)
            print opt + '\t= ' + str(visitor)
            traverse_list(visitor, items)
        elif '--fe' == opt:
            visitor = FolderNameFilterVisitor(arg, include=False)
Exemplo n.º 3
0
        self.task_depth+=1
    def end_task (self, task):
        self.task_depth-=1
    def begin_context (self, context):
        self.task_depth = 0
        print >>self.out, ('#' * (self.header_depth+1)) + ' ' + context.name
        self.header_depth+=1
    def end_context (self, context):
        print >>self.out
        self.header_depth-=1
    def done (self, completed):
        if completed != None:
            return completed.strftime(" @%Y-%m-%d-%a")
        return ""

if __name__ == "__main__":

    root_projects_and_folders, root_contexts = build_model (find_database ())
    
    file_name=os.environ['HOME'] + '/Desktop/OF.md'
    
    out=codecs.open(file_name, 'w', 'utf-8')
    
    print >>out, '# Projects:'
    traverse_list (PrintMarkdownVisitor (out, depth=1), root_projects_and_folders)
    print >>out, '# Contexts:'
    traverse_list (PrintMarkdownVisitor (out, depth=1), root_contexts, project_mode=False)
    
    out.close()
    
    os.system("open '" + file_name + "'")
Exemplo n.º 4
0
     elif opt in ('-?', '-h', '--help'):
         print_help ()
         sys.exit()
 
 if file_name == None:
     # This blank suffix is mapped to a plugin/template in the config
     fmt = ''
 else:
     assert file_name.find ('.') != -1, "filename has no suffix"
     dot = file_name.index ('.')
     fmt = file_name[dot+1:]
 
 if infile != None:
     root_project, root_context = read_json (infile)
 else:    
     root_project, root_context = build_model (find_database (config['db_search_path']))
 
 subject = root_project
     
 for opt, arg in opts:
     logger.debug ("executing option %s : %s", opt, arg)
     visitor = None
     if opt in ('--project', '-p'):
         fixed_arg = fix_abbrieviated_expr(PROJECT, arg)
         visitor = make_filter (fixed_arg, include)
     elif opt in ('--task', '-t'):
         fixed_arg = fix_abbrieviated_expr(TASK, arg)
         visitor = make_filter (fixed_arg, include)
     elif opt in ('--context', '-c'):
         fixed_arg = fix_abbrieviated_expr(CONTEXT, arg)
         visitor = make_filter (fixed_arg, include)