diff options
author | Sam Thursfield <sam.thursfield@codethink.co.uk> | 2015-07-14 13:27:10 +0100 |
---|---|---|
committer | Baserock Gerrit <gerrit@baserock.org> | 2015-07-28 09:46:13 +0000 |
commit | fabcc63e5dd0ad098dab3508f8c6cc78123517d0 (patch) | |
tree | 9b7f452481799a9d2cbab74638e9b32493d87598 /migrations/indent | |
parent | 8e4a341db6226deff45003f55afb57aa53c8fada (diff) | |
download | definitions-fabcc63e5dd0ad098dab3508f8c6cc78123517d0.tar.gz |
Add migration scripts for historical versions of the definitions format
See README for more information on how the migrations are intended work.
These migrations are probably not widely useful, as our definitions have
already been migrated manually. However, I want to come up with a good
pattern for writing migration scripts, and actually doing it seems like
the best way.
There is a 'migrations/indent' tool, which reformats a set of
definitions according to how the ruamel.yaml program writes them out.
This tool is nice if you like everything to have consistent indent and
line wrapping, and you can run it before running the migrations to
ensure that the migrations don't do any reformatting when writing the
.moprh files back to disk.
The migration scripts require the ruamel.yaml Python library. I have
sent a separate change to add this to the 'build' and 'devel' reference
systems.
Change-Id: Ibd62ba140d3f7e8e638beed6d714f671405bdc79
Diffstat (limited to 'migrations/indent')
-rwxr-xr-x | migrations/indent | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/migrations/indent b/migrations/indent new file mode 100755 index 00000000..8d6f034f --- /dev/null +++ b/migrations/indent @@ -0,0 +1,36 @@ +#!/usr/bin/env python +# Copyright (C) 2015 Codethink Limited +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; version 2 of the License. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License along +# with this program. If not, see <http://www.gnu.org/licenses/>. + + +'''Automatically reformat a set of Baserock definition files. + +This tool expects to be able to use ruamel.yaml to load and write YAML. +It will totally ruin things if used with PyYAML. + +It makes sense to run this script on your definitions, and check through +and commit the result, before running any of the automated migrations. This +way, you can be sure that the migrations will only change things that they need +to in the .morph files. + +''' + + +import migrations + + +def force_rewrite(contents, filename): + return True + +migrations.process_definitions(path='.', modify_cb=force_rewrite) |