aboutsummaryrefslogtreecommitdiff
path: root/examples/example_01.py
diff options
context:
space:
mode:
Diffstat (limited to 'examples/example_01.py')
-rw-r--r--examples/example_01.py69
1 files changed, 69 insertions, 0 deletions
diff --git a/examples/example_01.py b/examples/example_01.py
new file mode 100644
index 0000000..7915e5f
--- /dev/null
+++ b/examples/example_01.py
@@ -0,0 +1,69 @@
1#!/usr/bin/env python
2# Copyright (C) 2010 Leonard Thomas
3#
4# This file is part of Dodai.
5#
6# Dodai is free software: you can redistribute it and/or modify
7# it under the terms of the GNU General Public License as published by
8# the Free Software Foundation, either version 3 of the License, or
9# (at your option) any later version.
10#
11# Dodai is distributed in the hope that it will be useful,
12# but WITHOUT ANY WARRANTY; without even the implied warranty of
13# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14# GNU General Public License for more details.
15#
16# You should have received a copy of the GNU General Public License
17# along with Dodai. If not, see <http://www.gnu.org/licenses/>.
18
19
20##############################################################################
21# The following is for setting up the correct python path. Ignore this
22# section for your project
23import sys
24import os.path as p
25path = p.dirname(p.dirname(p.abspath(__file__)))
26sys.path.append(path)
27##############################################################################
28
29from dodai.config import Config
30
31def main(config):
32
33 config.log.debug('testing one two three')
34 config.log.critical('testing of critical')
35 print config.__dict__
36
37
38
39if __name__ == "__main__":
40
41 config = Config()
42 config.options().add_quiet()
43 config.options().add_log_level()
44 config.options().parser.add_option('-c', '--crazy', dest='crazy',
45 default=False, help="Crazy mode")
46 config.set('crazy', config.options().get_options().crazy)
47 config.set('verbose', config.options().get_options().verbose)
48
49
50 path = p.join(p.dirname(p.abspath(__file__)), 'logs')
51 config.logs().set_directory(path)
52 config.logs().set_log_level(config.options().get_options().log_level)
53 log = config.logs().load(__file__)
54 config.logs().attach_file_handler(log, 'example.log')
55 config.logs().attach_screen_handler(log, 'critical')
56 config.set('log', log)
57
58
59 path = p.join(p.dirname(p.abspath(__file__)), 'config')
60 config.files().set_directory(path)
61 config.files().load('config.cfg')
62 foo = config.files().parser().get('title', 'foo')
63 config.set('foo', foo)
64
65
66
67
68
69 main(config())