From c5c2c5e39a2e9eb65a7b25e67cee5c1fed88777d Mon Sep 17 00:00:00 2001 From: Steve Kowalik Date: Tue, 22 Sep 2015 14:57:31 +1000 Subject: [PATCH] No longer read an existing zanata.xml There is code in ZanataUtils that will read an existing zanata.xml, and parse the details into an instance to support changing an existing XML file. We have never made use of this functionality, and it just tripped me up when testing a change for the last time, destroy it. Change-Id: Ie3e3ba3d8171ae912f2706dfeb756c007b51b703 --- jenkins/scripts/ZanataUtils.py | 36 ++++------------------------------ 1 file changed, 4 insertions(+), 32 deletions(-) diff --git a/jenkins/scripts/ZanataUtils.py b/jenkins/scripts/ZanataUtils.py index 59b5b37788..5224063fc5 100755 --- a/jenkins/scripts/ZanataUtils.py +++ b/jenkins/scripts/ZanataUtils.py @@ -101,9 +101,7 @@ class ZanataRestService: class ProjectConfig: """Object that stores zanata.xml per-project configuration. - Given an existing zanata.xml, read in the values and make - them accessible. Otherwise, write out a zanata.xml file - for the project given the supplied values. + Write out a zanata.xml file for the project given the supplied values. Attributes: zconfig (IniConfig): zanata.ini values @@ -114,12 +112,9 @@ class ProjectConfig: self.rest_service = ZanataRestService(zconfig, verify=verify) self.xmlfile = xmlfile self.rules = self._parse_rules(rules) - if os.path.isfile(os.path.abspath(xmlfile)): - self._load_config() - else: - for key, value in kwargs.items(): - setattr(self, key, value) - self._create_config() + for key, value in kwargs.items(): + setattr(self, key, value) + self._create_config() def _get_tag_prefix(self, root): """XML utility method @@ -137,29 +132,6 @@ class ProjectConfig: """ return [{'pattern': rule[0], 'rule': rule[1]} for rule in rules] - def _load_config(self): - """Load configuration from an existing zanata.xml - - Load and store project configuration from zanata.xml - - """ - try: - with open(self.xmlfile, 'r') as f: - xml = etree.parse(f) - except IOError: - raise ValueError('Cannot load zanata.xml for this project') - except etree.ParseError: - raise ValueError('Cannot parse zanata.xml for this project') - root = xml.getroot() - tag_prefix = self._get_tag_prefix(root) - self.project = root.find('%sproject' % tag_prefix).text - self.version = root.find('%sproject-version' % tag_prefix).text - self.srcdir = root.find('%ssrc-dir' % tag_prefix).text - self.txdir = root.find('%strans-dir' % tag_prefix).text - rules = root.find('%srules' % tag_prefix) - self.rules = self._parse_rules([(tag.get('pattern', tag.text)) - for tag in rules.getchildren()]) - def _create_config(self): """Create zanata.xml