[2017] | 1 | # PyKota - Print Quotas for CUPS and LPRng |
---|
| 2 | # |
---|
[3133] | 3 | # (c) 2003, 2004, 2005, 2006, 2007 Jerome Alet <alet@librelogiciel.com> |
---|
[2017] | 4 | # This program is free software; you can redistribute it and/or modify |
---|
| 5 | # it under the terms of the GNU General Public License as published by |
---|
| 6 | # the Free Software Foundation; either version 2 of the License, or |
---|
| 7 | # (at your option) any later version. |
---|
| 8 | # |
---|
| 9 | # This program is distributed in the hope that it will be useful, |
---|
| 10 | # but WITHOUT ANY WARRANTY; without even the implied warranty of |
---|
| 11 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
---|
| 12 | # GNU General Public License for more details. |
---|
| 13 | # |
---|
| 14 | # You should have received a copy of the GNU General Public License |
---|
| 15 | # along with this program; if not, write to the Free Software |
---|
[2302] | 16 | # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. |
---|
[2017] | 17 | # |
---|
| 18 | # $Id$ |
---|
| 19 | # |
---|
| 20 | # |
---|
| 21 | |
---|
[3184] | 22 | """This module defines some helper functions to use in CGI scripts.""" |
---|
| 23 | |
---|
[3055] | 24 | import sys |
---|
[2017] | 25 | import os |
---|
| 26 | |
---|
| 27 | def getLanguagePreference() : |
---|
| 28 | """Returns the preferred language.""" |
---|
| 29 | languages = os.environ.get("HTTP_ACCEPT_LANGUAGE", "") |
---|
| 30 | langs = [l.strip().split(';')[0] for l in languages.split(",")] |
---|
[3120] | 31 | #sys.stderr.write("Languages preferences : %s\n" % langs) |
---|
[3055] | 32 | return langs[0].replace("-", "_") |
---|
[2017] | 33 | |
---|
| 34 | def getCharsetPreference() : |
---|
| 35 | """Returns the preferred charset.""" |
---|
| 36 | charsets = os.environ.get("HTTP_ACCEPT_CHARSET", "UTF-8") |
---|
| 37 | charsets = [l.strip().split(';')[0] for l in charsets.split(",")] |
---|
[3120] | 38 | #sys.stderr.write("Charsets preferences : %s\n" % charsets) |
---|
[2017] | 39 | return charsets[0] |
---|