# PyKota - Print Quotas for CUPS and LPRng # # (c) 2003-2004 Jerome Alet # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA. # # $Id$ # # $Log$ # Revision 1.1 2005/01/08 17:13:01 jalet # Move some functions outside of the CGI to allow their use in other CGI scripts # # import os def getLanguagePreference() : """Returns the preferred language.""" languages = os.environ.get("HTTP_ACCEPT_LANGUAGE", "") langs = [l.strip().split(';')[0] for l in languages.split(",")] return "%s_%s" % (langs[0], langs[0].upper()) def getCharsetPreference() : """Returns the preferred charset.""" charsets = os.environ.get("HTTP_ACCEPT_CHARSET", "UTF-8") charsets = [l.strip().split(';')[0] for l in charsets.split(",")] return charsets[0]