update editor
[redakcja.git] / lib / vstorage / hgui.py
1 # -*- coding: utf-8 -*-
2 """
3     Mercurial ui module replacement.
4 """
5
6 import mercurial.ui
7 import logging
8
9
10 class SilentUI(mercurial.ui.ui):
11
12     def __init__(self, *args, **kwargs):
13         super(SilentUI, self).__init__(*args, **kwargs)
14
15         # make sure this doesn't collide with anything in Mercurial
16         self.__logger = logging.getLogger('mercurial')
17
18     def _is_trusted(self, fd, filename):
19         """ Checks if config file is trusted - on server side, this isn't very useful. """
20         return True
21
22     def write(self, *args):
23         if self._buffers:
24             self._buffers[-1].extend([str(a) for a in args])
25         else:
26             self.__logger.info(''.join(args))
27
28     def write_err(self, *args):
29         self.__logger.error(''.join(args))
30
31     def flush(self):
32         pass
33
34     def interactive(self):
35         return False
36
37     def _readline(self, prompt=''):
38         return u''
39
40     def status(self, *msg):
41         self.__logger.debug(''.join(msg))
42
43     def warn(self, *msg):
44         self.__logger.warn(''.join(msg))
45
46     def note(self, *msg):
47         self.__logger.info(''.join(msg))
48
49     def debug(self, *msg):
50         self.__logger.debug(''.join(msg))
51
52     def edit(self, text, user):
53         return text
54
55     def traceback(self, exc=None):
56         if exc is not None:
57             self.__logger.exception()
58
59     def progress(self, *args, **kwargs):
60         pass