Пример #1
0
    def confirm(self, msg):
        msg = str(msg)
        if ctx.config.options and ctx.config.options.yes_all:
            return True

        import re, tty

        try:
            locale.setlocale(locale.LC_ALL, "")
        except:
            # Ignore "unsupported locale setting" errors
            pass

        yes_expr = re.compile(locale.nl_langinfo(locale.YESEXPR))
        no_expr = re.compile(locale.nl_langinfo(locale.NOEXPR))
        locale.setlocale(locale.LC_ALL, "C")

        while True:
            tty.tcflush(sys.stdin.fileno(), 0)
            prompt = msg + pisi.util.colorize(_(' (yes/no)'), 'red')
            s = input(prompt)

            if yes_expr.search(s):
                return True

            if no_expr.search(s):
                return False
Пример #2
0
    def confirm(self, msg):
        msg = unicode(msg)
        if ctx.config.options and ctx.config.options.yes_all:
            return True

        import re, tty

        try:
            locale.setlocale(locale.LC_ALL, "")
        except:
            # Ignore "unsupported locale setting" errors
            pass

        yes_expr = re.compile(locale.nl_langinfo(locale.YESEXPR))
        no_expr = re.compile(locale.nl_langinfo(locale.NOEXPR))
        locale.setlocale(locale.LC_ALL, "C")

        while True:
            tty.tcflush(sys.stdin.fileno(), 0)
            prompt = msg + pisi.util.colorize(_(' (yes/no)'), 'red')
            s = raw_input(prompt.encode('utf-8'))

            if yes_expr.search(s):
                return True

            if no_expr.search(s):
                return False
Пример #3
0
    def confirm(self, msg):
        msg = unicode(msg)
        if ctx.config.options and ctx.config.options.yes_all:
            return True
        while True:
            import re, tty
            yesexpr = re.compile(locale.nl_langinfo(locale.YESEXPR))

            tty.tcflush(sys.stdin.fileno(), 0)
            prompt = msg + pisi.util.colorize(_(' (yes/no)'), 'red')
            s = raw_input(prompt.encode('utf-8'))
            if yesexpr.search(s):
                return True

            return False
Пример #4
0
    def confirm(self, msg):
        msg = unicode(msg)
        if ctx.config.options and ctx.config.options.yes_all:
            return True
        while True:
            import re, tty
            yesexpr = re.compile(locale.nl_langinfo(locale.YESEXPR))

            tty.tcflush(sys.stdin.fileno(), 0)
            prompt = msg + pisi.util.colorize(_(' (yes/no)'), 'red')
            s = raw_input(prompt.encode('utf-8'))
            if yesexpr.search(s):
                return True

            return False
Пример #5
0
    def confirm(self, msg):
        msg = str(msg)
        if ctx.config.options and ctx.config.options.yes_all:
            return True

        import re, tty

        locale.setlocale(locale.LC_ALL, "")
        yes_expr = re.compile(locale.nl_langinfo(locale.YESEXPR))
        no_expr = re.compile(locale.nl_langinfo(locale.NOEXPR))
        locale.setlocale(locale.LC_ALL, "C")

        while True:
            tty.tcflush(sys.stdin.fileno(), 0)
            prompt = msg + pisilinux.util.colorize(_(' (yes/no)'), 'red')
            s = input(prompt.encode('utf-8'))

            if yes_expr.search(s):
                return True

            if no_expr.search(s):
                return False
Пример #6
0
    def confirm(self, msg, invert=False):
        msg = str(msg)
        if ctx.config.options and ctx.config.options.yes_all:
            return True

        yes_expr_nl = re.compile("^[" + _('(yes')[1].upper() + _('(yes')[1] +
                                 "]")
        yes_expr = re.compile("^[Yy]")
        tty.tcflush(sys.stdin.fileno(), 0)

        if invert:
            prompt = msg + util.colorize(" " + _('(yes'),
                                         'red') + '/' + util.colorize(
                                             _('no)'), 'green') + ":  "
        else:
            prompt = msg + util.colorize(" " + _('(yes'),
                                         'green') + '/' + util.colorize(
                                             _('no)'), 'red') + ":  "

        s = input(prompt)
        if yes_expr.search(s) or yes_expr_nl.search(s):
            return True
        else:
            return False
Пример #7
0
 def flush(self):
     tty.tcflush(self.fd, tty.TCIOFLUSH)
Пример #8
0
 def flush(self):
     tty.tcflush(self.fd, tty.TCIOFLUSH)