Advertisement
Guest User

Untitled

a guest
Jun 30th, 2015
203
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.45 KB | None | 0 0
  1. def get_info():
  2. holder = []
  3. problem_dict = {}
  4. selection_container = []
  5. for moselect in base_page.find_all('div', attrs={'class': 'Moselect'}):
  6. if moselect.find('div', attrs={'id': 'noSize'}):
  7. holder.append(moselect.find_all('div')[1:])
  8.  
  9. for held_item in holder[0]:
  10. if held_item.find_all('option')[1:]:
  11. for m in held_item.find_all('option')[1:]:
  12.  
  13. append_dict(selection_container, m)
  14.  
  15. if len(m.text.split(' ')) > 1:
  16. stock_info = {
  17. 'message': reduce(lambda x, y: x + ' ' + y, m.text.split(' ')[1:])[1:-1],
  18. 'status': 'pre-order'
  19. }
  20. problem_dict.update({'stock': stock_info})
  21.  
  22. else:
  23. for m in held_item.find_all('option'):
  24.  
  25. append_dict(selection_container, m)
  26.  
  27. if len(m.text.split(' ')) > 1:
  28. stock_info = {
  29. 'message': reduce(lambda x, y: x + ' ' + y, m.text.split(' ')[1:])[1:-1],
  30. 'status': 'pre-order'
  31. }
  32. problem_dict.update({'stock': stock_info})
  33.  
  34. problem_dict.update(dict(selections=selection_container))
  35. return problem_dict
  36.  
  37. problem_dict = {'selection': [{'key': 'value'},{'key': 'value'},]}
  38.  
  39. problem_dict = {'selection': [{'key': 'value'},{'key': 'value'}], 'stock': {'key': 'value', 'key': 'value'} }
  40.  
  41. if held_item.find_all('option')[1:]:
  42. ...
  43. else:
  44. ...
  45.  
  46. options = held_item.find_all('option')
  47. if len(options) > 1:
  48. options.pop(0)
  49.  
  50. for option in options:
  51. append_dict(selection_container, option)
  52.  
  53. # If there is a non-zero amount of spaces, there will be at least
  54. # 2 partitions when split.
  55. if option.text.count(' '):
  56. stock_info = {'message': reduce(lambda x, y: x + ' ' + y, option.text.split(' ')[1:])[1:-1],
  57. 'status': 'pre-order'}
  58. problem_dict.update({'stock': stock_info})
  59.  
  60. stock_info = {
  61. 'message': reduce(lambda x, y: x + ' ' + y, m.text.split(' ')[1:])[1:-1],
  62. 'status': 'pre-order'
  63. }
  64.  
  65. stock_info = {'message': reduce(lambda x, y: x + ' ' + y, m.text.split(' ')[1:])[1:-1],
  66. 'status': 'pre-order'}
  67.  
  68. stock_info = {'message': m.split(' ', 1)[-1][1:-1] ...
  69.  
  70. # Below is reduced version of:
  71. # m[m.index(' ') + 1:][1:-1]
  72. stock_info = {'message': m[m.index(' ') + 2:-1] ...
  73.  
  74. holder = [moselect.find_all('div')[1:]
  75. for moselect in base_page.find_all('div', attrs={'class': 'Moselect'})
  76. if moselect.find('div', attrs={'id': 'noSize'})]
  77.  
  78. def get_info():
  79. problem_dict = {}
  80. selection_container = []
  81. holder = [moselect.find_all('div')[1:]
  82. for moselect in base_page.find_all('div', attrs={'class': 'Moselect'})
  83. if moselect.find('div', attrs={'id': 'noSize'})]
  84.  
  85. for held_item in holder[0]:
  86. options = held_item.find_all('option')
  87. if len(options) > 1:
  88. options.pop(0)
  89.  
  90. for option in options:
  91. append_dict(selection_container, option)
  92.  
  93. # If there is a non-zero amount of spaces, there will be at least
  94. # 2 partitions when split.
  95. if option.text.count(' '):
  96. stock_info = {'message': {'message': m[m.index(' ') + 2:-1],
  97. 'status': 'pre-order'}
  98. problem_dict.update({'stock': stock_info})
  99.  
  100. problem_dict.update(dict(selections=selection_container))
  101. return problem_dict
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement