Module: check_mk
Branch: master
Commit: b247e77bd4d48080ce393ba73c6fdada22278794
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=b247e77bd4d480…
Author: Lars Michelsen <lm(a)mathias-kettner.de>
Date: Thu Feb 16 09:09:26 2017 +0100
Moved werk text changelog formating to lib (also needed for relase
mechanisms)
Change-Id: Ie7cf235afb26c48a6c945d231bcbc229aede9f73
---
lib/werks.py | 43 +++++++++++++++++++++++++++++++++++++++++++
scripts/create-changelog.py | 44 +-------------------------------------------
2 files changed, 44 insertions(+), 43 deletions(-)
diff --git a/lib/werks.py b/lib/werks.py
index fa57d8d..b4ea681 100644
--- a/lib/werks.py
+++ b/lib/werks.py
@@ -180,6 +180,49 @@ def write_precompiled_werks(path, werks):
#store.save_data_to_file(path, werks, pretty=False)
+# Writhe the given werks to a file object. This is used for creating a textual
+# change log for the released versions and the announcement mails
+def write_as_text(werks, f):
+ version, component = None, None
+ for werk in sort_by_version_and_component(werks.values()):
+ if version != werk["version"]:
+ if version is not None:
+ f.write("\n\n")
+
+ version, component = werk["version"], None
+
+ f.write("%s:\n" % werk["version"])
+
+ if component != werk["component"]:
+ if component is not None:
+ f.write("\n")
+
+ component = werk["component"]
+
+ f.write(" %s:\n" % \
+ werk_components().get(component, component))
+
+ write_werk_as_text(f, werk)
+
+
+def write_werk_as_text(f, werk):
+ prefix = ""
+ if werk["class"] == "fix":
+ prefix = " FIX:"
+ elif werk["class"] == "security":
+ prefix = " SEC:"
+
+ if werk.get("description") and len(werk["description"]) > 3:
+ omit = "..."
+ else:
+ omit = ""
+
+ f.write(" * %04d%s %s%s\n" %
+ (werk["id"], prefix, werk["title"].encode("utf-8"),
omit))
+
+ if werk["compatible"] == "incomp":
+ f.write(" NOTE: Please refer to the migration notes!\n")
+
# sort by version and within one version by component
def sort_by_version_and_component(werks):
diff --git a/scripts/create-changelog.py b/scripts/create-changelog.py
index 56d9fd6..379279c 100755
--- a/scripts/create-changelog.py
+++ b/scripts/create-changelog.py
@@ -9,7 +9,7 @@ def create_changelog(dest_file, precompiled_werk_files):
werks = load_werks(precompiled_werk_files)
with open(dest_file, "w") as f:
- write_changelog(werks, f)
+ cmk.werks.write_as_text(werks, f)
# Append previous werk changes
if os.path.exists(dest_file + ".in"):
@@ -24,48 +24,6 @@ def load_werks(precompiled_werk_files):
return werks
-def write_changelog(werks, f):
- version, component = None, None
- for werk in cmk.werks.sort_by_version_and_component(werks.values()):
- if version != werk["version"]:
- if version is not None:
- f.write("\n\n")
-
- version, component = werk["version"], None
-
- f.write("%s:\n" % werk["version"])
-
- if component != werk["component"]:
- if component is not None:
- f.write("\n")
-
- component = werk["component"]
-
- f.write(" %s:\n" % \
- cmk.werks.werk_components().get(component, component))
-
- write_changelog_line(f, werk)
-
-
-def write_changelog_line(f, werk):
- prefix = ""
- if werk["class"] == "fix":
- prefix = " FIX:"
- elif werk["class"] == "security":
- prefix = " SEC:"
-
- if werk.get("description") and len(werk["description"]) > 3:
- omit = "..."
- else:
- omit = ""
-
- f.write(" * %04d%s %s%s\n" %
- (werk["id"], prefix, werk["title"].encode("utf-8"),
omit))
-
- if werk["compatible"] == "incomp":
- f.write(" NOTE: Please refer to the migration notes!\n")
-
-
#
# MAIN
#