def packagename(s):
    """
    For package name like 'module.submodule.subsubmodule' returns
    'module.submodule'. If name does not contain any dots '.',
    empty string '' is returned.
    """
    i = s.rfind('.')
    if i >= 0:
        return s[:i]
    else:
        return ''