(self)
if not existing_dirname.startswith(plugin_base_dir):
            plugin_dir = "%s/%s" % (plugin_base_dir, existing_dirname)
        else:
            plugin_dir = existing_dirname
if not existing_dirname.startswith(plugin_base_dir):
            plugin_dir = "%s/%s" % (plugin_base_dir, existing_dirname)
        else:
            plugin_dir = existing_dirname
if not existing_dirname . startswith ( plugin_base_dir ) : plugin_dir = %s / %s % ( plugin_base_dir existing_dirname ) else : plugin_dir = existing_dirname
def execute(self):

        dist_dir = self.kwargs.get("dist_dir")
        if not dist_dir:
            dist_dir = Environment.get_dist_dir()

        version = self.kwargs.get("version")
        from_version = self.kwargs.get("from_version")
        if from_version in ['None', None]:
            from_version = ''

        assert version
       
        # code is the same as dirname usually
        code = self.kwargs.get('code')

        search = Search("config/plugin")
        search.add_filter("code", code)
        plugin = search.get_sobject()
        # In case there is extra plugins folder which is the case when the user 
        # is developing. 
        relative_dir = plugin.get_value("rel_dir")
        relative_parts = relative_dir.split('/') 
        relative_dir_no_leaf = '/'.join(relative_parts[0:-1])
        relative_dir_head = relative_parts[0]
       
        plugin_base_dir = Environment.get_plugin_dir()
        plugin_dir = "%s/%s" % (plugin_base_dir, relative_dir)



        existing_dirname = code
        if from_version:
            existing_dirname = '%s-%s'%(existing_dirname, from_version)
       
        new_dirname = code
        if version:
            new_dirname = '%s-%s'%(new_dirname, version)

        basecode = os.path.basename(code)

        zip_path = "%s/%s-%s.zip" % (dist_dir, basecode, version)

        """
        
        if not existing_dirname.startswith(plugin_base_dir):
            plugin_dir = "%s/%s" % (plugin_base_dir, existing_dirname)
        else:
            plugin_dir = existing_dirname
        """
        
        if relative_dir_no_leaf:
            new_plugin_dir = "%s/%s/%s" % (plugin_base_dir, relative_dir_no_leaf, new_dirname)
            root_dir = "%s/%s" % (plugin_base_dir, relative_dir_head)
            new_relative_dir =  "%s/%s" %(relative_dir_no_leaf, new_dirname)
            new_relative_parts = new_relative_dir.split('/')
            include_dirs = ['/'.join(new_relative_parts[1:])]
        else:
            new_plugin_dir = "%s/%s" % (plugin_base_dir, new_dirname)
            root_dir = new_plugin_dir
            include_dirs = None

        if os.path.exists(new_plugin_dir):
            os.makedirs(new_plugin_dir)

        try:
            from shutil import ignore_patterns
            ignore_pat = ignore_patterns('*.pyc', '*.swp', '*.swo', '*.py~','*.bak')
            shutil.copytree(plugin_dir, new_plugin_dir, ignore=ignore_pat)
        except ImportError:    
            shutil.copytree(plugin_dir, new_plugin_dir)
        
        # find manifest
        manifest_path = "%s/manifest.xml" % new_plugin_dir
        f = open(manifest_path)
        manifest = f.read()
        f.close()

        xml = Xml()
        xml.read_string(manifest)

        node = xml.get_node("manifest/data/version")
        if node is not None:
            xml.set_node_value(node, version)
        else:
            node = xml.create_element("version")
            xml.set_node_value(node, version)
            data_node = xml.get_node("manifest/data")
            xml.append_child(data_node, node)
    

        f = open(manifest_path, 'wb')
        f.write( xml.to_string())
        f.close()

        # zip up the folder from the plugin root
        # FIXME: this doesn't quite work yet
        """
        from pyasm.common import ZipUtil
        plugin_base_dir = Environment.get_plugin_dir()
        zip_path = "%s.zip" % new_plugin_dir

        include_dirs = ['southpaw']
        zip_util = ZipUtil()
        zip_util.zip_dir(plugin_base_dir, zip_path=zip_path, include_dirs=include_dirs)
        """

        # OLD logic to be deleted
        """
        #parts = new_plugin_dir.split("/")
        #include_dirs = [parts[-1]]
        #root_dir = '/'.join(parts[0:-1])
        
        # e.g. vfx or spt/vfx
        parts = code.split("/")
        root_dir = "%s/%s" % (plugin_base_dir, parts[0])
        if len(parts) >= 2:
            include_dirs = ["/".join(parts[1:])]
        else:
            include_dirs = None
        """

        ignore_dirs = ['.svn']
        ZipUtil.zip_dir(root_dir, zip_path, ignore_dirs=ignore_dirs, include_dirs=include_dirs)
def execute ( self ) : dist_dir = self . kwargs . get ( "dist_dir" ) if not dist_dir : dist_dir = Environment . get_dist_dir ( ) version = self . kwargs . get ( "version" ) from_version = self . kwargs . get ( "from_version" ) if from_version in [ 'None' , None ] : from_version = '' assert version # code is the same as dirname usually code = self . kwargs . get ( 'code' ) search = Search ( "config/plugin" ) search . add_filter ( "code" , code ) plugin = search . get_sobject ( ) # In case there is extra plugins folder which is the case when the user  # is developing.  relative_dir = plugin . get_value ( "rel_dir" ) relative_parts = relative_dir . split ( '/' ) relative_dir_no_leaf = '/' . join ( relative_parts [ 0 : - 1 ] ) relative_dir_head = relative_parts [ 0 ] plugin_base_dir = Environment . get_plugin_dir ( ) plugin_dir = "%s/%s" % ( plugin_base_dir , relative_dir ) existing_dirname = code if from_version : existing_dirname = '%s-%s' % ( existing_dirname , from_version ) new_dirname = code if version : new_dirname = '%s-%s' % ( new_dirname , version ) basecode = os . path . basename ( code ) zip_path = "%s/%s-%s.zip" % ( dist_dir , basecode , version ) if relative_dir_no_leaf : new_plugin_dir = "%s/%s/%s" % ( plugin_base_dir , relative_dir_no_leaf , new_dirname ) root_dir = "%s/%s" % ( plugin_base_dir , relative_dir_head ) new_relative_dir = "%s/%s" % ( relative_dir_no_leaf , new_dirname ) new_relative_parts = new_relative_dir . split ( '/' ) include_dirs = [ '/' . join ( new_relative_parts [ 1 : ] ) ] else : new_plugin_dir = "%s/%s" % ( plugin_base_dir , new_dirname ) root_dir = new_plugin_dir include_dirs = None if os . path . exists ( new_plugin_dir ) : os . makedirs ( new_plugin_dir ) try : from shutil import ignore_patterns ignore_pat = ignore_patterns ( '*.pyc' , '*.swp' , '*.swo' , '*.py~' , '*.bak' ) shutil . copytree ( plugin_dir , new_plugin_dir , ignore = ignore_pat ) except ImportError : shutil . copytree ( plugin_dir , new_plugin_dir ) # find manifest manifest_path = "%s/manifest.xml" % new_plugin_dir f = open ( manifest_path ) manifest = f . read ( ) f . close ( ) xml = Xml ( ) xml . read_string ( manifest ) node = xml . get_node ( "manifest/data/version" ) if node is not None : xml . set_node_value ( node , version ) else : node = xml . create_element ( "version" ) xml . set_node_value ( node , version ) data_node = xml . get_node ( "manifest/data" ) xml . append_child ( data_node , node ) f = open ( manifest_path , 'wb' ) f . write ( xml . to_string ( ) ) f . close ( ) # zip up the folder from the plugin root # FIXME: this doesn't quite work yet """
        from pyasm.common import ZipUtil
        plugin_base_dir = Environment.get_plugin_dir()
        zip_path = "%s.zip" % new_plugin_dir

        include_dirs = ['southpaw']
        zip_util = ZipUtil()
        zip_util.zip_dir(plugin_base_dir, zip_path=zip_path, include_dirs=include_dirs)
        """ # OLD logic to be deleted """
        #parts = new_plugin_dir.split("/")
        #include_dirs = [parts[-1]]
        #root_dir = '/'.join(parts[0:-1])
        
        # e.g. vfx or spt/vfx
        parts = code.split("/")
        root_dir = "%s/%s" % (plugin_base_dir, parts[0])
        if len(parts) >= 2:
            include_dirs = ["/".join(parts[1:])]
        else:
            include_dirs = None
        """ ignore_dirs = [ '.svn' ] ZipUtil . zip_dir ( root_dir , zip_path , ignore_dirs = ignore_dirs , include_dirs = include_dirs )