starting to add select2 box for batch codes
This commit is contained in:
21
src/BatchcodeOptionsSetter.py
Normal file
21
src/BatchcodeOptionsSetter.py
Normal file
@@ -0,0 +1,21 @@
|
||||
from bs4 import BeautifulSoup
|
||||
|
||||
|
||||
class BatchcodeOptionsSetter:
|
||||
|
||||
def setBatchcodeOptions(self, html, options):
|
||||
soup = self._setBatchcodeOptions(self._parse(html), self._parseOptions(options))
|
||||
return str(soup)
|
||||
|
||||
def _setBatchcodeOptions(self, soup, options):
|
||||
batchcodeSelect = soup.find(id = "batchCodeSelect")
|
||||
batchcodeSelect.clear()
|
||||
for option in options:
|
||||
batchcodeSelect.append(option)
|
||||
return soup
|
||||
|
||||
def _parseOptions(self, options):
|
||||
return [self._parse(option).option for option in options]
|
||||
|
||||
def _parse(self, html):
|
||||
return BeautifulSoup(html, 'lxml')
|
||||
Reference in New Issue
Block a user