本文整理汇总了Python中treemodel.traverse_list函数的典型用法代码示例。如果您正苦于以下问题:Python traverse_list函数的具体用法?Python traverse_list怎么用?Python traverse_list使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了traverse_list函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: test_ContextNameFilterVisitor_exclude
def test_ContextNameFilterVisitor_exclude (self):
n1 = Context (name=u'n1')
n2 = Context (name=u'n2 xxx')
nodes = [n1, n2]
visitor = ContextNameFilterVisitor ('xxx', include=False)
traverse_list (visitor, nodes)
self.assertTrue(n1.marked)
self.assertFalse(n2.marked)
开发者ID:tmarkiewicz,项目名称:ofexport,代码行数:8,代码来源:visitors_test.py
示例2: test_TaskNameFilterVisitor_exclude
def test_TaskNameFilterVisitor_exclude (self):
n1 = Task (name=u'n1')
n2 = Task (name=u'n2 xxx')
nodes = [n1, n2]
visitor = Filter ([PROJECT, CONTEXT, TASK, FOLDER], lambda x: match_name(x, 'xxx'), False, 'pretty')
traverse_list (visitor, nodes)
self.assertTrue(n1.marked)
self.assertFalse(n2.marked)
开发者ID:markokaestner,项目名称:ofexport,代码行数:8,代码来源:visitors_test.py
示例3: test_ProjectNameFilterVisitor_include
def test_ProjectNameFilterVisitor_include (self):
n1 = Project (name=u'n1')
n2 = Project (name=u'n2 xxx')
nodes = [n1, n2]
visitor = ProjectNameFilterVisitor ('xxx')
traverse_list (visitor, nodes)
self.assertFalse(n1.marked)
self.assertTrue(n2.marked)
开发者ID:tmarkiewicz,项目名称:ofexport,代码行数:8,代码来源:visitors_test.py
示例4: test_include
def test_include (self):
n1 = Folder (name=u'n1')
n2 = Folder (name=u'n2 xxx')
nodes = [n1, n2]
visitor = Filter ([PROJECT, CONTEXT, TASK, FOLDER], lambda x: match_name(x, 'xxx'), True, "pretty")
traverse_list (visitor, nodes)
self.assertFalse(n1.marked)
self.assertTrue(n2.marked)
开发者ID:markokaestner,项目名称:ofexport,代码行数:8,代码来源:visitors_test.py
示例5: test_traverse_list_folders
def test_traverse_list_folders (self):
n1 = Folder (name=u'n1')
n2 = Folder (name=u'n2')
nodes = [n1,n2]
visitor = DemoVisitor ()
traverse_list (visitor, nodes)
self.assertEqual(2, len(visitor.folders_started))
self.assertTrue(n1 in visitor.folders_started)
self.assertTrue(n2 in visitor.folders_started)
self.assertEqual(2, len(visitor.folders_ended))
self.assertTrue(n1 in visitor.folders_ended)
self.assertTrue(n2 in visitor.folders_ended)
self.assertEqual(0, len(visitor.tasks_started))
self.assertEqual(0, len(visitor.projects_started))
self.assertEqual(0, len(visitor.contexts_started))
开发者ID:markokaestner,项目名称:ofexport,代码行数:17,代码来源:treemodel_test.py
示例6: test_Scenario_4
def test_Scenario_4 (self):
'''
In context mode select a single deeply nested task for exclusion
'''
f1 = Folder (name='1')
p1 = Project (name='2', parent=f1)
t1 = Task (name='3', parent=p1)
t2_selected = Task (name='xxx', parent=t1)
t3 = Task (name='5', parent=t2_selected)
t4 = Task (name='3', parent=t1)
f2 = Folder (name='1', parent=f1)
p2 = Project (name='2', parent=f2)
t5 = Task (name='3', parent=p2)
t6 = Task (name='3', parent=t5)
t7 = Task (name='5', parent=t6)
c1_on_path = Context (name='6')
c2_on_path = Context (name='6', parent=c1_on_path)
c2_on_path.add_child(t2_selected)
c3 = Context (name='7', parent=c2_on_path)
traverse_list (TaskNameFilterVisitor ('xxx', include=False), [c1_on_path], project_mode=False)
self.assertTrue(f1.marked)
self.assertTrue(p1.marked)
self.assertTrue(t1.marked)
self.assertFalse(t2_selected.marked)
self.assertTrue(t3.marked)
self.assertTrue(t4.marked)
self.assertTrue(t5.marked)
self.assertTrue(t6.marked)
self.assertTrue(t7.marked)
self.assertTrue(f2.marked)
self.assertTrue(p2.marked)
self.assertTrue(t5.marked)
self.assertTrue(t6.marked)
self.assertTrue(t7.marked)
self.assertTrue(c1_on_path.marked)
self.assertTrue(c2_on_path.marked)
self.assertTrue(c3.marked)
开发者ID:tmarkiewicz,项目名称:ofexport,代码行数:44,代码来源:visitors_test.py
示例7: test_Scenario_4
def test_Scenario_4 (self):
'''
In context mode select a single deeply nested task for exclusion
'''
f1 = Folder (name='1')
p1 = Project (name='2', parent=f1)
t1 = Task (name='3', parent=p1)
t2_selected = Task (name='xxx', parent=t1)
t3 = Task (name='5', parent=t2_selected)
t4 = Task (name='3', parent=t1)
f2 = Folder (name='1', parent=f1)
p2 = Project (name='2', parent=f2)
t5 = Task (name='3', parent=p2)
t6 = Task (name='3', parent=t5)
t7 = Task (name='5', parent=t6)
c1_on_path = Context (name='6')
c2_on_path = Context (name='6', parent=c1_on_path)
c2_on_path.add_child(t2_selected)
c3 = Context (name='7', parent=c2_on_path)
traverse_list (Filter ([PROJECT, CONTEXT, TASK, FOLDER], lambda x: match_name(x, 'xxx'), False, 'pretty'), [c1_on_path], project_mode=False)
self.assertTrue(f1.marked)
self.assertTrue(p1.marked)
self.assertTrue(t1.marked)
self.assertFalse(t2_selected.marked)
self.assertTrue(t3.marked)
self.assertTrue(t4.marked)
self.assertTrue(t5.marked)
self.assertTrue(t6.marked)
self.assertTrue(t7.marked)
self.assertTrue(f2.marked)
self.assertTrue(p2.marked)
self.assertTrue(t5.marked)
self.assertTrue(t6.marked)
self.assertTrue(t7.marked)
self.assertTrue(c1_on_path.marked)
self.assertTrue(c2_on_path.marked)
self.assertTrue(c3.marked)
开发者ID:markokaestner,项目名称:ofexport,代码行数:44,代码来源:visitors_test.py
示例8: test_Scenario_1
def test_Scenario_1 (self):
'''
In project mode select a single deeply nested task for inclusion
'''
f_on_path = Folder (name='1')
p_on_path = Project (name='2', parent=f_on_path)
t1_on_path = Task (name='3', parent=p_on_path)
t2_selected = Task (name='xxx', parent=t1_on_path)
t3_on_path = Task (name='5', parent=t2_selected)
t4 = Task (name='3', parent=t1_on_path)
f = Folder (name='1', parent=f_on_path)
p = Project (name='2', parent=f)
t1 = Task (name='3', parent=p)
t2 = Task (name='3', parent=t1)
t3 = Task (name='5', parent=t2)
c1 = Context (name='6')
c1.add_child(t2_selected)
c2 = Context (name='7')
c2.add_child(t3)
traverse_list (Filter ([PROJECT, CONTEXT, TASK, FOLDER], lambda x: match_name(x, 'xxx'), True, 'pretty'), [f_on_path])
self.assertTrue(f_on_path.marked)
self.assertTrue(p_on_path.marked)
self.assertTrue(t1_on_path.marked)
self.assertTrue(t2_selected.marked)
self.assertTrue(t3_on_path.marked)
self.assertTrue(c1.marked)
self.assertTrue(c2.marked)
self.assertFalse(f.marked)
self.assertFalse(p.marked)
self.assertFalse(t1.marked)
self.assertFalse(t2.marked)
self.assertFalse(t3.marked)
self.assertFalse(t4.marked)
开发者ID:markokaestner,项目名称:ofexport,代码行数:40,代码来源:visitors_test.py
示例9: test_Scenario_2
def test_Scenario_2 (self):
'''
In project mode select a single deeply nested task for exclusion
'''
f_on_path = Folder (name='1')
p_on_path = Project (name='2', parent=f_on_path)
t1_on_path = Task (name='3', parent=p_on_path)
t2_selected = Task (name='xxx', parent=t1_on_path)
t3_on_path = Task (name='5', parent=t2_selected)
t4 = Task (name='3', parent=t1_on_path)
f = Folder (name='1', parent=f_on_path)
p = Project (name='2', parent=f)
t1 = Task (name='3', parent=p)
t2 = Task (name='3', parent=t1)
t3 = Task (name='5', parent=t2)
c1 = Context (name='6')
c1.add_child(t2_selected)
c2 = Context (name='7')
c2.add_child(t3)
traverse_list (TaskNameFilterVisitor ('xxx', include=False), [f_on_path])
self.assertTrue(f_on_path.marked)
self.assertTrue(p_on_path.marked)
self.assertTrue(t1_on_path.marked)
self.assertFalse(t2_selected.marked)
self.assertFalse(t3_on_path.marked)
self.assertTrue(c1.marked)
self.assertTrue(c2.marked)
self.assertTrue(f.marked)
self.assertTrue(p.marked)
self.assertTrue(t1.marked)
self.assertTrue(t2.marked)
self.assertTrue(t3.marked)
self.assertTrue(t4.marked)
开发者ID:tmarkiewicz,项目名称:ofexport,代码行数:40,代码来源:visitors_test.py
示例10: begin_project
def begin_project (self, project):
self.generate_entry ('task', project)
def begin_context (self, context):
self.generate_entry ('context', context)
def generate_entry (self, link_type, item):
if 'persistentIdentifier' in item.ofattribs:
ident = item.ofattribs['persistentIdentifier']
link = 'omnifocus:///' + link_type + '/' + ident
base = item.name.replace('/','_').replace('\\','/').replace('\.', '_')
file_name=os.environ['HOME'] + '/Desktop/db/' + base + ' ' + ident + '.html'
out=codecs.open(file_name, 'w', 'utf-8')
link = 'omnifocus:///' + link_type + '/' + ident
print >>out, '<html>'
print >>out, '<head>'
print >>out, '<meta http-equiv="refresh" content="0; url=' + link + '">'
print >>out, '</head>'
print >>out, '<body>'
print >>out, '<p><a href="' + link + '">' + self.escape(item.name) + '</a>'
print >>out, '</body>'
print >>out, '</html>'
out.close ()
def escape (self, val):
return val.replace('"','"').replace('&','&').replace('<','<').replace('>','>')
if __name__ == "__main__":
root_projects_and_folders, root_contexts = build_model (find_database ())
traverse_list (GenerateTagDBVisitor (), root_projects_and_folders)
traverse_list (GenerateTagDBVisitor (), root_contexts, project_mode=False)
开发者ID:dareiff,项目名称:ofexport,代码行数:31,代码来源:of_to_tags.py
示例11: len
if item.flagged:
tags.append ("@flagged")
if item.date_to_start != None:
tags.append(item.date_to_start.strftime("@start(%Y-%m-%d)"))
if item.date_due != None:
tags.append (item.date_due.strftime("@due(%Y-%m-%d)"))
if item.context != None:
tags.append ('@' + ''.join (item.context.name.split ()))
if len (tags) > 0:
return ' ' + ' '.join(tags)
return ''
def tabs (self):
return '\t' * (self.depth)
if __name__ == "__main__":
root_projects_and_folders, root_contexts = build_model (find_database ())
file_name=os.environ['HOME'] + '/Desktop/OF.taskpaper'
out=codecs.open(file_name, 'w', 'utf-8')
print >>out, 'Projects:'
traverse_list (PrintTaskpaperVisitor (out, depth=1), root_projects_and_folders)
print >>out, 'Contexts:'
traverse_list (PrintTaskpaperVisitor (out, depth=1), root_contexts)
out.close()
os.system("open '" + file_name + "'")
开发者ID:nickwild99,项目名称:ofexport,代码行数:30,代码来源:of_to_tp.py
示例12: format_document
def format_document(root, formatter, project_mode):
if formatter.template.preamble != None:
print >>formatter.out, formatter.template.preamble
traverse_list(formatter, root.children, project_mode=project_mode)
if formatter.template.postamble != None:
print >>formatter.out, formatter.template.postamble
开发者ID:zinoff,项目名称:ofexport,代码行数:6,代码来源:fmt_template.py
示例13: len
if item.context != None:
tags.append ('@' + ''.join (item.context.name.split ()))
if len (tags) > 0:
return ' ' + ' '.join(tags)
return ''
def remove_trailing_colon (self, string):
if string.endswith(':'):
return string[:-1]
return string
def is_empty (self, item):
return len ([x for x in item.children if x.marked]) == 0
def tabs (self):
return '\t' * (self.depth)
if __name__ == "__main__":
root_projects_and_folders, root_contexts = build_model (find_database ())
file_name=os.environ['HOME'] + '/Desktop/OF.taskpaper'
out=codecs.open(file_name, 'w', 'utf-8')
print >>out, 'Projects:'
traverse_list (PrintTaskpaperVisitor (out, True, depth=1), root_projects_and_folders)
print >>out, 'Contexts:'
traverse_list (PrintTaskpaperVisitor (out, False, depth=1), root_contexts, project_mode=False)
out.close()
os.system("open '" + file_name + "'")
开发者ID:tmarkiewicz,项目名称:ofexport,代码行数:30,代码来源:of_to_tp.py
示例14: print_structure
def print_structure (visitor, root_projects_and_folders, root_contexts, project_mode):
if project_mode:
traverse_list (visitor, root_projects_and_folders)
else:
traverse_list (visitor, root_contexts, project_mode=False)
开发者ID:dareiff,项目名称:ofexport,代码行数:5,代码来源:ofexport.py
示例15: AnyNameFilterVisitor
for opt, arg in opts:
# PROJECT MODE
if '-P' == opt:
project_mode = True
items = root_contexts
# CONTEXT MODE
elif '-C' == opt:
project_mode = False
items = root_contexts
# ANYTHING
if '-i' == opt:
visitor = AnyNameFilterVisitor (arg, include=True)
print opt + '\t= ' + str (visitor)
traverse_list (visitor, items, project_mode=project_mode)
elif '-e' == opt:
visitor = AnyNameFilterVisitor (arg, include=False)
print opt + '\t= ' + str (visitor)
traverse_list (visitor, items, project_mode=project_mode)
elif '--Fi' == opt:
visitor = AnyFlaggedFilterVisitor (include=True)
print opt + '\t= ' + str (visitor)
traverse_list (visitor, items, project_mode=project_mode)
elif '--Fe' == opt:
visitor = AnyFlaggedFilterVisitor (include=False)
print opt + '\t= ' + str (visitor)
traverse_list (visitor, items, project_mode=project_mode)
# FOLDER
elif '--fi' == opt:
开发者ID:dareiff,项目名称:ofexport,代码行数:31,代码来源:ofexport.py
示例16: begin_context
self.depth-=1
def begin_context (self, context):
print >>self.out, self.spaces() + '* Context: ' + context.name
self.depth+=1
def end_context (self, context):
self.depth-=1
def attribs (self, task):
attribs = []
if task.date_completed != None:
attribs.append ('Done:' + task.date_completed.strftime ('%Y-%m-%d'))
if task.flagged:
attribs.append ('Flagged')
if len (attribs) > 0:
return ' ' + ' '.join(attribs)
return ''
def spaces (self):
return ' ' * self.depth * self.indent
if __name__ == "__main__":
file_name=os.environ['HOME'] + '/Desktop/OF.txt'
out=codecs.open(file_name, 'w', 'utf-8')
visitor = PrintTextVisitor (out)
root_projects_and_folders, root_contexts = build_model (find_database ())
traverse_list (visitor, root_projects_and_folders)
traverse_list (visitor, root_contexts)
os.system("open '" + file_name + "'")
out.close()
开发者ID:McPolemic,项目名称:ofexport,代码行数:31,代码来源:of_to_text.py
示例17: escape
def escape (self, val):
return val.replace('"','"').replace('&','&').replace('<','<').replace('>','>')
if __name__ == "__main__":
root_projects_and_folders, root_contexts = build_model (find_database ())
file_name=os.environ['HOME'] + '/Desktop/OF.opml'
out=codecs.open(file_name, 'w', 'utf-8')
print >>out, '<?xml version="1.0" encoding="UTF-8" standalone="no"?>'
print >>out, '<opml version="1.0">'
print >>out, ' <head>'
print >>out, ' <title>OmniFocus</title>'
print >>out, ' </head>'
print >>out, ' <body>'
print >>out, ' <outline text="OmniFocus">'
print >>out, ' <outline text="Projects">'
traverse_list (PrintOpmlVisitor (out, depth=4), root_projects_and_folders)
print >>out, ' </outline>'
print >>out, ' <outline text="Contexts">'
traverse_list (PrintOpmlVisitor (out, depth=4), root_contexts, project_mode=False)
print >>out, ' </outline>'
print >>out, ' </outline>'
print >>out, ' </body>'
print >>out, '</opml>'
out.close()
os.system("open '" + file_name + "'")
开发者ID:tmarkiewicz,项目名称:ofexport,代码行数:31,代码来源:of_to_opml.py
示例18: end_context
def end_context (self, context):
self.depth-=1
def print_link (self, link_type, item):
ident = item.ofattribs['persistentIdentifier']
print >>self.out, '<tr><td class="projectIcon"><svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" version="1.1" x="0px" y="0px" width="30px" height="30px" viewBox="0 0 100 100" enable-background="new 0 0 100 100" xml:space="preserve"><g id="Your_Icon"><path fill="none" stroke="#B473FC" stroke-width="4" stroke-miterlimit="10" d="M90,20L30,80L10,60"/></g></svg></td><td class="taskName">' + self.escape(item.name) + '</td></tr>'
# print >>self.out, self.spaces() + item.type + ': <a href="omnifocus:///' + link_type + '/' + ident + '">' + self.escape(item.name) + '</a><br>'
# This happens on "No Context" - we fabricate it and it has no persistentIdentifier
if 'persistentIdentifier' in item.ofattribs:
ident = item.ofattribs['persistentIdentifier']
print >>self.out, self.spaces() + item.type + ': <a href="omnifocus:///' + link_type + '/' + ident + '">' + self.escape(item.name) + '</a><br>'
def spaces (self):
return ' ' * self.depth * self.indent
def escape (self, val):
return val.replace('"','"').replace('&','&').replace('<','<').replace('>','>')
if __name__ == "__main__":
root_projects_and_folders, root_contexts = build_model (find_database ())
file_name=os.environ['HOME'] + '/Desktop/OF.html'
out=codecs.open(file_name, 'w', 'utf-8')
print >>out, '<head><title>Omnifocus</title></head><body>'
traverse_list (PrintHtmlVisitor (out), root_projects_and_folders)
print >>out, '<hr/>'
traverse_list (PrintHtmlVisitor (out), root_contexts, project_mode=False)
print >>out, '<hr/>'
print >>out, '</body>'
out.close()
os.system("open '" + file_name + "'")
开发者ID:dareiff,项目名称:ofexport,代码行数:31,代码来源:of_to_html.py
示例19: end_task
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 + "'")
开发者ID:tmarkiewicz,项目名称:ofexport,代码行数:31,代码来源:of_to_md.py
示例20: build_model
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:
# ANYTHING
if '-i' == opt:
visitor = AnyNameFilterVisitor (arg, include=True)
print opt + '\t= ' + str (visitor)
traverse_list (visitor, items)
elif '-e' == opt:
visitor = AnyNameFilterVisitor (arg, include=False)
print opt + '\t= ' + str (visitor)
traverse_list (visitor, items)
elif '--Fi' == opt:
visitor = AnyFlaggedFilterVisitor (include=True)
print opt + '\t= ' + str (visitor)
traverse_list (visitor, items)
elif '--Fe' == opt:
visitor = AnyFlaggedFilterVisitor (include=False)
print opt + '\t= ' + str (visitor)
traverse_list (visitor, items)
# FOLDER
elif '--fi' == opt:
开发者ID:nickwild99,项目名称:ofexport,代码行数:31,代码来源:ofexport.py
注:本文中的treemodel.traverse_list函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论