| # Gaudi Framework, version v25r0 |

Home |  | Generated: Mon Feb 17 2014

- Main Page
- Related Pages
- Modules
- Namespaces
- Classes
- Files

- Namespace List
- Namespace Members

All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
Functions | Variables
update_versions Namespace Reference

## Functions
def | extract_version
def | change_cml_version
def | change_hwaf_version
def | change_version
def | gather_new_versions
def | extract_recent_rel_notes
def | add_release_separator_bar
def | main

## Variables
string | __author__ "Marco Clemencic <Marco.Clemencic@cern.ch>"
string | __version__ "$Id: update_versions.py,v 1.3 2008/11/10 19:43:31 marcocle Exp $"
tuple | _req_version_pattern re.compile(r"^\s*version\s*(v[0-9]+r[0-9]+(?:p[0-9]+)?)\s*$")
tuple | _cml_version_pattern re.compile(r"^\s*gaudi_subdir\s*\(\s*\S+\s+(v[0-9]+r[0-9]+(?:p[0-9]+)?)\)\s*$")
tuple | _hwaf_hpyscript_version_pattern re.compile(r"^\s*[\"']version[\"']\s*:\s*[\"'](v[0-9]+r[0-9]+(?:p[0-9]+)?)[\"'].*$")
tuple | _hwaf_ymlscript_version_pattern re.compile(r"^\s*version\s*:\s*[\"'](v[0-9]+r[0-9]+(?:p[0-9]+)?)[\"'].*$")
tuple | _use_pattern re.compile(r"^\s*use\s*(\w+)\s*(v[0-9]+r[0-9]+(?:p[0-9]+)?)\s*(\w+)?\s*$")

## Function Documentation

def update_versions.add_release_separator_bar | ( |  | filename,
|  |  | pkg,
|  |  | version
| ) |  |

Definition at line 137 of file update_versions.py.

137
138 def add_release_separator_bar(filename, pkg, version):
139 changelog_entry = re.compile(r'^(! [0-9]{4}-[0-9]{2}-[0-9]{2} -)|============')
140 title = " %s %s " % (pkg, version)
141 letf_chars = (78 - len(title)) / 2
142 right_chars = 78 - letf_chars - len(title)
143 separator = ("=" * letf_chars) + title + ("=" * right_chars) + "\n"
144 out = []
145 found = False
146 for l in open(filename):
147 # looking for the first changelog entry
148 if not found:
149 if changelog_entry.match(l):
150 out.append(separator)
151 found = True
152 # if found, just go on appending lines
153 out.append(l)
154 if found:
155 open(filename,"w").writelines(out)
156 else:
157 print "Warning: could not update release.notes in %s" % pkg

def update_versions.change_cml_version | ( |  | cml,
|  |  | newversion
| ) |  |

Definition at line 27 of file update_versions.py.

27
28 def change_cml_version(cml, newversion):
29 if os.path.exists(cml):
30 out = []
31 changed = False
32 for l in open(cml):
33 m = _cml_version_pattern.match(l)
34 if m and m.group(1) != newversion:
35 print "%s: %s -> %s"%(cml, m.group(1), newversion)
36 l = l.replace(m.group(1), newversion)
37 changed = True
38 out.append(l)
39 if changed:
40 open(cml, "w").writelines(out)

def update_versions.change_hwaf_version | ( |  | pkgdir,
|  |  | newversion
| ) |  |

Definition at line 41 of file update_versions.py.

41
42 def change_hwaf_version(pkgdir, newversion):
43 hname = os.path.join(pkgdir, "..", "hscript.py")
44 yname = os.path.join(pkgdir, "..", "hscript.yml")
45 fname = None
46 pat = None
47 if os.path.exists(hname):
48 pat = _hwaf_hpyscript_version_pattern
49 fname = hname
50 elif os.path.exists(yname):
51 pat = _hwaf_ymlscript_version_pattern
52 fname = yname
53 else:
54 print ("*** package [%s] has no hwaf script" % pkgdir)
55 return
56
57 out = []
58 changed = False
59 for l in open(fname):
60 m = pat.match(l)
61 if m and m.group(1) != newversion:
62 print "%s: %s -> %s"%(fname, m.group(1), newversion)
63 l = l.replace(m.group(1), newversion)
64 changed = True
65 out.append(l)
66 if changed:
67 open(fname, "w").writelines(out)
68 return

def update_versions.change_version | ( |  | packagedir,
|  |  | newversion
| ) |  |

    Compare the version of the package with the new one and update the package if
    needed.

    Returns true if the package have been modified.

Definition at line 69 of file update_versions.py.

69
70 def change_version(packagedir, newversion):
71 """
72 Compare the version of the package with the new one and update the package if
73 needed.
74
75 Returns true if the package have been modified.
76 """
77 global _req_version_pattern
78 changed = False
79 out = []
80 req = os.path.join(packagedir,"requirements")
81 for l in open(req):
82 m = _req_version_pattern.match(l)
83 if m:
84 if m.group(1) != newversion:
85 print "%s: %s -> %s"%(packagedir,m.group(1),newversion)
86 l = l.replace(m.group(1),newversion)
87 changed = True
88 out.append(l)
89 if changed:
90 open(req,"w").writelines(out)
91 # verify the version.cmt file
92 ver = os.path.join(packagedir,"version.cmt")
93 if os.path.exists(ver):
94 current = open(ver).read().strip()
95 if current != newversion:
96 open(ver,"w").write(newversion + "\n")
97 # update CMakeLists.txt
98 cml = os.path.normpath(os.path.join(packagedir, "..", "CMakeLists.txt"))
99 change_cml_version(cml, newversion)
100 if "GaudiKernel" in packagedir:
101 cml = os.path.normpath(os.path.join(packagedir, "..", "src", "Util", "CMakeLists.txt"))
102 change_cml_version(cml, newversion)
103
104 # update hscripts
105 change_hwaf_version(packagedir, newversion)
106 return changed

def update_versions.extract_recent_rel_notes | ( |  | filename | ) |

Definition at line 117 of file update_versions.py.

117
118 def extract_recent_rel_notes(filename):
119 changelog_entry = re.compile(r'^(! [0-9]{4}-[0-9]{2}-[0-9]{2} -)|!?============')
120 separator_entry = re.compile(r'^!?============')
121 notes = []
122 state = "searching"
123 for l in open(filename):
124 # looking for the first changelog entry
125 if state == "searching":
126 if changelog_entry.match(l):
127 state = "found"
128 # when found, we start collecting lines until the next separator
129 if state == "found":
130 if not separator_entry.match(l):
131 notes.append(l)
132 else:
133 break
134 # remove trailing empty lines
135 while notes and not notes[-1].strip(): notes.pop()
136 return "".join(notes)

def update_versions.extract_version | ( |  | f | ) |

    Find the version number in a requirements file.

Definition at line 16 of file update_versions.py.

16
17 def extract_version(f):
18 """
19 Find the version number in a requirements file.
20 """
21 global _req_version_pattern
22 for l in open(f):
23 m = _req_version_pattern.match(l)
24 if m:
25 return m.group(1)
26 return None

def update_versions.gather_new_versions | ( |  | f | ) |

Definition at line 108 of file update_versions.py.

108
109 def gather_new_versions(f):
110 global _use_pattern
111 versions = {}
112 for l in open(f):
113 m = _use_pattern.match(l)
114 if m:
115 versions[m.group(1)] = m.group(2)
116 return versions

def update_versions.main | ( |  | ) |

Definition at line 158 of file update_versions.py.

158
159 def main():
160
161 # Find the version of LCGCMT
162 m = re.search("use\s*LCGCMT\s*LCGCMT_(\S*)",open(os.path.join("..","..","cmt","project.cmt")).read())
163 if m:
164 LCGCMTVers = m.group(1)
165 print "Using LCGCMT", LCGCMTVers
166 else:
167 print "Cannot find LCGCMT version"
168 sys.exit(1)
169
170 # Collect all the packages in the project with their directory
171 # (I want to preserve the order that cmt broadcast gives)
172 all_packages_tmp = []
173 exec(os.popen(r"""cmt broadcast 'echo "all_packages_tmp.append((\"<package>\"", \"$PWD\""))"'""","r").read())
174 all_packages_names = []
175 all_packages = {}
176 for k,v in all_packages_tmp:
177 all_packages_names.append(k)
178 all_packages[k] = v
179
180 # Packages which version must match the version of the project
181 special_packages = ["Gaudi", "GaudiExamples", "GaudiSys", "GaudiRelease"]
182
183 # Ask for the version of the project
184 old_version = extract_version("requirements")
185 new_version = raw_input("The old version of the project is %s, which is the new one? " % old_version)
186
187 old_versions = {}
188 release_notes = {}
189 new_versions = {}
190 # for each package in the project check if there were changes and ask for the new version number
191 for pkg in all_packages_names:
192 reqfile = os.path.join(all_packages[pkg], "requirements")
193 relnotefile = os.path.join(all_packages[pkg], "..", "doc", "release.notes")
194 old_versions[pkg] = extract_version(reqfile)
195 if os.path.exists(relnotefile): # ignore missing release.notes
196 release_notes[pkg] = extract_recent_rel_notes(relnotefile)
197 else:
198 release_notes[pkg] = ""
199 if pkg in special_packages:
200 new_versions[pkg] = new_version
201 else:
202 if release_notes[pkg]:
203 new_versions[pkg] = raw_input("\nThe old version of %s is %s, this are the changes:\n%s\nWhich version you want (old is %s)? " % (pkg, old_versions[pkg], release_notes[pkg], old_versions[pkg]))
204 else:
205 new_versions[pkg] = old_versions[pkg]
206 # update infos
207 if new_versions[pkg] != old_versions[pkg]:
208 change_version(all_packages[pkg], new_versions[pkg])
209 if os.path.exists(relnotefile):
210 add_release_separator_bar(relnotefile, pkg, new_versions[pkg])
211 print "=" * 80
212 # The changes in the GaudiRelease requirements for the other packages can be postponed to now
213 reqfile = os.path.join(all_packages["GaudiRelease"], "requirements")
214 out = []
215 for l in open(reqfile):
216 sl = l.strip().split()
217 if sl and sl[0] == "use":
218 if sl[1] in new_versions:
219 if sl[2] != new_versions[sl[1]]:
220 l = l.replace(sl[2], new_versions[sl[1]])
221 out.append(l)
222 open(reqfile, "w").writelines(out)
223
224 # update the global release notes
225 new_lines = []
226 new_lines.append("<!-- ====================================================================== -->")
227 data = { "vers": new_version, "date": time.strftime("%Y-%m-%d") }
228 new_lines.append('<h2><a name="%(vers)s">Gaudi %(vers)s</a> (%(date)s)</h2>' % data)
229 data = { "vers": LCGCMTVers }
230 new_lines.append('<h3>Externals version: <a href="http://lcgsoft.cern.ch/index.py?page=cfg_overview&cfg=%(vers)s">LCGCMT_%(vers)s</a></h3>' % data)
231 new_lines.append("<h3>General Changes</h3>")
232 new_lines.append('<ul>\n<li><br/>\n (<span class="author"></span>)</li>\n</ul>')
233 new_lines.append("<h3>Packages Changes</h3>")
234 new_lines.append("<ul>")
235 for pkg in all_packages_names:
236 if release_notes[pkg]:
237 new_lines.append('<li>%s (%s):\n<ul>\n<li><br/>\n (<span class="author"></span>)</li>\n</ul>\n<pre>'%(pkg,new_versions[pkg]))
238 new_lines.append(release_notes[pkg].replace('&','&amp;') \
239 .replace('<','&lt;') \
240 .replace('>','&gt;') + "</pre>")
241 new_lines.append("</li>")
242 new_lines.append("</ul>")
243
244 global_rel_notes = os.path.join("..", "doc", "release.notes.html")
245 out = []
246 separator = re.compile("<!-- =+ -->")
247 block_added = False
248 for l in open(global_rel_notes):
249 if not block_added and separator.match(l.strip()):
250 out.append("\n".join(new_lines) + "\n")
251 block_added = True
252 out.append(l)
253 open(global_rel_notes, "w").writelines(out)
254
255 # update the global CMakeLists.txt
256 global_cmakelists = os.path.join("..","..","CMakeLists.txt")
257 out = []
258 for l in open(global_cmakelists):
259 if l.strip().startswith('gaudi_project'):
260 l = 'gaudi_project(Gaudi %s)\n' % new_version
261 out.append(l)
262 open(global_cmakelists, "w").writelines(out)

## Variable Documentation

string update_versions.__author__ "Marco Clemencic <Marco.Clemencic@cern.ch>"

Definition at line 3 of file update_versions.py.

string update_versions.__version__ "$Id: update_versions.py,v 1.3 2008/11/10 19:43:31 marcocle Exp $"

Definition at line 4 of file update_versions.py.

tuple update_versions._cml_version_pattern re.compile(r"^\s*gaudi_subdir\s*\(\s*\S+\s+(v[0-9]+r[0-9]+(?:p[0-9]+)?)\)\s*$")

Definition at line 12 of file update_versions.py.

tuple update_versions._hwaf_hpyscript_version_pattern re.compile(r"^\s*[\"']version[\"']\s*:\s*[\"'](v[0-9]+r[0-9]+(?:p[0-9]+)?)[\"'].*$")

Definition at line 13 of file update_versions.py.

tuple update_versions._hwaf_ymlscript_version_pattern re.compile(r"^\s*version\s*:\s*[\"'](v[0-9]+r[0-9]+(?:p[0-9]+)?)[\"'].*$")

Definition at line 14 of file update_versions.py.

tuple update_versions._req_version_pattern re.compile(r"^\s*version\s*(v[0-9]+r[0-9]+(?:p[0-9]+)?)\s*$")

Definition at line 11 of file update_versions.py.

tuple update_versions._use_pattern re.compile(r"^\s*use\s*(\w+)\s*(v[0-9]+r[0-9]+(?:p[0-9]+)?)\s*(\w+)?\s*$")

Definition at line 107 of file update_versions.py.