Back to index

moin  1.9.0~rc2
Public Member Functions | Public Attributes | Static Public Attributes | Static Private Attributes Class Reference
Collaboration diagram for
Collaboration graph

List of all members.

Public Member Functions

def __init__
def __call__

Public Attributes


Static Public Attributes

tuple platforms
tuple browsers

Static Private Attributes

string _browser_version_re = r'(?:%s)[/\sa-z(]*(\d+[.\da-z]+)?(?i)'
tuple _language_re

Detailed Description

A simple user agent parser.  Used by the `UserAgent`.

Definition at line 17 of file

Constructor & Destructor Documentation

Definition at line 63 of file

00064     def __init__(self):
00065         self.platforms = [(b, re.compile(a, re.I)) for a, b in self.platforms]
00066         self.browsers = [(b, re.compile(self._browser_version_re % a))
00067                          for a, b in self.browsers]

Member Function Documentation

Definition at line 68 of file

00069     def __call__(self, user_agent):
00070         for platform, regex in self.platforms:
00071             match =
00072             if match is not None:
00073                 break
00074         else:
00075             platform = None
00076         for browser, regex in self.browsers:
00077             match =
00078             if match is not None:
00079                 version =
00080                 break
00081         else:
00082             browser = version = None
00083         match =
00084         if match is not None:
00085             language = or
00086         else:
00087             language = None
00088         return platform, browser, version, language

Member Data Documentation

string = r'(?:%s)[/\sa-z(]*(\d+[.\da-z]+)?(?i)' [static, private]

Definition at line 57 of file

Initial value:

Definition at line 58 of file

Initial value:
        ('googlebot', 'google'),
        ('msnbot', 'msn'),
        ('yahoo', 'yahoo'),
        ('ask jeeves', 'ask'),
        (r'aol|america\s+online\s+browser', 'aol'),
        ('opera', 'opera'),
        ('chrome', 'chrome'),
        ('firefox|firebird|phoenix|iceweasel', 'firefox'),
        ('galeon', 'galeon'),
        ('safari', 'safari'),
        ('webkit', 'webkit'),
        ('camino', 'camino'),
        ('konqueror', 'konqueror'),
        ('k-meleon', 'kmeleon'),
        ('netscape', 'netscape'),
        (r'msie|microsoft\s+internet\s+explorer', 'msie'),
        ('lynx', 'lynx'),
        ('links', 'links'),
        ('seamonkey|mozilla', 'seamonkey')

Definition at line 35 of file

Definition at line 65 of file

Initial value:
        ('iphone', 'iphone'),
        (r'darwin|mac|os\s*x', 'macos'),
        ('win', 'windows'),
        (r'android', 'android'),
        (r'x11|lin(\b|ux)?', 'linux'),
        ('(sun|i86)os', 'solaris'),
        (r'nintendo\s+wii', 'wii'),
        ('irix', 'irix'),
        ('hp-?ux', 'hpux'),
        ('aix', 'aix'),
        ('sco|unix_sv', 'sco'),
        ('bsd', 'bsd'),
        ('amiga', 'amiga')

Definition at line 20 of file

Definition at line 64 of file

The documentation for this class was generated from the following file: