pyweblib.helper
index
/home/michael/Proj/python/PyWebLib/pyweblib/helper.py

pyweblib.helper - Misc. stuff useful in CGI-BINs
(C) 1998-2015 by Michael Ströder <michael@stroeder.com>
 
This module is distributed under the terms of the
GPL (GNU GENERAL PUBLIC LICENSE) Version 2
(see http://www.gnu.org/copyleft/gpl.html)

 
Modules
       
UserDict
os
re

 
Classes
       
UserDict.UserDict
AcceptHeaderDict
AcceptCharsetDict

 
class AcceptCharsetDict(AcceptHeaderDict)
    Special class for Accept-Charset header
 
 
Method resolution order:
AcceptCharsetDict
AcceptHeaderDict
UserDict.UserDict

Methods defined here:
__init__(self, envKey='HTTP_ACCEPT_CHARSET', env=None, defaultValue='utf-8')
preferred(self)
Return the value name with highest capability weigth

Methods inherited from AcceptHeaderDict:
__getitem__(self, value)
value
    String representing the value for which to return
    the floating point capability weight.
items(self)
Return the accepted values as tuples (value,weigth)
in descending order of capability weight
keys(self)
Return the accepted values in descending order of capability weight

Methods inherited from UserDict.UserDict:
__cmp__(self, dict)
__contains__(self, key)
__delitem__(self, key)
__len__(self)
__repr__(self)
__setitem__(self, key, item)
clear(self)
copy(self)
get(self, key, failobj=None)
has_key(self, key)
iteritems(self)
iterkeys(self)
itervalues(self)
pop(self, key, *args)
popitem(self)
setdefault(self, key, failobj=None)
update(self, dict=None, **kwargs)
values(self)

Class methods inherited from UserDict.UserDict:
fromkeys(cls, iterable, value=None) from __builtin__.classobj

Data and other attributes inherited from UserDict.UserDict:
__hash__ = None

 
class AcceptHeaderDict(UserDict.UserDict)
    This dictionary class is used to parse
Accept-header lines with quality weights.
 
It's a base class for all Accept-* headers described
in sections 14.1 to 14.5 of RFC2616.
 
  Methods defined here:
__getitem__(self, value)
value
    String representing the value for which to return
    the floating point capability weight.
__init__(self, envKey, env=None, defaultValue=None)
Parse the Accept-* header line.
 
httpHeader
    string with value of Accept-* header line
items(self)
Return the accepted values as tuples (value,weigth)
in descending order of capability weight
keys(self)
Return the accepted values in descending order of capability weight

Methods inherited from UserDict.UserDict:
__cmp__(self, dict)
__contains__(self, key)
__delitem__(self, key)
__len__(self)
__repr__(self)
__setitem__(self, key, item)
clear(self)
copy(self)
get(self, key, failobj=None)
has_key(self, key)
iteritems(self)
iterkeys(self)
itervalues(self)
pop(self, key, *args)
popitem(self)
setdefault(self, key, failobj=None)
update(self, dict=None, **kwargs)
values(self)

Class methods inherited from UserDict.UserDict:
fromkeys(cls, iterable, value=None) from __builtin__.classobj

Data and other attributes inherited from UserDict.UserDict:
__hash__ = None

 
Functions
       
BrowserType(http_user_agent)
Parse the HTTP_USER_AGENT environment variable and return the
tuple (Browser,Version).
 
Not sure if this succeeds in every situation since most
browsers have very obscure HTTP_USER_AGENT entries for compability reasons.
The following browsers are known by name:
Netscape  Netscape Navigator, Netscape Communicator)
MSIE    MS Internet Explorer
Opera   Opera browser from http://www.operasoftware.com/
StarOffice  built-in browser of Star Office
Lynx    the text-based browser Lynx
NetPositive Net Positive (BeOS)
guessClientAddr(env=None)
Guesses the host name or IP address of the HTTP client by looking
at various HTTP headers mapped to CGI-BIN environment.
 
env
      dictionary containing environment vars (default os.env)

 
Data
        __info__ = '$Id: pyweblib.helper.html,v 1.13 2015/01/10 14:40:54 michael Exp $'
__revision__ = '1.17'
b = 'NetPositive'
compatible_browsers = ['Lynx', 'Opera', 'StarOffice', 'NCSA_Mosaic', 'MSIE', 'NetPositive']
compatible_browsers_re = <_sre.SRE_Pattern object>
known_browsers = {'Lynx': 'Lynx', 'MSIE': 'Microsoft Internet Explorer', 'Mozilla': 'Seamonkey', 'NCSA_Mosaic': 'NCSA Mosaic', 'NetPositive': 'Net Positive', 'Opera': 'Opera', 'StarOffice': 'StarOffice'}
known_browsers_rev = {'Lynx': 'Lynx', 'Microsoft Internet Explorer': 'MSIE', 'NCSA Mosaic': 'NCSA_Mosaic', 'Net Positive': 'NetPositive', 'Opera': 'Opera', 'Seamonkey': 'Mozilla', 'StarOffice': 'StarOffice'}
mozilla_re = <_sre.SRE_Pattern object>