Commit 84421e39 authored by Bram Schoenmakers's avatar Bram Schoenmakers

Move list_limit to a ls section, move paths to topydo section.

parent d115d38b
; See https://github.com/bram85/topydo/wiki/How-to-use for more info
[topydo] [topydo]
default_action = ls default_command = ls
; filename = todo.txt
; archive_filename = done.txt
colors = 1 colors = 1
highlight_projects_contexts = 1 highlight_projects_contexts = 1
list_limit = 25
[paths] [ls]
; filename = todo.txt list_limit = 25
; archive_filename = done.txt
[tags] [tags]
tag_start = t tag_start = t
......
...@@ -20,10 +20,10 @@ from Config import config ...@@ -20,10 +20,10 @@ from Config import config
class ConfigTest(unittest.TestCase): class ConfigTest(unittest.TestCase):
def test_config1(self): def test_config1(self):
self.assertEquals(config("data/config1").default_action(), 'do') self.assertEquals(config("data/config1").default_command(), 'do')
def test_config2(self): def test_config2(self):
self.assertNotEquals(config("").default_action(), 'do') self.assertNotEquals(config("").default_command(), 'do')
def test_config3(self): def test_config3(self):
self.assertTrue(config("data/config2").ignore_weekends()) self.assertTrue(config("data/config2").ignore_weekends())
[topydo] [topydo]
default_action = do default_command = do
[topydo] [ls]
list_limit = 1 list_limit = 1
...@@ -113,7 +113,7 @@ class CLIApplication(object): ...@@ -113,7 +113,7 @@ class CLIApplication(object):
try: try:
subcommand = sys.argv[1] subcommand = sys.argv[1]
except IndexError: except IndexError:
subcommand = config().default_action() subcommand = config().default_command()
subcommand_map = { subcommand_map = {
'add': AddCommand, 'add': AddCommand,
...@@ -141,7 +141,7 @@ class CLIApplication(object): ...@@ -141,7 +141,7 @@ class CLIApplication(object):
args = arguments() args = arguments()
if not subcommand in subcommand_map: if not subcommand in subcommand_map:
subcommand = config().default_action() subcommand = config().default_command()
args = arguments(1) args = arguments(1)
command = subcommand_map[subcommand](args, self.todolist, command = subcommand_map[subcommand](args, self.todolist,
......
...@@ -27,19 +27,19 @@ class ConfigError(Exception): ...@@ -27,19 +27,19 @@ class ConfigError(Exception):
class _Config: class _Config:
def __init__(self, p_path=None): def __init__(self, p_path=None):
self.sections = ['topydo', 'tags', 'sort', 'paths'] self.sections = ['topydo', 'tags', 'sort', 'ls']
self.defaults = { self.defaults = {
# topydo # topydo
'default_action': 'ls', 'default_command': 'ls',
'colors': '1', 'colors': '1',
'highlight_projects_contexts': '1', 'highlight_projects_contexts': '1',
'list_limit': '25',
# paths
'filename' : 'todo.txt', 'filename' : 'todo.txt',
'archive_filename' : 'done.txt', 'archive_filename' : 'done.txt',
# ls
'list_limit': '25',
# tags # tags
'tag_start': 't', 'tag_start': 't',
'tag_due': 'due', 'tag_due': 'due',
...@@ -68,8 +68,8 @@ class _Config: ...@@ -68,8 +68,8 @@ class _Config:
def _home_config_path(self): def _home_config_path(self):
return os.path.join(os.getenv('HOME'), '.topydo') return os.path.join(os.getenv('HOME'), '.topydo')
def default_action(self): def default_command(self):
return self.cp.get('topydo', 'default_action') return self.cp.get('topydo', 'default_command')
def colors(self): def colors(self):
try: try:
...@@ -84,14 +84,14 @@ class _Config: ...@@ -84,14 +84,14 @@ class _Config:
return self.defaults['highlight_projects_contexts'] == '1' return self.defaults['highlight_projects_contexts'] == '1'
def todotxt(self): def todotxt(self):
return self.cp.get('paths', 'filename') return self.cp.get('topydo', 'filename')
def archive(self): def archive(self):
return self.cp.get('paths', 'archive_filename') return self.cp.get('topydo', 'archive_filename')
def list_limit(self): def list_limit(self):
try: try:
return self.cp.getint('topydo', 'list_limit') return self.cp.getint('ls', 'list_limit')
except ValueError: except ValueError:
return int(self.defaults['list_limit']) return int(self.defaults['list_limit'])
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment