Gaudi Framework, version v23r4

Home   Generated: Mon Sep 17 2012
Functions | Variables

update_versions Namespace Reference

Functions

def extract_version
def change_cml_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 _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 103 of file update_versions.py.

00104                                                      :
00105     changelog_entry = re.compile(r'^(! [0-9]{4}-[0-9]{2}-[0-9]{2} -)|============')
00106     title = " %s %s " % (pkg, version)
00107     letf_chars = (78 - len(title)) / 2
00108     right_chars = 78 - letf_chars - len(title)
00109     separator = ("=" * letf_chars) + title + ("=" * right_chars) + "\n"
00110     out = []
00111     found = False
00112     for l in open(filename):
00113         # looking for the first changelog entry
00114         if not found:
00115             if changelog_entry.match(l):
00116                 out.append(separator)
00117                 found = True
00118         # if found, just go on appending lines
00119         out.append(l)
00120     if found:
00121         open(filename,"w").writelines(out)
00122     else:
00123         print "Warning: could not update release.notes in %s" % pkg

def update_versions::change_cml_version (   cml,
  newversion 
)

Definition at line 24 of file update_versions.py.

00025                                        :
00026     if os.path.exists(cml):
00027         out = []
00028         changed = False
00029         for l in open(cml):
00030             m = _cml_version_pattern.match(l)
00031             if m and m.group(1) != newversion:
00032                 print "%s: %s -> %s"%(cml, m.group(1), newversion)
00033                 l = l.replace(m.group(1), newversion)
00034                 changed = True
00035             out.append(l)
00036         if changed:
00037             open(cml, "w").writelines(out)

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 38 of file update_versions.py.

00039                                           :
00040     """
00041     Compare the version of the package with the new one and update the package if
00042     needed.
00043 
00044     Returns true if the package have been modified.
00045     """
00046     global _req_version_pattern
00047     changed = False
00048     out = []
00049     req = os.path.join(packagedir,"requirements")
00050     for l in open(req):
00051         m = _req_version_pattern.match(l)
00052         if m:
00053             if m.group(1) != newversion:
00054                 print "%s: %s -> %s"%(packagedir,m.group(1),newversion)
00055                 l = l.replace(m.group(1),newversion)
00056                 changed = True
00057         out.append(l)
00058     if changed:
00059         open(req,"w").writelines(out)
00060     # verify the version.cmt file
00061     ver = os.path.join(packagedir,"version.cmt")
00062     if os.path.exists(ver):
00063         current = open(ver).read().strip()
00064         if current != newversion:
00065             open(ver,"w").write(newversion + "\n")
00066     # update CMakeLists.txt
00067     cml = os.path.normpath(os.path.join(packagedir, "..", "CMakeLists.txt"))
00068     change_cml_version(cml, newversion)
00069     if "GaudiKernel" in packagedir:
00070         cml = os.path.normpath(os.path.join(packagedir, "..", "src", "Util", "CMakeLists.txt"))
00071         change_cml_version(cml, newversion)
00072     return changed

def update_versions::extract_recent_rel_notes (   filename )

Definition at line 83 of file update_versions.py.

00084                                       :
00085     changelog_entry = re.compile(r'^(! [0-9]{4}-[0-9]{2}-[0-9]{2} -)|============')
00086     separator_entry = re.compile(r'^!?============')
00087     notes = []
00088     state = "searching"
00089     for l in open(filename):
00090         # looking for the first changelog entry
00091         if state == "searching":
00092             if changelog_entry.match(l):
00093                 state = "found"
00094         # when found, we start collecting lines until the next separator
00095         if state == "found":
00096             if not separator_entry.match(l):
00097                 notes.append(l)
00098             else:
00099                 break
00100     # remove trailing empty lines
00101     while notes and not notes[-1].strip(): notes.pop()
00102     return "".join(notes)

def update_versions::extract_version (   f )
Find the version number in a requirements file.

Definition at line 13 of file update_versions.py.

00014                       :
00015     """
00016     Find the version number in a requirements file.
00017     """
00018     global _req_version_pattern
00019     for l in open(f):
00020         m = _req_version_pattern.match(l)
00021         if m:
00022             return m.group(1)
00023     return None

def update_versions::gather_new_versions (   f )

Definition at line 74 of file update_versions.py.

00075                           :
00076     global _use_pattern
00077     versions = {}
00078     for l in open(f):
00079         m = _use_pattern.match(l)
00080         if m:
00081             versions[m.group(1)] = m.group(2)
00082     return versions

def update_versions::main (  )

Definition at line 124 of file update_versions.py.

00125           :
00126 
00127     # Find the version of LCGCMT
00128     m = re.search("use\s*LCGCMT\s*LCGCMT_(\S*)",open(os.path.join("..","..","cmt","project.cmt")).read())
00129     if m:
00130         LCGCMTVers = m.group(1)
00131         print "Using LCGCMT", LCGCMTVers
00132     else:
00133         print "Cannot find LCGCMT version"
00134         sys.exit(1)
00135 
00136     # Collect all the packages in the project with their directory
00137     # (I want to preserve the order that cmt broadcast gives)
00138     all_packages_tmp = []
00139     exec(os.popen(r"""cmt broadcast 'echo "all_packages_tmp.append((\"<package>\"", \"$PWD\""))"'""","r").read())
00140     all_packages_names = []
00141     all_packages = {}
00142     for k,v in all_packages_tmp:
00143         all_packages_names.append(k)
00144         all_packages[k] = v
00145 
00146     # Packages which version must match the version of the project
00147     special_packages = ["Gaudi", "GaudiExamples", "GaudiSys", "GaudiRelease"]
00148 
00149     # Ask for the version of the project
00150     old_version = extract_version("requirements")
00151     new_version = raw_input("The old version of the project is %s, which is the new one? " % old_version)
00152 
00153     old_versions = {}
00154     release_notes = {}
00155     new_versions = {}
00156     # for each package in the project check if there were changes and ask for the new version number
00157     for pkg in all_packages_names:
00158         reqfile = os.path.join(all_packages[pkg], "requirements")
00159         relnotefile = os.path.join(all_packages[pkg], "..", "doc", "release.notes")
00160         old_versions[pkg] = extract_version(reqfile)
00161         if os.path.exists(relnotefile): # ignore missing release.notes
00162             release_notes[pkg] = extract_recent_rel_notes(relnotefile)
00163         else:
00164             release_notes[pkg] = ""
00165         if pkg in special_packages:
00166             new_versions[pkg] = new_version
00167         else:
00168             if release_notes[pkg]:
00169                 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]))
00170             else:
00171                 new_versions[pkg] = old_versions[pkg]
00172         # update infos
00173         if new_versions[pkg] != old_versions[pkg]:
00174             change_version(all_packages[pkg], new_versions[pkg])
00175             if os.path.exists(relnotefile):
00176                 add_release_separator_bar(relnotefile, pkg, new_versions[pkg])
00177         print "=" * 80
00178     # The changes in the GaudiRelease requirements for the other packages can be postponed to now
00179     reqfile = os.path.join(all_packages["GaudiRelease"], "requirements")
00180     out = []
00181     for l in open(reqfile):
00182         sl = l.strip().split()
00183         if sl and sl[0] == "use":
00184             if sl[1] in new_versions:
00185                 if sl[2] != new_versions[sl[1]]:
00186                     l = l.replace(sl[2], new_versions[sl[1]])
00187         out.append(l)
00188     open(reqfile, "w").writelines(out)
00189 
00190     # update the global release notes
00191     new_lines = []
00192     new_lines.append("<!-- ====================================================================== -->")
00193     data = { "vers": new_version, "date": time.strftime("%Y-%m-%d") }
00194     new_lines.append('<h2><a name="%(vers)s">Gaudi %(vers)s</a> (%(date)s)</h2>' % data)
00195     data = { "vers": LCGCMTVers }
00196     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)
00197     new_lines.append("<h3>General Changes</h3>")
00198     new_lines.append('<ul>\n<li><br/>\n    (<span class="author"></span>)</li>\n</ul>')
00199     new_lines.append("<h3>Packages Changes</h3>")
00200     new_lines.append("<ul>")
00201     for pkg in all_packages_names:
00202         if release_notes[pkg]:
00203             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]))
00204             new_lines.append(release_notes[pkg].replace('&','&amp;') \
00205                                                .replace('<','&lt;') \
00206                                                .replace('>','&gt;') + "</pre>")
00207             new_lines.append("</li>")
00208     new_lines.append("</ul>")
00209 
00210     global_rel_notes = os.path.join("..", "doc", "release.notes.html")
00211     out = []
00212     separator = re.compile("<!-- =+ -->")
00213     block_added = False
00214     for l in open(global_rel_notes):
00215         if not block_added and separator.match(l.strip()):
00216             out.append("\n".join(new_lines) + "\n")
00217             block_added = True
00218         out.append(l)
00219     open(global_rel_notes, "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::_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 73 of file update_versions.py.

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Defines

Generated at Mon Sep 17 2012 13:50:01 for Gaudi Framework, version v23r4 by Doxygen version 1.7.2 written by Dimitri van Heesch, © 1997-2004