diff options
Diffstat (limited to 'examples/example_01.py')
-rw-r--r-- | examples/example_01.py | 36 |
1 files changed, 15 insertions, 21 deletions
diff --git a/examples/example_01.py b/examples/example_01.py index 7915e5f..d77c163 100644 --- a/examples/example_01.py +++ b/examples/example_01.py | |||
@@ -35,35 +35,29 @@ def main(config): | |||
35 | print config.__dict__ | 35 | print config.__dict__ |
36 | 36 | ||
37 | 37 | ||
38 | |||
39 | if __name__ == "__main__": | 38 | if __name__ == "__main__": |
40 | 39 | ||
41 | config = Config() | 40 | config = Config() |
42 | config.options().add_quiet() | 41 | config.options.add_quiet() |
43 | config.options().add_log_level() | 42 | config.options.add_log_level() |
44 | config.options().parser.add_option('-c', '--crazy', dest='crazy', | 43 | config.options.parser.add_option('-c', '--crazy', dest='crazy', |
45 | default=False, help="Crazy mode") | 44 | default=False, help="Crazy mode") |
46 | config.set('crazy', config.options().get_options().crazy) | 45 | config.set('crazy', config.options.get_options().crazy) |
47 | config.set('verbose', config.options().get_options().verbose) | 46 | config.set('verbose', config.options.get_options().verbose) |
48 | 47 | ||
49 | 48 | ||
50 | path = p.join(p.dirname(p.abspath(__file__)), 'logs') | 49 | log_directory = p.join(p.dirname(p.abspath(__file__)), 'config') |
51 | config.logs().set_directory(path) | 50 | config.logs.set_directory(log_directory) |
52 | config.logs().set_log_level(config.options().get_options().log_level) | 51 | config.logs.set_log_level(config.options.get_options().log_level) |
53 | log = config.logs().load(__file__) | 52 | log = config.logs.load('test_log') |
54 | config.logs().attach_file_handler(log, 'example.log') | 53 | config.logs.attach_file_handler(log, 'example.log') |
55 | config.logs().attach_screen_handler(log, 'critical') | 54 | config.logs.attach_screen_handler(log, 'critical') |
56 | config.set('log', log) | 55 | config.set('log', log) |
57 | 56 | ||
58 | 57 | ||
59 | path = p.join(p.dirname(p.abspath(__file__)), 'config') | 58 | path = p.join(p.dirname(p.abspath(__file__)), 'config') |
60 | config.files().set_directory(path) | 59 | filename = p.join(path, 'config.cfg') |
61 | config.files().load('config.cfg') | 60 | config.files.add(filename) |
62 | foo = config.files().parser().get('title', 'foo') | 61 | sections = config.files.load() |
63 | config.set('foo', foo) | 62 | config.set('foo', sections['title']['foo']) |
64 | |||
65 | |||
66 | |||
67 | |||
68 | |||
69 | main(config()) | 63 | main(config()) |