Plone Code Modifier Tool aka Code Upgrades

Today we, @thet and myself, created plone-codemod to auto-update old code-bases (like 5.2 - yes we have those still) to Plone 6.1/ 6.2.

It covers Python, ZCML, GenericSetup, Pagetemplates/ Bootstrap, PEP420 namespace Packages and Packaging (setup.py -> pyproject.toml).

Still early, but worked well on our codebase, is expandable and a huge help. Some manual work is left, though.

4 Likes

That's very nice! I will give it a go :smiley:

One question about it though: as time passes more updates will be needed, how is that handled?

An entry on the README about how to contribute new method updates, ZCML replacements, etc. would be nice :nerd_face:

At the moment there`s a migration_config.yaml file with all conversions shipped with the wheel. So, this can be extended (PRs welcome). I am pretty sure we did not catch all conversions.

--config is the parameter for custom YAML.

Further development Idea: We could add an command line parameter to point to an "additional rule" file.

EDIT: I added a real documentation, here the Configuration Format - plone-codemod 1.0 documentation

A nice helper :slight_smile: When I run it (installed in a pyenv virtualenv via pip) I get Could not find plone_codemod.import_migrator in any configured modules though.

$ plone-codemod ../collective.behavior.banner/src
Plone 5.2 → 6.x Migration Tool
Source: /Users/pbauer/workspace/collective.behavior.banner/src
Config: /Users/pbauer/.pyenv/versions/3.13.12/envs/codemod/lib/python3.13/site-packages/plone_codemod/migration_config.yaml

=== Phase 1: Python import migration (libcst) ===
Initializing libcst in ../collective.behavior.banner/src
Successfully wrote default config file to /Users/pbauer/workspace/collective.behavior.banner/src/.libcst.codemod.yaml
Loaded 129 import mappings from /Users/pbauer/.pyenv/versions/3.13.12/envs/codemod/lib/python3.13/site-packages/plone_codemod/migration_config.yaml
Running PloneImportMigrator on ../collective.behavior.banner/src ...
stderr: Could not find plone_codemod.import_migrator in any configured modules

[...]

The other steps work fine.

Same when running via uvx plone-codemod src

This looks like the libcst configuration is not created ... and it isnt, I had it already local from my manual runs. Bug. Stay tuned.

fixed 1.0.0a5 released

1 Like

Works now. Thanks.