Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
View | Details | Raw Unified | Return to bug 61889
Collapse All | Expand All

(-)/usr/bin/emerge (-6 / +52 lines)
Lines 21-26 Link Here
21
	else:
21
	else:
22
		return os.path.normpath(mystr)
22
		return os.path.normpath(mystr)
23
23
24
def getch():
25
        """Gets a single character from standard input.  Does not echo to the
26
        screen."""
27
        try:
28
                import msvcrt
29
                char = msvcrt.getch()
30
        except ImportError:
31
                import sys, tty, termios
32
                fd = sys.stdin.fileno()
33
                old_settings = termios.tcgetattr(fd)
34
                try:
35
                        tty.setraw(sys.stdin.fileno())
36
                        char = sys.stdin.read(1)
37
                finally:
38
                        termios.tcsetattr(fd, termios.TCSADRAIN, old_settings)
39
        return char
40
41
42
def userchoice(choices):
43
	"""Displays a prompt and a set of responses, then waits for a response
44
	which is checked against the responses and the first to match is 
45
	returned.
46
	
47
	choice: a List of Strings.
48
	choice_color: a Function taking and returning a String 
49
50
	Returns the number of the response."""
51
        for i in range(1, len(choices) + 1) :
52
                print green("\t[" + `i` + "] ") + red(choices[i - 1])
53
   
54
        while 1: 
55
                choice = getch()
56
                try:
57
                        choice = int(choice)
58
                except ValueError:
59
                        continue 
60
                if choice > len(choices) :
61
                        continue
62
                
63
                return choice - 1 
64
24
def userquery(prompt, responses=None, colours=None):
65
def userquery(prompt, responses=None, colours=None):
25
	"""Displays a prompt and a set of responses, then waits for a response
66
	"""Displays a prompt and a set of responses, then waits for a response
26
	which is checked against the responses and the first to match is 
67
	which is checked against the responses and the first to match is 
Lines 873-884 Link Here
873
				try: 
914
				try: 
874
					mykey=portage.dep_expand(x,portage.portdb)
915
					mykey=portage.dep_expand(x,portage.portdb)
875
				except ValueError, errpkgs:
916
				except ValueError, errpkgs:
876
					print "\n\n!!! The short ebuild name \"" + x + "\" is ambiguous.  Please specify"
917
					print "\n!!! The short ebuild name \"" + x + "\" is ambiguous.  Please specify"
877
					print "!!! one of the following fully-qualified ebuild names instead:\n"
918
                                        print "!!! one of the following fully-qualified ebuild names instead:\n" 
878
					for i in errpkgs[0]:
919
                                        if "--ask" in myopts:
879
						print "    " + green(i)
920
                                                choice = userchoice(errpkgs[0])
880
					print
921
                                                mykey = errpkgs[0][choice]
881
					sys.exit(1)
922
		        			print
923
                                        else :
924
        					for i in errpkgs[0]:
925
	        					print "    " + green(i)
926
		        			print
927
			        		sys.exit(1)
882
928
883
				# select needs to return 0 on dep_check failure
929
				# select needs to return 0 on dep_check failure
884
930

Return to bug 61889