Improved format listing and added a test case for this command.
This commit is contained in:
parent
f7e3fded29
commit
3982c133be
|
@ -238,8 +238,8 @@ def list_formats ():
|
|||
print
|
||||
except util.PatoolError:
|
||||
handlers = programs.get(None, programs.get(command))
|
||||
print " %8s: - (no program found; install one of %s)" % \
|
||||
(command, ", ".join(handlers))
|
||||
print " %8s: - (no program found; install %s)" % \
|
||||
(command, util.strlist_with_or(handlers))
|
||||
return 0
|
||||
|
||||
|
||||
|
|
|
@ -120,3 +120,10 @@ def find_program (program):
|
|||
# XXX memoize result of this function
|
||||
path = os.environ['PATH']
|
||||
return find_executable(program, path=path)
|
||||
|
||||
|
||||
def strlist_with_or (list):
|
||||
"""Return comma separated string, and last entry appended with ' or '."""
|
||||
if len(list) > 1:
|
||||
return "%s or %s" % (", ".join(list[:-1]), list[-1])
|
||||
return ", ".join(list)
|
||||
|
|
|
@ -0,0 +1,22 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
# Copyright (C) 2010 Bastian Kleineidam
|
||||
#
|
||||
# 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 3 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, see <http://www.gnu.org/licenses/>.
|
||||
import unittest
|
||||
import patoolib
|
||||
|
||||
class TestFormats (unittest.TestCase):
|
||||
|
||||
def test_list_formats (self):
|
||||
patoolib.list_formats()
|
Loading…
Reference in New Issue