]> git.phdru.name Git - m_librarian.git/blob - m_librarian/config.py
c57406ba1601e11901b337e43b8ba6a01d60c340
[m_librarian.git] / m_librarian / config.py
1 #! /usr/bin/env python
2
3 __all__ = ['ml_conf']
4
5 import os
6 from ConfigParser import SafeConfigParser
7
8 config_dirs = []
9 if 'XDG_CONFIG_HOME' in os.environ:
10     config_dirs.append(os.environ['XDG_CONFIG_HOME'])
11 if 'XDG_CONFIG_DIRS' in os.environ:
12     config_dirs.extend(os.environ['XDG_CONFIG_DIRS'].split(':'))
13 home_config = os.path.expanduser('~/.config')
14 if home_config not in config_dirs:
15     config_dirs.append(home_config)
16
17 for d in config_dirs:
18     ml_conf_file = os.path.join(d, 'm_librarian.conf')
19     if os.path.exists(ml_conf_file):
20         ml_conf = SafeConfigParser()
21         ml_conf.read(ml_conf_file)
22         break
23 else:
24     ml_conf = ml_conf_file = None
25
26
27 def test():
28     print "Config dirs:", config_dirs
29     print "Config file:", ml_conf_file
30
31 if __name__ == '__main__':
32     test()