when many products are found, ask user to select one
This commit is contained in:
parent
3fb58ede8b
commit
b37c2160b5
1 changed files with 10 additions and 2 deletions
|
|
@ -94,14 +94,22 @@ class Comparoob(ReplApplication):
|
||||||
for backend, product in self.do('search_products', pattern):
|
for backend, product in self.do('search_products', pattern):
|
||||||
products.append(product)
|
products.append(product)
|
||||||
|
|
||||||
|
product = None
|
||||||
if len(products) == 0:
|
if len(products) == 0:
|
||||||
print >>sys.stderr, 'Error: no product found with this pattern'
|
print >>sys.stderr, 'Error: no product found with this pattern'
|
||||||
return 1
|
return 1
|
||||||
elif len(products) == 1:
|
elif len(products) == 1:
|
||||||
product = products[0]
|
product = products[0]
|
||||||
else:
|
else:
|
||||||
print >>sys.stderr, 'Error: too many results, TODO'
|
print 'What product do you want to compare?'
|
||||||
return 1
|
for i, product in enumerate(products):
|
||||||
|
print ' %s%2d)%s %s' % (self.BOLD, i+1, self.NC, product.name)
|
||||||
|
r = int(self.ask(' Select a product', regexp='\d+'))
|
||||||
|
while product is None:
|
||||||
|
if r <= 0 or r > len(products):
|
||||||
|
print 'Error: Please enter a valid ID'
|
||||||
|
continue
|
||||||
|
product = products[r-1]
|
||||||
|
|
||||||
self.change_path([u'prices'])
|
self.change_path([u'prices'])
|
||||||
self.start_format()
|
self.start_format()
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue