def w2p_pack_plugin(filename, path, plugin_name):
 filename = abspath(filename)
 path = abspath(path)
 if (not filename.endswith(('web2py.plugin.%s.w2p' % plugin_name))):
  raise Exception('Not a web2py plugin name')
 plugin_tarball = tarfile.open(filename, 'w:gz')
 try:
  app_dir = path
  while (app_dir[(-1)] == '/'):
   app_dir = app_dir[:(-1)]
  files1 = glob.glob(os.path.join(app_dir, ('*/plugin_%s.*' % plugin_name)))
  files2 = glob.glob(os.path.join(app_dir, ('*/plugin_%s/*' % plugin_name)))
  for file in (files1 + files2):
   plugin_tarball.add(file, arcname=file[(len(app_dir) + 1):])
 finally:
  plugin_tarball.close()

def w2p_pack_plugin ( filename , path , plugin_name ) : filename = abspath ( filename ) path = abspath ( path ) if ( not filename . endswith ( ( 'web2py.plugin.%s.w2p' % plugin_name ) ) ) : raise Exception ( 'Not a web2py plugin name' ) plugin_tarball = tarfile . open ( filename , 'w:gz' ) try : app_dir = path while ( app_dir [ ( - 1 ) ] == '/' ) : app_dir = app_dir [ : ( - 1 ) ] files1 = glob . glob ( os . path . join ( app_dir , ( '*/plugin_%s.*' % plugin_name ) ) ) files2 = glob . glob ( os . path . join ( app_dir , ( '*/plugin_%s/*' % plugin_name ) ) ) for file in ( files1 + files2 ) : plugin_tarball . add ( file , arcname = file [ ( len ( app_dir ) + 1 ) : ] ) finally : plugin_tarball . close ( )
packs the given plugin into a w2p file .