commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From s...@apache.org
Subject svn commit: r1719062 - /commons/cms-site/trunk/conf/parse-latest-release.py
Date Thu, 10 Dec 2015 11:09:28 GMT
Author: sebb
Date: Thu Dec 10 11:09:27 2015
New Revision: 1719062

URL: http://svn.apache.org/viewvc?rev=1719062&view=rev
Log:
Fix up to use new DOAP location

Modified:
    commons/cms-site/trunk/conf/parse-latest-release.py

Modified: commons/cms-site/trunk/conf/parse-latest-release.py
URL: http://svn.apache.org/viewvc/commons/cms-site/trunk/conf/parse-latest-release.py?rev=1719062&r1=1719061&r2=1719062&view=diff
==============================================================================
--- commons/cms-site/trunk/conf/parse-latest-release.py (original)
+++ commons/cms-site/trunk/conf/parse-latest-release.py Thu Dec 10 11:09:27 2015
@@ -1,10 +1,11 @@
 #!/usr/bin/python
 
-from string import split
-from string import replace
+import os
+import os.path
 
-import subprocess
+# TODO rewrite to use standard Python XML(minidom or xml.etree) instead of requiring extra
package
 from lxml import etree
+
 from distutils.version import LooseVersion, StrictVersion
 
 def findLatestVersion(element, version_tag, date_tag):
@@ -22,14 +23,9 @@ def findLatestVersion(element, version_t
 
 	return latest_version, latest_date
 
-def getReleaseInfo(url):
-	try:
-		content = subprocess.check_output('svn cat ' + doap_file_url, shell=True, stderr=subprocess.STDOUT)
-	except subprocess.CalledProcessError:
-		return None, None
-
-	root = etree.XML(content)
-	tree = etree.ElementTree(root)
+def getReleaseInfo(file):
+	with open(file) as f:
+		tree = etree.parse(f).getroot()
 
 	version = None
 	date = None
@@ -52,21 +48,18 @@ def getReleaseInfo(url):
 
 
 # start
-svnbaseurl='http://svn.apache.org/repos/asf/commons/proper/'
+DIR = '../doap' # location relative to the properties file
 
 f = open('component_releases.properties', 'w+')
-s = subprocess.check_output('svn ls ' + svnbaseurl, shell=True)
-
-for component in split(s):
-	comp_name = replace(component, "/", "")
-	doap_file_url = svnbaseurl + comp_name + '/' + 'trunk/' + 'doap_' + comp_name + '.rdf'
 
-	version, date = getReleaseInfo(doap_file_url)
-	print comp_name, version, date
+for file in os.listdir(DIR):
+	comp_name = file[5:-4] # drop doap_ prefix and .rdf suffix
+	version, date = getReleaseInfo(os.path.join(DIR, file))
+	print(comp_name, version, date)
 	if version != None:
 		f.write(comp_name + 'Version=' + version + '\n')
 		f.write(comp_name + 'Released=' + date + '\n')
-	else:
+	else: # should not happen unless DOAP syntax is wrong
 		f.write(comp_name + 'Version=N/A\n')
 		f.write(comp_name + 'Released=N/A\n')		
 



Mime
View raw message