# Path: uamobile/parser/base.py
# class UserAgentParser(object):
#     def parse(self, useragent):
#         raise NotImplementedError()


import re
from uamobile.parser.base import UserAgentParser
    def parse(self, useragent):
        if useragent.startswith('Mozilla/4.0'):
            return self._parse_windows_ce(useragent)

        matcher = WILLCOM_RE.match(useragent)
        if not matcher:
            return {}

        (vendor,
         model,
         model_version,
         browser_version,
         cache) = matcher.group(1).split('/')

        cache_size = None
        if cache and cache.lower().startswith('c'):
            try:
                cache_size = int(cache[1:])
            except ValueError:
                pass

        return { 'vendor'         : vendor,
                 'model'          : model,
                 'model_version'  : model_version,
                 'browser_version': browser_version,
                 'cache_size'     : cache_size,
                 }

    def _parse_windows_ce(self, useragent):
        # Mozilla/4.0 (compatible; MSIE 4.01; Windows CE; SHARP/WS007SH; PPC; 480x640)

# Path: uamobile/parser/base.py
# class UserAgentParser(object):
#     def parse(self, useragent):
#         raise NotImplementedError()


# Path: uamobile/parser/willcom.py
import re
from uamobile.parser.base import UserAgentParser

    def parse(self, useragent):
        if useragent.startswith('Mozilla/4.0'):
            return self._parse_windows_ce(useragent)

        matcher = WILLCOM_RE.match(useragent)
        if not matcher:
            return {}

        (vendor,
         model,
         model_version,
         browser_version,
         cache) = matcher.group(1).split('/')

        cache_size = None
        if cache and cache.lower().startswith('c'):
            try:
                cache_size = int(cache[1:])
            except ValueError:
                pass

        return { 'vendor'         : vendor,
                 'model'          : model,
                 'model_version'  : model_version,
                 'browser_version': browser_version,
                 'cache_size'     : cache_size,
                 }

    def _parse_windows_ce(self, useragent):
        # Mozilla/4.0 (compatible; MSIE 4.01; Windows CE; SHARP/WS007SH; PPC; 480x640)

        matcher = WINDOWS_CE_RE.match(useragent)