changeset 21:07053ecfb124

Cleanup package namespace a bit.
author cmlenz
date Fri, 17 Jun 2005 12:10:58 +0000
parents c668a9386194
children e67713b7936f
files bitten/build/__init__.py bitten/build/ctools.py bitten/build/pythontools.py bitten/recipe.py bitten/recipe/__init__.py bitten/recipe/api.py bitten/recipe/ctools.py bitten/recipe/pythontools.py bitten/recipe/tests/__init__.py bitten/recipe/tests/api.py bitten/tests/__init__.py bitten/tests/recipe.py recipe.xml setup.py
diffstat 11 files changed, 134 insertions(+), 164 deletions(-) [+]
line wrap: on
line diff
rename from bitten/recipe/__init__.py
rename to bitten/build/__init__.py
--- a/bitten/recipe/__init__.py
+++ b/bitten/build/__init__.py
@@ -17,5 +17,3 @@
 # Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
 #
 # Author: Christopher Lenz <cmlenz@gmx.de>
-
-from bitten.recipe.api import *
\ No newline at end of file
rename from bitten/recipe/ctools.py
rename to bitten/build/ctools.py
rename from bitten/recipe/pythontools.py
rename to bitten/build/pythontools.py
new file mode 100644
--- /dev/null
+++ b/bitten/recipe.py
@@ -0,0 +1,83 @@
+# -*- coding: iso8859-1 -*-
+#
+# Copyright (C) 2005 Christopher Lenz <cmlenz@gmx.de>
+#
+# Bitten 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; either version 2 of the
+# License, or (at your option) any later version.
+#
+# Trac 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., 675 Mass Ave, Cambridge, MA 02139, USA.
+#
+# Author: Christopher Lenz <cmlenz@gmx.de>
+
+import os.path
+from xml.dom import minidom
+
+from bitten import BuildError
+
+__all__ = ['Recipe']
+
+
+class Step(object):
+    """Represents a single step of a build recipe.
+
+    Iterate over an object of this class to get the commands to execute, and
+    their keyword arguments.
+    """
+
+    def __init__(self, node):
+        self._node = node
+        self.id = node.getAttribute('id')
+        self.description = node.getAttribute('description')
+
+    def __iter__(self):
+        for child in [c for c in self._node.childNodes if c.nodeType == 1]:
+            if child.namespaceURI:
+                # Commands
+                yield self._translate(child)
+            elif child.tagName == 'reports':
+                # Reports
+                for child in [c for c in child.childNodes if c.nodeType == 1]:
+                    yield self._translate(child)
+            else:
+                raise BuildError, "Unknown element <%s>" % child.tagName
+
+    def _translate(self, node):
+        if not node.namespaceURI.startswith('bitten:'):
+            # Ignore elements in a foreign namespace
+            return None
+
+        module = __import__(node.namespaceURI[7:], globals(), locals(),
+                            node.localName)
+        func = getattr(module, node.localName)
+        attrs = {}
+        for name, value in node.attributes.items():
+            attrs[name.encode()] = value.encode()
+        return func, attrs
+
+
+class Recipe(object):
+    """Represents a build recipe.
+    
+    Iterate over this object to get the individual build steps in the order they
+    have been defined in the recipe file."""
+
+    def __init__(self, filename='recipe.xml', basedir=os.getcwd()):
+        self.filename = filename
+        self.basedir = basedir
+        self.path = os.path.join(basedir, filename)
+        self.root = minidom.parse(self.path).documentElement
+        self.description = self.root.getAttribute('description')
+
+    def __iter__(self):
+        """Provide an iterator over the individual steps of the recipe."""
+        for child in self.root.getElementsByTagName('step'):
+            yield Step(child)
deleted file mode 100644
--- a/bitten/recipe/api.py
+++ /dev/null
@@ -1,83 +0,0 @@
-# -*- coding: iso8859-1 -*-
-#
-# Copyright (C) 2005 Christopher Lenz <cmlenz@gmx.de>
-#
-# Bitten 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; either version 2 of the
-# License, or (at your option) any later version.
-#
-# Trac 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., 675 Mass Ave, Cambridge, MA 02139, USA.
-#
-# Author: Christopher Lenz <cmlenz@gmx.de>
-
-import os.path
-from xml.dom import minidom
-
-from bitten import BuildError
-
-__all__ = ['Recipe']
-
-
-class Step(object):
-    """Represents a single step of a build recipe.
-
-    Iterate over an object of this class to get the commands to execute, and
-    their keyword arguments.
-    """
-
-    def __init__(self, node):
-        self._node = node
-        self.id = node.getAttribute('id')
-        self.description = node.getAttribute('description')
-
-    def __iter__(self):
-        for child in [c for c in self._node.childNodes if c.nodeType == 1]:
-            if child.namespaceURI:
-                # Commands
-                yield self._translate(child)
-            elif child.tagName == 'reports':
-                # Reports
-                for child in [c for c in child.childNodes if c.nodeType == 1]:
-                    yield self._translate(child)
-            else:
-                raise BuildError, "Unknown element <%s>" % child.tagName
-
-    def _translate(self, node):
-        if not node.namespaceURI.startswith('bitten:'):
-            # Ignore elements in a foreign namespace
-            return None
-
-        module = __import__(node.namespaceURI[7:], globals(), locals(),
-                            node.localName)
-        func = getattr(module, node.localName)
-        attrs = {}
-        for name, value in node.attributes.items():
-            attrs[name.encode()] = value.encode()
-        return func, attrs
-
-
-class Recipe(object):
-    """Represents a build recipe.
-    
-    Iterate over this object to get the individual build steps in the order they
-    have been defined in the recipe file."""
-
-    def __init__(self, filename='recipe.xml', basedir=os.getcwd()):
-        self.filename = filename
-        self.basedir = basedir
-        self.path = os.path.join(basedir, filename)
-        self.root = minidom.parse(self.path).documentElement
-        self.description = self.root.getAttribute('description')
-
-    def __iter__(self):
-        """Provide an iterator over the individual steps of the recipe."""
-        for child in self.root.getElementsByTagName('step'):
-            yield Step(child)
deleted file mode 100644
--- a/bitten/recipe/tests/__init__.py
+++ /dev/null
@@ -1,28 +0,0 @@
-# -*- coding: iso8859-1 -*-
-#
-# Copyright (C) 2005 Christopher Lenz <cmlenz@gmx.de>
-#
-# Bitten 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; either version 2 of the
-# License, or (at your option) any later version.
-#
-# Trac 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., 675 Mass Ave, Cambridge, MA 02139, USA.
-#
-# Author: Christopher Lenz <cmlenz@gmx.de>
-
-import unittest
-
-from bitten.recipe.tests import api
-
-def suite():
-    suite = unittest.TestSuite()
-    suite.addTest(api.suite())
-    return suite
deleted file mode 100644
--- a/bitten/recipe/tests/api.py
+++ /dev/null
@@ -1,47 +0,0 @@
-# -*- coding: iso8859-1 -*-
-#
-# Copyright (C) 2005 Christopher Lenz <cmlenz@gmx.de>
-#
-# Bitten 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; either version 2 of the
-# License, or (at your option) any later version.
-#
-# Trac 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., 675 Mass Ave, Cambridge, MA 02139, USA.
-#
-# Author: Christopher Lenz <cmlenz@gmx.de>
-
-import os
-import os.path
-import tempfile
-import unittest
-
-from bitten.recipe import Recipe
-
-
-class RecipeTestCase(unittest.TestCase):
-
-    def setUp(self):
-        self.temp_dir = tempfile.gettempdir()
-        self.recipe_xml = open(os.path.join(self.temp_dir, 'recipe.xml'), 'w')
-
-    def tearDown(self):
-        os.unlink(os.path.join(self.temp_dir, 'recipe.xml'))
-
-    def testDescription(self):
-        self.recipe_xml.write('<?xml version="1.0"?>'
-                              '<recipe description="test">'
-                              '</recipe>')
-        self.recipe_xml.close()
-        recipe = Recipe(basedir=self.temp_dir)
-        self.assertEqual('test', recipe.description)
-
-def suite():
-    return unittest.makeSuite(RecipeTestCase, 'test')
--- a/bitten/tests/__init__.py
+++ b/bitten/tests/__init__.py
@@ -20,7 +20,7 @@
 
 import unittest
 
-from bitten.recipe import tests as recipe
+from bitten.tests import recipe
 from bitten.util import tests as util
 
 def suite():
new file mode 100644
--- /dev/null
+++ b/bitten/tests/recipe.py
@@ -0,0 +1,47 @@
+# -*- coding: iso8859-1 -*-
+#
+# Copyright (C) 2005 Christopher Lenz <cmlenz@gmx.de>
+#
+# Bitten 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; either version 2 of the
+# License, or (at your option) any later version.
+#
+# Trac 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., 675 Mass Ave, Cambridge, MA 02139, USA.
+#
+# Author: Christopher Lenz <cmlenz@gmx.de>
+
+import os
+import os.path
+import tempfile
+import unittest
+
+from bitten.recipe import Recipe
+
+
+class RecipeTestCase(unittest.TestCase):
+
+    def setUp(self):
+        self.temp_dir = tempfile.gettempdir()
+        self.recipe_xml = open(os.path.join(self.temp_dir, 'recipe.xml'), 'w')
+
+    def tearDown(self):
+        os.unlink(os.path.join(self.temp_dir, 'recipe.xml'))
+
+    def testDescription(self):
+        self.recipe_xml.write('<?xml version="1.0"?>'
+                              '<recipe description="test">'
+                              '</recipe>')
+        self.recipe_xml.close()
+        recipe = Recipe(basedir=self.temp_dir)
+        self.assertEqual('test', recipe.description)
+
+def suite():
+    return unittest.makeSuite(RecipeTestCase, 'test')
--- a/recipe.xml
+++ b/recipe.xml
@@ -1,7 +1,7 @@
 <?xml version="1.0"?>
 <recipe description="My project"
-    xmlns:c="bitten:bitten.recipe.ctools"
-    xmlns:python="bitten:bitten.recipe.pythontools">
+    xmlns:c="bitten:bitten.build.ctools"
+    xmlns:python="bitten:bitten.build.pythontools">
 
     <step id="build" title="Let Distutils build the python code">
         <python:distutils command="build"/>
--- a/setup.py
+++ b/setup.py
@@ -25,6 +25,6 @@
 from bitten.setuptools.testrunner import unittest
 
 setup(name='bitten', version=VERSION,
-      packages=['bitten', 'bitten.recipe', 'bitten.setuptools', 'bitten.util'],
+      packages=['bitten', 'bitten.build', 'bitten.setuptools', 'bitten.util'],
       author="Christopher Lenz", author_email="cmlenz@gmx.de",
       url="http://bitten.cmlenz.net/", cmdclass={'unittest': unittest})
Copyright (C) 2012-2017 Edgewall Software