~ubuntu-branches/ubuntu/trusty/pyx/trusty

« back to all changes in this revision

Viewing changes to pyx/config.py

  • Committer: Bazaar Package Importer
  • Author(s): Graham Wilson
  • Date: 2004-12-25 06:42:57 UTC
  • Revision ID: james.westby@ubuntu.com-20041225064257-31469ij5uysqq302
Tags: upstream-0.7.1
Import upstream version 0.7.1

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#!/usr/bin/env python
 
2
# -*- coding: ISO-8859-1 -*-
 
3
#
 
4
#
 
5
# Copyright (C) 2003-2004 J�rg Lehmann <joergl@users.sourceforge.net>
 
6
# Copyright (C) 2003-2004 Andr� Wobst <wobsta@users.sourceforge.net>
 
7
#
 
8
# This file is part of PyX (http://pyx.sourceforge.net/).
 
9
#
 
10
# PyX is free software; you can redistribute it and/or modify
 
11
# it under the terms of the GNU General Public License as published by
 
12
# the Free Software Foundation; either version 2 of the License, or
 
13
# (at your option) any later version.
 
14
#
 
15
# PyX is distributed in the hope that it will be useful,
 
16
# but WITHOUT ANY WARRANTY; without even the implied warranty of
 
17
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
18
# GNU General Public License for more details.
 
19
#
 
20
# You should have received a copy of the GNU General Public License
 
21
# along with PyX; if not, write to the Free Software
 
22
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 
23
 
 
24
import ConfigParser, os.path
 
25
import siteconfig
 
26
 
 
27
cflist = [siteconfig.pyxrc,  os.path.expanduser("~/.pyxrc")]
 
28
 
 
29
config = ConfigParser.ConfigParser()
 
30
config.read(cflist)
 
31
 
 
32
def get(section, option, default):
 
33
    try:
 
34
        return config.get(section, option)
 
35
    except:
 
36
        return default
 
37
 
 
38
def getint(section, option, default):
 
39
    try:
 
40
        return config.getint(section, option)
 
41
    except:
 
42
        return default
 
43
 
 
44
def getfloat(section, option, default):
 
45
    try:
 
46
        return config.getfloat(section, option)
 
47
    except:
 
48
        return default
 
49
 
 
50
def getboolean(section, option, default):
 
51
    try:
 
52
        return config.getboolean(section, option)
 
53
    except:
 
54
        return default
 
55