@positional(1)
def get_package_for_module(module):
 if isinstance(module, basestring):
  try:
   module = sys.modules[module]
  except KeyError:
   return None
 try:
  return unicode(module.package)
 except AttributeError:
  if (module.__name__ == '__main__'):
   try:
    file_name = module.__file__
   except AttributeError:
    pass
   else:
    base_name = os.path.basename(file_name)
    split_name = os.path.splitext(base_name)
    if (len(split_name) == 1):
     return unicode(base_name)
    else:
     return u'.'.join(split_name[:(-1)])
  return unicode(module.__name__)

@ positional ( 1 ) def get_package_for_module ( module ) : if isinstance ( module , basestring ) : try : module = sys . modules [ module ] except KeyError : return None try : return unicode ( module . package ) except AttributeError : if ( module . __name__ == '__main__' ) : try : file_name = module . __file__ except AttributeError : pass else : base_name = os . path . basename ( file_name ) split_name = os . path . splitext ( base_name ) if ( len ( split_name ) == 1 ) : return unicode ( base_name ) else : return u'.' . join ( split_name [ : ( - 1 ) ] ) return unicode ( module . __name__ )
get package name for a module .