def is_package_dir(dirname):
    # Make sure it's a directory name.
    if not isinstance(dirname, basestring):
        return False
    if not os.path.isdir(dirname):
        return False
    dirname = os.path.abspath(dirname)
    # Make sure it's a valid identifier.  (Special case for
    # "foo/", where os.path.split -> ("foo", "").)
    (parent, dir) = os.path.split(dirname)
    if dir == '': (parent, dir) = os.path.split(parent)
    if not re.match('\w+$', dir):
        return False
    
    for name in os.listdir(dirname):
        filename = os.path.join(dirname, name)
        if name.startswith('__init__.') and is_module_file(filename):
            return True
    else:
        return False
Convert the libcloud load-balancer object into something more serializable.
dataset/ETHPy150Open ardekantur/pyglet/tools/epydoc/epydoc/util.py/is_package_dir--crossover with--dataset/ETHPy150Open saltstack/salt/salt/cloud/clouds/gce.py/_expand_balancer