Exemple #1
0
 def testCommand(self):
     Logger.command(('ls', 'a b'))
     self.assertEqual(Logger.stdout.getvalue(), '')
     Logger.set_verbosity(True)
     Logger.command(('ls', 'a b'))
     self.assertEqual(Logger.stdout.getvalue(), 'test: I: ls "a b"\n')
     self.assertEqual(Logger.stderr.getvalue(), '')
Exemple #2
0
# MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
# ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
# WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
# ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
# OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
"""This module implements facilities to deal with Debian control."""

import os
import sys

from devscripts.logger import Logger

try:
    import debian.deb822
except ImportError:
    Logger.error(
        "Please install 'python3-debian' in order to use this utility.")
    sys.exit(1)


def _insert_after(paragraph, item_before, new_item, new_value):
    """Insert new_item into directly after item_before

       New items added to a dictionary are appended."""
    item_found = False
    for item in paragraph:
        if item_found:
            value = paragraph.pop(item)
            paragraph[item] = value
        if item == item_before:
            item_found = True
            paragraph[new_item] = new_value
Exemple #3
0
 def testArgs(self):
     # pylint: disable=no-member
     Logger.normal('hello %s', 'world')
     self.assertEqual(Logger.stdout.getvalue(), 'test: hello world\n')
     self.assertEqual(Logger.stderr.getvalue(), '')
Exemple #4
0
# ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
# WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
# ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
# OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.

"""This module implements facilities to deal with Debian control."""

import os
import sys

from devscripts.logger import Logger

try:
    import debian.deb822
except ImportError:
    Logger.error("Please install 'python-debian' in order to use this utility.")
    sys.exit(1)

def _insert_after(paragraph, item_before, new_item, new_value):
    """Insert new_item into directly after item_before

       New items added to a dictionary are appended."""
    item_found = False
    for item in paragraph:
        if item_found:
            value = paragraph.pop(item)
            paragraph[item] = value
        if item == item_before:
            item_found = True
            paragraph[new_item] = new_value
    if not item_found:
Exemple #5
0
 def testArgs(self):
     Logger.normal('hello %s', 'world')
     self.assertEqual(Logger.stdout.getvalue(), 'test: hello world\n')
     self.assertEqual(Logger.stderr.getvalue(), '')
Exemple #6
0
 def testNoArgs(self):
     Logger.normal('hello %s')
     self.assertEqual(Logger.stdout.getvalue(), 'test: hello %s\n')
     self.assertEqual(Logger.stderr.getvalue(), '')