summaryrefslogtreecommitdiffstats
path: root/layman/__init__.py
blob: 7a6bff5f81a10b0ca137d9ead311dfd676a15da9 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
#!/usr/bin/python
# -*- coding: utf-8 -*-

"""Layman is a complete library for the operation and maintainance
on all gentoo repositories and overlays
"""

import sys

try:
    from layman.api import LaymanAPI
    from layman.config import BareConfig
    from layman.output import Message
except ImportError:
    sys.stderr.write("!!! Layman API imports failed.")
    raise



class Layman(LaymanAPI):
    """A complete high level interface capable of performing all
    overlay repository actions."""

    def __init__(self, stdout=sys.stdout, stdin=sys.stdin, stderr=sys.stderr,
        config=None, read_configfile=True, quiet=False, quietness=4,
        verbose=False, nocolor=False, width=0, root=None
        ):
        """Input parameters are optional to override the defaults.
        sets up our LaymanAPI with defaults or passed in values
        and returns an instance of it"""
        self.message = Message(out=stdout, err=stderr)
        self.config = BareConfig(
                output=self.message,
                stdout=stdout,
                stdin=stdin,
                stderr=stderr,
                config=config,
                read_configfile=read_configfile,
                quiet=quiet,
                quietness=quietness,
                verbose=verbose,
                nocolor=nocolor,
                width=width,
                root=root
            )
        LaymanAPI.__init__(self, self.config,
                             report_errors=True,
                             output=self.config['output']
                            )
        return