[148551] users/mojca/scripts/add-perl-branch.py

mojca at macports.org mojca at macports.org
Wed May 11 03:19:36 PDT 2016


Revision: 148551
          https://trac.macports.org/changeset/148551
Author:   mojca at macports.org
Date:     2016-05-11 03:19:36 -0700 (Wed, 11 May 2016)
Log Message:
-----------
mojca/scripts: a script to add a new branch to perl modules

Added Paths:
-----------
    users/mojca/scripts/add-perl-branch.py

Added: users/mojca/scripts/add-perl-branch.py
===================================================================
--- users/mojca/scripts/add-perl-branch.py	                        (rev 0)
+++ users/mojca/scripts/add-perl-branch.py	2016-05-11 10:19:36 UTC (rev 148551)
@@ -0,0 +1,40 @@
+#!/usr/bin/python
+
+import glob
+import re
+
+def replace_perl_versions(filename):
+    print(filename)
+
+    # read the file
+    f = open(filename)
+    lines = f.readlines()
+    f.close()
+
+    # write the file with a changed version string
+    f = open(filename, 'w')
+    for line in lines:
+        match = re.search(r'^perl5.branches\s+(.*)', line)
+        if match:
+            versions_old = match.group(1)
+            # remove 5.16 5.28 5.20
+            versions_new = re.sub(r'5[.](22)\s*', '5.22 5.24', versions_old)
+            # new version string (properly formatted for 20 spaces)
+            line_new     = "perl5.branches      {}".format(versions_new)
+            # just debug output
+            # print(versions_old)
+            # print(versions_new)
+            print(line.strip())
+            print(line_new)
+            print()
+            # write the new version string to the file
+            f.write(line_new + "\n")
+        else:
+            # or write the original line if it wasn't about versions
+            f.write(line)
+    f.close()
+
+
+file_list = glob.glob("perl/p5-*/Portfile")
+for l in file_list:
+    replace_perl_versions(l)


Property changes on: users/mojca/scripts/add-perl-branch.py
___________________________________________________________________
Added: svn:executable
   + *
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.macosforge.org/pipermail/macports-changes/attachments/20160511/7d5e7706/attachment.html>


More information about the macports-changes mailing list