From: Ed Bartosh Date: Mon, 13 May 2013 10:26:02 +0000 (+0300) Subject: Revert "Implemented BuildData API" X-Git-Tag: 0.16~7 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=e195359a38874ff563dc8c4e5a75c87108eb24d0;p=tools%2Fgbs.git Revert "Implemented BuildData API" This reverts commit 927ec38d83ab355905379997aad73c672a7505ee. Change-Id: I2b393c7db05d3e3190f549448271d92f3d3bf9e4 --- diff --git a/debian/gbs-api.install b/debian/gbs-api.install index fdac632..e15459d 100644 --- a/debian/gbs-api.install +++ b/debian/gbs-api.install @@ -5,5 +5,4 @@ usr/lib/python*/*packages/gitbuildsys/log.py usr/lib/python*/*packages/gitbuildsys/safe_url.py usr/lib/python*/*packages/gitbuildsys/conf.py usr/lib/python*/*packages/gitbuildsys/utils.py -usr/lib/python*/*packages/gitbuildsys/builddata.py usr/lib/python*/*packages/gbs-*.egg-info diff --git a/gitbuildsys/builddata.py b/gitbuildsys/builddata.py deleted file mode 100644 index c6aa613..0000000 --- a/gitbuildsys/builddata.py +++ /dev/null @@ -1,145 +0,0 @@ -# vim: ai ts=4 sts=4 et sw=4 -# -# Copyright (c) 2012 Intel, Inc. -# -# This program is free software; you can redistribute it and/or modify it -# under the terms of the GNU General Public License as published by the Free -# Software Foundation; version 2 of the License -# -# This program is distributed in the hope that it will be useful, but -# WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY -# or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License -# for more details. -# -# You should have received a copy of the GNU General Public License along -# with this program; if not, write to the Free Software Foundation, Inc., 59 -# Temple Place - Suite 330, Boston, MA 02111-1307, USA. - -""" -This module takes care of handling/generating/parsing of build.xml -""" - -import re - -from collections import OrderedDict -from xml.dom import minidom - -class BuildDataError(Exception): - """Custom BuildData exception.""" - pass - -class BuildData(object): - """Class for handling build data. - - NOTE! For now it contains only APIs used by pre-release job - (see usage example below). - NOTE! Feel free to add APIs, used by gbs here - - """ - - # fixing of buggy xml.dom.minidom.toprettyxml - XMLTEXT_RE = re.compile('>\n\s+([^<>\s].*?)\n\s+<%s> not found" % \ - (node.nodeName, name)) - dom = minidom.parseString(xml) - btargets = get_elem(dom, "buildtargets") - - for btarget in btargets.getElementsByTagName("buildtarget"): - print btarget.childNodes - bconf = get_elem(btarget, "buildconf") - - target = { - "name": btarget.getAttribute("name"), - "archs": [], - "buildconf": { - "location": - get_elem(bconf, "location").getAttribute("href"), - "checksum": { - "type": get_elem(bconf, "checksum").getAttribute("type"), - "value": get_elem(bconf, "checksum").firstChild.data - } - } - } - - # Get archs - for barch in btarget.getElementsByTagName("arch"): - target["archs"].append(barch.getAttribute("name")) - - self.targets[target["name"]] = target - - def to_xml(self, hreadable=True): - """Format build data as xml.""" - content = ''\ - '%s' % self.build_id - # list of repos - content += '' - archs = [] - for name, target in self.targets.iteritems(): - content += '%s' % name - archs.extend(target['archs']) - content += '' - - # list of architectures - content += '' - for arch in set(archs): - content += '%s' % arch - content += '' - - # build config - #for name in self.targets: - # content += '%s' % \ - # self.targets[name]['buildconf'] - - # build targets - content += '' - for name in self.targets: - target = self.targets[name] - content += '' % name - - # buildconf - content += '' - buildconf = target['buildconf'] - content += '' % buildconf['location'] - content += '%s' % \ - (buildconf['checksum']['type'], - buildconf['checksum']['value']) - content += '' - - # archs - content += '%s' % target['archs'][0] - for arch in target["archs"][1:]: - content += '%s' % arch - - content += '' - content += '' - - # make it human readable - if hreadable: - dom = minidom.parseString(content) - content = self.XMLTEXT_RE.sub('>\g<1> - - - i586 - armv7l - - - exynos - atom - - - - - - 3bd64bd5fa862d99dbc363ccb1557d137b5685bc3bfe9a86bcbf50767da5e2e8 - - - repos/atom/i586/packages - repos/atom/i586/debug - repos/atom/i586/sources - - - repos/atom/x86_64/packages - repos/atom/x86_64/debug - repos/atom/x86_64/sources - - - - - - 3bd64bd5fa862d99dbc363ccb1557d137b5685bc3bfe9a86bcbf50767da5e2e8 - - - repos/exynos/armv7l/packages - repos/exynos/armv7l/debug - repos/exynos/armv7l/sources - - - - tizen-2.1_20130326.13 - -""" - -class BuildDataTest(unittest.TestCase): - '''Tests for BuildData functionality.''' - - def test_load(self): - bdata = BuildData(build_id='test.id') - bdata.load(TEST_XML) - self.assertEqual(bdata.targets, OrderedDict( - [(u'atom', {'buildconf': - {'checksum': {'type': u'sh256', - 'value': u'3bd64bd5fa862d99dbc363ccb1557d137b5685bc3bfe9a86bcbf50767da5e2e8'}, - 'location': u'3bd64bd5fa862d99dbc363ccb1557d137b5685bc3bfe9a86bcbf50767da5e2e8-build.conf'}, - 'name': u'atom', 'archs': [u'i586', u'x86_64']}), - (u'exynos', {'buildconf': - {'checksum': {'type': u'sh256', - 'value': u'3bd64bd5fa862d99dbc363ccb1557d137b5685bc3bfe9a86bcbf50767da5e2e8'}, - 'location': u'3bd64bd5fa862d99dbc363ccb1557d137b5685bc3bfe9a86bcbf50767da5e2e8-build.conf'}, - 'name': u'exynos', 'archs': [u'armv7l']})])) - - def test_load_error(self): - """Test rasing BuildDataError.""" - bdata = BuildData(1) - self.assertRaises(BuildDataError, bdata.load, '') - - - def test_add_target(self): - """Test adding new target.""" - bdata = BuildData(1) - target = {"name": "test_target", - "archs": ['i586'], - "buildconf": { - "checksum": { - "type": "md5", - "value": "45c5fb8bd2b9065bd7eb961cf3663b8c" - }, - "location": 'build.conf' - } - } - - bdata.add_target(target) - self.assertTrue(target["name"] in bdata.targets) - - - def test_to_xml(self): - """Test xml output.""" - bdata = BuildData(build_id='test.id') - bdata.load(TEST_XML) - self.assertEqual(len(bdata.to_xml()), 964) - self.assertEqual(len(bdata.to_xml(hreadable=False)), 809) - - - def test_save(self): - bdata = BuildData(build_id='test.id') - bdata.load(TEST_XML) - fname = 'test_save.tmp' - bdata.save(fname) - self.assertEqual(len(open(fname).read()), 964) - os.unlink(fname)