本文整理汇总了Python中topydo.lib.Config.config函数的典型用法代码示例。如果您正苦于以下问题:Python config函数的具体用法?Python config怎么用?Python config使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了config函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_priority_color4
def test_priority_color4(self):
config("test/data/ColorsTest4.conf")
color = Colors().get_priority_colors()
self.assertEqual(color['A'], NEUTRAL_COLOR)
self.assertEqual(color['B'], NEUTRAL_COLOR)
self.assertEqual(color['C'], NEUTRAL_COLOR)
示例2: test_priority_color2
def test_priority_color2(self):
config("test/data/ColorsTest2.conf")
color = Colors().get_priority_colors()
self.assertEqual(color['A'], '\033[0;35m')
self.assertEqual(color['B'], '\033[0;1;36m')
self.assertEqual(color['C'], '\033[0;37m')
示例3: test_alias_default_cmd02
def test_alias_default_cmd02(self):
config("test/data/aliases.conf", {('topydo', 'default_command'): 'foo'})
args = []
real_cmd, final_args = get_subcommand(args)
self.assertTrue(issubclass(real_cmd, DeleteCommand))
self.assertEqual(final_args, ["-f", "test"])
示例4: test_uid3
def test_uid3(self):
"""
Must be able to handle integers when text identifiers are enabled.
"""
config("test/data/todolist-uid.conf")
self.assertRaises(InvalidTodoException, self.todolist.todo, 1)
示例5: test_importance_ignore_weekends_due_not_next_monday
def test_importance_ignore_weekends_due_not_next_monday(self):
# Today is sunday
# due on a monday, but over a month away.
# So 2 + 0 (no priority) + 0 (no star) + 0 (due > 14 days)
config(p_overrides={('sort', 'ignore_weekends'): '1'})
todo = Todo("Foo " + config().tag_due() + ":" + "2016-11-28")
self.assertEqual(importance(todo), 2)
示例6: _process_flags
def _process_flags(self):
args = sys.argv[1:]
if PY2:
args = [arg.decode('utf-8') for arg in args]
try:
opts, args = getopt.getopt(args, MAIN_OPTS)
except getopt.GetoptError as e:
error(str(e))
sys.exit(1)
alt_config_path = None
overrides = {}
for opt, value in opts:
if opt == "-a":
self.do_archive = False
elif opt == "-c":
alt_config_path = value
elif opt == "-t":
overrides[('topydo', 'filename')] = value
elif opt == "-d":
overrides[('topydo', 'archive_filename')] = value
elif opt == "-v":
version()
else:
self._usage()
if alt_config_path:
config(alt_config_path, overrides)
elif len(overrides):
config(p_overrides=overrides)
return args
示例7: filter
def filter(self, p_todo_str, p_todo):
""" Applies the colors. """
if config().colors():
p_todo_str = TopydoString(p_todo_str, p_todo)
priority_color = config().priority_color(p_todo.priority())
colors = [
(r'\[email protected](\S*\w)', AbstractColor.CONTEXT),
(r'\B\+(\S*\w)', AbstractColor.PROJECT),
(r'\b\S+:[^/\s]\S*\b', AbstractColor.META),
(r'(^|\s)(\w+:){1}(//\S+)', AbstractColor.LINK),
]
# color by priority
p_todo_str.set_color(0, priority_color)
for pattern, color in colors:
for match in re.finditer(pattern, p_todo_str.data):
p_todo_str.set_color(match.start(), color)
p_todo_str.set_color(match.end(), priority_color)
p_todo_str.append('', AbstractColor.NEUTRAL)
return p_todo_str
示例8: test_priority_color1
def test_priority_color1(self):
config("test/data/ColorsTest1.conf")
color = Colors().get_priority_colors()
self.assertEqual(color['A'], '\033[0;38;5;1m')
self.assertEqual(color['B'], '\033[0;38;5;2m')
self.assertEqual(color['C'], '\033[0;38;5;3m')
示例9: test_alias_default_cmd03
def test_alias_default_cmd03(self):
config("test/data/aliases.conf", {('topydo', 'default_command'): 'nonexisting_default'})
args = ['nonexisting']
real_cmd, final_args = get_subcommand(args)
self.assertFalse(real_cmd)
self.assertEqual(final_args, ['nonexisting'])
示例10: test_new_uid
def test_new_uid(self):
""" Make sure that item has new text ID after append. """
config("test/data/todolist-uid.conf")
todo = self.todolist.todo('t5c')
self.todolist.append(todo, "A")
self.assertNotEqual(self.todolist.number(todo), 't5c')
示例11: test_alias04
def test_alias04(self):
config("test/data/aliases.conf")
args = ["star", "foo"]
real_cmd, final_args = get_subcommand(args)
self.assertTrue(issubclass(real_cmd, TagCommand))
self.assertEqual(final_args, ["foo", "star", "1"])
示例12: test_alias01
def test_alias01(self):
config("test/data/aliases.conf")
args = ["foo"]
real_cmd, final_args = get_subcommand(args)
self.assertTrue(issubclass(real_cmd, DeleteCommand))
self.assertEqual(final_args, ["-f", "test"])
示例13: test_alias02
def test_alias02(self):
config("test/data/aliases.conf")
args = ["format"]
real_cmd, final_args = get_subcommand(args)
self.assertTrue(issubclass(real_cmd, ListCommand))
self.assertEqual(final_args, ["-F", "|I| x c d {(}p{)} s k", "-n", "25"])
示例14: _post_execute
def _post_execute(self):
"""
Should be called when executing the user requested command has been
completed. It will do some maintenance and write out the final result
to the todo.txt file.
"""
if self.todolist.dirty:
# do not archive when the value of the filename is an empty string
# (i.e. explicitly left empty in the configuration
if self.do_archive and config().archive():
self._archive()
elif config().archive() and self.backup:
archive = _retrieve_archive()[0]
self.backup.add_archive(archive)
self._post_archive_action()
if config().keep_sorted():
from topydo.commands.SortCommand import SortCommand
self._execute(SortCommand, [])
if self.backup:
self.backup.save(self.todolist)
self.todofile.write(self.todolist.print_todos())
self.todolist.dirty = False
self.backup = None
示例15: test_uid2
def test_uid2(self):
""" Changing the priority should not change the identifier. """
config("test/data/todolist-uid.conf")
todo = self.todolist.todo("t5c")
self.todolist.set_priority(todo, "B")
self.assertEqual(self.todolist.todo("t5c").source(), "(B) Foo @Context2 [email protected] +Project1 Not+Project")