[wstool] 01/01: Imported Upstream version 0.1.10
Jochen Sprickerhof
jspricke-guest at moszumanska.debian.org
Mon Sep 21 09:02:12 UTC 2015
This is an automated email from the git hooks/post-receive script.
jspricke-guest pushed a commit to annotated tag upstream/0.1.10
in repository wstool.
commit 298ce807e7f721b8d2c1101e2f981e41a34cd629
Author: Jochen Sprickerhof <git at jochen.sprickerhof.de>
Date: Mon Sep 21 10:56:28 2015 +0200
Imported Upstream version 0.1.10
---
doc/changelog.rst | 6 ++++++
src/wstool/__version__.py | 2 +-
src/wstool/common.py | 2 +-
src/wstool/config_yaml.py | 21 +++++++++++++++----
src/wstool/multiproject_cmd.py | 6 ++++--
src/wstool/wstool_cli.py | 11 +++++++++-
test/local/test_config_yaml.py | 34 +++++++++++++++++++++++++++++++
test/local/test_multiproject_functions.py | 10 +++++++++
8 files changed, 83 insertions(+), 9 deletions(-)
diff --git a/doc/changelog.rst b/doc/changelog.rst
index 3b8af1c..63b171e 100644
--- a/doc/changelog.rst
+++ b/doc/changelog.rst
@@ -1,3 +1,9 @@
+0.1.10
+------
+
+- Fix regression which broke the -j option.
+- Enable pretty printing of the ``.rosinstall`` file's YAML.
+
0.1.9
-----
diff --git a/src/wstool/__version__.py b/src/wstool/__version__.py
index 1f299cb..727dc8d 100644
--- a/src/wstool/__version__.py
+++ b/src/wstool/__version__.py
@@ -1 +1 @@
-version = '0.1.9'
+version = '0.1.10'
diff --git a/src/wstool/common.py b/src/wstool/common.py
index 9556cad..050f933 100644
--- a/src/wstool/common.py
+++ b/src/wstool/common.py
@@ -309,7 +309,7 @@ class DistributedWork():
self.threads = []
self.sequentializers = {}
self.index = 0
- self.num_threads = capacity if num_threads <= 0 else max(num_threads, capacity)
+ self.num_threads = capacity if num_threads <= 0 else min(num_threads, capacity)
self.silent = silent
def add_thread(self, worker):
diff --git a/src/wstool/config_yaml.py b/src/wstool/config_yaml.py
index 0c26c50..4ca2942 100644
--- a/src/wstool/config_yaml.py
+++ b/src/wstool/config_yaml.py
@@ -377,7 +377,8 @@ def get_path_spec_from_yaml(yaml_dict):
tags=tags)
-def generate_config_yaml(config, filename, header):
+def generate_config_yaml(config, filename, header, pretty=False,
+ sort_with_localname=False):
"""
Writes file filename with header first and then the config as yaml
"""
@@ -386,7 +387,19 @@ def generate_config_yaml(config, filename, header):
with open(os.path.join(config.get_base_path(), filename), 'w+b') as f:
if header is not None:
f.write(header.encode('UTF-8'))
- items = [x.get_legacy_yaml() for x in config.get_source()]
- if items:
+ if sort_with_localname:
+ items = [x.get_legacy_yaml() for x in
+ sorted(config.get_source(),
+ key=lambda x:x.get_local_name())]
+ else:
+ items = [x.get_legacy_yaml() for x in config.get_source()]
+
+ if not items:
+ return
+
+ if pretty:
+ content = yaml.safe_dump(items, allow_unicode=True,
+ default_flow_style=False)
+ else:
content = yaml.safe_dump(items)
- f.write(content.encode('UTF-8'))
+ f.write(content.encode('UTF-8'))
diff --git a/src/wstool/multiproject_cmd.py b/src/wstool/multiproject_cmd.py
index a5e5585..f56f1fb 100644
--- a/src/wstool/multiproject_cmd.py
+++ b/src/wstool/multiproject_cmd.py
@@ -177,9 +177,11 @@ def add_uris(config,
return actions
-def cmd_persist_config(config, filename, header=None):
+def cmd_persist_config(config, filename, header=None,
+ pretty=False, sort_with_localname=False):
"""writes config to given file in yaml syntax"""
- generate_config_yaml(config, filename, header)
+ generate_config_yaml(config, filename, header,
+ pretty, sort_with_localname)
def cmd_version():
diff --git a/src/wstool/wstool_cli.py b/src/wstool/wstool_cli.py
index 689ae6d..147f18e 100644
--- a/src/wstool/wstool_cli.py
+++ b/src/wstool/wstool_cli.py
@@ -67,11 +67,20 @@ _PROGNAME = 'wstool'
class WstoolCLI(MultiprojectCLI):
def __init__(self, config_filename=ROSINSTALL_FILENAME, progname=_PROGNAME):
+
+ def config_generator(config, filename, header=None):
+ wstool.multiproject_cmd.cmd_persist_config(
+ config,
+ filename,
+ header,
+ pretty=True,
+ sort_with_localname=True)
+
MultiprojectCLI.__init__(
self,
progname=progname,
config_filename=config_filename,
- config_generator=wstool.multiproject_cmd.cmd_persist_config)
+ config_generator=config_generator)
def wstool_main(argv=None, usage=None):
diff --git a/test/local/test_config_yaml.py b/test/local/test_config_yaml.py
index a6da357..993f0f4 100644
--- a/test/local/test_config_yaml.py
+++ b/test/local/test_config_yaml.py
@@ -203,6 +203,40 @@ class ConfigFile_Test(unittest.TestCase):
self.assertEqual("# Hello", lines[0])
self.assertEqual("- svn: {local-name: ros, uri: %s/some/uri}" % self.directory, lines[1])
+ def test_generate_with_pretty_format(self):
+ self.directory = tempfile.mkdtemp()
+ config = wstool.config.Config([PathSpec('ros', 'svn', 'some/uri')],
+ self.directory)
+ wstool.config_yaml.generate_config_yaml(config, 'foo', "# Hello\n",
+ pretty=True)
+ filepath = os.path.join(self.directory, 'foo')
+ self.assertTrue(os.path.exists(filepath))
+ with open(filepath, 'r') as f:
+ read_data = f.read()
+ self.assertEqual("""\
+# Hello
+- svn:
+ local-name: ros
+ uri: %s/some/uri
+""" % self.directory, read_data)
+
+ def test_generate_sorted_with_localname(self):
+ self.directory = tempfile.mkdtemp()
+ elements = [PathSpec('ros', 'svn', 'some/uri1'),
+ PathSpec('git', 'git', 'some/uri2')]
+ config = wstool.config.Config(elements, self.directory)
+ wstool.config_yaml.generate_config_yaml(config, 'foo', "# Hello\n",
+ sort_with_localname=True)
+ filepath = os.path.join(self.directory, 'foo')
+ self.assertTrue(os.path.exists(filepath))
+ with open(filepath, 'r') as f:
+ read_data = f.read()
+ self.assertEqual("""\
+# Hello
+- git: {local-name: git, uri: %s/some/uri2}
+- svn: {local-name: ros, uri: %s/some/uri1}
+""" % (self.directory, self.directory), read_data)
+
def tearDown(self):
if os.path.exists(self.directory):
shutil.rmtree(self.directory)
diff --git a/test/local/test_multiproject_functions.py b/test/local/test_multiproject_functions.py
index d52f799..6de2a5f 100644
--- a/test/local/test_multiproject_functions.py
+++ b/test/local/test_multiproject_functions.py
@@ -187,6 +187,16 @@ class FunctionsTest(unittest.TestCase):
self.assertEqual(thing.done, True, result)
self.assertEqual(False, 'error' in result[0], result)
+ def test_distributed_work_init(self):
+ work = DistributedWork(capacity=200)
+ self.assertEqual(10, work.num_threads)
+ work = DistributedWork(capacity=3, num_threads=5)
+ self.assertEqual(3, work.num_threads)
+ work = DistributedWork(capacity=5, num_threads=3)
+ self.assertEqual(3, work.num_threads)
+ work = DistributedWork(capacity=3, num_threads=-1)
+ self.assertEqual(3, work.num_threads)
+
def test_distributed_work(self):
work = DistributedWork(3)
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/debian-science/packages/ros/wstool.git
More information about the debian-science-commits
mailing list