3 # extract-release-date-from-doap-file.py VERSION DOAP-FILE
5 # Extract release date for the given release version from a DOAP file
7 # Copyright (C) 2020 Tim-Philipp Müller <tim centricular com>
9 # This library is free software; you can redistribute it and/or
10 # modify it under the terms of the GNU Library General Public
11 # License as published by the Free Software Foundation; either
12 # version 2 of the License, or (at your option) any later version.
14 # This library is distributed in the hope that it will be useful,
15 # but WITHOUT ANY WARRANTY; without even the implied warranty of
16 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17 # Library General Public License for more details.
19 # You should have received a copy of the GNU Library General Public
20 # License along with this library; if not, write to the
21 # Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
22 # Boston, MA 02110-1301, USA.
25 import xml.etree.ElementTree as ET
27 if len(sys.argv) != 3:
28 sys.exit('Usage: {} VERSION DOAP-FILE'.format(sys.argv[0]))
30 release_version = sys.argv[1]
33 tree = ET.parse(doap_fn)
36 namespaces = {'doap': 'http://usefulinc.com/ns/doap#'}
38 for v in root.findall('doap:release/doap:Version', namespaces=namespaces):
39 if v.findtext('doap:revision', namespaces=namespaces) == release_version:
40 release_date = v.findtext('doap:created', namespaces=namespaces)
45 sys.exit('Could not find a release with version {} in {}'.format(release_version, doap_fn))