moinsetup

Changeset

65:5da783917a9f
2012-07-17 Paul Boddie raw files shortlog changelog graph Added support for making hierarchical page packages. Introduced detection of setup.py files when installing plugins.
README.txt (file) moinsetup.py (file)
     1.1 --- a/README.txt	Fri Jul 13 22:20:23 2012 +0200
     1.2 +++ b/README.txt	Tue Jul 17 23:36:13 2012 +0200
     1.3 @@ -317,6 +317,8 @@
     1.4    * Added support for separate static URL paths enforced by limited hosting
     1.5      environments.
     1.6    * Added web_user and web_group settings.
     1.7 +  * Added support for making hierarchical page packages.
     1.8 +  * Introduced detection of setup.py files when installing plugins.
     1.9  
    1.10  New in moinsetup 0.3 (Changes since moinsetup 0.2)
    1.11  --------------------------------------------------
     2.1 --- a/moinsetup.py	Fri Jul 13 22:20:23 2012 +0200
     2.2 +++ b/moinsetup.py	Tue Jul 17 23:36:13 2012 +0200
     2.3 @@ -1332,6 +1332,12 @@
     2.4  
     2.5          status("Copying %s modules to %s..." % (plugin_type, plugin_target_dir))
     2.6  
     2.7 +        # If a setup file is detected, abandon the installation.
     2.8 +
     2.9 +        if exists(join(plugins_dir, "setup%spy" % extsep)):
    2.10 +            print "Plugins not installed: setup%spy was detected." % extsep
    2.11 +            return
    2.12 +
    2.13          for module in glob(join(plugins_dir, "*%spy" % extsep)):
    2.14              shutil.copy(module, plugin_target_dir)
    2.15  
    2.16 @@ -1477,33 +1483,55 @@
    2.17  
    2.18          try:
    2.19              script = ["MoinMoinPackage|1"]
    2.20 +            self._add_page_package_files(page_directory, "", package, script)
    2.21 +            package.writestr("MOIN_PACKAGE", "\n".join(script) + "\n")
    2.22  
    2.23 -            for filename in listdir(page_directory):
    2.24 -                pathname = join(page_directory, filename)
    2.25 +        finally:
    2.26 +            package.close()
    2.27 +
    2.28 +    def _add_page_package_files(self, page_directory, prefix, package, script):
    2.29 +
    2.30 +        """
    2.31 +        Add files in the given 'page_directory' as pages with the given 'prefix'
    2.32 +        to the given 'package', recording them in the given 'script'.
    2.33 +        """
    2.34  
    2.35 -                # Add files as pages having the filename as page name.
    2.36 +        filenames = listdir(page_directory)
    2.37 +        filenames.sort()
    2.38 +
    2.39 +        for filename in filenames:
    2.40 +            pathname = join(page_directory, filename)
    2.41 +
    2.42 +            # Add files as pages having the filename as page name.
    2.43  
    2.44 -                if os.path.isfile(pathname):
    2.45 -                    package.write(pathname, filename)
    2.46 -                    script.append("AddRevision|%s|%s" % (filename, filename))
    2.47 +            if os.path.isfile(pathname):
    2.48 +                pagename = prefix + filename
    2.49 +                zipname = pagename.replace("/", "__")
    2.50 +                package.write(pathname, zipname)
    2.51 +                script.append("AddRevision|%s|%s" % (zipname, pagename))
    2.52 +
    2.53 +            elif os.path.isdir(pathname):
    2.54  
    2.55                  # Add directories ending with "-attachments" as collections of
    2.56                  # attachments for a particular page.
    2.57  
    2.58 -                elif os.path.isdir(pathname) and filename.endswith("-attachments"):
    2.59 -                    parent = filename[:-len("-attachments")]
    2.60 +                if filename.endswith("-attachments"):
    2.61 +                    pagename = prefix + filename[:-len("-attachments")]
    2.62 +                    zipname = pagename.replace("/", "__")
    2.63  
    2.64                      # Add each file as an attachment.
    2.65  
    2.66                      for attachment in listdir(pathname):
    2.67 -                        zipname = "%s_%s" % (filename, attachment)
    2.68 -                        package.write(join(pathname, attachment), zipname)
    2.69 -                        script.append("AddAttachment|%s|%s|%s||" % (zipname, attachment, parent))
    2.70 +                        azipname = "%s_%s" % (zipname, attachment)
    2.71 +                        package.write(join(pathname, attachment), azipname)
    2.72 +                        script.append("AddAttachment|%s|%s|%s||" % (
    2.73 +                            azipname, attachment, pagename))
    2.74  
    2.75 -            package.writestr("MOIN_PACKAGE", "\n".join(script))
    2.76 +                # Descend into other directories.
    2.77  
    2.78 -        finally:
    2.79 -            package.close()
    2.80 +                else:
    2.81 +                    pagename = prefix + filename
    2.82 +                    self._add_page_package_files(pathname, "%s/" % pagename, package, script)
    2.83  
    2.84      def install_page_package(self, package_filename):
    2.85