Rev 1: The start of a plugin to ease packaging woes. in http://bzr.arbash-meinel.com/plugins/packaging

John Arbash Meinel john at arbash-meinel.com
Fri Aug 22 20:15:15 BST 2008


At http://bzr.arbash-meinel.com/plugins/packaging

------------------------------------------------------------
revno: 1
revision-id: john at arbash-meinel.com-20080822191514-5yb1fwcrbebllb8a
committer: John Arbash Meinel <john at arbash-meinel.com>
branch nick: packaging
timestamp: Fri 2008-08-22 14:15:14 -0500
message:
  The start of a plugin to ease packaging woes.
added:
  __init__.py                    __init__.py-20080822191441-sumy669zzount6o6-1
  config.py                      config.py-20080822191441-sumy669zzount6o6-2
  test_config.py                 test_config.py-20080822191441-sumy669zzount6o6-3
-------------- next part --------------
=== added file '__init__.py'
--- a/__init__.py	1970-01-01 00:00:00 +0000
+++ b/__init__.py	2008-08-22 19:15:14 +0000
@@ -0,0 +1,35 @@
+# Copyright (C) 2008 Canonical Ltd
+#
+# 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; either version 2 of the License, or
+# (at your option) any later version.
+#
+# 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
+
+"""A bzr plugin to automate packaging of bzr."""
+
+from bzrlib import (
+    commands,
+    )
+
+version_info = (0, 0, 1, 'dev', 0)
+__version__ = '.'.join(map(str, version_info))
+
+
+class cmd_update_packaging(commands.Command):
+    """Update all of the packaging branches."""
+
+
+def load_tests(standard_tests, module, loader):
+    standard_tests.addTests(loader.loadTestsFromModuleNames([
+        'bzrlib.plugins.packaging.test_config',
+        ]))
+    return standard_tests

=== added file 'config.py'
--- a/config.py	1970-01-01 00:00:00 +0000
+++ b/config.py	2008-08-22 19:15:14 +0000
@@ -0,0 +1,33 @@
+# Copyright (C) 2008 Canonical Ltd
+#
+# 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; either version 2 of the License, or
+# (at your option) any later version.
+#
+# 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
+
+"""Some configuration definitions for bzr-packaging."""
+
+from bzrlib import (
+    config,
+    osutils,
+    )
+
+
+def _get_config_filename():
+    conf_dir = config.config_dir()
+    return osutils.pathjoin(conf_dir, 'packaging.conf')
+
+
+def get_config_obj():
+    c = config.GlobalConfig()
+    c._get_filename = _get_config_filename
+    return c

=== added file 'test_config.py'
--- a/test_config.py	1970-01-01 00:00:00 +0000
+++ b/test_config.py	2008-08-22 19:15:14 +0000
@@ -0,0 +1,43 @@
+# Copyright (C) 2008 Canonical Ltd
+#
+# 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; either version 2 of the License, or
+# (at your option) any later version.
+#
+# 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
+
+"""Tests for the bzr packaging plugin."""
+
+from bzrlib import tests
+
+from bzrlib.plugins.packaging import config
+
+
+class TestConfig(tests.TestCaseInTempDir):
+
+    def test_get_config_obj(self):
+        conf = config.get_config_obj()
+        self.assertIs(None, conf.get_user_option('not-available'))
+        # Now set a value
+        conf.set_user_option('my-key', 'value')
+        self.assertEqual('value', conf.get_user_option('my-key'))
+
+        self.check_file_contents(config._get_config_filename(),
+            "[DEFAULT]\n"
+            "my-key = value\n"
+            )
+
+    def test_config_path(self):
+        from bzrlib import config as bzrconfig
+        conf_file = config._get_config_filename()
+        conf_dir = bzrconfig.config_dir()
+        self.assertStartsWith(conf_file, conf_dir)
+        self.assertEndsWith(conf_file, 'packaging.conf')



More information about the bazaar-commits mailing list